aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2014-08-11 21:22:25 +0200
committermarha <marha@users.sourceforge.net>2014-08-11 21:22:25 +0200
commit8e27619ab489dece35cc4bec86950ee7729cd309 (patch)
treeab59dbc661e00c12ed4777cf9d0d37393c4163aa
parentffc99ce2402fe5c9a6eb8fcf193e8e9472fd993b (diff)
parentfdbedba4d50e1b28b0249c83ba11c029f096e400 (diff)
downloadvcxsrv-8e27619ab489dece35cc4bec86950ee7729cd309.tar.gz
vcxsrv-8e27619ab489dece35cc4bec86950ee7729cd309.tar.bz2
vcxsrv-8e27619ab489dece35cc4bec86950ee7729cd309.zip
Merge remote-tracking branch 'origin/released'
Conflicts: libxcb/src/c_client.py mesalib/include/GL/glext.h mesalib/include/GL/glxext.h mesalib/src/glsl/.gitignore mesalib/src/mesa/drivers/dri/common/xmlconfig.h mesalib/src/mesa/main/.gitignore xorg-server/Xext/xvmain.c xorg-server/dix/dispatch.c xorg-server/hw/xfree86/common/compiler.h
-rw-r--r--fontconfig/conf.d/45-latin.conf8
-rw-r--r--fontconfig/src/fcatomic.c2
-rw-r--r--fontconfig/src/fcweight.c15
-rw-r--r--libX11/configure.ac23
-rw-r--r--libX11/nls/cs_CZ.UTF-8/Compose.pre12
-rw-r--r--libX11/nls/cs_CZ.UTF-8/XI18N_OBJS0
-rw-r--r--libX11/nls/cs_CZ.UTF-8/XLC_LOCALE.pre0
-rw-r--r--libX11/src/Makefile.am2
-rw-r--r--libxcb/.gitignore2
-rw-r--r--libxcb/INSTALL229
-rw-r--r--libxcb/Makefile.am12
-rw-r--r--libxcb/NEWS18
-rw-r--r--libxcb/configure.ac73
-rw-r--r--libxcb/m4/xcb.m423
-rwxr-xr-x[-rw-r--r--]libxcb/src/c_client.py584
-rw-r--r--libxcb/src/xcb.h4
-rw-r--r--libxcb/xcb-proto/NEWS14
-rw-r--r--libxcb/xcb-proto/configure.ac2
-rw-r--r--libxcb/xcb-proto/doc/xml-xcb.txt8
-rw-r--r--libxcb/xcb-proto/src/xcb.xsd35
-rw-r--r--libxcb/xcb-proto/src/xinput.xml2
-rw-r--r--libxcb/xcb-proto/src/xkb.xml4
-rw-r--r--libxcb/xcb-proto/src/xproto.xml8
-rw-r--r--mesalib/configure.ac58
-rw-r--r--mesalib/docs/GL3.txt39
-rw-r--r--mesalib/docs/index.html8
-rw-r--r--mesalib/docs/relnotes.html1
-rw-r--r--mesalib/docs/relnotes/10.2.5.html188
-rw-r--r--mesalib/docs/relnotes/10.3.html6
-rwxr-xr-xmesalib/include/GL/glext.h94
-rwxr-xr-x[-rw-r--r--]mesalib/include/GL/glxext.h14
-rw-r--r--mesalib/include/GL/internal/dri_interface.h17
-rw-r--r--mesalib/src/Makefile.am2
-rw-r--r--mesalib/src/SConscript1
-rw-r--r--mesalib/src/gallium/Automake.inc3
-rw-r--r--mesalib/src/gallium/SConscript4
-rw-r--r--mesalib/src/gallium/auxiliary/Makefile.am4
-rw-r--r--mesalib/src/gallium/auxiliary/Makefile.sources1
-rw-r--r--mesalib/src/gallium/auxiliary/SConscript8
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_caps.c4
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_format_pack.py2
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_format_s3tc.c2
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_math.h10
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_prim.h15
-rwxr-xr-x[-rw-r--r--]mesalib/src/glsl/.gitignore4
-rw-r--r--mesalib/src/glsl/Makefile.am18
-rw-r--r--mesalib/src/glsl/Makefile.sources1
-rw-r--r--mesalib/src/glsl/SConscript5
-rw-r--r--mesalib/src/glsl/ast_function.cpp15
-rw-r--r--mesalib/src/glsl/ast_to_hir.cpp92
-rwxr-xr-xmesalib/src/glsl/builtin_functions.cpp3
-rw-r--r--mesalib/src/glsl/builtin_types.cpp81
-rw-r--r--mesalib/src/glsl/builtin_variables.cpp2
-rw-r--r--mesalib/src/glsl/glcpp/glcpp-lex.l449
-rw-r--r--mesalib/src/glsl/glcpp/glcpp-parse.y426
-rw-r--r--mesalib/src/glsl/glcpp/glcpp.c6
-rw-r--r--mesalib/src/glsl/glcpp/glcpp.h6
-rw-r--r--mesalib/src/glsl/glcpp/pp.c96
-rw-r--r--mesalib/src/glsl/glsl_lexer.ll5
-rw-r--r--mesalib/src/glsl/glsl_parser_extras.cpp28
-rw-r--r--mesalib/src/glsl/glsl_types.cpp45
-rw-r--r--mesalib/src/glsl/glsl_types.h41
-rw-r--r--mesalib/src/glsl/ir.h11
-rw-r--r--mesalib/src/glsl/ir_function.cpp10
-rw-r--r--mesalib/src/glsl/ir_reader.cpp3
-rw-r--r--mesalib/src/glsl/ir_variable_refcount.cpp2
-rw-r--r--mesalib/src/glsl/link_functions.cpp2
-rw-r--r--mesalib/src/glsl/link_uniform_block_active_visitor.cpp39
-rw-r--r--mesalib/src/glsl/link_uniform_block_active_visitor.h3
-rw-r--r--mesalib/src/glsl/link_uniform_blocks.cpp20
-rw-r--r--mesalib/src/glsl/link_uniforms.cpp90
-rw-r--r--mesalib/src/glsl/link_varyings.cpp6
-rw-r--r--mesalib/src/glsl/linker.cpp3
-rw-r--r--mesalib/src/glsl/linker.h12
-rw-r--r--mesalib/src/glsl/list.h2
-rw-r--r--mesalib/src/glsl/loop_controls.cpp17
-rw-r--r--mesalib/src/glsl/lower_packed_varyings.cpp2
-rw-r--r--mesalib/src/glsl/lower_ubo_reference.cpp150
-rw-r--r--mesalib/src/glsl/opt_dead_code.cpp31
-rw-r--r--mesalib/src/glsl/standalone_scaffolding.cpp2
-rwxr-xr-xmesalib/src/loader/Makefile.am1
-rw-r--r--mesalib/src/mapi/glapi/gen/ARB_copy_image.xml28
-rw-r--r--mesalib/src/mapi/glapi/gen/GL4x.xml26
-rw-r--r--mesalib/src/mapi/glapi/gen/Makefile.am1
-rwxr-xr-xmesalib/src/mapi/glapi/gen/gl_API.xml2
-rw-r--r--mesalib/src/mapi/glapi/gen/gl_genexec.py1
-rwxr-xr-xmesalib/src/mapi/glapi/gen/gl_gentable.py2
-rw-r--r--mesalib/src/mesa/Makefile.am10
-rw-r--r--mesalib/src/mesa/Makefile.sources8
-rw-r--r--mesalib/src/mesa/SConscript349
-rw-r--r--mesalib/src/mesa/drivers/common/meta.c66
-rw-r--r--mesalib/src/mesa/drivers/common/meta.h10
-rw-r--r--mesalib/src/mesa/drivers/common/meta_blit.c5
-rw-r--r--mesalib/src/mesa/drivers/common/meta_copy_image.c199
-rw-r--r--mesalib/src/mesa/drivers/common/meta_generate_mipmap.c4
-rw-r--r--mesalib/src/mesa/drivers/dri/common/SConscript1
-rw-r--r--mesalib/src/mesa/drivers/dri/common/xmlconfig.c2
-rwxr-xr-x[-rw-r--r--]mesalib/src/mesa/drivers/dri/common/xmlconfig.h2
-rw-r--r--mesalib/src/mesa/drivers/windows/gdi/SConscript2
-rwxr-xr-x[-rw-r--r--]mesalib/src/mesa/main/.gitignore1
-rw-r--r--mesalib/src/mesa/main/bufferobj.c64
-rw-r--r--mesalib/src/mesa/main/buffers.c14
-rw-r--r--mesalib/src/mesa/main/compiler.h110
-rw-r--r--mesalib/src/mesa/main/copyimage.c356
-rw-r--r--mesalib/src/mesa/main/copyimage.h49
-rw-r--r--mesalib/src/mesa/main/dd.h16
-rw-r--r--mesalib/src/mesa/main/enable.c4
-rw-r--r--mesalib/src/mesa/main/errors.c2
-rw-r--r--mesalib/src/mesa/main/extensions.c1
-rw-r--r--mesalib/src/mesa/main/format_info.py192
-rw-r--r--mesalib/src/mesa/main/format_pack.c102
-rw-r--r--mesalib/src/mesa/main/format_parser.py521
-rw-r--r--mesalib/src/mesa/main/format_unpack.c69
-rw-r--r--mesalib/src/mesa/main/format_unpack.h3
-rw-r--r--mesalib/src/mesa/main/format_utils.c977
-rw-r--r--mesalib/src/mesa/main/format_utils.h45
-rw-r--r--mesalib/src/mesa/main/formats.c1786
-rw-r--r--mesalib/src/mesa/main/formats.csv282
-rw-r--r--mesalib/src/mesa/main/formats.h30
-rw-r--r--mesalib/src/mesa/main/get_hash_params.py1
-rw-r--r--mesalib/src/mesa/main/glformats.c164
-rw-r--r--mesalib/src/mesa/main/glformats.h9
-rw-r--r--mesalib/src/mesa/main/hash.c2
-rwxr-xr-xmesalib/src/mesa/main/imports.h32
-rw-r--r--mesalib/src/mesa/main/macros.h6
-rw-r--r--mesalib/src/mesa/main/mtypes.h36
-rw-r--r--mesalib/src/mesa/main/performance_monitor.c2
-rw-r--r--mesalib/src/mesa/main/pipelineobj.c2
-rw-r--r--mesalib/src/mesa/main/set.c2
-rw-r--r--mesalib/src/mesa/main/shaderapi.c4
-rw-r--r--mesalib/src/mesa/main/shaderobj.c2
-rw-r--r--mesalib/src/mesa/main/shared.c2
-rw-r--r--mesalib/src/mesa/main/syncobj.c2
-rw-r--r--mesalib/src/mesa/main/texcompress_etc.c19
-rw-r--r--mesalib/src/mesa/main/texcompress_s3tc.c25
-rw-r--r--mesalib/src/mesa/main/teximage.c105
-rw-r--r--mesalib/src/mesa/main/teximage.h3
-rw-r--r--mesalib/src/mesa/main/texstorage.c25
-rw-r--r--mesalib/src/mesa/main/texstore.c2827
-rw-r--r--mesalib/src/mesa/main/textureview.c36
-rw-r--r--mesalib/src/mesa/main/textureview.h4
-rw-r--r--mesalib/src/mesa/main/uniform_query.cpp70
-rw-r--r--mesalib/src/mesa/main/uniforms.c35
-rw-r--r--mesalib/src/mesa/main/uniforms.h63
-rw-r--r--mesalib/src/mesa/main/varray.c130
-rw-r--r--mesalib/src/mesa/main/vdpau.c2
-rw-r--r--mesalib/src/mesa/program/arbprogparse.c7
-rw-r--r--mesalib/src/mesa/program/ir_to_mesa.cpp2
-rw-r--r--mesalib/src/mesa/program/prog_execute.c5
-rw-r--r--mesalib/src/mesa/program/program.c88
-rw-r--r--mesalib/src/mesa/program/register_allocate.c2
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c5
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_clear.c7
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_drawpixels.c11
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_texture.c2
-rw-r--r--mesalib/src/mesa/state_tracker/st_extensions.c5
-rw-r--r--mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp180
-rw-r--r--mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.h1
-rw-r--r--mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c11
-rw-r--r--mesalib/src/mesa/state_tracker/st_program.c22
-rw-r--r--mesalib/src/mesa/swrast/s_texfetch.c30
-rw-r--r--mesalib/src/mesa/swrast/s_texfetch_tmp.h34
-rw-r--r--mesalib/src/mesa/x86/common_x86.c16
-rw-r--r--mesalib/src/util/.gitignore1
-rw-r--r--mesalib/src/util/Makefile.am41
-rw-r--r--mesalib/src/util/Makefile.sources6
-rw-r--r--mesalib/src/util/SConscript35
-rw-r--r--mesalib/src/util/format_srgb.h (renamed from mesalib/src/gallium/auxiliary/util/u_format_srgb.h)104
-rw-r--r--mesalib/src/util/format_srgb.py (renamed from mesalib/src/gallium/auxiliary/util/u_format_srgb.py)8
-rw-r--r--mesalib/src/util/hash_table.c (renamed from mesalib/src/mesa/main/hash_table.c)4
-rw-r--r--mesalib/src/util/hash_table.h (renamed from mesalib/src/mesa/main/hash_table.h)5
-rw-r--r--mesalib/src/util/macros.h128
-rw-r--r--mesalib/src/util/ralloc.c (renamed from mesalib/src/glsl/ralloc.c)0
-rw-r--r--mesalib/src/util/ralloc.h (renamed from mesalib/src/glsl/ralloc.h)3
-rw-r--r--xorg-server/Xext/saver.c16
-rw-r--r--xorg-server/Xext/xvdisp.c98
-rw-r--r--xorg-server/Xext/xvdix.h31
-rwxr-xr-x[-rw-r--r--]xorg-server/Xext/xvmain.c144
-rw-r--r--xorg-server/dix/devices.c2
-rwxr-xr-x[-rw-r--r--]xorg-server/dix/dispatch.c4
-rw-r--r--xorg-server/doc/Xserver-spec.xml6
-rw-r--r--xorg-server/dri3/dri3.h2
-rw-r--r--xorg-server/glamor/glamor_egl.c1
-rw-r--r--xorg-server/glamor/glamor_eglmodule.c1
-rw-r--r--xorg-server/glamor/glamor_priv.h1
-rw-r--r--xorg-server/glamor/glamor_xv.c13
-rw-r--r--xorg-server/hw/kdrive/Xkdrive.man7
-rw-r--r--xorg-server/hw/kdrive/src/kxv.c270
-rw-r--r--xorg-server/hw/kdrive/src/kxv.h16
-rwxr-xr-x[-rw-r--r--]xorg-server/hw/xfree86/common/compiler.h659
-rw-r--r--xorg-server/hw/xfree86/common/xf86.h8
-rw-r--r--xorg-server/hw/xfree86/common/xf86Cursor.c19
-rw-r--r--xorg-server/hw/xfree86/common/xf86Events.c1
-rw-r--r--xorg-server/hw/xfree86/common/xf86Init.c2
-rw-r--r--xorg-server/hw/xfree86/common/xf86RandR.c32
-rw-r--r--xorg-server/hw/xfree86/common/xf86pciBus.c39
-rw-r--r--xorg-server/hw/xfree86/common/xf86platformBus.c7
-rw-r--r--xorg-server/hw/xfree86/common/xf86xv.c237
-rw-r--r--xorg-server/hw/xfree86/common/xf86xv.h2
-rw-r--r--xorg-server/hw/xfree86/common/xf86xvpriv.h1
-rw-r--r--xorg-server/hw/xfree86/doc/ddxDesign.xml35
-rw-r--r--xorg-server/hw/xfree86/dri/dri.c73
-rw-r--r--xorg-server/hw/xfree86/dri/dri.h8
-rw-r--r--xorg-server/hw/xfree86/int10/generic.c36
-rw-r--r--xorg-server/hw/xfree86/loader/loader.c1
-rw-r--r--xorg-server/hw/xfree86/modes/xf86Rotate.c3
-rw-r--r--xorg-server/hw/xfree86/os-support/bsd/alpha_video.c12
-rw-r--r--xorg-server/hw/xfree86/os-support/bsd/arm_video.c139
-rw-r--r--xorg-server/hw/xfree86/os-support/bsd/bsd_ev56.c24
-rw-r--r--xorg-server/hw/xfree86/os-support/bus/xf86Pci.h21
-rw-r--r--xorg-server/hw/xfree86/os-support/linux/lnx_ev56.c24
-rw-r--r--xorg-server/hw/xfree86/os-support/linux/lnx_video.c12
-rw-r--r--xorg-server/hw/xfree86/os-support/xf86OSpriv.h2
-rw-r--r--xorg-server/hw/xfree86/os-support/xf86_OSlib.h4
-rw-r--r--xorg-server/hw/xfree86/ramdac/xf86RamDacCmap.c1
-rw-r--r--xorg-server/hw/xfree86/vgahw/Makefile.am2
-rw-r--r--xorg-server/hw/xfree86/vgahw/vgaCmap.c276
-rw-r--r--xorg-server/hw/xquartz/xpr/dri.c51
-rw-r--r--xorg-server/hw/xquartz/xpr/dri.h8
-rw-r--r--xorg-server/hw/xwayland/xwayland.h1
-rwxr-xr-xxorg-server/include/os.h40
-rwxr-xr-xxorg-server/include/servermd.h5
-rw-r--r--xorg-server/include/xorg-server.h.in7
-rwxr-xr-xxorg-server/mi/mi.h3
-rw-r--r--xorg-server/mi/micoord.h20
-rw-r--r--xorg-server/mi/miwindow.c14
-rw-r--r--xorg-server/miext/shadow/shadow.c54
-rw-r--r--xorg-server/miext/shadow/shadow.h6
-rw-r--r--xorg-server/os/access.c27
-rwxr-xr-xxorg-server/os/utils.c48
-rw-r--r--xorg-server/present/present.c21
-rw-r--r--xorg-server/present/present_priv.h2
-rw-r--r--xorg-server/present/present_screen.c1
-rw-r--r--xorg-server/randr/rrpointer.c11
-rw-r--r--xorg-server/render/picture.c81
-rw-r--r--xorg-server/render/picturestr.h3
-rw-r--r--xorg-server/xkb/xkbEvents.c9
-rw-r--r--xorg-server/xkeyboard-config/rules/base.extras.xml.in15
-rw-r--r--xorg-server/xkeyboard-config/symbols/cm125
-rw-r--r--xorg-server/xkeyboard-config/symbols/md6
240 files changed, 6908 insertions, 8947 deletions
diff --git a/fontconfig/conf.d/45-latin.conf b/fontconfig/conf.d/45-latin.conf
index aa62ed42e..996fb81e6 100644
--- a/fontconfig/conf.d/45-latin.conf
+++ b/fontconfig/conf.d/45-latin.conf
@@ -57,10 +57,6 @@
<family>Palatino Linotype</family>
<default><family>serif</family></default>
</alias>
- <alias>
- <family>Trebuchet MS</family>
- <default><family>serif</family></default>
- </alias>
<!--
Sans-serif faces
-->
@@ -104,6 +100,10 @@
<family>Luxi Sans</family>
<default><family>sans-serif</family></default>
</alias>
+ <alias>
+ <family>Trebuchet MS</family>
+ <default><family>sans-serif</family></default>
+ </alias>
<!--
Monospace faces
-->
diff --git a/fontconfig/src/fcatomic.c b/fontconfig/src/fcatomic.c
index c35a829fd..ab1340047 100644
--- a/fontconfig/src/fcatomic.c
+++ b/fontconfig/src/fcatomic.c
@@ -131,7 +131,7 @@ FcAtomicLock (FcAtomic *atomic)
return FcFalse;
}
ret = link ((char *) atomic->tmp, (char *) atomic->lck);
- if (ret < 0 && errno == EPERM)
+ if (ret < 0 && (errno == EPERM || errno == ENOTSUP))
{
/* the filesystem where atomic->lck points to may not supports
* the hard link. so better try to fallback
diff --git a/fontconfig/src/fcweight.c b/fontconfig/src/fcweight.c
index 87bbe67ab..77b78ad54 100644
--- a/fontconfig/src/fcweight.c
+++ b/fontconfig/src/fcweight.c
@@ -45,15 +45,22 @@ static int lerp(int x, int x1, int x2, int y1, int y2)
{
int dx = x2 - x1;
int dy = y2 - y1;
- assert (dx > 0 && dy > 0 && x1 <= x && x <= x2);
+ assert (dx > 0 && dy >= 0 && x1 <= x && x <= x2);
return y1 + (dy*(x-x1) + dx/2) / dx;
}
-FcPublic int
+int
FcWeightFromOpenType (int ot_weight)
{
int i;
- if (ot_weight <= 0 || ot_weight > 1000)
+
+ /* Follow WPF Font Selection Model's advice. */
+ if (1 <= ot_weight && ot_weight <= 9)
+ ot_weight *= 100;
+
+ /* WPF Font Selection Model rejects 1000, we allow it
+ * because Pango uses that number. */
+ if (ot_weight < 1 || ot_weight > 1000)
return -1;
for (i = 1; ot_weight > map[i].ot; i++)
@@ -66,7 +73,7 @@ FcWeightFromOpenType (int ot_weight)
return lerp (ot_weight, map[i-1].ot, map[i].ot, map[i-1].fc, map[i].fc);
}
-FcPublic int
+int
FcWeightToOpenType (int fc_weight)
{
int i;
diff --git a/libX11/configure.ac b/libX11/configure.ac
index 161206114..047917dd8 100644
--- a/libX11/configure.ac
+++ b/libX11/configure.ac
@@ -431,17 +431,18 @@ AX_DEFINE_DIR(XLOCALEDIR, X11_LOCALEDIR, [Location of libX11 locale data])
AC_SUBST(X11_LOCALEDIR)
locales="\
- am_ET.UTF-8 armscii-8 C el_GR.UTF-8 en_US.UTF-8 fi_FI.UTF-8 \
- georgian-academy georgian-ps ibm-cp1133 iscii-dev isiri-3342 \
- iso8859-1 iso8859-10 iso8859-11 iso8859-13 iso8859-14 iso8859-15 \
- iso8859-2 iso8859-3 iso8859-4 iso8859-5 iso8859-6 iso8859-7 \
- iso8859-8 iso8859-9 iso8859-9e ja ja.JIS ja_JP.UTF-8\
- ja.SJIS km_KH.UTF-8 ko koi8-c koi8-r koi8-u \
- ko_KR.UTF-8 microsoft-cp1251 microsoft-cp1255 microsoft-cp1256 \
- mulelao-1 nokhchi-1 pt_BR.UTF-8 ru_RU.UTF-8 sr_CS.UTF-8 \
- tatar-cyr th_TH th_TH.UTF-8 tscii-0 vi_VN.tcvn vi_VN.viscii \
- zh_CN zh_CN.gb18030 zh_CN.gbk zh_CN.UTF-8 zh_HK.big5 \
- zh_HK.big5hkscs zh_HK.UTF-8 zh_TW zh_TW.big5 zh_TW.UTF-8"
+ am_ET.UTF-8 armscii-8 C cs_CZ.UTF-8 el_GR.UTF-8 en_US.UTF-8 \
+ fi_FI.UTF-8 georgian-academy georgian-ps ibm-cp1133 iscii-dev \
+ isiri-3342 iso8859-1 iso8859-10 iso8859-11 iso8859-13 iso8859-14 \
+ iso8859-15 iso8859-2 iso8859-3 iso8859-4 iso8859-5 iso8859-6 \
+ iso8859-7 iso8859-8 iso8859-9 iso8859-9e ja ja.JIS \
+ ja_JP.UTF-8 ja.SJIS km_KH.UTF-8 ko koi8-c koi8-r \
+ koi8-u ko_KR.UTF-8 microsoft-cp1251 microsoft-cp1255 \
+ microsoft-cp1256 mulelao-1 nokhchi-1 pt_BR.UTF-8 ru_RU.UTF-8 \
+ sr_CS.UTF-8 tatar-cyr th_TH th_TH.UTF-8 tscii-0 vi_VN.tcvn \
+ vi_VN.viscii zh_CN zh_CN.gb18030 zh_CN.gbk zh_CN.UTF-8 \
+ zh_HK.big5 zh_HK.big5hkscs zh_HK.UTF-8 zh_TW zh_TW.big5 \
+ zh_TW.UTF-8"
AC_SUBST(locales)
XKEYSYMDB="${X11_DATADIR}/XKeysymDB"
diff --git a/libX11/nls/cs_CZ.UTF-8/Compose.pre b/libX11/nls/cs_CZ.UTF-8/Compose.pre
new file mode 100644
index 000000000..022753ea9
--- /dev/null
+++ b/libX11/nls/cs_CZ.UTF-8/Compose.pre
@@ -0,0 +1,12 @@
+XCOMM UTF-8 (Unicode) compose sequences
+XCOMM
+XCOMM Modified for Czech, following iso8859-2/Compose
+XCOMM by James Cloos <cloos@jhcloos.com>
+XCOMM based on bug report by Vladimír Marek <vlmarek@volny.cz>
+
+XCOMM Use the sequences from en_US.UTF-8 as the basis:
+include "X11_LOCALEDATADIR/en_US.UTF-8/Compose"
+
+XCOMM Overriding U with caron:
+<dead_caron> <u> : "ů" U016F # LATIN SMALL LETTER U WITH RING ABOVE
+<dead_caron> <U> : "Ů" U016E # LATIN CAPITAL LETTER U WITH RING ABOVE
diff --git a/libX11/nls/cs_CZ.UTF-8/XI18N_OBJS b/libX11/nls/cs_CZ.UTF-8/XI18N_OBJS
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/libX11/nls/cs_CZ.UTF-8/XI18N_OBJS
diff --git a/libX11/nls/cs_CZ.UTF-8/XLC_LOCALE.pre b/libX11/nls/cs_CZ.UTF-8/XLC_LOCALE.pre
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/libX11/nls/cs_CZ.UTF-8/XLC_LOCALE.pre
diff --git a/libX11/src/Makefile.am b/libX11/src/Makefile.am
index d46b49301..ceb836625 100644
--- a/libX11/src/Makefile.am
+++ b/libX11/src/Makefile.am
@@ -398,7 +398,7 @@ lintlibdir = $(libdir)
lintlib_DATA = $(LINTLIB)
-lintlib_src = $(libX11_la_SOURCES) xcms/*.c xkb/*.c
+lintlib_src = $(libX11_la_SOURCES) $(srcdir)/xcms/*.c $(srcdir)/xkb/*.c
CLEANFILES += $(lintlib_DATA)
diff --git a/libxcb/.gitignore b/libxcb/.gitignore
index 0981ed2d9..a408472cf 100644
--- a/libxcb/.gitignore
+++ b/libxcb/.gitignore
@@ -21,3 +21,5 @@ libtool
m4/l*.m4
mkinstalldirs
stamp-h1
+ChangeLog
+INSTALL
diff --git a/libxcb/INSTALL b/libxcb/INSTALL
deleted file mode 100644
index 54caf7c19..000000000
--- a/libxcb/INSTALL
+++ /dev/null
@@ -1,229 +0,0 @@
-Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002 Free Software
-Foundation, Inc.
-
- This file is free documentation; the Free Software Foundation gives
-unlimited permission to copy, distribute and modify it.
-
-Basic Installation
-==================
-
- These are generic installation instructions.
-
- The `configure' shell script attempts to guess correct values for
-various system-dependent variables used during compilation. It uses
-those values to create a `Makefile' in each directory of the package.
-It may also create one or more `.h' files containing system-dependent
-definitions. Finally, it creates a shell script `config.status' that
-you can run in the future to recreate the current configuration, and a
-file `config.log' containing compiler output (useful mainly for
-debugging `configure').
-
- It can also use an optional file (typically called `config.cache'
-and enabled with `--cache-file=config.cache' or simply `-C') that saves
-the results of its tests to speed up reconfiguring. (Caching is
-disabled by default to prevent problems with accidental use of stale
-cache files.)
-
- If you need to do unusual things to compile the package, please try
-to figure out how `configure' could check whether to do them, and mail
-diffs or instructions to the address given in the `README' so they can
-be considered for the next release. If you are using the cache, and at
-some point `config.cache' contains results you don't want to keep, you
-may remove or edit it.
-
- The file `configure.ac' (or `configure.in') is used to create
-`configure' by a program called `autoconf'. You only need
-`configure.ac' if you want to change it or regenerate `configure' using
-a newer version of `autoconf'.
-
-The simplest way to compile this package is:
-
- 1. `cd' to the directory containing the package's source code and type
- `./configure' to configure the package for your system. If you're
- using `csh' on an old version of System V, you might need to type
- `sh ./configure' instead to prevent `csh' from trying to execute
- `configure' itself.
-
- Running `configure' takes awhile. While running, it prints some
- messages telling which features it is checking for.
-
- 2. Type `make' to compile the package.
-
- 3. Optionally, type `make check' to run any self-tests that come with
- the package.
-
- 4. Type `make install' to install the programs and any data files and
- documentation.
-
- 5. You can remove the program binaries and object files from the
- source code directory by typing `make clean'. To also remove the
- files that `configure' created (so you can compile the package for
- a different kind of computer), type `make distclean'. There is
- also a `make maintainer-clean' target, but that is intended mainly
- for the package's developers. If you use it, you may have to get
- all sorts of other programs in order to regenerate files that came
- with the distribution.
-
-Compilers and Options
-=====================
-
- Some systems require unusual options for compilation or linking that
-the `configure' script does not know about. Run `./configure --help'
-for details on some of the pertinent environment variables.
-
- You can give `configure' initial values for configuration parameters
-by setting variables in the command line or in the environment. Here
-is an example:
-
- ./configure CC=c89 CFLAGS=-O2 LIBS=-lposix
-
- *Note Defining Variables::, for more details.
-
-Compiling For Multiple Architectures
-====================================
-
- You can compile the package for more than one kind of computer at the
-same time, by placing the object files for each architecture in their
-own directory. To do this, you must use a version of `make' that
-supports the `VPATH' variable, such as GNU `make'. `cd' to the
-directory where you want the object files and executables to go and run
-the `configure' script. `configure' automatically checks for the
-source code in the directory that `configure' is in and in `..'.
-
- If you have to use a `make' that does not support the `VPATH'
-variable, you have to compile the package for one architecture at a
-time in the source code directory. After you have installed the
-package for one architecture, use `make distclean' before reconfiguring
-for another architecture.
-
-Installation Names
-==================
-
- By default, `make install' will install the package's files in
-`/usr/local/bin', `/usr/local/man', etc. You can specify an
-installation prefix other than `/usr/local' by giving `configure' the
-option `--prefix=PATH'.
-
- You can specify separate installation prefixes for
-architecture-specific files and architecture-independent files. If you
-give `configure' the option `--exec-prefix=PATH', the package will use
-PATH as the prefix for installing programs and libraries.
-Documentation and other data files will still use the regular prefix.
-
- In addition, if you use an unusual directory layout you can give
-options like `--bindir=PATH' to specify different values for particular
-kinds of files. Run `configure --help' for a list of the directories
-you can set and what kinds of files go in them.
-
- If the package supports it, you can cause programs to be installed
-with an extra prefix or suffix on their names by giving `configure' the
-option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
-
-Optional Features
-=================
-
- Some packages pay attention to `--enable-FEATURE' options to
-`configure', where FEATURE indicates an optional part of the package.
-They may also pay attention to `--with-PACKAGE' options, where PACKAGE
-is something like `gnu-as' or `x' (for the X Window System). The
-`README' should mention any `--enable-' and `--with-' options that the
-package recognizes.
-
- For packages that use the X Window System, `configure' can usually
-find the X include and library files automatically, but if it doesn't,
-you can use the `configure' options `--x-includes=DIR' and
-`--x-libraries=DIR' to specify their locations.
-
-Specifying the System Type
-==========================
-
- There may be some features `configure' cannot figure out
-automatically, but needs to determine by the type of machine the package
-will run on. Usually, assuming the package is built to be run on the
-_same_ architectures, `configure' can figure that out, but if it prints
-a message saying it cannot guess the machine type, give it the
-`--build=TYPE' option. TYPE can either be a short name for the system
-type, such as `sun4', or a canonical name which has the form:
-
- CPU-COMPANY-SYSTEM
-
-where SYSTEM can have one of these forms:
-
- OS KERNEL-OS
-
- See the file `config.sub' for the possible values of each field. If
-`config.sub' isn't included in this package, then this package doesn't
-need to know the machine type.
-
- If you are _building_ compiler tools for cross-compiling, you should
-use the `--target=TYPE' option to select the type of system they will
-produce code for.
-
- If you want to _use_ a cross compiler, that generates code for a
-platform different from the build platform, you should specify the
-"host" platform (i.e., that on which the generated programs will
-eventually be run) with `--host=TYPE'.
-
-Sharing Defaults
-================
-
- If you want to set default values for `configure' scripts to share,
-you can create a site shell script called `config.site' that gives
-default values for variables like `CC', `cache_file', and `prefix'.
-`configure' looks for `PREFIX/share/config.site' if it exists, then
-`PREFIX/etc/config.site' if it exists. Or, you can set the
-`CONFIG_SITE' environment variable to the location of the site script.
-A warning: not all `configure' scripts look for a site script.
-
-Defining Variables
-==================
-
- Variables not defined in a site shell script can be set in the
-environment passed to `configure'. However, some packages may run
-configure again during the build, and the customized values of these
-variables may be lost. In order to avoid this problem, you should set
-them in the `configure' command line, using `VAR=value'. For example:
-
- ./configure CC=/usr/local2/bin/gcc
-
-will cause the specified gcc to be used as the C compiler (unless it is
-overridden in the site shell script).
-
-`configure' Invocation
-======================
-
- `configure' recognizes the following options to control how it
-operates.
-
-`--help'
-`-h'
- Print a summary of the options to `configure', and exit.
-
-`--version'
-`-V'
- Print the version of Autoconf used to generate the `configure'
- script, and exit.
-
-`--cache-file=FILE'
- Enable the cache: use and save the results of the tests in FILE,
- traditionally `config.cache'. FILE defaults to `/dev/null' to
- disable caching.
-
-`--config-cache'
-`-C'
- Alias for `--cache-file=config.cache'.
-
-`--quiet'
-`--silent'
-`-q'
- Do not print messages saying which checks are being made. To
- suppress all normal output, redirect it to `/dev/null' (any error
- messages will still be shown).
-
-`--srcdir=DIR'
- Look for the package's source code in directory DIR. Usually
- `configure' can determine that directory automatically.
-
-`configure' also accepts some other, not widely useful, options. Run
-`configure --help' for more details.
-
diff --git a/libxcb/Makefile.am b/libxcb/Makefile.am
index e9124892b..2475b6e60 100644
--- a/libxcb/Makefile.am
+++ b/libxcb/Makefile.am
@@ -97,3 +97,15 @@ tools/api_conv.pl \
tools/constants \
autogen.sh \
$(TESTS)
+
+MAINTAINERCLEANFILES = ChangeLog INSTALL
+
+.PHONY: ChangeLog INSTALL
+
+INSTALL:
+ $(INSTALL_CMD)
+
+ChangeLog:
+ $(CHANGELOG_CMD)
+
+dist-hook: ChangeLog INSTALL
diff --git a/libxcb/NEWS b/libxcb/NEWS
index 0152bcba6..00285c272 100644
--- a/libxcb/NEWS
+++ b/libxcb/NEWS
@@ -1,3 +1,21 @@
+Release 1.11 (2014-08-01)
+=========================
+* Force structures with 64-bit fields to be packed
+* Add support for <pad align="n">
+* Use X.org's build machinery from xorg-macros
+* Fix leak with xcb_disconnect() and connections in an error state
+* Make xcb_disconnect(NULL) safe
+* Use less #include statements in generated code
+* Automatically validate the Requires lines in our .pc.in files
+* Fix a race that resulted in a failed assertion
+* Improve launchd secure socket support
+* Improve API documentation
+* Remove trailing whitespaces
+* c_client.py: prefix all monkey-patched fields with c_
+* c_client.py: make the man page output deterministic
+* c_client.py: remove useless generated comments
+* xcb.h: add 'struct' before xcb_setup_t, xcb_query_extension_reply_t
+
Release 1.10 (2013-12-22)
=========================
* Bump libxcb-xkb SONAME due to ABI break introduced in 1.9.2
diff --git a/libxcb/configure.ac b/libxcb/configure.ac
index 68c3b2f0c..6e7e9c3c9 100644
--- a/libxcb/configure.ac
+++ b/libxcb/configure.ac
@@ -2,7 +2,7 @@ dnl Process this file with autoconf to produce a configure script.
# Initialize Autoconf
AC_PREREQ([2.60])
-AC_INIT([libxcb],[1.10],
+AC_INIT([libxcb],[1.11],
[https://bugs.freedesktop.org/enter_bug.cgi?product=xcb],
[libxcb])
AC_CONFIG_AUX_DIR([build-aux])
@@ -50,7 +50,7 @@ fi
AC_SUBST(HTML_CHECK_RESULT)
# Checks for pkg-config packages
-PKG_CHECK_MODULES(XCBPROTO, xcb-proto >= 1.10)
+PKG_CHECK_MODULES(XCBPROTO, xcb-proto >= 1.11)
NEEDED="pthread-stubs xau >= 0.99.2"
PKG_CHECK_MODULES(NEEDED, $NEEDED)
@@ -90,14 +90,8 @@ AC_HEADER_STDC
AC_SEARCH_LIBS(getaddrinfo, socket)
AC_SEARCH_LIBS(connect, socket)
-AC_ARG_ENABLE(sendfds, AS_HELP_STRING([--disable-sendfds], [Support FD passing (default: auto)]),
- [sendfds=$enableval], [sendfds=auto])
-
-case x$sendfds in
-xauto)
- AC_SEARCH_LIBS(sendmsg, socket, [sendfds="yes"], [sendfds="no"])
- ;;
-esac
+# Find support for sending a message from a socket
+AC_SEARCH_LIBS(sendmsg, socket, [have_sendmsg="yes"], [have_sendmsg="no"])
# XPG4v2/UNIX95 added msg_control - check to see if we need to define
# _XOPEN_SOURCE to get it (such as on Solaris)
@@ -126,14 +120,14 @@ if test "x$ac_cv_member_struct_msghdr_msg_control" = xno; then
AC_CHECK_MEMBER([struct msghdr.msg_control],
[AC_DEFINE([_XOPEN_SOURCE], [500],
[Defined if needed to expose struct msghdr.msg_control])
- ], [sendfds="no"], [
+ ], [have_sendmsg="no"], [
#define _XOPEN_SOURCE 500
AC_INCLUDES_DEFAULT
#include <sys/socket.h>
])
fi
-case x$sendfds in
+case x$have_sendmsg in
xyes)
AC_DEFINE([HAVE_SENDMSG],1,[Define if your platform supports sendmsg])
;;
@@ -212,32 +206,32 @@ case $host_os in
;;
esac
-XCB_EXTENSION(Composite, "yes")
-XCB_EXTENSION(Damage, "yes")
-XCB_EXTENSION(DPMS, "yes")
-XCB_EXTENSION(DRI2, "yes")
-XCB_EXTENSION(DRI3, "$sendfds")
-XCB_EXTENSION(GLX, "yes")
-XCB_EXTENSION(Present, "yes")
-XCB_EXTENSION(RandR, "yes")
-XCB_EXTENSION(Record, "yes")
-XCB_EXTENSION(Render, "yes")
-XCB_EXTENSION(Resource, "yes")
-XCB_EXTENSION(Screensaver, "yes")
-XCB_EXTENSION(Shape, "yes")
-XCB_EXTENSION(Shm, "yes")
-XCB_EXTENSION(Sync, "yes")
-XCB_EXTENSION(Xevie, "yes")
-XCB_EXTENSION(XFixes, "yes")
-XCB_EXTENSION(XFree86-DRI, "yes")
-XCB_EXTENSION(Xinerama, "yes")
-XCB_EXTENSION(XInput, "no")
-XCB_EXTENSION(XKB, "yes")
-XCB_EXTENSION(Xprint, "yes")
-XCB_EXTENSION(SELinux, "no")
-XCB_EXTENSION(XTest, "yes")
-XCB_EXTENSION(Xv, "yes")
-XCB_EXTENSION(XvMC, "yes")
+XCB_EXTENSION(Composite, yes)
+XCB_EXTENSION(Damage, yes)
+XCB_EXTENSION(DPMS, yes)
+XCB_EXTENSION(DRI2, yes)
+XCB_EXTENSION(DRI3, $have_sendmsg)
+XCB_EXTENSION(GLX, yes)
+XCB_EXTENSION(Present, yes)
+XCB_EXTENSION(RandR, yes)
+XCB_EXTENSION(Record, yes)
+XCB_EXTENSION(Render, yes)
+XCB_EXTENSION(Resource, yes)
+XCB_EXTENSION(Screensaver, yes)
+XCB_EXTENSION(Shape, yes)
+XCB_EXTENSION(Shm, yes)
+XCB_EXTENSION(Sync, yes)
+XCB_EXTENSION(Xevie, no)
+XCB_EXTENSION(XFixes, yes)
+XCB_EXTENSION(XFree86-DRI, yes)
+XCB_EXTENSION(Xinerama, yes)
+XCB_EXTENSION(XInput, no)
+XCB_EXTENSION(XKB, yes)
+XCB_EXTENSION(Xprint, no)
+XCB_EXTENSION(SELinux, no)
+XCB_EXTENSION(XTest, yes)
+XCB_EXTENSION(Xv, yes)
+XCB_EXTENSION(XvMC, yes)
AC_ARG_WITH(launchd, AS_HELP_STRING([--with-launchd], [Build with support for Apple's launchd (default: auto)]), [LAUNCHD=$withval], [LAUNCHD=auto])
if test "x$LAUNCHD" = xauto; then
@@ -300,7 +294,7 @@ echo " Package: ${PACKAGE_NAME} ${PACKAGE_VERSION}"
echo ""
echo " Configuration"
echo " XDM support.........: ${have_xdmcp}"
-echo " sendmsg fd passing..: ${sendfds}"
+echo " sendmsg fd passing..: ${have_sendmsg}"
echo " Build unit tests....: ${HAVE_CHECK}"
echo " with html results.: ${HTML_CHECK_RESULT}"
echo " XCB buffer size.....: ${xcb_queue_buffer_size}"
@@ -335,7 +329,6 @@ echo ""
echo " Used CFLAGS:"
echo " CPPFLAGS............: ${CPPFLAGS}"
echo " CFLAGS..............: ${CFLAGS}"
-echo " Warning CFLAGS......: ${BASE_CFLAGS}"
echo ""
echo " Installation:"
echo " Prefix..............: ${prefix}"
diff --git a/libxcb/m4/xcb.m4 b/libxcb/m4/xcb.m4
index 32e852dd5..a43082a8e 100644
--- a/libxcb/m4/xcb.m4
+++ b/libxcb/m4/xcb.m4
@@ -38,15 +38,32 @@ dnl XCB_EXTENSION(name, default)
dnl set the X extension
dnl
AC_DEFUN([XCB_EXTENSION],
-[
+[dnl
pushdef([UP], translit([$1], [-a-z], [_A-Z]))dnl
pushdef([DOWN], translit([$1], [A-Z], [a-z]))dnl
+dnl
+m4_if([$2], [yes], [m4_define([xcb_defopt], [yes])],
+ [$2], [no], [m4_define([xcb_defopt], [no])],
+ m4_define([xcb_defopt], [auto]))dnl
AC_ARG_ENABLE(DOWN,
- [AS_HELP_STRING([--enable-[]DOWN], [Build XCB $1 Extension (default: $2)])],
+ [AS_HELP_STRING([--enable-[]DOWN],
+ [Build XCB $1 Extension (default: ]xcb_defopt[)])],
[BUILD_[]UP=$enableval],
- [BUILD_[]UP=$2])
+ [BUILD_[]UP=xcb_defopt])
+dnl
+m4_if(xcb_defopt, [auto], [
+# This extension has a default value of "auto" and depends on the value of $2
+if test "x$BUILD_[]UP" = "xauto" ; then
+ BUILD_[]UP=$2
+fi
+if test "x$BUILD_[]UP" = "xyes" ; then
+ if test "x$2" = "xno" ; then
+ AC_MSG_ERROR([Extension []UP requested, but dependencies are not met])
+ fi
+fi])
+m4_undefine([xcb_defopt])dnl
AM_CONDITIONAL(BUILD_[]UP, [test "x$BUILD_[]UP" = "xyes"])
])
diff --git a/libxcb/src/c_client.py b/libxcb/src/c_client.py
index e3f191b90..2f9e36079 100644..100755
--- a/libxcb/src/c_client.py
+++ b/libxcb/src/c_client.py
@@ -28,7 +28,7 @@ _clines = []
_clevel = 0
_ns = None
-# global variable to keep track of serializers and
+# global variable to keep track of serializers and
# switch data types due to weird dependencies
finished_serializers = []
finished_sizeof = []
@@ -44,13 +44,13 @@ def _h(fmt, *args):
Writes the given line to the header file.
'''
_hlines[_hlevel].append(fmt % args)
-
+
def _c(fmt, *args):
'''
Writes the given line to the source file.
'''
_clines[_clevel].append(fmt % args)
-
+
def _hc(fmt, *args):
'''
Writes the given line to both the header and source files.
@@ -68,7 +68,7 @@ def _h_setlevel(idx):
while len(_hlines) <= idx:
_hlines.append([])
_hlevel = idx
-
+
def _c_setlevel(idx):
'''
Changes the array that source lines are written to.
@@ -78,7 +78,7 @@ def _c_setlevel(idx):
while len(_clines) <= idx:
_clines.append([])
_clevel = idx
-
+
def _n_item(str):
'''
Does C-name conversion on a single string fragment.
@@ -90,7 +90,7 @@ def _n_item(str):
split = _cname_re.finditer(str)
name_parts = [match.group(0) for match in split]
return '_'.join(name_parts)
-
+
def _cpp(str):
'''
Checks for certain C++ reserved words and fixes them.
@@ -111,7 +111,7 @@ def _ext(str):
return _n_item(str).lower()
else:
return str.lower()
-
+
def _n(list):
'''
Does C-name conversion on a tuple of strings.
@@ -142,7 +142,7 @@ def _t(list):
else:
parts = [list[0]] + [_n_item(i) for i in list[1:]] + ['t']
return '_'.join(parts).lower()
-
+
def c_open(self):
'''
@@ -186,7 +186,7 @@ def c_open(self):
_c('#include "xcbext.h"')
_c('#include "%s.h"', _ns.header)
_c('#include <X11/Xtrans/Xtrans.h>')
-
+
_c('')
_c('#define ALIGNOF(type) offsetof(struct { char dummy; type member; }, member)')
@@ -203,7 +203,7 @@ def c_open(self):
_h('')
_h('#define XCB_%s_MAJOR_VERSION %s', _ns.ext_name.upper(), _ns.major_version)
_h('#define XCB_%s_MINOR_VERSION %s', _ns.ext_name.upper(), _ns.minor_version)
- _h(' ') #XXX
+ _h('') #XXX
_h('XCB_EXTERN xcb_extension_t %s;', _ns.c_ext_global_name)
_c('')
@@ -306,9 +306,9 @@ def _c_type_setup(self, name, postfix):
self.c_cookie_type = _t(name + ('cookie',))
self.c_reply_fds_name = _n(name + ('reply_fds',))
- self.need_aux = False
- self.need_serialize = False
- self.need_sizeof = False
+ self.c_need_aux = False
+ self.c_need_serialize = False
+ self.c_need_sizeof = False
self.c_aux_name = _n(name + ('aux',))
self.c_aux_checked_name = _n(name + ('aux', 'checked'))
@@ -319,10 +319,10 @@ def _c_type_setup(self, name, postfix):
self.c_sizeof_name = _n(name + ('sizeof',))
# special case: structs where variable size fields are followed by fixed size fields
- self.var_followed_by_fixed_fields = False
+ self.c_var_followed_by_fixed_fields = False
if self.is_switch:
- self.need_serialize = True
+ self.c_need_serialize = True
self.c_container = 'struct'
for bitcase in self.bitcases:
bitcase.c_field_name = _cpp(bitcase.field_name)
@@ -340,8 +340,8 @@ def _c_type_setup(self, name, postfix):
_c_type_setup(field.type, field.field_type, ())
if field.type.is_list:
_c_type_setup(field.type.member, field.field_type, ())
- if (field.type.nmemb is None):
- self.need_sizeof = True
+ if (field.type.nmemb is None):
+ self.c_need_sizeof = True
field.c_field_type = _t(field.field_type)
field.c_field_const_type = ('' if field.type.nmemb == 1 else 'const ') + field.c_field_type
@@ -358,9 +358,9 @@ def _c_type_setup(self, name, postfix):
if field.type.is_switch:
field.c_pointer = '*'
field.c_field_const_type = 'const ' + field.c_field_type
- self.need_aux = True
+ self.c_need_aux = True
elif not field.type.fixed_size() and not field.type.is_bitcase:
- self.need_sizeof = True
+ self.c_need_sizeof = True
field.c_iterator_type = _t(field.field_type + ('iterator',)) # xcb_fieldtype_iterator_t
field.c_iterator_name = _n(name + (field.field_name, 'iterator')) # xcb_container_field_iterator
@@ -380,22 +380,22 @@ def _c_type_setup(self, name, postfix):
# special case: intermixed fixed and variable size fields
if prev_varsized_field is not None and not field.type.is_pad and field.wire:
if not self.is_union:
- self.need_serialize = True
- self.var_followed_by_fixed_fields = True
+ self.c_need_serialize = True
+ self.c_var_followed_by_fixed_fields = True
else:
self.last_varsized_field = field
prev_varsized_field = field
- prev_varsized_offset = 0
+ prev_varsized_offset = 0
- if self.var_followed_by_fixed_fields:
+ if self.c_var_followed_by_fixed_fields:
if field.type.fixed_size():
field.prev_varsized_field = None
-
- if self.need_serialize:
- # when _unserialize() is wanted, create _sizeof() as well for consistency reasons
- self.need_sizeof = True
- # as switch does never appear at toplevel,
+ if self.c_need_serialize:
+ # when _unserialize() is wanted, create _sizeof() as well for consistency reasons
+ self.c_need_sizeof = True
+
+ # as switch does never appear at toplevel,
# continue here with type construction
if self.is_switch:
if self.c_type not in finished_switch:
@@ -405,11 +405,11 @@ def _c_type_setup(self, name, postfix):
for bitcase in self.bitcases:
bitcase_name = bitcase.type.name if bitcase.type.has_name else name
_c_accessors(bitcase.type, bitcase_name, bitcase_name)
- # no list with switch as element, so no call to
+ # no list with switch as element, so no call to
# _c_iterator(field.type, field_name) necessary
if not self.is_bitcase:
- if self.need_serialize:
+ if self.c_need_serialize:
if self.c_serialize_name not in finished_serializers:
finished_serializers.append(self.c_serialize_name)
_c_serialize('serialize', self)
@@ -417,10 +417,10 @@ def _c_type_setup(self, name, postfix):
# _unpack() and _unserialize() are only needed for special cases:
# switch -> unpack
# special cases -> unserialize
- if self.is_switch or self.var_followed_by_fixed_fields:
+ if self.is_switch or self.c_var_followed_by_fixed_fields:
_c_serialize('unserialize', self)
-
- if self.need_sizeof:
+
+ if self.c_need_sizeof:
if self.c_sizeof_name not in finished_sizeof:
if not module.namespace.is_ext or self.name[:2] == module.namespace.prefix:
finished_sizeof.append(self.c_sizeof_name)
@@ -446,7 +446,7 @@ def _c_helper_absolute_name(prefix, field=None):
prefix_str += _cpp(field.field_name)
return prefix_str
# _c_absolute_name
-
+
def _c_helper_field_mapping(complex_type, prefix, flat=False):
"""
generate absolute names, based on prefix, for all fields starting from complex_type
@@ -459,7 +459,7 @@ def _c_helper_field_mapping(complex_type, prefix, flat=False):
switch_name, switch_sep, switch_type = prefix[-1]
bitcase_prefix = prefix + [(b.type.name[-1], '.', b.type)]
else:
- bitcase_prefix = prefix
+ bitcase_prefix = prefix
if (True==flat and not b.type.has_name) or False==flat:
all_fields.update(_c_helper_field_mapping(b.type, bitcase_prefix, flat))
@@ -506,7 +506,7 @@ def _c_helper_resolve_field_names (prefix):
def get_expr_fields(self):
"""
- get the Fields referenced by switch or list expression
+ get the Fields referenced by switch or list expression
"""
def get_expr_field_names(expr):
if expr.op is None:
@@ -521,7 +521,7 @@ def get_expr_fields(self):
elif expr.op == 'popcount':
return get_expr_field_names(expr.rhs)
elif expr.op == 'sumof':
- # sumof expr references another list,
+ # sumof expr references another list,
# we need that list's length field here
field = None
for f in expr.lenfield_parent.fields:
@@ -537,7 +537,7 @@ def get_expr_fields(self):
else:
return get_expr_field_names(expr.lhs) + get_expr_field_names(expr.rhs)
# get_expr_field_names()
-
+
# resolve the field names with the parent structure(s)
unresolved_fields_names = get_expr_field_names(self.expr)
@@ -550,7 +550,7 @@ def get_expr_fields(self):
resolved_fields_names = list(filter(lambda x: x in all_fields.keys(), unresolved_fields_names))
if len(unresolved_fields_names) != len(resolved_fields_names):
raise Exception("could not resolve all fields for %s" % self.name)
-
+
resolved_fields = [all_fields[n][1] for n in resolved_fields_names]
return resolved_fields
# get_expr_fields()
@@ -577,13 +577,13 @@ def resolve_expr_fields(complex_obj):
unresolved.append(e)
return unresolved
# resolve_expr_fields()
-
+
def get_serialize_params(context, self, buffer_var='_buffer', aux_var='_aux'):
"""
functions like _serialize(), _unserialize(), and _unpack() sometimes need additional parameters:
- E.g. in order to unpack switch, extra parameters might be needed to evaluate the switch
- expression. This function tries to resolve all fields within a structure, and returns the
- unresolved fields as the list of external parameters.
+ E.g. in order to unpack switch, extra parameters might be needed to evaluate the switch
+ expression. This function tries to resolve all fields within a structure, and returns the
+ unresolved fields as the list of external parameters.
"""
def add_param(params, param):
if param not in params:
@@ -602,9 +602,9 @@ def get_serialize_params(context, self, buffer_var='_buffer', aux_var='_aux'):
# field in the xcb_out structure
wire_fields.append(field)
# fields like 'pad0' are skipped!
-
+
# in case of switch, parameters always contain any fields referenced in the switch expr
- # we do not need any variable size fields here, as the switch data type contains both
+ # we do not need any variable size fields here, as the switch data type contains both
# fixed and variable size fields
if self.is_switch:
param_fields = get_expr_fields(self)
@@ -612,7 +612,7 @@ def get_serialize_params(context, self, buffer_var='_buffer', aux_var='_aux'):
# _serialize()/_unserialize()/_unpack() function parameters
# note: don't use set() for params, it is unsorted
params = []
-
+
# 1. the parameter for the void * buffer
if 'serialize' == context:
params.append(('void', '**', buffer_var))
@@ -629,25 +629,25 @@ def get_serialize_params(context, self, buffer_var='_buffer', aux_var='_aux'):
for p in param_fields:
if self.is_switch:
typespec = p.c_field_const_type
- pointerspec = p.c_pointer
+ pointerspec = p.c_pointer
add_param(params, (typespec, pointerspec, p.c_field_name))
else:
if p.visible and not p.wire and not p.auto:
typespec = p.c_field_type
pointerspec = ''
add_param(params, (typespec, pointerspec, p.c_field_name))
-
+
# 4. aux argument
if 'serialize' == context:
add_param(params, ('const %s' % self.c_type, '*', aux_var))
- elif 'unserialize' == context:
+ elif 'unserialize' == context:
add_param(params, ('%s' % self.c_type, '**', aux_var))
elif 'unpack' == context:
add_param(params, ('%s' % self.c_type, '*', aux_var))
# 5. switch contains all variable size fields as struct members
# for other data types though, these have to be supplied separately
- # this is important for the special case of intermixed fixed and
+ # this is important for the special case of intermixed fixed and
# variable size fields
if not self.is_switch and 'serialize' == context:
for p in param_fields:
@@ -675,20 +675,20 @@ def _c_serialize_helper_insert_padding(context, code_lines, space, postpone):
code_lines.append('%s xcb_pad = 0;' % space)
code_lines.append('%s }' % space)
-
+
code_lines.append('%s xcb_block_len = 0;' % space)
# keep tracking of xcb_parts entries for serialize
return 1
# _c_serialize_helper_insert_padding()
-def _c_serialize_helper_switch(context, self, complex_name,
- code_lines, temp_vars,
+def _c_serialize_helper_switch(context, self, complex_name,
+ code_lines, temp_vars,
space, prefix):
count = 0
switch_expr = _c_accessor_get_expr(self.expr, None)
- for b in self.bitcases:
+ for b in self.bitcases:
len_expr = len(b.type.expr)
for n, expr in enumerate(b.type.expr):
bitcase_expr = _c_accessor_get_expr(expr, None)
@@ -706,11 +706,11 @@ def _c_serialize_helper_switch(context, self, complex_name,
b_prefix = prefix
if b.type.has_name:
b_prefix = prefix + [(b.c_field_name, '.', b.type)]
-
- count += _c_serialize_helper_fields(context, b.type,
- code_lines, temp_vars,
- "%s " % space,
- b_prefix,
+
+ count += _c_serialize_helper_fields(context, b.type,
+ code_lines, temp_vars,
+ "%s " % space,
+ b_prefix,
is_bitcase = True)
code_lines.append(' }')
@@ -720,7 +720,7 @@ def _c_serialize_helper_switch(context, self, complex_name,
# # padding
# code_lines.append('%s xcb_pad = -xcb_block_len & 3;' % space)
# code_lines.append('%s xcb_buffer_len += xcb_block_len + xcb_pad;' % space)
-
+
return count
# _c_serialize_helper_switch
@@ -736,7 +736,7 @@ def _c_serialize_helper_switch_field(context, self, field, c_switch_variable, pr
# find the parameters that need to be passed to _serialize()/_unpack():
# all switch expr fields must be given as parameters
args = get_expr_fields(field.type)
- # length fields for variable size types in switch, normally only some of need
+ # length fields for variable size types in switch, normally only some of need
# need to be passed as parameters
switch_len_fields = resolve_expr_fields(field.type)
@@ -746,7 +746,7 @@ def _c_serialize_helper_switch_field(context, self, field, c_switch_variable, pr
if len(bitcase_unresolved) != 0:
raise Exception('unresolved fields within bitcase is not supported at this point')
- # get the C names for the parameters
+ # get the C names for the parameters
c_field_names = ''
for a in switch_len_fields:
c_field_names += "%s, " % field_mapping[a.c_field_name][0]
@@ -756,16 +756,16 @@ def _c_serialize_helper_switch_field(context, self, field, c_switch_variable, pr
# call _serialize()/_unpack() to determine the actual size
if 'serialize' == context:
length = "%s(&%s, %s&%s%s)" % (field.type.c_serialize_name, c_switch_variable,
- c_field_names, prefix_str, field.c_field_name)
+ c_field_names, prefix_str, field.c_field_name)
elif context in ('unserialize', 'unpack'):
- length = "%s(xcb_tmp, %s&%s%s)" % (field.type.c_unpack_name,
+ length = "%s(xcb_tmp, %s&%s%s)" % (field.type.c_unpack_name,
c_field_names, prefix_str, field.c_field_name)
return length
# _c_serialize_helper_switch_field()
-def _c_serialize_helper_list_field(context, self, field,
- code_lines, temp_vars,
+def _c_serialize_helper_list_field(context, self, field,
+ code_lines, temp_vars,
space, prefix):
"""
helper function to cope with lists of variable length
@@ -774,21 +774,21 @@ def _c_serialize_helper_list_field(context, self, field,
prefix_str = _c_helper_absolute_name(prefix)
param_fields, wire_fields, params = get_serialize_params('sizeof', self)
param_names = [p[2] for p in params]
-
+
expr_fields_names = [f.field_name for f in get_expr_fields(field.type)]
resolved = list(filter(lambda x: x in param_names, expr_fields_names))
unresolved = list(filter(lambda x: x not in param_names, expr_fields_names))
-
+
field_mapping = {}
for r in resolved:
field_mapping[r] = (r, None)
-
+
if len(unresolved)>0:
tmp_prefix = prefix
if len(tmp_prefix)==0:
- raise Exception("found an empty prefix while resolving expr field names for list %s",
- field.c_field_name)
-
+ raise Exception("found an empty prefix while resolving expr field names for list %s",
+ field.c_field_name)
+
field_mapping.update(_c_helper_resolve_field_names(prefix))
resolved += list(filter(lambda x: x in field_mapping, unresolved))
unresolved = list(filter(lambda x: x not in field_mapping, unresolved))
@@ -800,7 +800,7 @@ def _c_serialize_helper_list_field(context, self, field,
# default: list with fixed size elements
length = '%s * sizeof(%s)' % (list_length, field.type.member.c_wiretype)
- # list with variable-sized elements
+ # list with variable-sized elements
if not field.type.member.fixed_size():
length = ''
if context in ('unserialize', 'sizeof', 'unpack'):
@@ -813,12 +813,12 @@ def _c_serialize_helper_list_field(context, self, field,
# loop over all list elements and call sizeof repeatedly
# this should be a bit faster than using the iterators
code_lines.append("%s for(i=0; i<%s; i++) {" % (space, list_length))
- code_lines.append("%s xcb_tmp_len = %s(xcb_tmp);" %
+ code_lines.append("%s xcb_tmp_len = %s(xcb_tmp);" %
(space, field.type.c_sizeof_name))
code_lines.append("%s xcb_block_len += xcb_tmp_len;" % space)
code_lines.append("%s xcb_tmp += xcb_tmp_len;" % space)
- code_lines.append("%s }" % space)
-
+ code_lines.append("%s }" % space)
+
elif 'serialize' == context:
code_lines.append('%s xcb_parts[xcb_parts_idx].iov_len = 0;' % space)
code_lines.append('%s xcb_tmp = (char *) %s%s;' % (space, prefix_str, field.c_field_name))
@@ -827,12 +827,12 @@ def _c_serialize_helper_list_field(context, self, field,
code_lines.append('%s xcb_parts[xcb_parts_idx].iov_len += xcb_block_len;' % space)
code_lines.append('%s }' % space)
code_lines.append('%s xcb_block_len = xcb_parts[xcb_parts_idx].iov_len;' % space)
-
+
return length
# _c_serialize_helper_list_field()
-def _c_serialize_helper_fields_fixed_size(context, self, field,
- code_lines, temp_vars,
+def _c_serialize_helper_fields_fixed_size(context, self, field,
+ code_lines, temp_vars,
space, prefix):
# keep the C code a bit more readable by giving the field name
if not self.is_bitcase:
@@ -848,14 +848,14 @@ def _c_serialize_helper_fields_fixed_size(context, self, field,
if context in ('unserialize', 'unpack', 'sizeof'):
# default: simple cast
- value = ' %s = *(%s *)xcb_tmp;' % (abs_field_name, field.c_field_type)
-
+ value = ' %s = *(%s *)xcb_tmp;' % (abs_field_name, field.c_field_type)
+
# padding - we could probably just ignore it
if field.type.is_pad and field.type.nmemb > 1:
value = ''
for i in range(field.type.nmemb):
- code_lines.append('%s %s[%d] = *(%s *)xcb_tmp;' %
- (space, abs_field_name, i, field.c_field_type))
+ code_lines.append('%s %s[%d] = *(%s *)xcb_tmp;' %
+ (space, abs_field_name, i, field.c_field_type))
# total padding = sizeof(pad0) * nmemb
length += " * %d" % field.type.nmemb
@@ -864,15 +864,15 @@ def _c_serialize_helper_fields_fixed_size(context, self, field,
raise Exception('list with fixed number of elemens unhandled in _unserialize()')
elif 'serialize' == context:
- value = ' xcb_parts[xcb_parts_idx].iov_base = (char *) '
+ value = ' xcb_parts[xcb_parts_idx].iov_base = (char *) '
if field.type.is_expr:
# need to register a temporary variable for the expression in case we know its type
if field.type.c_type is None:
- raise Exception("type for field '%s' (expression '%s') unkown" %
+ raise Exception("type for field '%s' (expression '%s') unkown" %
(field.field_name, _c_accessor_get_expr(field.type.expr)))
-
- temp_vars.append(' %s xcb_expr_%s = %s;' % (field.type.c_type, _cpp(field.field_name),
+
+ temp_vars.append(' %s xcb_expr_%s = %s;' % (field.type.c_type, _cpp(field.field_name),
_c_accessor_get_expr(field.type.expr, prefix)))
value += "&xcb_expr_%s;" % _cpp(field.field_name)
@@ -897,25 +897,25 @@ def _c_serialize_helper_fields_fixed_size(context, self, field,
return (value, length)
# _c_serialize_helper_fields_fixed_size()
-def _c_serialize_helper_fields_variable_size(context, self, field,
- code_lines, temp_vars,
+def _c_serialize_helper_fields_variable_size(context, self, field,
+ code_lines, temp_vars,
space, prefix):
prefix_str = _c_helper_absolute_name(prefix)
if context in ('unserialize', 'unpack', 'sizeof'):
value = ''
var_field_name = 'xcb_tmp'
-
+
# special case: intermixed fixed and variable size fields
- if self.var_followed_by_fixed_fields and 'unserialize' == context:
+ if self.c_var_followed_by_fixed_fields and 'unserialize' == context:
value = ' %s = (%s *)xcb_tmp;' % (field.c_field_name, field.c_field_type)
temp_vars.append(' %s *%s;' % (field.type.c_type, field.c_field_name))
# special case: switch
if 'unpack' == context:
value = ' %s%s = (%s *)xcb_tmp;' % (prefix_str, field.c_field_name, field.c_field_type)
-
+
elif 'serialize' == context:
- # variable size fields appear as parameters to _serialize() if the
+ # variable size fields appear as parameters to _serialize() if the
# 'toplevel' container is not a switch
prefix_string = prefix_str if prefix[0][2].is_switch else ''
var_field_name = "%s%s" % (prefix_string, field.c_field_name)
@@ -930,19 +930,19 @@ def _c_serialize_helper_fields_variable_size(context, self, field,
# in any context, list is already a pointer, so the default assignment is ok
code_lines.append("%s%s" % (space, value))
value = ''
- length = _c_serialize_helper_list_field(context, self, field,
- code_lines, temp_vars,
+ length = _c_serialize_helper_list_field(context, self, field,
+ code_lines, temp_vars,
space, prefix)
-
+
elif field.type.is_switch:
value = ''
if context == 'serialize':
# the _serialize() function allocates the correct amount memory if given a NULL pointer
value = ' xcb_parts[xcb_parts_idx].iov_base = (char *)0;'
- length = _c_serialize_helper_switch_field(context, self, field,
- 'xcb_parts[xcb_parts_idx].iov_base',
+ length = _c_serialize_helper_switch_field(context, self, field,
+ 'xcb_parts[xcb_parts_idx].iov_base',
prefix)
-
+
else:
# in all remaining special cases - call _sizeof()
length = "%s(%s)" % (field.type.c_sizeof_name, var_field_name)
@@ -950,8 +950,8 @@ def _c_serialize_helper_fields_variable_size(context, self, field,
return (value, length)
# _c_serialize_helper_fields_variable_size
-def _c_serialize_helper_fields(context, self,
- code_lines, temp_vars,
+def _c_serialize_helper_fields(context, self,
+ code_lines, temp_vars,
space, prefix, is_bitcase):
count = 0
need_padding = False
@@ -962,20 +962,20 @@ def _c_serialize_helper_fields(context, self,
if not ((field.wire and not field.auto) or 'unserialize' == context):
continue
- # switch/bitcase: fixed size fields must be considered explicitly
+ # switch/bitcase: fixed size fields must be considered explicitly
if field.type.fixed_size():
- if self.is_bitcase or self.var_followed_by_fixed_fields:
+ if self.is_bitcase or self.c_var_followed_by_fixed_fields:
if prev_field_was_variable and need_padding:
# insert padding
-# count += _c_serialize_helper_insert_padding(context, code_lines, space,
-# self.var_followed_by_fixed_fields)
+# count += _c_serialize_helper_insert_padding(context, code_lines, space,
+# self.c_var_followed_by_fixed_fields)
prev_field_was_variable = False
# prefix for fixed size fields
fixed_prefix = prefix
- value, length = _c_serialize_helper_fields_fixed_size(context, self, field,
- code_lines, temp_vars,
+ value, length = _c_serialize_helper_fields_fixed_size(context, self, field,
+ code_lines, temp_vars,
space, fixed_prefix)
else:
continue
@@ -985,37 +985,37 @@ def _c_serialize_helper_fields(context, self,
if field.type.is_pad:
# Variable length pad is <pad align= />
code_lines.append('%s xcb_align_to = %d;' % (space, field.type.align))
- count += _c_serialize_helper_insert_padding(context, code_lines, space,
- self.var_followed_by_fixed_fields)
+ count += _c_serialize_helper_insert_padding(context, code_lines, space,
+ self.c_var_followed_by_fixed_fields)
continue
else:
# switch/bitcase: always calculate padding before and after variable sized fields
if need_padding or is_bitcase:
count += _c_serialize_helper_insert_padding(context, code_lines, space,
- self.var_followed_by_fixed_fields)
+ self.c_var_followed_by_fixed_fields)
value, length = _c_serialize_helper_fields_variable_size(context, self, field,
code_lines, temp_vars,
space, prefix)
prev_field_was_variable = True
-
+
# save (un)serialization C code
if '' != value:
- code_lines.append('%s%s' % (space, value))
-
+ code_lines.append('%s%s' % (space, value))
+
if field.type.fixed_size():
- if is_bitcase or self.var_followed_by_fixed_fields:
+ if is_bitcase or self.c_var_followed_by_fixed_fields:
# keep track of (un)serialized object's size
code_lines.append('%s xcb_block_len += %s;' % (space, length))
if context in ('unserialize', 'unpack', 'sizeof'):
code_lines.append('%s xcb_tmp += %s;' % (space, length))
- else:
+ else:
# variable size objects or bitcase:
# value & length might have been inserted earlier for special cases
if '' != length:
# special case: intermixed fixed and variable size fields
- if (not field.type.fixed_size() and
- self.var_followed_by_fixed_fields and 'unserialize' == context):
+ if (not field.type.fixed_size() and
+ self.c_var_followed_by_fixed_fields and 'unserialize' == context):
temp_vars.append(' int %s_len;' % field.c_field_name)
code_lines.append('%s %s_len = %s;' % (space, field.c_field_name, length))
code_lines.append('%s xcb_block_len += %s_len;' % (space, field.c_field_name))
@@ -1025,7 +1025,7 @@ def _c_serialize_helper_fields(context, self,
# increase pointer into the byte stream accordingly
if context in ('unserialize', 'sizeof', 'unpack'):
code_lines.append('%s xcb_tmp += xcb_block_len;' % space)
-
+
if 'serialize' == context:
if '' != length:
code_lines.append('%s xcb_parts[xcb_parts_idx].iov_len = %s;' % (space, length))
@@ -1035,14 +1035,14 @@ def _c_serialize_helper_fields(context, self,
code_lines.append('%s xcb_align_to = ALIGNOF(%s);' % (space, 'char' if field.c_field_type == 'void' else field.c_field_type))
need_padding = True
- if self.var_followed_by_fixed_fields:
+ if self.c_var_followed_by_fixed_fields:
need_padding = False
-
+
return count
-# _c_serialize_helper_fields()
+# _c_serialize_helper_fields()
-def _c_serialize_helper(context, complex_type,
- code_lines, temp_vars,
+def _c_serialize_helper(context, complex_type,
+ code_lines, temp_vars,
space='', prefix=[]):
# count tracks the number of fields to serialize
count = 0
@@ -1052,38 +1052,38 @@ def _c_serialize_helper(context, complex_type,
complex_name = complex_type.name
else:
self = complex_type
- if self.var_followed_by_fixed_fields and 'unserialize' == context:
+ if self.c_var_followed_by_fixed_fields and 'unserialize' == context:
complex_name = 'xcb_out'
else:
complex_name = '_aux'
-
+
# special case: switch is serialized by evaluating each bitcase separately
if self.is_switch:
- count += _c_serialize_helper_switch(context, self, complex_name,
- code_lines, temp_vars,
+ count += _c_serialize_helper_switch(context, self, complex_name,
+ code_lines, temp_vars,
space, prefix)
# all other data types can be evaluated one field a time
- else:
+ else:
# unserialize & fixed size fields: simply cast the buffer to the respective xcb_out type
- if context in ('unserialize', 'unpack', 'sizeof') and not self.var_followed_by_fixed_fields:
+ if context in ('unserialize', 'unpack', 'sizeof') and not self.c_var_followed_by_fixed_fields:
code_lines.append('%s xcb_block_len += sizeof(%s);' % (space, self.c_type))
code_lines.append('%s xcb_tmp += xcb_block_len;' % space)
code_lines.append('%s xcb_buffer_len += xcb_block_len;' % space)
code_lines.append('%s xcb_block_len = 0;' % space)
- count += _c_serialize_helper_fields(context, self,
- code_lines, temp_vars,
+ count += _c_serialize_helper_fields(context, self,
+ code_lines, temp_vars,
space, prefix, False)
# "final padding"
count += _c_serialize_helper_insert_padding(context, code_lines, space, False)
- return count
+ return count
# _c_serialize_helper()
def _c_serialize(context, self):
"""
- depending on the context variable, generate _serialize(), _unserialize(), _unpack(), or _sizeof()
+ depending on the context variable, generate _serialize(), _unserialize(), _unpack(), or _sizeof()
for the ComplexType variable self
"""
_h_setlevel(1)
@@ -1096,25 +1096,25 @@ def _c_serialize(context, self):
if self.is_switch and 'unserialize' == context:
context = 'unpack'
- cases = { 'serialize' : self.c_serialize_name,
- 'unserialize' : self.c_unserialize_name,
- 'unpack' : self.c_unpack_name,
+ cases = { 'serialize' : self.c_serialize_name,
+ 'unserialize' : self.c_unserialize_name,
+ 'unpack' : self.c_unpack_name,
'sizeof' : self.c_sizeof_name }
func_name = cases[context]
-
+
param_fields, wire_fields, params = get_serialize_params(context, self)
variable_size_fields = 0
# maximum space required for type definition of function arguments
maxtypelen = 0
- # determine N(variable_fields)
+ # determine N(variable_fields)
for field in param_fields:
# if self.is_switch, treat all fields as if they are variable sized
if not field.type.fixed_size() or self.is_switch:
variable_size_fields += 1
# determine maxtypelen
for p in params:
- maxtypelen = max(maxtypelen, len(p[0]) + len(p[1]))
+ maxtypelen = max(maxtypelen, len(p[0]) + len(p[1]))
# write to .c/.h
indent = ' '*(len(func_name)+2)
@@ -1137,7 +1137,7 @@ def _c_serialize(context, self):
prefix = []
if 'serialize' == context:
- if not self.is_switch and not self.var_followed_by_fixed_fields:
+ if not self.is_switch and not self.c_var_followed_by_fixed_fields:
_c(' %s *xcb_out = *_buffer;', self.c_type)
_c(' unsigned int xcb_out_pad = -sizeof(%s) & 3;', self.c_type)
_c(' unsigned int xcb_buffer_len = sizeof(%s) + xcb_out_pad;', self.c_type)
@@ -1152,7 +1152,7 @@ def _c_serialize(context, self):
elif context in ('unserialize', 'unpack'):
_c(' char *xcb_tmp = (char *)_buffer;')
if not self.is_switch:
- if not self.var_followed_by_fixed_fields:
+ if not self.c_var_followed_by_fixed_fields:
_c(' const %s *_aux = (%s *)_buffer;', self.c_type, self.c_type)
prefix = [('_aux', '->', self)]
else:
@@ -1178,7 +1178,7 @@ def _c_serialize(context, self):
_c(' return %s(%s, &_aux);', self.c_unpack_name, reduce(lambda x,y: "%s, %s" % (x, y), param_names))
_c('}')
return
- elif self.var_followed_by_fixed_fields:
+ elif self.c_var_followed_by_fixed_fields:
# special case: call _unserialize()
_c(' return %s(%s, NULL);', self.c_unserialize_name, reduce(lambda x,y: "%s, %s" % (x, y), param_names))
_c('}')
@@ -1192,7 +1192,7 @@ def _c_serialize(context, self):
variable_size_fields = count
if 'serialize' == context:
temp_vars.append(' unsigned int xcb_pad = 0;')
- temp_vars.append(' char xcb_pad0[3] = {0, 0, 0};')
+ temp_vars.append(' char xcb_pad0[3] = {0, 0, 0};')
temp_vars.append(' struct iovec xcb_parts[%d];' % count)
temp_vars.append(' unsigned int xcb_parts_idx = 0;')
temp_vars.append(' unsigned int xcb_block_len = 0;')
@@ -1201,18 +1201,18 @@ def _c_serialize(context, self):
elif 'sizeof' == context:
# neither switch nor intermixed fixed and variable size fields:
# evaluate parameters directly
- if not (self.is_switch or self.var_followed_by_fixed_fields):
+ if not (self.is_switch or self.c_var_followed_by_fixed_fields):
# look if we have to declare an '_aux' variable at all
if len(list(filter(lambda x: x.find('_aux')!=-1, code_lines)))>0:
- if not self.var_followed_by_fixed_fields:
+ if not self.c_var_followed_by_fixed_fields:
_c(' const %s *_aux = (%s *)_buffer;', self.c_type, self.c_type)
else:
_c(' %s *_aux = malloc(sizeof(%s));', self.c_type, self.c_type)
_c(' unsigned int xcb_buffer_len = 0;')
_c(' unsigned int xcb_block_len = 0;')
- _c(' unsigned int xcb_pad = 0;')
+ _c(' unsigned int xcb_pad = 0;')
_c(' unsigned int xcb_align_to = 0;')
_c('')
@@ -1223,7 +1223,7 @@ def _c_serialize(context, self):
_c(l)
# variable sized fields have been collected, now
- # allocate memory and copy everything into a continuous memory area
+ # allocate memory and copy everything into a continuous memory area
# note: this is not necessary in case of unpack
if context in ('serialize', 'unserialize'):
# unserialize: check for sizeof-only invocation
@@ -1243,13 +1243,13 @@ def _c_serialize(context, self):
# serialize: handle variable size fields in a loop
if 'serialize' == context:
- if not self.is_switch and not self.var_followed_by_fixed_fields:
+ if not self.is_switch and not self.c_var_followed_by_fixed_fields:
if len(wire_fields)>0:
_c(' *xcb_out = *_aux;')
# copy variable size fields into the buffer
if variable_size_fields > 0:
# xcb_out padding
- if not self.is_switch and not self.var_followed_by_fixed_fields:
+ if not self.is_switch and not self.c_var_followed_by_fixed_fields:
_c(' xcb_tmp = (char*)++xcb_out;')
_c(' xcb_tmp += xcb_out_pad;')
else:
@@ -1262,7 +1262,7 @@ def _c_serialize(context, self):
_c(' if (0 != xcb_parts[i].iov_len)')
_c(' xcb_tmp += xcb_parts[i].iov_len;')
_c(' }')
-
+
# unserialize: assign variable size fields individually
if 'unserialize' == context:
_c(' xcb_tmp = ((char *)*_aux)+xcb_buffer_len;')
@@ -1272,7 +1272,7 @@ def _c_serialize(context, self):
_c(' xcb_tmp -= %s_len;', field.c_field_name)
_c(' memmove(xcb_tmp, %s, %s_len);', field.c_field_name, field.c_field_name)
_c(' *%s = xcb_out;', aux_ptr)
-
+
_c('')
_c(' return xcb_buffer_len;')
_c('}')
@@ -1321,16 +1321,6 @@ def _c_iterator(self, name):
_h(' * element. The member index is increased by sizeof(%s)', self.c_type)
_h(' */')
_c('')
- _hc('')
- _hc('/*****************************************************************************')
- _hc(' **')
- _hc(' ** void %s', self.c_next_name)
- _hc(' ** ')
- _hc(' ** @param %s *i', self.c_iterator_type)
- _hc(' ** @returns void')
- _hc(' **')
- _hc(' *****************************************************************************/')
- _hc(' ')
_hc('void')
_h('%s (%s *i /**< */);', self.c_next_name, self.c_iterator_type)
_c('%s (%s *i /**< */)', self.c_next_name, self.c_iterator_type)
@@ -1341,11 +1331,11 @@ def _c_iterator(self, name):
if self.is_union:
# FIXME - how to determine the size of a variable size union??
- _c(' /* FIXME - determine the size of the union %s */', self.c_type)
+ _c(' /* FIXME - determine the size of the union %s */', self.c_type)
else:
- if self.need_sizeof:
+ if self.c_need_sizeof:
_c(' xcb_generic_iterator_t child;')
- _c(' child.data = (%s *)(((char *)R) + %s(R));',
+ _c(' child.data = (%s *)(((char *)R) + %s(R));',
self.c_type, self.c_sizeof_name)
_c(' i->index = (char *) child.data - (char *) i->data;')
else:
@@ -1372,16 +1362,6 @@ def _c_iterator(self, name):
_h(' * last element.')
_h(' */')
_c('')
- _hc('')
- _hc('/*****************************************************************************')
- _hc(' **')
- _hc(' ** xcb_generic_iterator_t %s', self.c_end_name)
- _hc(' ** ')
- _hc(' ** @param %s i', self.c_iterator_type)
- _hc(' ** @returns xcb_generic_iterator_t')
- _hc(' **')
- _hc(' *****************************************************************************/')
- _hc(' ')
_hc('xcb_generic_iterator_t')
_h('%s (%s i /**< */);', self.c_end_name, self.c_iterator_type)
_c('%s (%s i /**< */)', self.c_end_name, self.c_iterator_type)
@@ -1405,7 +1385,7 @@ def _c_iterator(self, name):
def _c_accessor_get_length(expr, field_mapping=None):
'''
Figures out what C code is needed to get a length field.
- The field_mapping parameter can be used to change the absolute name of a length field.
+ The field_mapping parameter can be used to change the absolute name of a length field.
For fields that follow a variable-length field, use the accessor.
Otherwise, just reference the structure field directly.
'''
@@ -1414,7 +1394,7 @@ def _c_accessor_get_length(expr, field_mapping=None):
if lenfield_name is not None:
if field_mapping is not None:
lenfield_name = field_mapping[lenfield_name][0]
-
+
if expr.lenfield is not None and expr.lenfield.prev_varsized_field is not None:
# special case: variable and fixed size fields are intermixed
# if the lenfield is among the fixed size fields, there is no need
@@ -1428,7 +1408,7 @@ def _c_accessor_get_length(expr, field_mapping=None):
def _c_accessor_get_expr(expr, field_mapping):
'''
Figures out what C code is needed to get the length of a list field.
- The field_mapping parameter can be used to change the absolute name of a length field.
+ The field_mapping parameter can be used to change the absolute name of a length field.
Recurses for math operations.
Returns bitcount for value-mask fields.
Otherwise, uses the value of the length field.
@@ -1461,8 +1441,8 @@ def _c_accessor_get_expr(expr, field_mapping):
c_length_func = _c_accessor_get_expr(field.type.expr, field_mapping)
return 'xcb_sumof(%s, %s)' % (list_name, c_length_func)
elif expr.op != None:
- return ('(' + _c_accessor_get_expr(expr.lhs, field_mapping) +
- ' ' + expr.op + ' ' +
+ return ('(' + _c_accessor_get_expr(expr.lhs, field_mapping) +
+ ' ' + expr.op + ' ' +
_c_accessor_get_expr(expr.rhs, field_mapping) + ')')
elif expr.bitfield:
return 'xcb_popcount(' + lenexp + ')'
@@ -1489,16 +1469,6 @@ def _c_accessors_field(self, field):
if field.type.is_simple:
_hc('')
- _hc('')
- _hc('/*****************************************************************************')
- _hc(' ** ')
- _hc(' ** %s %s', field.c_field_type, field.c_accessor_name)
- _hc(' ** ')
- _hc(' ** @param const %s *R', c_type)
- _hc(' ** @returns %s', field.c_field_type)
- _hc(' **')
- _hc(' *****************************************************************************/')
- _hc(' ')
_hc('%s', field.c_field_type)
_h('%s (const %s *R /**< */);', field.c_accessor_name, c_type)
_c('%s (const %s *R /**< */)', field.c_accessor_name, c_type)
@@ -1507,21 +1477,11 @@ def _c_accessors_field(self, field):
_c(' return (%s *) (R + 1);', field.c_field_type)
else:
_c(' xcb_generic_iterator_t prev = %s;', _c_iterator_get_end(field.prev_varsized_field, 'R'))
- _c(' return * (%s *) ((char *) prev.data + XCB_TYPE_PAD(%s, prev.index) + %d);',
+ _c(' return * (%s *) ((char *) prev.data + XCB_TYPE_PAD(%s, prev.index) + %d);',
field.c_field_type, type_pad_type(field.first_field_after_varsized.type.c_type), field.prev_varsized_offset)
_c('}')
else:
_hc('')
- _hc('')
- _hc('/*****************************************************************************')
- _hc(' **')
- _hc(' ** %s * %s', field.c_field_type, field.c_accessor_name)
- _hc(' ** ')
- _hc(' ** @param const %s *R', c_type)
- _hc(' ** @returns %s *', field.c_field_type)
- _hc(' **')
- _hc(' *****************************************************************************/')
- _hc(' ')
if field.type.is_switch and switch_obj is None:
return_type = 'void *'
else:
@@ -1534,15 +1494,15 @@ def _c_accessors_field(self, field):
if field.prev_varsized_field is None:
_c(' return (%s) (R + 1);', return_type)
# note: the special case 'variable fields followed by fixed size fields'
- # is not of any consequence here, since the ordering gets
+ # is not of any consequence here, since the ordering gets
# 'corrected' in the reply function
else:
_c(' xcb_generic_iterator_t prev = %s;', _c_iterator_get_end(field.prev_varsized_field, 'R'))
- _c(' return (%s) ((char *) prev.data + XCB_TYPE_PAD(%s, prev.index) + %d);',
+ _c(' return (%s) ((char *) prev.data + XCB_TYPE_PAD(%s, prev.index) + %d);',
return_type, type_pad_type(field.first_field_after_varsized.type.c_type), field.prev_varsized_offset)
_c('}')
-
+
def _c_accessors_list(self, field):
'''
Declares the accessor functions for a list field.
@@ -1567,7 +1527,7 @@ def _c_accessors_list(self, field):
# in case of switch, 2 params have to be supplied to certain accessor functions:
# 1. the anchestor object (request or reply)
# 2. the (anchestor) switch object
- # the reason is that switch is either a child of a request/reply or nested in another switch,
+ # the reason is that switch is either a child of a request/reply or nested in another switch,
# so whenever we need to access a length field, we might need to refer to some anchestor type
switch_obj = self if self.is_switch else None
if self.is_bitcase:
@@ -1578,14 +1538,14 @@ def _c_accessors_list(self, field):
params = []
fields = {}
parents = self.parents if hasattr(self, 'parents') else [self]
- # 'R': parents[0] is always the 'toplevel' container type
+ # 'R': parents[0] is always the 'toplevel' container type
params.append(('const %s *R' % parents[0].c_type, parents[0]))
fields.update(_c_helper_field_mapping(parents[0], [('R', '->', parents[0])], flat=True))
# auxiliary object for 'R' parameters
R_obj = parents[0]
if switch_obj is not None:
- # now look where the fields are defined that are needed to evaluate
+ # now look where the fields are defined that are needed to evaluate
# the switch expr, and store the parent objects in accessor_params and
# the fields in switch_fields
@@ -1600,7 +1560,7 @@ def _c_accessors_list(self, field):
# look for fields in the remaining containers
for p in parents[2:] + [self]:
- # the separator between parent and child is always '.' here,
+ # the separator between parent and child is always '.' here,
# because of nested switch statements
if not p.is_bitcase or (p.is_bitcase and p.has_name):
prefix.append((p.name[-1], '.', p))
@@ -1614,16 +1574,6 @@ def _c_accessors_list(self, field):
if list.member.fixed_size():
idx = 1 if switch_obj is not None else 0
_hc('')
- _hc('')
- _hc('/*****************************************************************************')
- _hc(' **')
- _hc(' ** %s * %s', field.c_field_type, field.c_accessor_name)
- _hc(' ** ')
- _hc(' ** @param %s', params[idx][0])
- _hc(' ** @returns %s *', field.c_field_type)
- _hc(' **')
- _hc(' *****************************************************************************/')
- _hc(' ')
_hc('%s *', field.c_field_type)
_h('%s (%s /**< */);', field.c_accessor_name, params[idx][0])
@@ -1648,16 +1598,6 @@ def _c_accessors_list(self, field):
_c('}')
_hc('')
- _hc('')
- _hc('/*****************************************************************************')
- _hc(' **')
- _hc(' ** int %s', field.c_length_name)
- _hc(' ** ')
- _hc(' ** @param const %s *R', c_type)
- _hc(' ** @returns int')
- _hc(' **')
- _hc(' *****************************************************************************/')
- _hc(' ')
_hc('int')
if switch_obj is not None:
_hc('%s (const %s *R /**< */,', field.c_length_name, R_obj.c_type)
@@ -1675,16 +1615,6 @@ def _c_accessors_list(self, field):
if field.type.member.is_simple:
_hc('')
- _hc('')
- _hc('/*****************************************************************************')
- _hc(' **')
- _hc(' ** xcb_generic_iterator_t %s', field.c_end_name)
- _hc(' ** ')
- _hc(' ** @param const %s *R', c_type)
- _hc(' ** @returns xcb_generic_iterator_t')
- _hc(' **')
- _hc(' *****************************************************************************/')
- _hc(' ')
_hc('xcb_generic_iterator_t')
if switch_obj is not None:
_hc('%s (const %s *R /**< */,', field.c_end_name, R_obj.c_type)
@@ -1696,18 +1626,18 @@ def _c_accessors_list(self, field):
_c('%s (const %s *R /**< */)', field.c_end_name, c_type)
_c('{')
_c(' xcb_generic_iterator_t i;')
-
+
param = 'R' if switch_obj is None else 'S'
if switch_obj is not None:
- _c(' i.data = %s + %s;', fields[field.c_field_name][0],
+ _c(' i.data = %s + %s;', fields[field.c_field_name][0],
_c_accessor_get_expr(field.type.expr, fields))
elif field.prev_varsized_field == None:
- _c(' i.data = ((%s *) (R + 1)) + (%s);', field.type.c_wiretype,
+ _c(' i.data = ((%s *) (R + 1)) + (%s);', field.type.c_wiretype,
_c_accessor_get_expr(field.type.expr, fields))
else:
- _c(' xcb_generic_iterator_t child = %s;',
+ _c(' xcb_generic_iterator_t child = %s;',
_c_iterator_get_end(field.prev_varsized_field, 'R'))
- _c(' i.data = ((%s *) child.data) + (%s);', field.type.c_wiretype,
+ _c(' i.data = ((%s *) child.data) + (%s);', field.type.c_wiretype,
_c_accessor_get_expr(field.type.expr, fields))
_c(' i.rem = 0;')
@@ -1717,17 +1647,6 @@ def _c_accessors_list(self, field):
else:
_hc('')
- _hc('')
- _hc('/*****************************************************************************')
- _hc(' **')
- _hc(' ** %s %s', field.c_iterator_type, field.c_iterator_name)
- _hc(' ** ')
- _hc(' ** @param const %s *R', c_type)
- _hc(' ** @returns %s', field.c_iterator_type)
- _hc(' **')
- _hc(' *****************************************************************************/')
- _hc(' ')
-
_hc('%s', field.c_iterator_type)
if switch_obj is not None:
_hc('%s (const %s *R /**< */,', field.c_iterator_name, R_obj.c_type)
@@ -1767,7 +1686,7 @@ def _c_accessors(self, name, base):
'''
Declares the accessor functions for the fields of a structure.
'''
- # no accessors for switch itself -
+ # no accessors for switch itself -
# switch always needs to be unpacked explicitly
# if self.is_switch:
# pass
@@ -1819,7 +1738,7 @@ def _c_complex(self, force_packed = False):
continue
if field.wire:
struct_fields.append(field)
-
+
for field in struct_fields:
length = len(field.c_field_type)
# account for '*' pointer_spec
@@ -1930,12 +1849,12 @@ def _c_request_helper(self, name, cookie_type, void, regular, aux=False, reply_f
if field.wire and not field.auto:
# We need to set the field up in the structure
wire_fields.append(field)
- if field.type.need_serialize or field.type.need_sizeof:
+ if field.type.c_need_serialize or field.type.c_need_sizeof:
serial_fields.append(field)
-
+
for field in param_fields:
- c_field_const_type = field.c_field_const_type
- if field.type.need_serialize and not aux:
+ c_field_const_type = field.c_field_const_type
+ if field.type.c_need_serialize and not aux:
c_field_const_type = "const void"
if len(c_field_const_type) > maxtypelen:
maxtypelen = len(c_field_const_type)
@@ -1998,7 +1917,7 @@ def _c_request_helper(self, name, cookie_type, void, regular, aux=False, reply_f
_h(' * No description yet')
else:
_h(' * Delivers a request to the X server.')
- _h(' * ')
+ _h(' *')
if checked:
_h(' * This form can be used only if the request will not cause')
_h(' * a reply to be generated. Any returned error will be')
@@ -2009,26 +1928,6 @@ def _c_request_helper(self, name, cookie_type, void, regular, aux=False, reply_f
_h(' * placed in the event queue.')
_h(' */')
_c('')
- _hc('')
- _hc('/*****************************************************************************')
- _hc(' **')
- _hc(' ** %s %s', cookie_type, func_name)
- _hc(' ** ')
-
- spacing = ' ' * (maxtypelen - len('xcb_connection_t'))
- _hc(' ** @param xcb_connection_t%s *c', spacing)
-
- for field in param_fields:
- c_field_const_type = field.c_field_const_type
- if field.type.need_serialize and not aux:
- c_field_const_type = "const void"
- spacing = ' ' * (maxtypelen - len(c_field_const_type))
- _hc(' ** @param %s%s %s%s', c_field_const_type, spacing, field.c_pointer, field.c_field_name)
-
- _hc(' ** @returns %s', cookie_type)
- _hc(' **')
- _hc(' *****************************************************************************/')
- _hc(' ')
_hc('%s', cookie_type)
spacing = ' ' * (maxtypelen - len('xcb_connection_t'))
@@ -2041,25 +1940,25 @@ def _c_request_helper(self, name, cookie_type, void, regular, aux=False, reply_f
count = len(param_fields)
for field in param_fields:
count = count - 1
- c_field_const_type = field.c_field_const_type
+ c_field_const_type = field.c_field_const_type
c_pointer = field.c_pointer
- if field.type.need_serialize and not aux:
+ if field.type.c_need_serialize and not aux:
c_field_const_type = "const void"
c_pointer = '*'
spacing = ' ' * (maxtypelen - len(c_field_const_type))
comma = ',' if count else ');'
- _h('%s%s%s %s%s /**< */%s', func_spacing, c_field_const_type,
+ _h('%s%s%s %s%s /**< */%s', func_spacing, c_field_const_type,
spacing, c_pointer, field.c_field_name, comma)
comma = ',' if count else ')'
- _c('%s%s%s %s%s /**< */%s', func_spacing, c_field_const_type,
+ _c('%s%s%s %s%s /**< */%s', func_spacing, c_field_const_type,
spacing, c_pointer, field.c_field_name, comma)
count = 2
- if not self.var_followed_by_fixed_fields:
+ if not self.c_var_followed_by_fixed_fields:
for field in param_fields:
if not field.type.fixed_size():
count = count + 2
- if field.type.need_serialize:
+ if field.type.c_need_serialize:
# _serialize() keeps track of padding automatically
count -= 1
dimension = count + 2
@@ -2071,15 +1970,15 @@ def _c_request_helper(self, name, cookie_type, void, regular, aux=False, reply_f
_c(' /* opcode */ %s,', self.c_request_name.upper())
_c(' /* isvoid */ %d', 1 if void else 0)
_c(' };')
- _c(' ')
+ _c('')
_c(' struct iovec xcb_parts[%d];', dimension)
_c(' %s xcb_ret;', func_cookie)
_c(' %s xcb_out;', self.c_type)
- if self.var_followed_by_fixed_fields:
+ if self.c_var_followed_by_fixed_fields:
_c(' /* in the protocol description, variable size fields are followed by fixed size fields */')
_c(' void *xcb_aux = 0;')
-
+
for idx, f in enumerate(serial_fields):
if aux:
@@ -2088,10 +1987,10 @@ def _c_request_helper(self, name, cookie_type, void, regular, aux=False, reply_f
_c(' unsigned int i;')
_c(' unsigned int xcb_tmp_len;')
_c(' char *xcb_tmp;')
- _c(' ')
+ _c('')
# simple request call tracing
-# _c(' printf("in function %s\\n");' % func_name)
-
+# _c(' printf("in function %s\\n");' % func_name)
+
# fixed size fields
for field in wire_fields:
if field.type.fixed_size():
@@ -2109,16 +2008,16 @@ def _c_request_helper(self, name, cookie_type, void, regular, aux=False, reply_f
_c(' memcpy(xcb_out.%s, %s, %d);', field.c_field_name, field.c_field_name, field.type.nmemb)
def get_serialize_args(type_obj, c_field_name, aux_var, context='serialize'):
- serialize_args = get_serialize_params(context, type_obj,
- c_field_name,
+ serialize_args = get_serialize_params(context, type_obj,
+ c_field_name,
aux_var)[2]
return reduce(lambda x,y: "%s, %s" % (x,y), [a[2] for a in serialize_args])
# calls in order to free dyn. all. memory
free_calls = []
- _c(' ')
- if not self.var_followed_by_fixed_fields:
+ _c('')
+ if not self.c_var_followed_by_fixed_fields:
_c(' xcb_parts[2].iov_base = (char *) &xcb_out;')
_c(' xcb_parts[2].iov_len = sizeof(xcb_out);')
_c(' xcb_parts[3].iov_base = 0;')
@@ -2130,25 +2029,25 @@ def _c_request_helper(self, name, cookie_type, void, regular, aux=False, reply_f
if not field.type.fixed_size():
_c(' /* %s %s */', field.type.c_type, field.c_field_name)
# default: simple cast to char *
- if not field.type.need_serialize and not field.type.need_sizeof:
+ if not field.type.c_need_serialize and not field.type.c_need_sizeof:
_c(' xcb_parts[%d].iov_base = (char *) %s;', count, field.c_field_name)
if field.type.is_list:
if field.type.member.fixed_size():
- _c(' xcb_parts[%d].iov_len = %s * sizeof(%s);', count,
- _c_accessor_get_expr(field.type.expr, None),
+ _c(' xcb_parts[%d].iov_len = %s * sizeof(%s);', count,
+ _c_accessor_get_expr(field.type.expr, None),
field.type.member.c_wiretype)
else:
list_length = _c_accessor_get_expr(field.type.expr, None)
-
+
length = ''
_c(" xcb_parts[%d].iov_len = 0;" % count)
_c(" xcb_tmp = (char *)%s;", field.c_field_name)
_c(" for(i=0; i<%s; i++) {" % list_length)
- _c(" xcb_tmp_len = %s(xcb_tmp);" %
+ _c(" xcb_tmp_len = %s(xcb_tmp);" %
(field.type.c_sizeof_name))
_c(" xcb_parts[%d].iov_len += xcb_tmp_len;" % count)
_c(" xcb_tmp += xcb_tmp_len;")
- _c(" }")
+ _c(" }")
else:
# not supposed to happen
raise Exception("unhandled variable size field %s" % field.c_field_name)
@@ -2158,7 +2057,7 @@ def _c_request_helper(self, name, cookie_type, void, regular, aux=False, reply_f
idx = serial_fields.index(field)
aux_var = '&xcb_aux%d' % idx
context = 'serialize' if aux else 'sizeof'
- _c(' xcb_parts[%d].iov_len = ', count)
+ _c(' xcb_parts[%d].iov_len =', count)
if aux:
serialize_args = get_serialize_args(field.type, aux_var, field.c_field_name, context)
_c(' %s (%s);', field.type.c_serialize_name, serialize_args)
@@ -2170,17 +2069,17 @@ def _c_request_helper(self, name, cookie_type, void, regular, aux=False, reply_f
_c(' %s (%s);', func_name, serialize_args)
count += 1
- if not (field.type.need_serialize or field.type.need_sizeof):
+ if not (field.type.c_need_serialize or field.type.c_need_sizeof):
# the _serialize() function keeps track of padding automatically
_c(' xcb_parts[%d].iov_base = 0;', count)
_c(' xcb_parts[%d].iov_len = -xcb_parts[%d].iov_len & 3;', count, count-1)
count += 1
- # elif self.var_followed_by_fixed_fields:
+ # elif self.c_var_followed_by_fixed_fields:
else:
_c(' xcb_parts[2].iov_base = (char *) &xcb_out;')
# request header: opcodes + length
- _c(' xcb_parts[2].iov_len = 2*sizeof(uint8_t) + sizeof(uint16_t);')
+ _c(' xcb_parts[2].iov_len = 2*sizeof(uint8_t) + sizeof(uint16_t);')
count += 1
# call _serialize()
buffer_var = '&xcb_aux'
@@ -2190,13 +2089,13 @@ def _c_request_helper(self, name, cookie_type, void, regular, aux=False, reply_f
free_calls.append(' free(xcb_aux);')
# no padding necessary - _serialize() keeps track of padding automatically
- _c(' ')
+ _c('')
for field in param_fields:
if field.isfd:
_c(' xcb_send_fd(c, %s);', field.c_field_name)
-
+
_c(' xcb_ret.sequence = xcb_send_request(c, %s, xcb_parts + 2, &xcb_req);', func_flags)
-
+
# free dyn. all. data, if any
for f in free_calls:
_c(f)
@@ -2210,7 +2109,7 @@ def _c_reply(self, name):
spacing1 = ' ' * (len(self.c_cookie_type) - len('xcb_connection_t'))
spacing2 = ' ' * (len(self.c_cookie_type) - len('xcb_generic_error_t'))
spacing3 = ' ' * (len(self.c_reply_name) + 2)
-
+
# check if _unserialize() has to be called for any field
def look_for_special_cases(complex_obj):
unserialize_fields = []
@@ -2220,19 +2119,19 @@ def _c_reply(self, name):
# three cases: 1. field with special case
# 2. container that contains special case field
# 3. list with special case elements
- if field.type.var_followed_by_fixed_fields:
+ if field.type.c_var_followed_by_fixed_fields:
unserialize_fields.append(field)
elif field.type.is_container:
unserialize_fields += look_for_special_cases(field.type)
elif field.type.is_list:
- if field.type.member.var_followed_by_fixed_fields:
+ if field.type.member.c_var_followed_by_fixed_fields:
unserialize_fields.append(field)
if field.type.member.is_container:
unserialize_fields += look_for_special_cases(field.type.member)
return unserialize_fields
-
+
unserialize_fields = look_for_special_cases(self.reply)
-
+
_h('')
_h('/**')
_h(' * Return the reply')
@@ -2241,7 +2140,7 @@ def _c_reply(self, name):
_h(' * @param e The xcb_generic_error_t supplied')
_h(' *')
_h(' * Returns the reply of the request asked by')
- _h(' * ')
+ _h(' *')
_h(' * The parameter @p e supplied to this function must be NULL if')
_h(' * %s(). is used.', self.c_unchecked_name)
_h(' * Otherwise, it stores the error if any.')
@@ -2249,28 +2148,16 @@ def _c_reply(self, name):
_h(' * The returned value must be freed by the caller using free().')
_h(' */')
_c('')
- _hc('')
- _hc('/*****************************************************************************')
- _hc(' **')
- _hc(' ** %s * %s', self.c_reply_type, self.c_reply_name)
- _hc(' ** ')
- _hc(' ** @param xcb_connection_t%s *c', spacing1)
- _hc(' ** @param %s cookie', self.c_cookie_type)
- _hc(' ** @param xcb_generic_error_t%s **e', spacing2)
- _hc(' ** @returns %s *', self.c_reply_type)
- _hc(' **')
- _hc(' *****************************************************************************/')
- _hc(' ')
_hc('%s *', self.c_reply_type)
_hc('%s (xcb_connection_t%s *c /**< */,', self.c_reply_name, spacing1)
_hc('%s%s cookie /**< */,', spacing3, self.c_cookie_type)
_h('%sxcb_generic_error_t%s **e /**< */);', spacing3, spacing2)
_c('%sxcb_generic_error_t%s **e /**< */)', spacing3, spacing2)
_c('{')
-
+
if len(unserialize_fields)>0:
# certain variable size fields need to be unserialized explicitly
- _c(' %s *reply = (%s *) xcb_wait_for_reply(c, cookie.sequence, e);',
+ _c(' %s *reply = (%s *) xcb_wait_for_reply(c, cookie.sequence, e);',
self.c_reply_type, self.c_reply_type)
_c(' int i;')
for field in unserialize_fields:
@@ -2286,13 +2173,13 @@ def _c_reply(self, name):
if field.type.is_list:
_c(' for(i=0; i<%s_len; i++) {', field.c_field_name)
_c(' %s_data = %s_iter.data;', field.c_field_name, field.c_field_name)
- _c(' %s((const void *)%s_data, &%s_data);', field.type.c_unserialize_name,
+ _c(' %s((const void *)%s_data, &%s_data);', field.type.c_unserialize_name,
field.c_field_name, field.c_field_name)
_c(' %s(&%s_iter);', field.type.c_next_name, field.c_field_name)
_c(' }')
# return the transformed reply
_c(' return reply;')
-
+
else:
_c(' return (%s *) xcb_wait_for_reply(c, cookie.sequence, e);', self.c_reply_type)
@@ -2317,31 +2204,20 @@ def _c_reply_fds(self, name):
_h(' * @param reply The reply')
_h(' *')
_h(' * Returns the array of reply fds of the request asked by')
- _h(' * ')
+ _h(' *')
_h(' * The returned value must be freed by the caller using free().')
_h(' */')
_c('')
- _hc('')
- _hc('/*****************************************************************************')
- _hc(' **')
- _hc(' ** int * %s', self.c_reply_fds_name)
- _hc(' ** ')
- _hc(' ** @param xcb_connection_t%s *c', spacing1)
- _hc(' ** @param %s *reply', self.c_reply_type)
- _hc(' ** @returns int *')
- _hc(' **')
- _hc(' *****************************************************************************/')
- _hc(' ')
_hc('int *')
_hc('%s (xcb_connection_t%s *c /**< */,', self.c_reply_fds_name, spacing1)
_h('%s%s *reply /**< */);', spacing3, self.c_reply_type)
_c('%s%s *reply /**< */)', spacing3, self.c_reply_type)
_c('{')
-
+
_c(' return xcb_get_reply_fds(c, reply, sizeof(%s) + 4 * reply->length);', self.c_reply_type)
_c('}')
-
+
def _c_opcode(name, opcode):
'''
@@ -2351,7 +2227,7 @@ def _c_opcode(name, opcode):
_h('')
_h('/** Opcode for %s. */', _n(name))
_h('#define %s %s', _n(name).upper(), opcode)
-
+
def _c_cookie(self, name):
'''
Declares the cookie type for a non-void request.
@@ -2402,7 +2278,7 @@ def _man_request(self, name, cookie_type, void, aux):
c_pointer = field.c_pointer
if c_pointer == ' ':
c_pointer = ''
- if field.type.need_serialize and not aux:
+ if field.type.c_need_serialize and not aux:
c_field_const_type = "const void"
c_pointer = '*'
comma = ', ' if count else ');'
@@ -2717,7 +2593,7 @@ def _man_request(self, name, cookie_type, void, aux):
(cookie_type, self.c_reply_name, base_func_name, section))
f.write('.SH ERRORS\n')
if hasattr(self, "doc") and self.doc:
- for errtype, errtext in self.doc.errors.items():
+ for errtype, errtext in sorted(self.doc.errors.items()):
f.write('.IP \\fI%s\\fP 1i\n' % (_t(('xcb', errtype, 'error'))))
errtext = re.sub(r'`([^`]+)`', r'\\fI\1\\fP', errtext)
f.write('%s\n' % (errtext))
@@ -2735,7 +2611,7 @@ def _man_request(self, name, cookie_type, void, aux):
see = ['.BR %s (%s)' % ('xcb-requests', section)]
if self.doc.example:
see.append('.BR %s (%s)' % ('xcb-examples', section))
- for seename, seetype in self.doc.see.items():
+ for seename, seetype in sorted(self.doc.see.items()):
if seetype == 'program':
see.append('.BR %s (1)' % seename)
elif seetype == 'event':
@@ -2865,7 +2741,7 @@ def _man_event(self, name):
see = ['.BR %s (%s)' % ('xcb_generic_event_t', section)]
if self.doc.example:
see.append('.BR %s (%s)' % ('xcb-examples', section))
- for seename, seetype in self.doc.see.items():
+ for seename, seetype in sorted(self.doc.see.items()):
if seetype == 'program':
see.append('.BR %s (1)' % seename)
elif seetype == 'event':
@@ -2906,7 +2782,7 @@ def c_request(self, name):
has_fds = _c_reply_has_fds(self.reply)
_c_request_helper(self, name, self.c_cookie_type, False, True, False, has_fds)
_c_request_helper(self, name, self.c_cookie_type, False, False, False, has_fds)
- if self.need_aux:
+ if self.c_need_aux:
_c_request_helper(self, name, self.c_cookie_type, False, True, True, has_fds)
_c_request_helper(self, name, self.c_cookie_type, False, False, True, has_fds)
# Reply accessors
@@ -2918,7 +2794,7 @@ def c_request(self, name):
# Request prototypes
_c_request_helper(self, name, 'xcb_void_cookie_t', True, False)
_c_request_helper(self, name, 'xcb_void_cookie_t', True, True)
- if self.need_aux:
+ if self.c_need_aux:
_c_request_helper(self, name, 'xcb_void_cookie_t', True, False, True)
_c_request_helper(self, name, 'xcb_void_cookie_t', True, True, True)
@@ -2998,7 +2874,7 @@ output = {'open' : c_open,
'union' : c_union,
'request' : c_request,
'event' : c_event,
- 'error' : c_error,
+ 'error' : c_error,
}
# Boilerplate below this point
@@ -3045,8 +2921,6 @@ except OSError as e:
if e.errno != errno.EEXIST:
raise
-today = time.strftime('%Y-%m-%d', time.gmtime(os.path.getmtime(args[0])))
-
# Parse the xml header
module = Module(args[0], output)
diff --git a/libxcb/src/xcb.h b/libxcb/src/xcb.h
index b180be8ef..b64754f55 100644
--- a/libxcb/src/xcb.h
+++ b/libxcb/src/xcb.h
@@ -402,7 +402,7 @@ void xcb_discard_reply(xcb_connection_t *c, unsigned int sequence);
* The result must not be freed. This storage is managed by the cache
* itself.
*/
-const xcb_query_extension_reply_t *xcb_get_extension_data(xcb_connection_t *c, xcb_extension_t *ext);
+const struct xcb_query_extension_reply_t *xcb_get_extension_data(xcb_connection_t *c, xcb_extension_t *ext);
/**
* @brief Prefetch of extension data into the extension cache
@@ -438,7 +438,7 @@ void xcb_prefetch_extension_data(xcb_connection_t *c, xcb_extension_t *ext);
*
* The result must not be freed.
*/
-const xcb_setup_t *xcb_get_setup(xcb_connection_t *c);
+const struct xcb_setup_t *xcb_get_setup(xcb_connection_t *c);
/**
* @brief Access the file descriptor of the connection.
diff --git a/libxcb/xcb-proto/NEWS b/libxcb/xcb-proto/NEWS
index 02727faf4..3ab5cc096 100644
--- a/libxcb/xcb-proto/NEWS
+++ b/libxcb/xcb-proto/NEWS
@@ -1,3 +1,17 @@
+Release 1.11 (2014-08-01)
+=========================
+* Add support for <pad align="n" />
+* xkb: Fix padding bug in GetMap
+* xcbgen: Track directly included modules
+* xprint: Fix PrintGetAttributes reply
+* xkb: Fix use of nKTLevels
+* xv: Fix padding in struct AdaptorInfo
+* xproto: Fix EnterNotify documentation
+* Update the protocol schema
+* xinput: Add missing pad in DeviceResolutionCtl
+* xinput: Add missing pad in XIChangeHierarchy
+* xinput: Add missing modLatches as comment in LatchLockState
+
Release 1.10 (2013-12-22)
=========================
* xkb: comment out portions that libxcb doesn't handle properly
diff --git a/libxcb/xcb-proto/configure.ac b/libxcb/xcb-proto/configure.ac
index a235f930c..d140bfe70 100644
--- a/libxcb/xcb-proto/configure.ac
+++ b/libxcb/xcb-proto/configure.ac
@@ -3,7 +3,7 @@
AC_PREREQ(2.57)
AC_INIT([XCB Proto],
- 1.10,
+ 1.11,
[xcb@lists.freedesktop.org])
AC_CONFIG_SRCDIR([xcb-proto.pc.in])
AM_INIT_AUTOMAKE([foreign dist-bzip2])
diff --git a/libxcb/xcb-proto/doc/xml-xcb.txt b/libxcb/xcb-proto/doc/xml-xcb.txt
index 7311911f6..97ce5bf8e 100644
--- a/libxcb/xcb-proto/doc/xml-xcb.txt
+++ b/libxcb/xcb-proto/doc/xml-xcb.txt
@@ -201,6 +201,14 @@ enum; the value is restricted to one of the constants named in the enum.
declares the data type of the field, and the name attribute gives the name
of the field.
+<fd name="identifier" />
+
+ This element represents a file descriptor field passed with the request. The
+ name attribute gives the name of the field.
+
+ While ordinary fields are encoded as part of the request, file descriptor
+ fields are generally passed via an out-of-band mechanism.
+
<list type="identifier" name="identifier">expression</list>
This element represents an array or list of fields in a data structure. The
diff --git a/libxcb/xcb-proto/src/xcb.xsd b/libxcb/xcb-proto/src/xcb.xsd
index 580d2588d..59bb9a883 100644
--- a/libxcb/xcb-proto/src/xcb.xsd
+++ b/libxcb/xcb-proto/src/xcb.xsd
@@ -91,7 +91,11 @@ authorization from the authors.
<xsd:element name="field" type="var" />
<!-- fd passing parameter -->
- <xsd:element name="fd" />
+ <xsd:element name="fd">
+ <xsd:complexType>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
<!-- list replaces ARRAYFIELD, LISTPARAM, and ARRAYREPLY. The name and type
are specified as attributes. The content is an expression giving the
@@ -158,8 +162,8 @@ authorization from the authors.
<xsd:attribute name="ref" use="required" type="xsd:string" />
</xsd:complexType>
</xsd:element>
- <xsd:element name="value" type="dec-or-hex-integer" />
- <xsd:element name="bit" type="xsd:integer" />
+ <xsd:element name="value" type="xsd:integer" />
+ <xsd:element name="bit" type="bitType" />
</xsd:choice>
</xsd:group>
@@ -220,18 +224,14 @@ authorization from the authors.
<xsd:attribute name="ref" type="xsd:string" use="required" />
</xsd:complexType>
- <!-- Type for hex integers -->
- <xsd:simpleType name="hex-integer">
- <xsd:restriction base="xsd:string">
- <xsd:pattern value="0x[0-9a-fA-F]+" />
+ <!-- Type for bit values -->
+ <xsd:simpleType name="bitType">
+ <xsd:restriction base="xsd:integer">
+ <xsd:minInclusive value="0" />
+ <xsd:maxExclusive value="32" />
</xsd:restriction>
</xsd:simpleType>
- <!-- Type for integers in either decimal or hex -->
- <xsd:simpleType name="dec-or-hex-integer">
- <xsd:union memberTypes="xsd:integer hex-integer" />
- </xsd:simpleType>
-
<!-- Type for documentation -->
<xsd:group name="doc-fields">
<xsd:sequence>
@@ -317,7 +317,7 @@ authorization from the authors.
<xsd:attribute name="name" type="xsd:string" use="required" />
<xsd:attribute name="opcode" type="xsd:integer" use="required" />
<xsd:attribute name="combine-adjacent" type="xsd:boolean"
- use="optional"/>
+ use="optional" default="false" />
</xsd:complexType>
</xsd:element>
<xsd:element name="event">
@@ -328,8 +328,9 @@ authorization from the authors.
<xsd:element ref="doc" minOccurs="0" maxOccurs="1" />
</xsd:sequence>
<xsd:attribute name="no-sequence-number" type="xsd:boolean"
- use="optional" />
- <xsd:attribute name="xge" type="xsd:boolean" use="optional" />
+ use="optional" default="false" />
+ <xsd:attribute name="xge" type="xsd:boolean"
+ use="optional" default="false" />
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
@@ -359,8 +360,8 @@ authorization from the authors.
<xsd:element name="item">
<xsd:complexType>
<xsd:choice minOccurs="1" maxOccurs="1">
- <xsd:element name="value" type="dec-or-hex-integer" />
- <xsd:element name="bit" type="xsd:integer" />
+ <xsd:element name="value" type="xsd:unsignedInt" />
+ <xsd:element name="bit" type="bitType" />
</xsd:choice>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
diff --git a/libxcb/xcb-proto/src/xinput.xml b/libxcb/xcb-proto/src/xinput.xml
index 924c003c7..86350dea0 100644
--- a/libxcb/xcb-proto/src/xinput.xml
+++ b/libxcb/xcb-proto/src/xinput.xml
@@ -914,6 +914,7 @@ authorization from the authors.
<field type="CARD16" name="len" />
<field type="CARD8" name="first_valuator" />
<field type="CARD8" name="num_valuators" />
+ <pad bytes="2" />
<list type="CARD32" name="resolution_values">
<fieldref>num_valuators</fieldref>
</list>
@@ -1229,6 +1230,7 @@ authorization from the authors.
<request name="XIChangeHierarchy" opcode="43">
<field type="CARD8" name="num_changes" />
+ <pad bytes="3" />
<list type="HierarchyChange" name="changes">
<fieldref>num_changes</fieldref>
</list>
diff --git a/libxcb/xcb-proto/src/xkb.xml b/libxcb/xcb-proto/src/xkb.xml
index 04ab4297a..ad52ea2a4 100644
--- a/libxcb/xcb-proto/src/xkb.xml
+++ b/libxcb/xcb-proto/src/xkb.xml
@@ -1204,6 +1204,10 @@ authorization from the authors.
<field name="lockGroup" type="BOOL" />
<field name="groupLock" type="CARD8" enum="Group" />
<field name="affectModLatches" type="CARD8" mask="ModMask" />
+ <pad bytes="1" /> <!-- This pad is a workaround to prevent an API break,
+ which the following field (correct fix) would cause.
+ <field name="modLatches" type="CARD8" mask="ModMask" />
+ -->
<pad bytes="1" />
<field name="latchGroup" type="BOOL" />
<field name="groupLatch" type="CARD16" />
diff --git a/libxcb/xcb-proto/src/xproto.xml b/libxcb/xcb-proto/src/xproto.xml
index 07795682c..bfb8a4cff 100644
--- a/libxcb/xcb-proto/src/xproto.xml
+++ b/libxcb/xcb-proto/src/xproto.xml
@@ -506,11 +506,11 @@ event.
<doc>
<brief>the pointer is in a different window</brief>
<field name="event"><![CDATA[
-The reconfigured window or its parent, depending on whether `StructureNotify`
-or `SubstructureNotify` was selected.
+The window on which the event was generated.
]]></field>
- <field name="window"><![CDATA[
-The window that was unmapped.
+ <field name="child"><![CDATA[
+If the `event` window has subwindows and the final pointer position is in one
+of them, then `child` is set to that subwindow, `XCB_WINDOW_NONE` otherwise.
]]></field>
<field name="root"><![CDATA[
The root window for the final cursor position.
diff --git a/mesalib/configure.ac b/mesalib/configure.ac
index d06730d34..cd02babd6 100644
--- a/mesalib/configure.ac
+++ b/mesalib/configure.ac
@@ -28,7 +28,7 @@ AC_SUBST([OSMESA_VERSION])
dnl Versions for external dependencies
LIBDRM_REQUIRED=2.4.38
-LIBDRM_RADEON_REQUIRED=2.4.54
+LIBDRM_RADEON_REQUIRED=2.4.56
LIBDRM_INTEL_REQUIRED=2.4.52
LIBDRM_NVVIEUX_REQUIRED=2.4.33
LIBDRM_NOUVEAU_REQUIRED="2.4.33 libdrm >= 2.4.41"
@@ -301,10 +301,20 @@ AC_ARG_ENABLE([debug],
if test "x$enable_debug" = xyes; then
DEFINES="$DEFINES -DDEBUG"
if test "x$GCC" = xyes; then
- CFLAGS="$CFLAGS -g -O0"
+ if ! echo "$CFLAGS" | grep -q -e '-g'; then
+ CFLAGS="$CFLAGS -g"
+ fi
+ if ! echo "$CFLAGS" | grep -q -e '-O'; then
+ CFLAGS="$CFLAGS -O0"
+ fi
fi
if test "x$GXX" = xyes; then
- CXXFLAGS="$CXXFLAGS -g -O0"
+ if ! echo "$CXXFLAGS" | grep -q -e '-g'; then
+ CXXFLAGS="$CXXFLAGS -g"
+ fi
+ if ! echo "$CXXFLAGS" | grep -q -e '-O'; then
+ CXXFLAGS="$CXXFLAGS -O0"
+ fi
fi
fi
@@ -525,10 +535,10 @@ AC_CHECK_FUNC([dlopen], [DEFINES="$DEFINES -DHAVE_DLOPEN"],
AC_SUBST([DLOPEN_LIBS])
dnl Check if that library also has dladdr
-save_LDFLAGS="$LDFLAGS"
-LDFLAGS="$LDFLAGS $DLOPEN_LIBS"
+save_LIBS="$LIBS"
+LIBS="$LIBS $DLOPEN_LIBS"
AC_CHECK_FUNCS([dladdr])
-LDFLAGS="$save_LDFLAGS"
+LIBS="$save_LIBS"
case "$host_os" in
darwin*|mingw*)
@@ -714,7 +724,7 @@ GALLIUM_DRIVERS_DEFAULT="r300,r600,svga,swrast"
AC_ARG_WITH([gallium-drivers],
[AS_HELP_STRING([--with-gallium-drivers@<:@=DIRS...@:>@],
[comma delimited Gallium drivers list, e.g.
- "i915,ilo,nouveau,r300,r600,radeonsi,freedreno,svga,swrast"
+ "i915,ilo,nouveau,r300,r600,radeonsi,freedreno,svga,swrast,vc4"
@<:@default=r300,r600,svga,swrast@:>@])],
[with_gallium_drivers="$withval"],
[with_gallium_drivers="$GALLIUM_DRIVERS_DEFAULT"])
@@ -1845,6 +1855,7 @@ gallium_check_st() {
gallium_require_llvm() {
if test "x$MESA_LLVM" = x0; then
+ case "$host" in *gnux32) return;; esac
case "$host_cpu" in
i*86|x86_64|amd64) AC_MSG_ERROR([LLVM is required to build $1 on x86 and x86_64]);;
esac
@@ -1935,7 +1946,7 @@ if test -n "$with_gallium_drivers"; then
gallium_require_drm_loader
gallium_require_llvm "Gallium R300"
GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS r300"
- gallium_check_st "radeon/drm" "dri/r300" "xa/r300" "" ""
+ gallium_check_st "radeon/drm" "dri/r300"
;;
xr600)
HAVE_GALLIUM_R600=yes
@@ -1952,7 +1963,7 @@ if test -n "$with_gallium_drivers"; then
if test "x$enable_opencl" = xyes; then
LLVM_COMPONENTS="${LLVM_COMPONENTS} bitreader asmparser"
fi
- gallium_check_st "radeon/drm" "dri/r600" "xa/r600" "xvmc/r600" "vdpau/r600" "omx/r600"
+ gallium_check_st "radeon/drm" "dri/r600" "" "xvmc/r600" "vdpau/r600" "omx/r600"
;;
xradeonsi)
HAVE_GALLIUM_RADEONSI=yes
@@ -1961,7 +1972,7 @@ if test -n "$with_gallium_drivers"; then
GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS radeonsi"
radeon_llvm_check "radeonsi"
require_egl_drm "radeonsi"
- gallium_check_st "radeon/drm" "dri/radeonsi" "xa/radeonsi" "" "vdpau/radeonsi" "omx/radeonsi"
+ gallium_check_st "radeon/drm" "dri/radeonsi" "" "" "vdpau/radeonsi" "omx/radeonsi"
;;
xnouveau)
HAVE_GALLIUM_NOUVEAU=yes
@@ -1988,6 +1999,22 @@ if test -n "$with_gallium_drivers"; then
if test "x$enable_dri" = xyes; then
GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS dri/swrast"
fi
+
+ if test "x$have_libdrm" = xyes; then
+ GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS dri/kms-swrast"
+ fi
+ ;;
+ xvc4)
+ HAVE_GALLIUM_VC4=yes
+ gallium_require_drm_loader
+ GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS vc4"
+ gallium_check_st "vc4/drm" "dri-vc4" "" "" ""
+
+ case "$host_cpu" in
+ i?86 | x86_64 | amd64)
+ USE_VC4_SIMULATOR=yes
+ ;;
+ esac
;;
*)
AC_MSG_ERROR([Unknown Gallium driver: $driver])
@@ -2050,6 +2077,7 @@ AM_CONDITIONAL(HAVE_GALLIUM_NOUVEAU, test "x$HAVE_GALLIUM_NOUVEAU" = xyes)
AM_CONDITIONAL(HAVE_GALLIUM_FREEDRENO, test "x$HAVE_GALLIUM_FREEDRENO" = xyes)
AM_CONDITIONAL(HAVE_GALLIUM_SOFTPIPE, test "x$HAVE_GALLIUM_SOFTPIPE" = xyes)
AM_CONDITIONAL(HAVE_GALLIUM_LLVMPIPE, test "x$HAVE_GALLIUM_LLVMPIPE" = xyes)
+AM_CONDITIONAL(HAVE_GALLIUM_VC4, test "x$HAVE_GALLIUM_VC4" = xyes)
AM_CONDITIONAL(NEED_GALLIUM_SOFTPIPE_DRIVER, test "x$HAVE_GALLIUM_SVGA" = xyes -o \
"x$HAVE_GALLIUM_SOFTPIPE" = xyes)
@@ -2115,6 +2143,10 @@ AM_CONDITIONAL(HAVE_LOADER_GALLIUM, test x$enable_gallium_loader = xyes)
AM_CONDITIONAL(HAVE_DRM_LOADER_GALLIUM, test x$enable_gallium_drm_loader = xyes)
AM_CONDITIONAL(HAVE_GALLIUM_COMPUTE, test x$enable_opencl = xyes)
AM_CONDITIONAL(HAVE_MESA_LLVM, test x$MESA_LLVM = x1)
+AM_CONDITIONAL(USE_VC4_SIMULATOR, test x$USE_VC4_SIMULATOR = xyes)
+if test "x$USE_VC4_SIMULATOR" = xyes -a "x$HAVE_GALLIUM_ILO" = xyes; then
+ AC_MSG_ERROR([VC4 simulator on x86 replaces i965 driver build, so ilo must be disabled.])
+fi
AC_SUBST([ELF_LIB])
@@ -2187,6 +2219,7 @@ AC_CONFIG_FILES([Makefile
src/gallium/drivers/softpipe/Makefile
src/gallium/drivers/svga/Makefile
src/gallium/drivers/trace/Makefile
+ src/gallium/drivers/vc4/Makefile
src/gallium/state_trackers/Makefile
src/gallium/state_trackers/clover/Makefile
src/gallium/state_trackers/dri/Makefile
@@ -2224,10 +2257,12 @@ AC_CONFIG_FILES([Makefile
src/gallium/winsys/svga/drm/Makefile
src/gallium/winsys/sw/dri/Makefile
src/gallium/winsys/sw/fbdev/Makefile
+ src/gallium/winsys/sw/kms-dri/Makefile
src/gallium/winsys/sw/null/Makefile
src/gallium/winsys/sw/wayland/Makefile
src/gallium/winsys/sw/wrapper/Makefile
src/gallium/winsys/sw/xlib/Makefile
+ src/gallium/winsys/vc4/drm/Makefile
src/gbm/Makefile
src/gbm/main/gbm.pc
src/glsl/Makefile
@@ -2264,7 +2299,8 @@ AC_CONFIG_FILES([Makefile
src/mesa/drivers/osmesa/osmesa.pc
src/mesa/drivers/x11/Makefile
src/mesa/main/tests/Makefile
- src/mesa/main/tests/hash_table/Makefile])
+ src/util/Makefile
+ src/util/tests/hash_table/Makefile])
dnl Sort the dirs alphabetically
GALLIUM_TARGET_DIRS=`echo $GALLIUM_TARGET_DIRS|tr " " "\n"|sort -u|tr "\n" " "`
diff --git a/mesalib/docs/GL3.txt b/mesalib/docs/GL3.txt
index f9e33b4fe..3d610f6e1 100644
--- a/mesalib/docs/GL3.txt
+++ b/mesalib/docs/GL3.txt
@@ -18,9 +18,8 @@ are exposed in the 3.0 context as extensions.
Feature Status
----------------------------------------------------- ------------------------
-GL 3.0 --- all DONE: i965, nv50, nvc0, r600, radeonsi
+GL 3.0, GLSL 1.30 --- all DONE: i965, nv50, nvc0, r600, radeonsi
- GLSL 1.30 DONE ()
glBindFragDataLocation, glGetFragDataLocation DONE
Conditional rendering (GL_NV_conditional_render) DONE (r300, swrast)
Map buffer subranges (GL_ARB_map_buffer_range) DONE (r300, swrast)
@@ -49,9 +48,8 @@ GL 3.0 --- all DONE: i965, nv50, nvc0, r600, radeonsi
Multisample anti-aliasing DONE (r300)
-GL 3.1 --- all DONE: i965, nv50, nvc0, r600, radeonsi
+GL 3.1, GLSL 1.40 --- all DONE: i965, nv50, nvc0, r600, radeonsi
- GLSL 1.40 DONE ()
Forward compatible context support/deprecations DONE ()
Instanced drawing (GL_ARB_draw_instanced) DONE (swrast)
Buffer copying (GL_ARB_copy_buffer) DONE (r300, swrast)
@@ -63,10 +61,9 @@ GL 3.1 --- all DONE: i965, nv50, nvc0, r600, radeonsi
Signed normalized textures (GL_EXT_texture_snorm) DONE (r300)
-GL 3.2 --- all DONE: i965, nv50, nvc0, r600, radeonsi
+GL 3.2, GLSL 1.50 --- all DONE: i965, nv50, nvc0, r600, radeonsi
Core/compatibility profiles DONE
- GLSL 1.50 DONE ()
Geometry shaders DONE ()
BGRA vertex order (GL_ARB_vertex_array_bgra) DONE (r300, swrast)
Base vertex offset(GL_ARB_draw_elements_base_vertex) DONE (r300, swrast)
@@ -79,9 +76,8 @@ GL 3.2 --- all DONE: i965, nv50, nvc0, r600, radeonsi
GLX_ARB_create_context_profile DONE
-GL 3.3 --- all DONE: i965, nv50, nvc0, r600, radeonsi
+GL 3.3, GLSL 3.30 --- all DONE: i965, nv50, nvc0, r600, radeonsi
- GLSL 3.30 DONE ()
GL_ARB_blend_func_extended DONE (softpipe)
GL_ARB_explicit_attrib_location DONE (all drivers that support GLSL)
GL_ARB_occlusion_query2 DONE (r300, swrast)
@@ -94,9 +90,8 @@ GL 3.3 --- all DONE: i965, nv50, nvc0, r600, radeonsi
GL_ARB_vertex_type_2_10_10_10_rev DONE ()
-GL 4.0:
+GL 4.0, GLSL 4.00:
- GLSL 4.0 not started
GL_ARB_draw_buffers_blend DONE (i965, nv50, nvc0, r600, radeonsi, softpipe)
GL_ARB_draw_indirect DONE (i965, nvc0, radeonsi, softpipe, llvmpipe)
GL_ARB_gpu_shader5 started
@@ -105,11 +100,11 @@ GL 4.0:
- Dynamically uniform UBO array indices started (Chris)
- Implicit signed -> unsigned conversions DONE
- Fused multiply-add DONE (i965, nvc0)
- - Packing/bitfield/conversion functions DONE (i965, nvc0)
- - Enhanced textureGather DONE (i965, nvc0, radeonsi)
+ - Packing/bitfield/conversion functions DONE (i965, nvc0, r600)
+ - Enhanced textureGather DONE (i965, nvc0, r600, radeonsi)
- Geometry shader instancing DONE (i965, nvc0)
- Geometry shader multiple streams DONE (i965, nvc0)
- - Enhanced per-sample shading DONE (i965)
+ - Enhanced per-sample shading DONE (i965, r600)
- Interpolation functions DONE (i965)
- New overload resolution rules DONE
GL_ARB_gpu_shader_fp64 started (Dave)
@@ -118,15 +113,14 @@ GL 4.0:
GL_ARB_tessellation_shader started (Fabian)
GL_ARB_texture_buffer_object_rgb32 DONE (i965, nvc0, r600, radeonsi, softpipe)
GL_ARB_texture_cube_map_array DONE (i965, nv50, nvc0, r600, radeonsi, softpipe)
- GL_ARB_texture_gather DONE (i965, nv50, nvc0, radeonsi, r600)
- GL_ARB_texture_query_lod DONE (i965, nv50, nvc0, radeonsi)
+ GL_ARB_texture_gather DONE (i965, nv50, nvc0, r600, radeonsi)
+ GL_ARB_texture_query_lod DONE (i965, nv50, nvc0, r600, radeonsi)
GL_ARB_transform_feedback2 DONE (i965, nv50, nvc0, r600, radeonsi)
GL_ARB_transform_feedback3 DONE (i965, nv50, nvc0, r600, radeonsi)
-GL 4.1:
+GL 4.1, GLSL 4.10:
- GLSL 4.1 not started
GL_ARB_ES2_compatibility DONE (i965, nv50, nvc0, r300, r600, radeonsi)
GL_ARB_get_program_binary DONE (0 binary formats)
GL_ARB_separate_shader_objects DONE (all drivers)
@@ -135,9 +129,8 @@ GL 4.1:
GL_ARB_viewport_array DONE (i965, nv50, nvc0, r600)
-GL 4.2:
+GL 4.2, GLSL 4.20:
- GLSL 4.2 not started
GL_ARB_texture_compression_bptc not started
GL_ARB_compressed_texture_pixel_storage DONE (all drivers)
GL_ARB_shader_atomic_counters DONE (i965)
@@ -151,14 +144,13 @@ GL 4.2:
GL_ARB_map_buffer_alignment DONE (all drivers)
-GL 4.3:
+GL 4.3, GLSL 4.30:
- GLSL 4.3 not started
GL_ARB_arrays_of_arrays started (Timothy)
GL_ARB_ES3_compatibility DONE (i965)
GL_ARB_clear_buffer_object DONE (all drivers)
GL_ARB_compute_shader started (currently stalled)
- GL_ARB_copy_image not started
+ GL_ARB_copy_image DONE (i965)
GL_KHR_debug DONE (all drivers)
GL_ARB_explicit_uniform_location DONE (all drivers that support GLSL)
GL_ARB_fragment_layer_viewport DONE (nv50, nvc0, r600)
@@ -178,9 +170,8 @@ GL 4.3:
GL_ARB_vertex_attrib_binding DONE (all drivers)
-GL 4.4:
+GL 4.4, GLSL 4.40:
- GLSL 4.4 not started
GL_MAX_VERTEX_ATTRIB_STRIDE not started
GL_ARB_buffer_storage DONE (i965, nv30, nv50, nvc0, r300, r600, radeonsi)
GL_ARB_clear_texture DONE (i965)
diff --git a/mesalib/docs/index.html b/mesalib/docs/index.html
index 8aef51a18..584bc4ec7 100644
--- a/mesalib/docs/index.html
+++ b/mesalib/docs/index.html
@@ -16,7 +16,13 @@
<h1>News</h1>
-<h2>July 78, 2014</h2>
+<h2>August 2, 2014</h2>
+<p>
+<a href="relnotes/10.2.5.html">Mesa 10.2.5</a> is released.
+This is a bug-fix release.
+</p>
+
+<h2>July 18, 2014</h2>
<p>
<a href="relnotes/10.2.4.html">Mesa 10.2.4</a> is released.
This is a bug-fix release.
diff --git a/mesalib/docs/relnotes.html b/mesalib/docs/relnotes.html
index ca008830a..c7e0983a8 100644
--- a/mesalib/docs/relnotes.html
+++ b/mesalib/docs/relnotes.html
@@ -21,6 +21,7 @@ The release notes summarize what's new or changed in each Mesa release.
</p>
<ul>
+<li><a href="relnotes/10.2.5.html">10.2.5 release notes</a>
<li><a href="relnotes/10.2.4.html">10.2.4 release notes</a>
<li><a href="relnotes/10.2.3.html">10.2.3 release notes</a>
<li><a href="relnotes/10.2.2.html">10.2.2 release notes</a>
diff --git a/mesalib/docs/relnotes/10.2.5.html b/mesalib/docs/relnotes/10.2.5.html
new file mode 100644
index 000000000..a75d9b5fc
--- /dev/null
+++ b/mesalib/docs/relnotes/10.2.5.html
@@ -0,0 +1,188 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html lang="en">
+<head>
+ <meta http-equiv="content-type" content="text/html; charset=utf-8">
+ <title>Mesa Release Notes</title>
+ <link rel="stylesheet" type="text/css" href="../mesa.css">
+</head>
+<body>
+
+<div class="header">
+ <h1>The Mesa 3D Graphics Library</h1>
+</div>
+
+<iframe src="../contents.html"></iframe>
+<div class="content">
+
+<h1>Mesa 10.2.5 Release Notes / August 2, 2014</h1>
+
+<p>
+Mesa 10.2.5 is a bug fix release which fixes bugs found since the 10.2.4 release.
+</p>
+<p>
+Mesa 10.2.5 implements the OpenGL 3.3 API, but the version reported by
+glGetString(GL_VERSION) or glGetIntegerv(GL_MAJOR_VERSION) /
+glGetIntegerv(GL_MINOR_VERSION) depends on the particular driver being used.
+Some drivers don't support all the features required in OpenGL 3.3. OpenGL
+3.3 is <strong>only</strong> available if requested at context creation
+because compatibility contexts are not supported.
+</p>
+
+<h2>SHA256 checksums</h2>
+<pre>
+b4459f0bf7f4a3c8fb78ece3c9d2eac3d0e5bf38cb470f2a72705e744bd0310d MesaLib-10.2.5.tar.bz2
+7b4dd0cb683f8c7dc48a3e7a315742bed58ddcd7b756c462aca4177bd1acdc79 MesaLib-10.2.5.tar.gz
+6180565914fb238dd77ccdaff96b6155d9a6e1b3e981ebbf6a6851301b384fed MesaLib-10.2.5.zip
+</pre>
+
+<h2>New features</h2>
+<p>None</p>
+
+<h2>Bug fixes</h2>
+
+<p>This list is likely incomplete.</p>
+
+<ul>
+
+<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=80991">Bug 80991</a> - [BDW]Piglit spec_ARB_sample_shading_builtin-gl-sample-mask_2 fails</li>
+
+</ul>
+
+<h2>Changes</h2>
+
+<p>Abdiel Janulgue (3):</p>
+<ul>
+ <li>i965/fs: Refactor check for potential copy propagated instructions.</li>
+ <li>i965/fs: skip copy-propate for logical instructions with negated src entries</li>
+ <li>i965/vec4: skip copy-propate for logical instructions with negated src entries</li>
+</ul>
+
+<p>Adel Gadllah (1):</p>
+<ul>
+ <li>i915: Fix up intelInitScreen2 for DRI3</li>
+</ul>
+
+<p>Anuj Phogat (2):</p>
+<ul>
+ <li>i965: Fix z_offset computation in intel_miptree_unmap_depthstencil()</li>
+ <li>mesa: Don't use memcpy() in _mesa_texstore() for float depth texture data</li>
+</ul>
+
+<p>Brian Paul (3):</p>
+<ul>
+ <li>mesa: fix geometry shader memory leaks</li>
+ <li>st/mesa: fix geometry shader memory leak</li>
+ <li>gallium/u_blitter: fix some shader memory leaks</li>
+</ul>
+
+<p>Carl Worth (6):</p>
+<ul>
+ <li>docs: Add sha256 checksums for the 10.2.3 release</li>
+ <li>Update VERSION to 10.2.4</li>
+ <li>Add release notes for 10.2.4</li>
+ <li>docs: Add SHA256 checksums for the 10.2.4 release</li>
+ <li>cherry-ignore: Ignore a few patches picked in the previous stable release</li>
+ <li>Update version to 10.2.5</li>
+</ul>
+
+<p>Christian König (1):</p>
+<ul>
+ <li>radeonsi: fix order of r600_need_dma_space and r600_context_bo_reloc</li>
+</ul>
+
+<p>Eric Anholt (1):</p>
+<ul>
+ <li>i965: Generalize the pixel_x/y workaround for all UW types.</li>
+</ul>
+
+<p>Ian Romanick (2):</p>
+<ul>
+ <li>mesa: Don't allow GL_TEXTURE_BORDER queries outside compat profile</li>
+ <li>mesa: Don't allow GL_TEXTURE_{LUMINANCE,INTENSITY}_* queries outside compat profile</li>
+</ul>
+
+<p>Ilia Mirkin (5):</p>
+<ul>
+ <li>nv50/ir: retrieve shadow compare from first arg</li>
+ <li>nv50/ir: ignore bias for samplerCubeShadow on nv50</li>
+ <li>nvc0/ir: do quadops on the right texture coordinates for TXD</li>
+ <li>nvc0/ir: use manual TXD when offsets are involved</li>
+ <li>nvc0: make sure that the local memory allocation is aligned to 0x10</li>
+</ul>
+
+<p>Jason Ekstrand (2):</p>
+<ul>
+ <li>main/format_pack: Fix a wrong datatype in pack_ubyte_R8G8_UNORM</li>
+ <li>main/get_hash_params: Add GL_SAMPLE_SHADING_ARB</li>
+</ul>
+
+<p>Jordan Justen (1):</p>
+<ul>
+ <li>i965: Add auxiliary surface field #defines for Broadwell.</li>
+</ul>
+
+<p>José Fonseca (1):</p>
+<ul>
+ <li>st/wgl: Clamp wglChoosePixelFormatARB's output nNumFormats to nMaxFormats.</li>
+</ul>
+
+<p>Kenneth Graunke (13):</p>
+<ul>
+ <li>i965: Don't copy propagate abs into Broadwell logic instructions.</li>
+ <li>i965: Set execution size to 8 for instructions with force_sechalf set.</li>
+ <li>i965/fs: Set force_uncompressed and force_sechalf on samplepos setup.</li>
+ <li>i965/fs: Use WE_all for gl_SampleID header register munging.</li>
+ <li>i965: Add plumbing for Broadwell's auxiliary surface support.</li>
+ <li>i965: Drop SINT workaround for CMS layout on Broadwell.</li>
+ <li>i965: Hook up the MCS buffers in SURFACE_STATE on Broadwell.</li>
+ <li>i965: Add 2x MSAA support to the MCS allocation function.</li>
+ <li>i965: Enable compressed multisample support (CMS) on Broadwell.</li>
+ <li>i965: Add missing persample_shading field to brw_wm_debug_recompile.</li>
+ <li>i965/fs: Fix gl_SampleID for 2x MSAA and SIMD16 mode.</li>
+ <li>i965/fs: Fix gl_SampleMask handling for SIMD16 on Gen8+.</li>
+ <li>i965/fs: Set LastRT on the final FB write on Broadwell.</li>
+</ul>
+
+<p>Marek Olšák (14):</p>
+<ul>
+ <li>gallium: fix u_default_transfer_inline_write for textures</li>
+ <li>st/mesa: fix samplerCubeShadow with bias</li>
+ <li>radeonsi: fix samplerCubeShadow with bias</li>
+ <li>radeonsi: add support for TXB2</li>
+ <li>r600g: switch SNORM conversion to DX and GLES behavior</li>
+ <li>radeonsi: fix CMASK and HTILE calculations for Hawaii</li>
+ <li>gallium/util: add a helper for calculating primitive count from vertex count</li>
+ <li>radeonsi: fix a hang with instancing on Hawaii</li>
+ <li>radeonsi: fix a hang with streamout on Hawaii</li>
+ <li>winsys/radeon: fix vram_size overflow with Hawaii</li>
+ <li>radeonsi: fix occlusion queries on Hawaii</li>
+ <li>r600g,radeonsi: switch all occurences of array_size to util_max_layer</li>
+ <li>radeonsi: fix build because of lack of draw_indirect infrastructure in 10.2</li>
+ <li>radeonsi: use DRAW_PREAMBLE on CIK</li>
+</ul>
+
+<p>Matt Turner (8):</p>
+<ul>
+ <li>i965/vec4: Don't return void from a void function.</li>
+ <li>i965/vec4: Don't fix_math_operand() on Gen &gt;= 8.</li>
+ <li>i965/fs: Don't fix_math_operand() on Gen &gt;= 8.</li>
+ <li>i965/fs: Make try_constant_propagate() static.</li>
+ <li>i965/fs: Constant propagate into 2-src math instructions on Gen8.</li>
+ <li>i965/vec4: Constant propagate into 2-src math instructions on Gen8.</li>
+ <li>i965/fs: Don't use brw_imm_* unnecessarily.</li>
+ <li>i965/fs: Set correct number of regs_written for MCS fetches.</li>
+</ul>
+
+<p>Thorsten Glaser (1):</p>
+<ul>
+ <li>nv50: fix build failure on m68k due to invalid struct alignment assumptions</li>
+</ul>
+
+<p>Tom Stellard (1):</p>
+<ul>
+ <li>clover: Call end_query before getting timestamp result v2</li>
+</ul>
+
+</div>
+</body>
+</html>
diff --git a/mesalib/docs/relnotes/10.3.html b/mesalib/docs/relnotes/10.3.html
index 1f4e1da7b..f023ca6dc 100644
--- a/mesalib/docs/relnotes/10.3.html
+++ b/mesalib/docs/relnotes/10.3.html
@@ -51,14 +51,16 @@ Note: some of the new features are only available with certain drivers.
<li>GL_ARB_sample_shading on radeonsi</li>
<li>GL_ARB_stencil_texturing on nv50, nvc0, r600, and radeonsi</li>
<li>GL_ARB_texture_cube_map_array on radeonsi</li>
-<li>GL_ARB_texture_gather on radeonsi, r600</li>
+<li>GL_ARB_texture_gather on r600, radeonsi</li>
<li>GL_ARB_texture_query_levels on nv50, nvc0, llvmpipe, r600, radeonsi, softpipe</li>
-<li>GL_ARB_texture_query_lod on radeonsi</li>
+<li>GL_ARB_texture_query_lod on r600, radeonsi</li>
<li>GL_ARB_viewport_array on nvc0</li>
<li>GL_ARB_seamless_cubemap_per_texture on i965, llvmpipe, nvc0, r600, radeonsi, softpipe</li>
<li>GL_ARB_fragment_layer_viewport on nv50, nvc0, llvmpipe, r600</li>
<li>GL_AMD_vertex_shader_viewport_index on i965/gen7+, r600</li>
<li>GL_ARB_clear_texture on i965</li>
+<li>A new software rasterizer driver (kms_swrast_dri.so) that works with
+DRM drivers that don't have a full-fledged GEM (such as qxl or simpledrm)</li>
</ul>
diff --git a/mesalib/include/GL/glext.h b/mesalib/include/GL/glext.h
index ebd537709..5e678306b 100755
--- a/mesalib/include/GL/glext.h
+++ b/mesalib/include/GL/glext.h
@@ -33,7 +33,7 @@ extern "C" {
** used to make the header, and the header can be found at
** http://www.opengl.org/registry/
**
-** Khronos $Revision: 27191 $ on $Date: 2014-06-30 15:11:33 -0700 (Mon, 30 Jun 2014) $
+** Khronos $Revision: 27498 $ on $Date: 2014-07-25 19:12:07 -0700 (Fri, 25 Jul 2014) $
*/
#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__)
@@ -53,7 +53,7 @@ extern "C" {
#define GLAPI extern
#endif
-#define GL_GLEXT_VERSION 20140630
+#define GL_GLEXT_VERSION 20140725
/* Generated C header for:
* API: gl
@@ -4429,11 +4429,11 @@ typedef void (APIENTRYP PFNGLTEXCOORD3BOESPROC) (GLbyte s, GLbyte t, GLbyte r);
typedef void (APIENTRYP PFNGLTEXCOORD3BVOESPROC) (const GLbyte *coords);
typedef void (APIENTRYP PFNGLTEXCOORD4BOESPROC) (GLbyte s, GLbyte t, GLbyte r, GLbyte q);
typedef void (APIENTRYP PFNGLTEXCOORD4BVOESPROC) (const GLbyte *coords);
-typedef void (APIENTRYP PFNGLVERTEX2BOESPROC) (GLbyte x);
+typedef void (APIENTRYP PFNGLVERTEX2BOESPROC) (GLbyte x, GLbyte y);
typedef void (APIENTRYP PFNGLVERTEX2BVOESPROC) (const GLbyte *coords);
-typedef void (APIENTRYP PFNGLVERTEX3BOESPROC) (GLbyte x, GLbyte y);
+typedef void (APIENTRYP PFNGLVERTEX3BOESPROC) (GLbyte x, GLbyte y, GLbyte z);
typedef void (APIENTRYP PFNGLVERTEX3BVOESPROC) (const GLbyte *coords);
-typedef void (APIENTRYP PFNGLVERTEX4BOESPROC) (GLbyte x, GLbyte y, GLbyte z);
+typedef void (APIENTRYP PFNGLVERTEX4BOESPROC) (GLbyte x, GLbyte y, GLbyte z, GLbyte w);
typedef void (APIENTRYP PFNGLVERTEX4BVOESPROC) (const GLbyte *coords);
#ifdef GL_GLEXT_PROTOTYPES
GLAPI void APIENTRY glMultiTexCoord1bOES (GLenum texture, GLbyte s);
@@ -4452,11 +4452,11 @@ GLAPI void APIENTRY glTexCoord3bOES (GLbyte s, GLbyte t, GLbyte r);
GLAPI void APIENTRY glTexCoord3bvOES (const GLbyte *coords);
GLAPI void APIENTRY glTexCoord4bOES (GLbyte s, GLbyte t, GLbyte r, GLbyte q);
GLAPI void APIENTRY glTexCoord4bvOES (const GLbyte *coords);
-GLAPI void APIENTRY glVertex2bOES (GLbyte x);
+GLAPI void APIENTRY glVertex2bOES (GLbyte x, GLbyte y);
GLAPI void APIENTRY glVertex2bvOES (const GLbyte *coords);
-GLAPI void APIENTRY glVertex3bOES (GLbyte x, GLbyte y);
+GLAPI void APIENTRY glVertex3bOES (GLbyte x, GLbyte y, GLbyte z);
GLAPI void APIENTRY glVertex3bvOES (const GLbyte *coords);
-GLAPI void APIENTRY glVertex4bOES (GLbyte x, GLbyte y, GLbyte z);
+GLAPI void APIENTRY glVertex4bOES (GLbyte x, GLbyte y, GLbyte z, GLbyte w);
GLAPI void APIENTRY glVertex4bvOES (const GLbyte *coords);
#endif
#endif /* GL_OES_byte_coordinates */
@@ -8406,6 +8406,16 @@ GLAPI void APIENTRY glMultiDrawElementsIndirectBindlessNV (GLenum mode, GLenum t
#endif
#endif /* GL_NV_bindless_multi_draw_indirect */
+#ifndef GL_NV_bindless_multi_draw_indirect_count
+#define GL_NV_bindless_multi_draw_indirect_count 1
+typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTBINDLESSCOUNTNVPROC) (GLenum mode, const void *indirect, GLsizei drawCount, GLsizei maxDrawCount, GLsizei stride, GLint vertexBufferCount);
+typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTBINDLESSCOUNTNVPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei drawCount, GLsizei maxDrawCount, GLsizei stride, GLint vertexBufferCount);
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glMultiDrawArraysIndirectBindlessCountNV (GLenum mode, const void *indirect, GLsizei drawCount, GLsizei maxDrawCount, GLsizei stride, GLint vertexBufferCount);
+GLAPI void APIENTRY glMultiDrawElementsIndirectBindlessCountNV (GLenum mode, GLenum type, const void *indirect, GLsizei drawCount, GLsizei maxDrawCount, GLsizei stride, GLint vertexBufferCount);
+#endif
+#endif /* GL_NV_bindless_multi_draw_indirect_count */
+
#ifndef GL_NV_bindless_texture
#define GL_NV_bindless_texture 1
typedef GLuint64 (APIENTRYP PFNGLGETTEXTUREHANDLENVPROC) (GLuint texture);
@@ -9136,6 +9146,40 @@ GLAPI void APIENTRY glProgramBufferParametersIuivNV (GLenum target, GLuint bindi
#define GL_FONT_HAS_KERNING_BIT_NV 0x10000000
#define GL_PRIMARY_COLOR_NV 0x852C
#define GL_SECONDARY_COLOR_NV 0x852D
+#define GL_ROUNDED_RECT_NV 0xE8
+#define GL_RELATIVE_ROUNDED_RECT_NV 0xE9
+#define GL_ROUNDED_RECT2_NV 0xEA
+#define GL_RELATIVE_ROUNDED_RECT2_NV 0xEB
+#define GL_ROUNDED_RECT4_NV 0xEC
+#define GL_RELATIVE_ROUNDED_RECT4_NV 0xED
+#define GL_ROUNDED_RECT8_NV 0xEE
+#define GL_RELATIVE_ROUNDED_RECT8_NV 0xEF
+#define GL_RELATIVE_RECT_NV 0xF7
+#define GL_FONT_GLYPHS_AVAILABLE_NV 0x9368
+#define GL_FONT_TARGET_UNAVAILABLE_NV 0x9369
+#define GL_FONT_UNAVAILABLE_NV 0x936A
+#define GL_FONT_UNINTELLIGIBLE_NV 0x936B
+#define GL_CONIC_CURVE_TO_NV 0x1A
+#define GL_RELATIVE_CONIC_CURVE_TO_NV 0x1B
+#define GL_FONT_NUM_GLYPH_INDICES_BIT_NV 0x20000000
+#define GL_STANDARD_FONT_FORMAT_NV 0x936C
+#define GL_2_BYTES_NV 0x1407
+#define GL_3_BYTES_NV 0x1408
+#define GL_4_BYTES_NV 0x1409
+#define GL_EYE_LINEAR_NV 0x2400
+#define GL_OBJECT_LINEAR_NV 0x2401
+#define GL_CONSTANT_NV 0x8576
+#define GL_PATH_PROJECTION_NV 0x1701
+#define GL_PATH_MODELVIEW_NV 0x1700
+#define GL_PATH_MODELVIEW_STACK_DEPTH_NV 0x0BA3
+#define GL_PATH_MODELVIEW_MATRIX_NV 0x0BA6
+#define GL_PATH_MAX_MODELVIEW_STACK_DEPTH_NV 0x0D36
+#define GL_PATH_TRANSPOSE_MODELVIEW_MATRIX_NV 0x84E3
+#define GL_PATH_PROJECTION_STACK_DEPTH_NV 0x0BA4
+#define GL_PATH_PROJECTION_MATRIX_NV 0x0BA7
+#define GL_PATH_MAX_PROJECTION_STACK_DEPTH_NV 0x0D38
+#define GL_PATH_TRANSPOSE_PROJECTION_MATRIX_NV 0x84E4
+#define GL_FRAGMENT_INPUT_NV 0x936D
typedef GLuint (APIENTRYP PFNGLGENPATHSNVPROC) (GLsizei range);
typedef void (APIENTRYP PFNGLDELETEPATHSNVPROC) (GLuint path, GLsizei range);
typedef GLboolean (APIENTRYP PFNGLISPATHNVPROC) (GLuint path);
@@ -9185,6 +9229,21 @@ typedef GLboolean (APIENTRYP PFNGLISPOINTINFILLPATHNVPROC) (GLuint path, GLuint
typedef GLboolean (APIENTRYP PFNGLISPOINTINSTROKEPATHNVPROC) (GLuint path, GLfloat x, GLfloat y);
typedef GLfloat (APIENTRYP PFNGLGETPATHLENGTHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments);
typedef GLboolean (APIENTRYP PFNGLPOINTALONGPATHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments, GLfloat distance, GLfloat *x, GLfloat *y, GLfloat *tangentX, GLfloat *tangentY);
+typedef void (APIENTRYP PFNGLMATRIXLOAD3X2FNVPROC) (GLenum matrixMode, const GLfloat *m);
+typedef void (APIENTRYP PFNGLMATRIXLOAD3X3FNVPROC) (GLenum matrixMode, const GLfloat *m);
+typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSE3X3FNVPROC) (GLenum matrixMode, const GLfloat *m);
+typedef void (APIENTRYP PFNGLMATRIXMULT3X2FNVPROC) (GLenum matrixMode, const GLfloat *m);
+typedef void (APIENTRYP PFNGLMATRIXMULT3X3FNVPROC) (GLenum matrixMode, const GLfloat *m);
+typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSE3X3FNVPROC) (GLenum matrixMode, const GLfloat *m);
+typedef void (APIENTRYP PFNGLSTENCILTHENCOVERFILLPATHNVPROC) (GLuint path, GLenum fillMode, GLuint mask, GLenum coverMode);
+typedef void (APIENTRYP PFNGLSTENCILTHENCOVERSTROKEPATHNVPROC) (GLuint path, GLint reference, GLuint mask, GLenum coverMode);
+typedef void (APIENTRYP PFNGLSTENCILTHENCOVERFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues);
+typedef void (APIENTRYP PFNGLSTENCILTHENCOVERSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues);
+typedef GLenum (APIENTRYP PFNGLPATHGLYPHINDEXRANGENVPROC) (GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint pathParameterTemplate, GLfloat emScale, GLuint baseAndCount[2]);
+typedef GLenum (APIENTRYP PFNGLPATHGLYPHINDEXARRAYNVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale);
+typedef GLenum (APIENTRYP PFNGLPATHMEMORYGLYPHINDEXARRAYNVPROC) (GLuint firstPathName, GLenum fontTarget, GLsizeiptr fontSize, const void *fontData, GLsizei faceIndex, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale);
+typedef void (APIENTRYP PFNGLPROGRAMPATHFRAGMENTINPUTGENNVPROC) (GLuint program, GLint location, GLenum genMode, GLint components, const GLfloat *coeffs);
+typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCEFVNVPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLfloat *params);
#ifdef GL_GLEXT_PROTOTYPES
GLAPI GLuint APIENTRY glGenPathsNV (GLsizei range);
GLAPI void APIENTRY glDeletePathsNV (GLuint path, GLsizei range);
@@ -9235,6 +9294,21 @@ GLAPI GLboolean APIENTRY glIsPointInFillPathNV (GLuint path, GLuint mask, GLfloa
GLAPI GLboolean APIENTRY glIsPointInStrokePathNV (GLuint path, GLfloat x, GLfloat y);
GLAPI GLfloat APIENTRY glGetPathLengthNV (GLuint path, GLsizei startSegment, GLsizei numSegments);
GLAPI GLboolean APIENTRY glPointAlongPathNV (GLuint path, GLsizei startSegment, GLsizei numSegments, GLfloat distance, GLfloat *x, GLfloat *y, GLfloat *tangentX, GLfloat *tangentY);
+GLAPI void APIENTRY glMatrixLoad3x2fNV (GLenum matrixMode, const GLfloat *m);
+GLAPI void APIENTRY glMatrixLoad3x3fNV (GLenum matrixMode, const GLfloat *m);
+GLAPI void APIENTRY glMatrixLoadTranspose3x3fNV (GLenum matrixMode, const GLfloat *m);
+GLAPI void APIENTRY glMatrixMult3x2fNV (GLenum matrixMode, const GLfloat *m);
+GLAPI void APIENTRY glMatrixMult3x3fNV (GLenum matrixMode, const GLfloat *m);
+GLAPI void APIENTRY glMatrixMultTranspose3x3fNV (GLenum matrixMode, const GLfloat *m);
+GLAPI void APIENTRY glStencilThenCoverFillPathNV (GLuint path, GLenum fillMode, GLuint mask, GLenum coverMode);
+GLAPI void APIENTRY glStencilThenCoverStrokePathNV (GLuint path, GLint reference, GLuint mask, GLenum coverMode);
+GLAPI void APIENTRY glStencilThenCoverFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues);
+GLAPI void APIENTRY glStencilThenCoverStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues);
+GLAPI GLenum APIENTRY glPathGlyphIndexRangeNV (GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint pathParameterTemplate, GLfloat emScale, GLuint baseAndCount[2]);
+GLAPI GLenum APIENTRY glPathGlyphIndexArrayNV (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale);
+GLAPI GLenum APIENTRY glPathMemoryGlyphIndexArrayNV (GLuint firstPathName, GLenum fontTarget, GLsizeiptr fontSize, const void *fontData, GLsizei faceIndex, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale);
+GLAPI void APIENTRY glProgramPathFragmentInputGenNV (GLuint program, GLint location, GLenum genMode, GLint components, const GLfloat *coeffs);
+GLAPI void APIENTRY glGetProgramResourcefvNV (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLfloat *params);
#endif
#endif /* GL_NV_path_rendering */
@@ -9403,6 +9477,10 @@ GLAPI void APIENTRY glGetCombinerStageParameterfvNV (GLenum stage, GLenum pname,
#define GL_NV_shader_atomic_float 1
#endif /* GL_NV_shader_atomic_float */
+#ifndef GL_NV_shader_atomic_int64
+#define GL_NV_shader_atomic_int64 1
+#endif /* GL_NV_shader_atomic_int64 */
+
#ifndef GL_NV_shader_buffer_load
#define GL_NV_shader_buffer_load 1
#define GL_BUFFER_GPU_ADDRESS_NV 0x8F1D
diff --git a/mesalib/include/GL/glxext.h b/mesalib/include/GL/glxext.h
index 2d8aa2290..b96133e34 100644..100755
--- a/mesalib/include/GL/glxext.h
+++ b/mesalib/include/GL/glxext.h
@@ -33,10 +33,10 @@ extern "C" {
** used to make the header, and the header can be found at
** http://www.opengl.org/registry/
**
-** Khronos $Revision: 27191 $ on $Date: 2014-06-30 15:11:33 -0700 (Mon, 30 Jun 2014) $
+** Khronos $Revision: 27498 $ on $Date: 2014-07-25 19:12:07 -0700 (Fri, 25 Jul 2014) $
*/
-#define GLX_GLXEXT_VERSION 20140630
+#define GLX_GLXEXT_VERSION 20140725
/* Generated C header for:
* API: glx
@@ -468,6 +468,16 @@ Bool glXSet3DfxModeMESA (int mode);
#endif
#endif /* GLX_MESA_set_3dfx_mode */
+#ifndef GLX_NV_copy_buffer
+#define GLX_NV_copy_buffer 1
+typedef void ( *PFNGLXCOPYBUFFERSUBDATANVPROC) (Display *dpy, GLXContext readCtx, GLXContext writeCtx, GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);
+typedef void ( *PFNGLXNAMEDCOPYBUFFERSUBDATANVPROC) (Display *dpy, GLXContext readCtx, GLXContext writeCtx, GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);
+#ifdef GLX_GLXEXT_PROTOTYPES
+void glXCopyBufferSubDataNV (Display *dpy, GLXContext readCtx, GLXContext writeCtx, GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);
+void glXNamedCopyBufferSubDataNV (Display *dpy, GLXContext readCtx, GLXContext writeCtx, GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);
+#endif
+#endif /* GLX_NV_copy_buffer */
+
#ifndef GLX_NV_copy_image
#define GLX_NV_copy_image 1
typedef void ( *PFNGLXCOPYIMAGESUBDATANVPROC) (Display *dpy, GLXContext srcCtx, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLXContext dstCtx, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth);
diff --git a/mesalib/include/GL/internal/dri_interface.h b/mesalib/include/GL/internal/dri_interface.h
index ad000bdfb..82835a293 100644
--- a/mesalib/include/GL/internal/dri_interface.h
+++ b/mesalib/include/GL/internal/dri_interface.h
@@ -1009,7 +1009,7 @@ struct __DRIdri2ExtensionRec {
* extensions.
*/
#define __DRI_IMAGE "DRI_IMAGE"
-#define __DRI_IMAGE_VERSION 9
+#define __DRI_IMAGE_VERSION 10
/**
* These formats correspond to the similarly named MESA_FORMAT_*
@@ -1138,6 +1138,13 @@ enum __DRIChromaSiting {
/*@}*/
/**
+ * \name Capabilities that might be returned by __DRIimageExtensionRec::getCapabilities
+ */
+/*@{*/
+#define __DRI_IMAGE_CAP_GLOBAL_NAMES 1
+/*@}*/
+
+/**
* blitImage flags
*/
@@ -1265,6 +1272,14 @@ struct __DRIimageExtensionRec {
int dstx0, int dsty0, int dstwidth, int dstheight,
int srcx0, int srcy0, int srcwidth, int srcheight,
int flush_flag);
+
+ /**
+ * Query for general capabilities of the driver that concern
+ * buffer sharing and image importing.
+ *
+ * \since 10
+ */
+ int (*getCapabilities)(__DRIscreen *screen);
};
diff --git a/mesalib/src/Makefile.am b/mesalib/src/Makefile.am
index d4a7090dc..cede5083a 100644
--- a/mesalib/src/Makefile.am
+++ b/mesalib/src/Makefile.am
@@ -19,7 +19,7 @@
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
-SUBDIRS = gtest mapi
+SUBDIRS = gtest util mapi
if NEED_OPENGL_COMMON
SUBDIRS += glsl mesa
diff --git a/mesalib/src/SConscript b/mesalib/src/SConscript
index 93a490dca..2657bba47 100644
--- a/mesalib/src/SConscript
+++ b/mesalib/src/SConscript
@@ -4,6 +4,7 @@ Import('*')
if env['platform'] == 'windows':
SConscript('getopt/SConscript')
+SConscript('util/SConscript')
SConscript('glsl/SConscript')
if env['hostonly']:
diff --git a/mesalib/src/gallium/Automake.inc b/mesalib/src/gallium/Automake.inc
index 73d65a4d1..74053eb2d 100644
--- a/mesalib/src/gallium/Automake.inc
+++ b/mesalib/src/gallium/Automake.inc
@@ -1,5 +1,6 @@
GALLIUM_CFLAGS = \
-I$(top_srcdir)/include \
+ -I$(top_srcdir)/src \
-I$(top_srcdir)/src/gallium/include \
-I$(top_srcdir)/src/gallium/auxiliary \
$(DEFINES)
@@ -10,6 +11,7 @@ GALLIUM_CFLAGS = \
# preprocessor is determined by the ordering of the -I flags.
GALLIUM_DRIVER_CFLAGS = \
-I$(srcdir)/include \
+ -I$(top_srcdir)/src \
-I$(top_srcdir)/include \
-I$(top_srcdir)/src/gallium/include \
-I$(top_srcdir)/src/gallium/auxiliary \
@@ -19,6 +21,7 @@ GALLIUM_DRIVER_CFLAGS = \
GALLIUM_DRIVER_CXXFLAGS = \
-I$(srcdir)/include \
+ -I$(top_srcdir)/src \
-I$(top_srcdir)/include \
-I$(top_srcdir)/src/gallium/include \
-I$(top_srcdir)/src/gallium/auxiliary \
diff --git a/mesalib/src/gallium/SConscript b/mesalib/src/gallium/SConscript
index 8d9849e00..cb6172007 100644
--- a/mesalib/src/gallium/SConscript
+++ b/mesalib/src/gallium/SConscript
@@ -71,6 +71,10 @@ if env['dri']:
])
SConscript([
+ 'winsys/sw/kms-dri/SConscript',
+ ])
+
+ SConscript([
'winsys/svga/drm/SConscript',
])
diff --git a/mesalib/src/gallium/auxiliary/Makefile.am b/mesalib/src/gallium/auxiliary/Makefile.am
index 727ed1f98..493d306f6 100644
--- a/mesalib/src/gallium/auxiliary/Makefile.am
+++ b/mesalib/src/gallium/auxiliary/Makefile.am
@@ -39,10 +39,6 @@ indices/u_unfilled_gen.c: $(srcdir)/indices/u_unfilled_gen.py
$(AM_V_at)$(MKDIR_P) indices
$(AM_V_GEN) $(PYTHON2) $< > $@
-util/u_format_srgb.c: $(srcdir)/util/u_format_srgb.py
- $(AM_V_at)$(MKDIR_P) util
- $(AM_V_GEN) $(PYTHON2) $< > $@
-
util/u_format_table.c: $(srcdir)/util/u_format_table.py $(srcdir)/util/u_format_pack.py $(srcdir)/util/u_format_parse.py $(srcdir)/util/u_format.csv
$(AM_V_at)$(MKDIR_P) util
$(AM_V_GEN) $(PYTHON2) $(srcdir)/util/u_format_table.py $(srcdir)/util/u_format.csv > $@
diff --git a/mesalib/src/gallium/auxiliary/Makefile.sources b/mesalib/src/gallium/auxiliary/Makefile.sources
index 8919783c2..3eae9e525 100644
--- a/mesalib/src/gallium/auxiliary/Makefile.sources
+++ b/mesalib/src/gallium/auxiliary/Makefile.sources
@@ -162,7 +162,6 @@ C_SOURCES := \
GENERATED_SOURCES := \
indices/u_indices_gen.c \
indices/u_unfilled_gen.c \
- util/u_format_srgb.c \
util/u_format_table.c
GALLIVM_SOURCES := \
diff --git a/mesalib/src/gallium/auxiliary/SConscript b/mesalib/src/gallium/auxiliary/SConscript
index 31dfed316..94041d247 100644
--- a/mesalib/src/gallium/auxiliary/SConscript
+++ b/mesalib/src/gallium/auxiliary/SConscript
@@ -3,6 +3,7 @@ Import('*')
from sys import executable as python_cmd
env.Append(CPPPATH = [
+ '#src',
'indices',
'util',
])
@@ -22,13 +23,6 @@ env.CodeGenerate(
)
env.CodeGenerate(
- target = 'util/u_format_srgb.c',
- script = 'util/u_format_srgb.py',
- source = [],
- command = python_cmd + ' $SCRIPT > $TARGET'
-)
-
-env.CodeGenerate(
target = 'util/u_format_table.c',
script = '#src/gallium/auxiliary/util/u_format_table.py',
source = ['#src/gallium/auxiliary/util/u_format.csv'],
diff --git a/mesalib/src/gallium/auxiliary/util/u_caps.c b/mesalib/src/gallium/auxiliary/util/u_caps.c
index 623070755..ec8938b37 100644
--- a/mesalib/src/gallium/auxiliary/util/u_caps.c
+++ b/mesalib/src/gallium/auxiliary/util/u_caps.c
@@ -198,13 +198,13 @@ static unsigned caps_sm3[] = {
UTIL_CHECK_SHADER(FRAGMENT, MAX_INPUTS, 10),
UTIL_CHECK_SHADER(FRAGMENT, MAX_TEMPS, 32),
UTIL_CHECK_SHADER(FRAGMENT, MAX_ADDRS, 1),
- UTIL_CHECK_SHADER(FRAGMENT, MAX_CONSTS, 224),
+ UTIL_CHECK_SHADER(FRAGMENT, MAX_CONST_BUFFER_SIZE, 224 * 16),
UTIL_CHECK_SHADER(VERTEX, MAX_INSTRUCTIONS, 512),
UTIL_CHECK_SHADER(VERTEX, MAX_INPUTS, 16),
UTIL_CHECK_SHADER(VERTEX, MAX_TEMPS, 32),
UTIL_CHECK_SHADER(VERTEX, MAX_ADDRS, 2),
- UTIL_CHECK_SHADER(VERTEX, MAX_CONSTS, 256),
+ UTIL_CHECK_SHADER(VERTEX, MAX_CONST_BUFFER_SIZE, 256 * 16),
UTIL_CHECK_TERMINATE
};
diff --git a/mesalib/src/gallium/auxiliary/util/u_format_pack.py b/mesalib/src/gallium/auxiliary/util/u_format_pack.py
index f9496de6c..a553e2346 100644
--- a/mesalib/src/gallium/auxiliary/util/u_format_pack.py
+++ b/mesalib/src/gallium/auxiliary/util/u_format_pack.py
@@ -669,7 +669,7 @@ def generate(formats):
print '#include "u_half.h"'
print '#include "u_format.h"'
print '#include "u_format_other.h"'
- print '#include "u_format_srgb.h"'
+ print '#include "util/format_srgb.h"'
print '#include "u_format_yuv.h"'
print '#include "u_format_zs.h"'
print
diff --git a/mesalib/src/gallium/auxiliary/util/u_format_s3tc.c b/mesalib/src/gallium/auxiliary/util/u_format_s3tc.c
index 11b46020b..7e05989e6 100644
--- a/mesalib/src/gallium/auxiliary/util/u_format_s3tc.c
+++ b/mesalib/src/gallium/auxiliary/util/u_format_s3tc.c
@@ -27,7 +27,7 @@
#include "u_math.h"
#include "u_format.h"
#include "u_format_s3tc.h"
-#include "u_format_srgb.h"
+#include "util/format_srgb.h"
#if defined(_WIN32) || defined(WIN32)
diff --git a/mesalib/src/gallium/auxiliary/util/u_math.h b/mesalib/src/gallium/auxiliary/util/u_math.h
index f6dcb228f..2823e0570 100644
--- a/mesalib/src/gallium/auxiliary/util/u_math.h
+++ b/mesalib/src/gallium/auxiliary/util/u_math.h
@@ -616,6 +616,14 @@ fui( float f )
return fi.ui;
}
+static INLINE float
+uif(uint32_t ui)
+{
+ union fi fi;
+ fi.ui = ui;
+ return fi.f;
+}
+
/**
* Convert ubyte to float in [0, 1].
@@ -817,7 +825,7 @@ util_memcpy_cpu_to_le32(void * restrict dest, const void * restrict src, size_t
{
#ifdef PIPE_ARCH_BIG_ENDIAN
size_t i, e;
- asset(n % 4 == 0);
+ assert(n % 4 == 0);
for (i = 0, e = n / 4; i < e; i++) {
uint32_t * restrict d = (uint32_t* restrict)dest;
diff --git a/mesalib/src/gallium/auxiliary/util/u_prim.h b/mesalib/src/gallium/auxiliary/util/u_prim.h
index fd95c0ba0..cf1a18f42 100644
--- a/mesalib/src/gallium/auxiliary/util/u_prim.h
+++ b/mesalib/src/gallium/auxiliary/util/u_prim.h
@@ -136,6 +136,21 @@ u_prim_vertex_count(unsigned prim)
return (likely(prim < PIPE_PRIM_MAX)) ? &prim_table[prim] : NULL;
}
+/**
+ * Given a vertex count, return the number of primitives.
+ * For polygons, return the number of triangles.
+ */
+static INLINE unsigned
+u_prims_for_vertices(unsigned prim, unsigned num)
+{
+ const struct u_prim_vertex_count *info = u_prim_vertex_count(prim);
+
+ if (num < info->min)
+ return 0;
+
+ return 1 + ((num - info->min) / info->incr);
+}
+
static INLINE boolean u_validate_pipe_prim( unsigned pipe_prim, unsigned nr )
{
const struct u_prim_vertex_count *count = u_prim_vertex_count(pipe_prim);
diff --git a/mesalib/src/glsl/.gitignore b/mesalib/src/glsl/.gitignore
index d9b4adce5..620ac3c93 100644..100755
--- a/mesalib/src/glsl/.gitignore
+++ b/mesalib/src/glsl/.gitignore
@@ -4,3 +4,7 @@ glsl_parser.cpp
glsl_parser.h
glsl_parser.output
glsl_test
+subtest-cr/
+subtest-lf/
+subtest-cr-lf/
+subtest-lf-cr/
diff --git a/mesalib/src/glsl/Makefile.am b/mesalib/src/glsl/Makefile.am
index 00261fd0d..0ccc81d75 100644
--- a/mesalib/src/glsl/Makefile.am
+++ b/mesalib/src/glsl/Makefile.am
@@ -21,6 +21,7 @@
AM_CPPFLAGS = \
-I$(top_srcdir)/include \
+ -I$(top_srcdir)/src \
-I$(top_srcdir)/src/mapi \
-I$(top_srcdir)/src/mesa/ \
-I$(top_srcdir)/src/glsl/glcpp \
@@ -32,9 +33,9 @@ AM_CXXFLAGS = $(VISIBILITY_CXXFLAGS)
include Makefile.sources
TESTS = glcpp/tests/glcpp-test \
+ glcpp/tests/glcpp-test-cr-lf \
tests/general-ir-test \
tests/optimization-test \
- tests/ralloc-test \
tests/sampler-types-test \
tests/uniform-initializer-test
@@ -47,14 +48,12 @@ check_PROGRAMS = \
glcpp/glcpp \
glsl_test \
tests/general-ir-test \
- tests/ralloc-test \
tests/sampler-types-test \
tests/uniform-initializer-test
noinst_PROGRAMS = glsl_compiler
tests_general_ir_test_SOURCES = \
- $(top_srcdir)/src/mesa/main/hash_table.c \
$(top_srcdir)/src/mesa/main/imports.c \
$(top_srcdir)/src/mesa/program/prog_hash_table.c\
$(top_srcdir)/src/mesa/program/symbol_table.c \
@@ -72,7 +71,6 @@ tests_general_ir_test_LDADD = \
$(PTHREAD_LIBS)
tests_uniform_initializer_test_SOURCES = \
- $(top_srcdir)/src/mesa/main/hash_table.c \
$(top_srcdir)/src/mesa/main/imports.c \
$(top_srcdir)/src/mesa/program/prog_hash_table.c\
$(top_srcdir)/src/mesa/program/symbol_table.c \
@@ -87,14 +85,6 @@ tests_uniform_initializer_test_LDADD = \
$(top_builddir)/src/glsl/libglsl.la \
$(PTHREAD_LIBS)
-tests_ralloc_test_SOURCES = \
- tests/ralloc_test.cpp \
- $(top_builddir)/src/glsl/ralloc.c
-tests_ralloc_test_CFLAGS = $(PTHREAD_CFLAGS)
-tests_ralloc_test_LDADD = \
- $(top_builddir)/src/gtest/libgtest.la \
- $(PTHREAD_LIBS)
-
tests_sampler_types_test_SOURCES = \
$(top_srcdir)/src/mesa/program/prog_hash_table.c\
$(top_srcdir)/src/mesa/program/symbol_table.c \
@@ -107,6 +97,8 @@ tests_sampler_types_test_LDADD = \
$(top_builddir)/src/glsl/libglsl.la \
$(PTHREAD_LIBS)
+libglcpp_la_LIBADD = \
+ $(top_builddir)/src/util/libmesautil.la
libglcpp_la_SOURCES = \
glcpp/glcpp-lex.c \
glcpp/glcpp-parse.c \
@@ -127,7 +119,6 @@ libglsl_la_SOURCES = \
$(LIBGLSL_FILES)
glsl_compiler_SOURCES = \
- $(top_srcdir)/src/mesa/main/hash_table.c \
$(top_srcdir)/src/mesa/main/imports.c \
$(top_srcdir)/src/mesa/program/prog_hash_table.c \
$(top_srcdir)/src/mesa/program/symbol_table.c \
@@ -138,7 +129,6 @@ glsl_compiler_LDADD = \
$(PTHREAD_LIBS)
glsl_test_SOURCES = \
- $(top_srcdir)/src/mesa/main/hash_table.c \
$(top_srcdir)/src/mesa/main/imports.c \
$(top_srcdir)/src/mesa/program/prog_hash_table.c \
$(top_srcdir)/src/mesa/program/symbol_table.c \
diff --git a/mesalib/src/glsl/Makefile.sources b/mesalib/src/glsl/Makefile.sources
index b54eae72d..2131ddafb 100644
--- a/mesalib/src/glsl/Makefile.sources
+++ b/mesalib/src/glsl/Makefile.sources
@@ -6,7 +6,6 @@ GLSL_BUILDDIR = $(top_builddir)/src/glsl
# libglcpp
LIBGLCPP_FILES = \
- $(GLSL_SRCDIR)/ralloc.c \
$(GLSL_SRCDIR)/glcpp/pp.c
LIBGLCPP_GENERATED_FILES = \
diff --git a/mesalib/src/glsl/SConscript b/mesalib/src/glsl/SConscript
index dc354775a..847e96246 100644
--- a/mesalib/src/glsl/SConscript
+++ b/mesalib/src/glsl/SConscript
@@ -8,12 +8,15 @@ env = env.Clone()
env.Prepend(CPPPATH = [
'#include',
+ '#src',
'#src/mapi',
'#src/mesa',
'#src/glsl',
'#src/glsl/glcpp',
])
+env.Prepend(LIBS = [mesautil])
+
# Make glcpp-parse.h and glsl_parser.h reachable from the include path.
env.Append(CPPPATH = [Dir('.').abspath, Dir('glcpp').abspath])
@@ -55,7 +58,6 @@ if env['msvc']:
# Copy these files to avoid generation object files into src/mesa/program
env.Prepend(CPPPATH = ['#src/mesa/main'])
-env.Command('hash_table.c', '#src/mesa/main/hash_table.c', Copy('$TARGET', '$SOURCE'))
env.Command('imports.c', '#src/mesa/main/imports.c', Copy('$TARGET', '$SOURCE'))
# Copy these files to avoid generation object files into src/mesa/program
env.Prepend(CPPPATH = ['#src/mesa/program'])
@@ -65,7 +67,6 @@ env.Command('symbol_table.c', '#src/mesa/program/symbol_table.c', Copy('$TARGET'
compiler_objs = env.StaticObject(source_lists['GLSL_COMPILER_CXX_FILES'])
mesa_objs = env.StaticObject([
- 'hash_table.c',
'imports.c',
'prog_hash_table.c',
'symbol_table.c',
diff --git a/mesalib/src/glsl/ast_function.cpp b/mesalib/src/glsl/ast_function.cpp
index 4981fe174..39c7beeb2 100644
--- a/mesalib/src/glsl/ast_function.cpp
+++ b/mesalib/src/glsl/ast_function.cpp
@@ -450,20 +450,21 @@ match_function_by_name(const char *name,
goto done; /* no match */
if (f != NULL) {
+ /* In desktop GL, the presence of a user-defined signature hides any
+ * built-in signatures, so we must ignore them. In contrast, in ES2
+ * user-defined signatures add new overloads, so we must consider them.
+ */
+ bool allow_builtins = state->es_shader || !f->has_user_signature();
+
/* Look for a match in the local shader. If exact, we're done. */
bool is_exact = false;
sig = local_sig = f->matching_signature(state, actual_parameters,
- &is_exact);
+ allow_builtins, &is_exact);
if (is_exact)
goto done;
- if (!state->es_shader && f->has_user_signature()) {
- /* In desktop GL, the presence of a user-defined signature hides any
- * built-in signatures, so we must ignore them. In contrast, in ES2
- * user-defined signatures add new overloads, so we must proceed.
- */
+ if (!allow_builtins)
goto done;
- }
}
/* Local shader has no exact candidates; check the built-ins. */
diff --git a/mesalib/src/glsl/ast_to_hir.cpp b/mesalib/src/glsl/ast_to_hir.cpp
index a15ee9c05..30b02d016 100644
--- a/mesalib/src/glsl/ast_to_hir.cpp
+++ b/mesalib/src/glsl/ast_to_hir.cpp
@@ -4110,12 +4110,27 @@ ast_function::hir(exec_list *instructions,
name);
}
+ /* Create an ir_function if one doesn't already exist. */
+ f = state->symbols->get_function(name);
+ if (f == NULL) {
+ f = new(ctx) ir_function(name);
+ if (!state->symbols->add_function(f)) {
+ /* This function name shadows a non-function use of the same name. */
+ YYLTYPE loc = this->get_location();
+
+ _mesa_glsl_error(&loc, state, "function name `%s' conflicts with "
+ "non-function", name);
+ return NULL;
+ }
+
+ emit_function(state, f);
+ }
+
/* Verify that this function's signature either doesn't match a previously
* seen signature for a function with the same name, or, if a match is found,
* that the previously seen signature does not have an associated definition.
*/
- f = state->symbols->get_function(name);
- if (f != NULL && (state->es_shader || f->has_user_signature())) {
+ if (state->es_shader || f->has_user_signature()) {
sig = f->exact_matching_signature(state, &hir_parameters);
if (sig != NULL) {
const char *badvar = sig->qualifiers_match(&hir_parameters);
@@ -4146,18 +4161,6 @@ ast_function::hir(exec_list *instructions,
}
}
}
- } else {
- f = new(ctx) ir_function(name);
- if (!state->symbols->add_function(f)) {
- /* This function name shadows a non-function use of the same name. */
- YYLTYPE loc = this->get_location();
-
- _mesa_glsl_error(&loc, state, "function name `%s' conflicts with "
- "non-function", name);
- return NULL;
- }
-
- emit_function(state, f);
}
/* Verify the return type of main() */
@@ -4597,12 +4600,6 @@ ast_case_statement_list::hir(exec_list *instructions,
*/
if (!default_case.is_empty()) {
- /* Default case was the last one, no checks required. */
- if (after_default.is_empty()) {
- instructions->append_list(&default_case);
- return NULL;
- }
-
ir_rvalue *const true_val = new (state) ir_constant(true);
ir_dereference_variable *deref_run_default_var =
new(state) ir_dereference_variable(state->switch_state.run_default);
@@ -4614,6 +4611,12 @@ ast_case_statement_list::hir(exec_list *instructions,
new(state) ir_assignment(deref_run_default_var, true_val);
instructions->push_tail(init_var);
+ /* Default case was the last one, no checks required. */
+ if (after_default.is_empty()) {
+ instructions->append_list(&default_case);
+ return NULL;
+ }
+
foreach_in_list(ir_instruction, ir, &after_default) {
ir_assignment *assign = ir->as_assignment();
@@ -5072,7 +5075,7 @@ ast_process_structure_or_interface_block(exec_list *instructions,
YYLTYPE &loc,
glsl_struct_field **fields_ret,
bool is_interface,
- bool block_row_major,
+ enum glsl_matrix_layout matrix_layout,
bool allow_reserved_names,
ir_variable_mode var_mode)
{
@@ -5203,13 +5206,29 @@ ast_process_structure_or_interface_block(exec_list *instructions,
"in uniform blocks or structures.");
}
- if (field_type->is_matrix() ||
- (field_type->is_array() && field_type->fields.array->is_matrix())) {
- fields[i].row_major = block_row_major;
+ /* Propogate row- / column-major information down the fields of the
+ * structure or interface block. Structures need this data because
+ * the structure may contain a structure that contains ... a matrix
+ * that need the proper layout.
+ */
+ if (field_type->without_array()->is_matrix()
+ || field_type->without_array()->is_record()) {
+ /* If no layout is specified for the field, inherit the layout
+ * from the block.
+ */
+ fields[i].matrix_layout = matrix_layout;
+
if (qual->flags.q.row_major)
- fields[i].row_major = true;
+ fields[i].matrix_layout = GLSL_MATRIX_LAYOUT_ROW_MAJOR;
else if (qual->flags.q.column_major)
- fields[i].row_major = false;
+ fields[i].matrix_layout = GLSL_MATRIX_LAYOUT_COLUMN_MAJOR;
+
+ /* If we're processing an interface block, the matrix layout must
+ * be decided by this point.
+ */
+ assert(!is_interface
+ || fields[i].matrix_layout == GLSL_MATRIX_LAYOUT_ROW_MAJOR
+ || fields[i].matrix_layout == GLSL_MATRIX_LAYOUT_COLUMN_MAJOR);
}
i++;
@@ -5264,7 +5283,7 @@ ast_struct_specifier::hir(exec_list *instructions,
loc,
&fields,
false,
- false,
+ GLSL_MATRIX_LAYOUT_INHERITED,
false /* allow_reserved_names */,
ir_var_auto);
@@ -5364,8 +5383,13 @@ ast_interface_block::hir(exec_list *instructions,
assert(!"interface block layout qualifier not found!");
}
+ enum glsl_matrix_layout matrix_layout = GLSL_MATRIX_LAYOUT_INHERITED;
+ if (this->layout.flags.q.row_major)
+ matrix_layout = GLSL_MATRIX_LAYOUT_ROW_MAJOR;
+ else if (this->layout.flags.q.column_major)
+ matrix_layout = GLSL_MATRIX_LAYOUT_COLUMN_MAJOR;
+
bool redeclaring_per_vertex = strcmp(this->block_name, "gl_PerVertex") == 0;
- bool block_row_major = this->layout.flags.q.row_major;
exec_list declared_variables;
glsl_struct_field *fields;
@@ -5381,7 +5405,7 @@ ast_interface_block::hir(exec_list *instructions,
loc,
&fields,
true,
- block_row_major,
+ matrix_layout,
redeclaring_per_vertex,
var_mode);
@@ -5589,6 +5613,9 @@ ast_interface_block::hir(exec_list *instructions,
var_mode);
}
+ var->data.matrix_layout = matrix_layout == GLSL_MATRIX_LAYOUT_INHERITED
+ ? GLSL_MATRIX_LAYOUT_COLUMN_MAJOR : matrix_layout;
+
if (state->stage == MESA_SHADER_GEOMETRY && var_mode == ir_var_shader_in)
handle_geometry_shader_input_decl(state, loc, var);
@@ -5629,6 +5656,13 @@ ast_interface_block::hir(exec_list *instructions,
var->data.sample = fields[i].sample;
var->init_interface_type(block_type);
+ if (fields[i].matrix_layout == GLSL_MATRIX_LAYOUT_INHERITED) {
+ var->data.matrix_layout = matrix_layout == GLSL_MATRIX_LAYOUT_INHERITED
+ ? GLSL_MATRIX_LAYOUT_COLUMN_MAJOR : matrix_layout;
+ } else {
+ var->data.matrix_layout = fields[i].matrix_layout;
+ }
+
if (fields[i].stream != -1 &&
((unsigned)fields[i].stream) != this->layout.stream) {
_mesa_glsl_error(&loc, state,
diff --git a/mesalib/src/glsl/builtin_functions.cpp b/mesalib/src/glsl/builtin_functions.cpp
index 8fc9051bb..0cf97dc43 100755
--- a/mesalib/src/glsl/builtin_functions.cpp
+++ b/mesalib/src/glsl/builtin_functions.cpp
@@ -706,7 +706,8 @@ builtin_builder::find(_mesa_glsl_parse_state *state,
if (f == NULL)
return NULL;
- ir_function_signature *sig = f->matching_signature(state, actual_parameters);
+ ir_function_signature *sig =
+ f->matching_signature(state, actual_parameters, true);
if (sig == NULL)
return NULL;
diff --git a/mesalib/src/glsl/builtin_types.cpp b/mesalib/src/glsl/builtin_types.cpp
index 0a0fa8cd3..10fac0f81 100644
--- a/mesalib/src/glsl/builtin_types.cpp
+++ b/mesalib/src/glsl/builtin_types.cpp
@@ -36,6 +36,7 @@
#include "glsl_types.h"
#include "glsl_parser_extras.h"
+#include "util/macros.h"
/**
* Declarations of type flyweights (glsl_type::_foo_type) and
@@ -48,69 +49,69 @@
#define STRUCT_TYPE(NAME) \
const glsl_type glsl_type::_struct_##NAME##_type = \
- glsl_type(NAME##_fields, Elements(NAME##_fields), #NAME); \
+ glsl_type(NAME##_fields, ARRAY_SIZE(NAME##_fields), #NAME); \
const glsl_type *const glsl_type::struct_##NAME##_type = \
&glsl_type::_struct_##NAME##_type;
static const struct glsl_struct_field gl_DepthRangeParameters_fields[] = {
- { glsl_type::float_type, "near", false, -1 },
- { glsl_type::float_type, "far", false, -1 },
- { glsl_type::float_type, "diff", false, -1 },
+ { glsl_type::float_type, "near", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
+ { glsl_type::float_type, "far", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
+ { glsl_type::float_type, "diff", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
};
static const struct glsl_struct_field gl_PointParameters_fields[] = {
- { glsl_type::float_type, "size", false, -1 },
- { glsl_type::float_type, "sizeMin", false, -1 },
- { glsl_type::float_type, "sizeMax", false, -1 },
- { glsl_type::float_type, "fadeThresholdSize", false, -1 },
- { glsl_type::float_type, "distanceConstantAttenuation", false, -1 },
- { glsl_type::float_type, "distanceLinearAttenuation", false, -1 },
- { glsl_type::float_type, "distanceQuadraticAttenuation", false, -1 },
+ { glsl_type::float_type, "size", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
+ { glsl_type::float_type, "sizeMin", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
+ { glsl_type::float_type, "sizeMax", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
+ { glsl_type::float_type, "fadeThresholdSize", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
+ { glsl_type::float_type, "distanceConstantAttenuation", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
+ { glsl_type::float_type, "distanceLinearAttenuation", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
+ { glsl_type::float_type, "distanceQuadraticAttenuation", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
};
static const struct glsl_struct_field gl_MaterialParameters_fields[] = {
- { glsl_type::vec4_type, "emission", false, -1 },
- { glsl_type::vec4_type, "ambient", false, -1 },
- { glsl_type::vec4_type, "diffuse", false, -1 },
- { glsl_type::vec4_type, "specular", false, -1 },
- { glsl_type::float_type, "shininess", false, -1 },
+ { glsl_type::vec4_type, "emission", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
+ { glsl_type::vec4_type, "ambient", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
+ { glsl_type::vec4_type, "diffuse", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
+ { glsl_type::vec4_type, "specular", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
+ { glsl_type::float_type, "shininess", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
};
static const struct glsl_struct_field gl_LightSourceParameters_fields[] = {
- { glsl_type::vec4_type, "ambient", false, -1 },
- { glsl_type::vec4_type, "diffuse", false, -1 },
- { glsl_type::vec4_type, "specular", false, -1 },
- { glsl_type::vec4_type, "position", false, -1 },
- { glsl_type::vec4_type, "halfVector", false, -1 },
- { glsl_type::vec3_type, "spotDirection", false, -1 },
- { glsl_type::float_type, "spotExponent", false, -1 },
- { glsl_type::float_type, "spotCutoff", false, -1 },
- { glsl_type::float_type, "spotCosCutoff", false, -1 },
- { glsl_type::float_type, "constantAttenuation", false, -1 },
- { glsl_type::float_type, "linearAttenuation", false, -1 },
- { glsl_type::float_type, "quadraticAttenuation", false, -1 },
+ { glsl_type::vec4_type, "ambient", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
+ { glsl_type::vec4_type, "diffuse", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
+ { glsl_type::vec4_type, "specular", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
+ { glsl_type::vec4_type, "position", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
+ { glsl_type::vec4_type, "halfVector", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
+ { glsl_type::vec3_type, "spotDirection", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
+ { glsl_type::float_type, "spotExponent", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
+ { glsl_type::float_type, "spotCutoff", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
+ { glsl_type::float_type, "spotCosCutoff", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
+ { glsl_type::float_type, "constantAttenuation", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
+ { glsl_type::float_type, "linearAttenuation", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
+ { glsl_type::float_type, "quadraticAttenuation", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
};
static const struct glsl_struct_field gl_LightModelParameters_fields[] = {
- { glsl_type::vec4_type, "ambient", false, -1 },
+ { glsl_type::vec4_type, "ambient", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
};
static const struct glsl_struct_field gl_LightModelProducts_fields[] = {
- { glsl_type::vec4_type, "sceneColor", false, -1 },
+ { glsl_type::vec4_type, "sceneColor", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
};
static const struct glsl_struct_field gl_LightProducts_fields[] = {
- { glsl_type::vec4_type, "ambient", false, -1 },
- { glsl_type::vec4_type, "diffuse", false, -1 },
- { glsl_type::vec4_type, "specular", false, -1 },
+ { glsl_type::vec4_type, "ambient", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
+ { glsl_type::vec4_type, "diffuse", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
+ { glsl_type::vec4_type, "specular", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
};
static const struct glsl_struct_field gl_FogParameters_fields[] = {
- { glsl_type::vec4_type, "color", false, -1 },
- { glsl_type::float_type, "density", false, -1 },
- { glsl_type::float_type, "start", false, -1 },
- { glsl_type::float_type, "end", false, -1 },
- { glsl_type::float_type, "scale", false, -1 },
+ { glsl_type::vec4_type, "color", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
+ { glsl_type::float_type, "density", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
+ { glsl_type::float_type, "start", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
+ { glsl_type::float_type, "end", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
+ { glsl_type::float_type, "scale", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
};
#include "builtin_type_macros.h"
@@ -265,7 +266,7 @@ _mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state)
{
struct glsl_symbol_table *symbols = state->symbols;
- for (unsigned i = 0; i < Elements(builtin_type_versions); i++) {
+ for (unsigned i = 0; i < ARRAY_SIZE(builtin_type_versions); i++) {
const struct builtin_type_versions *const t = &builtin_type_versions[i];
if (state->is_version(t->min_gl, t->min_es)) {
add_type(symbols, t->type);
@@ -276,7 +277,7 @@ _mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state)
* they're still present. We've removed them in 1.40+ (OpenGL 3.1+).
*/
if (!state->es_shader && state->language_version < 140) {
- for (unsigned i = 0; i < Elements(deprecated_types); i++) {
+ for (unsigned i = 0; i < ARRAY_SIZE(deprecated_types); i++) {
add_type(symbols, deprecated_types[i]);
}
}
diff --git a/mesalib/src/glsl/builtin_variables.cpp b/mesalib/src/glsl/builtin_variables.cpp
index 4c5b9c070..5b6f4ae62 100644
--- a/mesalib/src/glsl/builtin_variables.cpp
+++ b/mesalib/src/glsl/builtin_variables.cpp
@@ -317,7 +317,7 @@ per_vertex_accumulator::add_field(int slot, const glsl_type *type,
assert(this->num_fields < ARRAY_SIZE(this->fields));
this->fields[this->num_fields].type = type;
this->fields[this->num_fields].name = name;
- this->fields[this->num_fields].row_major = false;
+ this->fields[this->num_fields].matrix_layout = GLSL_MATRIX_LAYOUT_INHERITED;
this->fields[this->num_fields].location = slot;
this->fields[this->num_fields].interpolation = INTERP_QUALIFIER_NONE;
this->fields[this->num_fields].centroid = 0;
diff --git a/mesalib/src/glsl/glcpp/glcpp-lex.l b/mesalib/src/glsl/glcpp/glcpp-lex.l
index a1a8e76af..98d500ec0 100644
--- a/mesalib/src/glsl/glcpp/glcpp-lex.l
+++ b/mesalib/src/glsl/glcpp/glcpp-lex.l
@@ -52,14 +52,107 @@ void glcpp_set_column (int column_no , yyscan_t yyscanner);
yylloc->last_column = yycolumn + 1; \
parser->has_new_line_number = 0; \
parser->has_new_source_number = 0; \
- } while(0);
+ } while(0);
#define YY_USER_INIT \
do { \
yylineno = 1; \
- yycolumn = 1; \
+ yycolumn = 0; \
yylloc->source = 0; \
} while(0)
+
+/* It's ugly to have macros that have return statements inside of
+ * them, but flex-based lexer generation is all built around the
+ * return statement.
+ *
+ * To mitigate the ugliness, we defer as much of the logic as possible
+ * to an actual function, not a macro (see
+ * glcpplex_update_state_per_token) and we make the word RETURN
+ * prominent in all of the macros which may return.
+ *
+ * The most-commonly-used macro is RETURN_TOKEN which will perform all
+ * necessary state updates based on the provided token,, then
+ * conditionally return the token. It will not return a token if the
+ * parser is currently skipping tokens, (such as within #if
+ * 0...#else).
+ *
+ * The RETURN_TOKEN_NEVER_SKIP macro is a lower-level variant that
+ * makes the token returning unconditional. This is needed for things
+ * like #if and the tokens of its condition, (since these must be
+ * evaluated by the parser even when otherwise skipping).
+ *
+ * Finally, RETURN_STRING_TOKEN is a simple convenience wrapper on top
+ * of RETURN_TOKEN that performs a string copy of yytext before the
+ * return.
+ */
+#define RETURN_TOKEN_NEVER_SKIP(token) \
+ do { \
+ if (glcpp_lex_update_state_per_token (parser, token)) \
+ return token; \
+ } while (0)
+
+#define RETURN_TOKEN(token) \
+ do { \
+ if (! parser->skipping) { \
+ RETURN_TOKEN_NEVER_SKIP(token); \
+ } \
+ } while(0)
+
+#define RETURN_STRING_TOKEN(token) \
+ do { \
+ if (! parser->skipping) { \
+ yylval->str = ralloc_strdup (yyextra, yytext); \
+ RETURN_TOKEN_NEVER_SKIP (token); \
+ } \
+ } while(0)
+
+
+/* Update all state necessary for each token being returned.
+ *
+ * Here we'll be tracking newlines and spaces so that the lexer can
+ * alter its behavior as necessary, (for example, '#' has special
+ * significance if it is the first non-whitespace, non-comment token
+ * in a line, but does not otherwise).
+ *
+ * NOTE: If this function returns FALSE, then no token should be
+ * returned at all. This is used to suprress duplicate SPACE tokens.
+ */
+static int
+glcpp_lex_update_state_per_token (glcpp_parser_t *parser, int token)
+{
+ /* After the first non-space token in a line, we won't
+ * allow any '#' to introduce a directive. */
+ if (token == NEWLINE) {
+ parser->first_non_space_token_this_line = 1;
+ } else if (token != SPACE) {
+ parser->first_non_space_token_this_line = 0;
+ }
+
+ /* Track newlines just to know whether a newline needs
+ * to be inserted if end-of-file comes early. */
+ if (token == NEWLINE) {
+ parser->last_token_was_newline = 1;
+ } else {
+ parser->last_token_was_newline = 0;
+ }
+
+ /* Track spaces to avoid emitting multiple SPACE
+ * tokens in a row. */
+ if (token == SPACE) {
+ if (! parser->last_token_was_space) {
+ parser->last_token_was_space = 1;
+ return 1;
+ } else {
+ parser->last_token_was_space = 1;
+ return 0;
+ }
+ } else {
+ parser->last_token_was_space = 0;
+ return 1;
+ }
+}
+
+
%}
%option bison-bridge bison-locations reentrant noyywrap
@@ -67,14 +160,19 @@ void glcpp_set_column (int column_no , yyscan_t yyscanner);
%option prefix="glcpp_"
%option stack
%option never-interactive
+%option warn nodefault
+
+ /* Note: When adding any start conditions to this list, you must also
+ * update the "Internal compiler error" catch-all rule near the end of
+ * this file. */
-%x DONE COMMENT UNREACHABLE SKIP DEFINE NEWLINE_CATCHUP
+%x COMMENT DEFINE DONE HASH NEWLINE_CATCHUP UNREACHABLE
SPACE [[:space:]]
NONSPACE [^[:space:]]
-NEWLINE [\n]
HSPACE [ \t]
-HASH ^{HSPACE}*#{HSPACE}*
+HASH #
+NEWLINE (\r\n|\n\r|\r|\n)
IDENTIFIER [_a-zA-Z][_a-zA-Z0-9]*
PP_NUMBER [.]?[0-9]([._a-zA-Z0-9]|[eEpP][-+])*
PUNCTUATION [][(){}.&*~!/%<>^|;,=+-]
@@ -111,270 +209,357 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]?
parser->commented_newlines--;
if (parser->commented_newlines == 0)
BEGIN INITIAL;
- return NEWLINE;
+ RETURN_TOKEN_NEVER_SKIP (NEWLINE);
}
- /* The handling of the SKIP vs INITIAL start states requires
- * some special handling. Typically, a lexer would change
- * start states with statements like "BEGIN SKIP" within the
- * lexer rules. We can't get away with that here, since we
- * need the parser to actually evaluate expressions for
- * directives like "#if".
+ /* Set up the parser->skipping bit here before doing any lexing.
+ *
+ * This bit controls whether tokens are skipped, (as implemented by
+ * RETURN_TOKEN), such as between "#if 0" and "#endif".
*
- * So, here, in code that will be executed on every call to
- * the lexer,and before any rules, we examine the skip_stack
- * as set by the parser to know whether to change from INITIAL
- * to SKIP or from SKIP back to INITIAL.
+ * The parser maintains a skip_stack indicating whether we should be
+ * skipping, (and nested levels of #if/#ifdef/#ifndef/#endif) will
+ * push and pop items from the stack.
*
- * Three cases cause us to switch out of the SKIP state and
- * back to the INITIAL state:
+ * Here are the rules for determining whether we are skipping:
*
- * 1. The top of the skip_stack is of type SKIP_NO_SKIP
- * This means we're still evaluating some #if
- * hierarchy, but we're on a branch of it where
- * content should not be skipped (such as "#if 1" or
- * "#else" or so).
+ * 1. If the skip stack is NULL, we are outside of all #if blocks
+ * and we are not skipping.
*
- * 2. The skip_stack is NULL meaning that we've reached
- * the last #endif.
+ * 2. If the skip stack is non-NULL, the type of the top node in
+ * the stack determines whether to skip. A type of
+ * SKIP_NO_SKIP is used for blocks wheere we are emitting
+ * tokens, (such as between #if 1 and #endif, or after the
+ * #else of an #if 0, etc.).
*
- * 3. The lexing_directive bit is set. This indicates that we are
- * lexing a pre-processor directive, (such as #if, #elif, or
- * #else). For the #if and #elif directives we always need to
- * parse the conditions, (even if otherwise within an #if
- * 0). And for #else, we want to be able to generate an error
- * if any garbage follows #else.
+ * 3. The lexing_directive bit overrides the skip stack. This bit
+ * is set when we are actively lexing the expression for a
+ * pre-processor condition, (such as #if, #elif, or #else). In
+ * this case, even if otherwise skipping, we need to emit the
+ * tokens for this condition so that the parser can evaluate
+ * the expression. (For, #else, there's no expression, but we
+ * emit tokens so the parser can generate a nice error message
+ * if there are any tokens here).
*/
- if (YY_START == INITIAL || YY_START == SKIP) {
- if (parser->lexing_directive ||
- parser->skip_stack == NULL ||
- parser->skip_stack->type == SKIP_NO_SKIP)
- {
- BEGIN INITIAL;
- } else {
- BEGIN SKIP;
- }
+ if (parser->skip_stack &&
+ parser->skip_stack->type != SKIP_NO_SKIP &&
+ ! parser->lexing_directive)
+ {
+ parser->skipping = 1;
+ } else {
+ parser->skipping = 0;
}
/* Single-line comments */
-"//"[^\n]* {
+<INITIAL,DEFINE,HASH>"//"[^\r\n]* {
}
/* Multi-line comments */
-"/*" { yy_push_state(COMMENT, yyscanner); }
-<COMMENT>[^*\n]*
-<COMMENT>[^*\n]*\n { yylineno++; yycolumn = 0; parser->commented_newlines++; }
-<COMMENT>"*"+[^*/\n]*
-<COMMENT>"*"+[^*/\n]*\n { yylineno++; yycolumn = 0; parser->commented_newlines++; }
+<INITIAL,DEFINE,HASH>"/*" { yy_push_state(COMMENT, yyscanner); }
+<COMMENT>[^*\r\n]*
+<COMMENT>[^*\r\n]*{NEWLINE} { yylineno++; yycolumn = 0; parser->commented_newlines++; }
+<COMMENT>"*"+[^*/\r\n]*
+<COMMENT>"*"+[^*/\r\n]*{NEWLINE} { yylineno++; yycolumn = 0; parser->commented_newlines++; }
<COMMENT>"*"+"/" {
yy_pop_state(yyscanner);
- if (yyextra->space_tokens)
- return SPACE;
+ /* In the <HASH> start condition, we don't want any SPACE token. */
+ if (yyextra->space_tokens && YY_START != HASH)
+ RETURN_TOKEN (SPACE);
+}
+
+{HASH} {
+
+ /* If the '#' is the first non-whitespace, non-comment token on this
+ * line, then it introduces a directive, switch to the <HASH> start
+ * condition.
+ *
+ * Otherwise, this is just punctuation, so return the HASH_TOKEN
+ * token. */
+ if (parser->first_non_space_token_this_line) {
+ BEGIN HASH;
+ }
+
+ RETURN_TOKEN_NEVER_SKIP (HASH_TOKEN);
}
-{HASH}version{HSPACE}+ {
- yylval->str = ralloc_strdup (yyextra, yytext);
+<HASH>version{HSPACE}+ {
+ BEGIN INITIAL;
yyextra->space_tokens = 0;
- return HASH_VERSION;
+ RETURN_STRING_TOKEN (VERSION_TOKEN);
+}
+
+ /* Swallow empty #pragma directives, (to avoid confusing the
+ * downstream compiler). */
+<HASH>pragma{HSPACE}*/{NEWLINE} {
+ BEGIN INITIAL;
}
/* glcpp doesn't handle #extension, #version, or #pragma directives.
* Simply pass them through to the main compiler's lexer/parser. */
-{HASH}(extension|pragma)[^\n]* {
- if (parser->commented_newlines)
- BEGIN NEWLINE_CATCHUP;
- yylval->str = ralloc_strdup (yyextra, yytext);
- yylineno++;
- yycolumn = 0;
- return OTHER;
+<HASH>(extension|pragma)[^\r\n]* {
+ BEGIN INITIAL;
+ RETURN_STRING_TOKEN (PRAGMA);
}
-{HASH}line{HSPACE}+ {
- return HASH_LINE;
+<HASH>line{HSPACE}+ {
+ BEGIN INITIAL;
+ RETURN_TOKEN (LINE);
}
-<SKIP,INITIAL>{
-{HASH}ifdef {
+<HASH>{NEWLINE} {
+ BEGIN INITIAL;
+ RETURN_TOKEN_NEVER_SKIP (NEWLINE);
+}
+
+ /* For the pre-processor directives, we return these tokens
+ * even when we are otherwise skipping. */
+<HASH>ifdef {
+ BEGIN INITIAL;
yyextra->lexing_directive = 1;
yyextra->space_tokens = 0;
- return HASH_IFDEF;
+ RETURN_TOKEN_NEVER_SKIP (IFDEF);
}
-{HASH}ifndef {
+<HASH>ifndef {
+ BEGIN INITIAL;
yyextra->lexing_directive = 1;
yyextra->space_tokens = 0;
- return HASH_IFNDEF;
+ RETURN_TOKEN_NEVER_SKIP (IFNDEF);
}
-{HASH}if/[^_a-zA-Z0-9] {
+<HASH>if/[^_a-zA-Z0-9] {
+ BEGIN INITIAL;
yyextra->lexing_directive = 1;
yyextra->space_tokens = 0;
- return HASH_IF;
+ RETURN_TOKEN_NEVER_SKIP (IF);
}
-{HASH}elif/[^_a-zA-Z0-9] {
+<HASH>elif/[^_a-zA-Z0-9] {
+ BEGIN INITIAL;
yyextra->lexing_directive = 1;
yyextra->space_tokens = 0;
- return HASH_ELIF;
+ RETURN_TOKEN_NEVER_SKIP (ELIF);
}
-{HASH}else {
+<HASH>else {
+ BEGIN INITIAL;
yyextra->space_tokens = 0;
- return HASH_ELSE;
+ RETURN_TOKEN_NEVER_SKIP (ELSE);
}
-{HASH}endif {
+<HASH>endif {
+ BEGIN INITIAL;
yyextra->space_tokens = 0;
- return HASH_ENDIF;
-}
+ RETURN_TOKEN_NEVER_SKIP (ENDIF);
}
-<SKIP>[^\n] {
- if (parser->commented_newlines)
- BEGIN NEWLINE_CATCHUP;
+<HASH>error[^\r\n]* {
+ BEGIN INITIAL;
+ RETURN_STRING_TOKEN (ERROR_TOKEN);
}
-{HASH}error.* {
- char *p;
- for (p = yytext; !isalpha(p[0]); p++); /* skip " # " */
- p += 5; /* skip "error" */
- glcpp_error(yylloc, yyextra, "#error%s", p);
+ /* After we see a "#define" we enter the <DEFINE> start state
+ * for the lexer. Within <DEFINE> we are looking for the first
+ * identifier and specifically checking whether the identifier
+ * is followed by a '(' or not, (to lex either a
+ * FUNC_IDENTIFIER or an OBJ_IDENITIFIER token).
+ *
+ * While in the <DEFINE> state we also need to explicitly
+ * handle a few other things that may appear before the
+ * identifier:
+ *
+ * * Comments, (handled above with the main support for
+ * comments).
+ *
+ * * Whitespace (simply ignored)
+ *
+ * * Anything else, (not an identifier, not a comment,
+ * and not whitespace). This will generate an error.
+ */
+<HASH>define{HSPACE}* {
+ if (! parser->skipping) {
+ BEGIN DEFINE;
+ yyextra->space_tokens = 0;
+ RETURN_TOKEN (DEFINE_TOKEN);
+ }
}
-{HASH}define{HSPACE}+ {
+<HASH>undef {
+ BEGIN INITIAL;
yyextra->space_tokens = 0;
- yy_push_state(DEFINE, yyscanner);
- return HASH_DEFINE;
+ RETURN_TOKEN (UNDEF);
}
+<HASH>{HSPACE}+ {
+ /* Nothing to do here. Importantly, don't leave the <HASH>
+ * start condition, since it's legal to have space between the
+ * '#' and the directive.. */
+}
+
+ /* This will catch any non-directive garbage after a HASH */
+<HASH>{NONSPACE} {
+ BEGIN INITIAL;
+ RETURN_TOKEN (GARBAGE);
+}
+
+ /* An identifier immediately followed by '(' */
<DEFINE>{IDENTIFIER}/"(" {
- yy_pop_state(yyscanner);
- yylval->str = ralloc_strdup (yyextra, yytext);
- return FUNC_IDENTIFIER;
+ BEGIN INITIAL;
+ RETURN_STRING_TOKEN (FUNC_IDENTIFIER);
}
+ /* An identifier not immediately followed by '(' */
<DEFINE>{IDENTIFIER} {
- yy_pop_state(yyscanner);
- yylval->str = ralloc_strdup (yyextra, yytext);
- return OBJ_IDENTIFIER;
+ BEGIN INITIAL;
+ RETURN_STRING_TOKEN (OBJ_IDENTIFIER);
}
-{HASH}undef {
- yyextra->space_tokens = 0;
- return HASH_UNDEF;
+ /* Whitespace */
+<DEFINE>{HSPACE}+ {
+ /* Just ignore it. Nothing to do here. */
}
-{HASH} {
- yyextra->space_tokens = 0;
- return HASH;
+ /* '/' not followed by '*', so not a comment. This is an error. */
+<DEFINE>[/][^*]{NONSPACE}* {
+ BEGIN INITIAL;
+ glcpp_error(yylloc, yyextra, "#define followed by a non-identifier: %s", yytext);
+ RETURN_STRING_TOKEN (INTEGER_STRING);
+}
+
+ /* A character that can't start an identifier, comment, or
+ * space. This is an error. */
+<DEFINE>[^_a-zA-Z/[:space:]]{NONSPACE}* {
+ BEGIN INITIAL;
+ glcpp_error(yylloc, yyextra, "#define followed by a non-identifier: %s", yytext);
+ RETURN_STRING_TOKEN (INTEGER_STRING);
}
{DECIMAL_INTEGER} {
- yylval->str = ralloc_strdup (yyextra, yytext);
- return INTEGER_STRING;
+ RETURN_STRING_TOKEN (INTEGER_STRING);
}
{OCTAL_INTEGER} {
- yylval->str = ralloc_strdup (yyextra, yytext);
- return INTEGER_STRING;
+ RETURN_STRING_TOKEN (INTEGER_STRING);
}
{HEXADECIMAL_INTEGER} {
- yylval->str = ralloc_strdup (yyextra, yytext);
- return INTEGER_STRING;
+ RETURN_STRING_TOKEN (INTEGER_STRING);
}
"<<" {
- return LEFT_SHIFT;
+ RETURN_TOKEN (LEFT_SHIFT);
}
">>" {
- return RIGHT_SHIFT;
+ RETURN_TOKEN (RIGHT_SHIFT);
}
"<=" {
- return LESS_OR_EQUAL;
+ RETURN_TOKEN (LESS_OR_EQUAL);
}
">=" {
- return GREATER_OR_EQUAL;
+ RETURN_TOKEN (GREATER_OR_EQUAL);
}
"==" {
- return EQUAL;
+ RETURN_TOKEN (EQUAL);
}
"!=" {
- return NOT_EQUAL;
+ RETURN_TOKEN (NOT_EQUAL);
}
"&&" {
- return AND;
+ RETURN_TOKEN (AND);
}
"||" {
- return OR;
+ RETURN_TOKEN (OR);
+}
+
+"++" {
+ RETURN_TOKEN (PLUS_PLUS);
+}
+
+"--" {
+ RETURN_TOKEN (MINUS_MINUS);
}
"##" {
- if (parser->is_gles)
- glcpp_error(yylloc, yyextra, "Token pasting (##) is illegal in GLES");
- return PASTE;
+ if (! parser->skipping) {
+ if (parser->is_gles)
+ glcpp_error(yylloc, yyextra, "Token pasting (##) is illegal in GLES");
+ RETURN_TOKEN (PASTE);
+ }
}
"defined" {
- return DEFINED;
+ RETURN_TOKEN (DEFINED);
}
{IDENTIFIER} {
- yylval->str = ralloc_strdup (yyextra, yytext);
- return IDENTIFIER;
+ RETURN_STRING_TOKEN (IDENTIFIER);
}
{PP_NUMBER} {
- yylval->str = ralloc_strdup (yyextra, yytext);
- return OTHER;
+ RETURN_STRING_TOKEN (OTHER);
}
{PUNCTUATION} {
- return yytext[0];
+ RETURN_TOKEN (yytext[0]);
}
{OTHER}+ {
- yylval->str = ralloc_strdup (yyextra, yytext);
- return OTHER;
+ RETURN_STRING_TOKEN (OTHER);
}
{HSPACE} {
if (yyextra->space_tokens) {
- return SPACE;
+ RETURN_TOKEN (SPACE);
}
}
-<SKIP,INITIAL>\n {
+ /* We preserve all newlines, even between #if 0..#endif, so no
+ skipping.. */
+<*>{NEWLINE} {
if (parser->commented_newlines) {
BEGIN NEWLINE_CATCHUP;
+ } else {
+ BEGIN INITIAL;
}
+ yyextra->space_tokens = 1;
yyextra->lexing_directive = 0;
yylineno++;
yycolumn = 0;
- return NEWLINE;
+ RETURN_TOKEN_NEVER_SKIP (NEWLINE);
}
- /* Handle missing newline at EOF. */
-<INITIAL><<EOF>> {
+<INITIAL,COMMENT,DEFINE,HASH><<EOF>> {
+ if (YY_START == COMMENT)
+ glcpp_error(yylloc, yyextra, "Unterminated comment");
BEGIN DONE; /* Don't keep matching this rule forever. */
yyextra->lexing_directive = 0;
- return NEWLINE;
+ if (! parser->last_token_was_newline)
+ RETURN_TOKEN (NEWLINE);
}
+ /* This is a catch-all to avoid the annoying default flex action which
+ * matches any character and prints it. If any input ever matches this
+ * rule, then we have made a mistake above and need to fix one or more
+ * of the preceding patterns to match that input. */
+
+<*>. {
+ glcpp_error(yylloc, yyextra, "Internal compiler error: Unexpected character: %s", yytext);
+
/* We don't actually use the UNREACHABLE start condition. We
- only have this action here so that we can pretend to call some
+ only have this block here so that we can pretend to call some
generated functions, (to avoid "defined but not used"
warnings. */
-<UNREACHABLE>. {
- unput('.');
- yy_top_state(yyextra);
+ if (YY_START == UNREACHABLE) {
+ unput('.');
+ yy_top_state(yyextra);
+ }
}
%%
diff --git a/mesalib/src/glsl/glcpp/glcpp-parse.y b/mesalib/src/glsl/glcpp/glcpp-parse.y
index 084078eb0..a61697394 100644
--- a/mesalib/src/glsl/glcpp/glcpp-parse.y
+++ b/mesalib/src/glsl/glcpp/glcpp-parse.y
@@ -57,6 +57,9 @@ _string_list_append_item (string_list_t *list, const char *str);
static int
_string_list_contains (string_list_t *list, const char *member, int *index);
+static const char *
+_string_list_has_duplicate (string_list_t *list);
+
static int
_string_list_length (string_list_t *list);
@@ -105,18 +108,25 @@ _parser_active_list_pop (glcpp_parser_t *parser);
static int
_parser_active_list_contains (glcpp_parser_t *parser, const char *identifier);
+typedef enum {
+ EXPANSION_MODE_IGNORE_DEFINED,
+ EXPANSION_MODE_EVALUATE_DEFINED
+} expansion_mode_t;
+
/* Expand list, and begin lexing from the result (after first
* prefixing a token of type 'head_token_type').
*/
static void
_glcpp_parser_expand_and_lex_from (glcpp_parser_t *parser,
int head_token_type,
- token_list_t *list);
+ token_list_t *list,
+ expansion_mode_t mode);
/* Perform macro expansion in-place on the given list. */
static void
_glcpp_parser_expand_token_list (glcpp_parser_t *parser,
- token_list_t *list);
+ token_list_t *list,
+ expansion_mode_t mode);
static void
_glcpp_parser_print_expanded_token_list (glcpp_parser_t *parser,
@@ -164,14 +174,18 @@ add_builtin_define(glcpp_parser_t *parser, const char *name, int value);
%lex-param {glcpp_parser_t *parser}
%expect 0
-%token COMMA_FINAL DEFINED ELIF_EXPANDED HASH HASH_DEFINE FUNC_IDENTIFIER OBJ_IDENTIFIER HASH_ELIF HASH_ELSE HASH_ENDIF HASH_IF HASH_IFDEF HASH_IFNDEF HASH_LINE HASH_UNDEF HASH_VERSION IDENTIFIER IF_EXPANDED INTEGER INTEGER_STRING LINE_EXPANDED NEWLINE OTHER PLACEHOLDER SPACE
+
+ /* We use HASH_TOKEN, DEFINE_TOKEN and VERSION_TOKEN (as opposed to
+ * HASH, DEFINE, and VERSION) to avoid conflicts with other symbols,
+ * (such as the <HASH> and <DEFINE> start conditions in the lexer). */
+%token DEFINED ELIF_EXPANDED HASH_TOKEN DEFINE_TOKEN FUNC_IDENTIFIER OBJ_IDENTIFIER ELIF ELSE ENDIF ERROR_TOKEN IF IFDEF IFNDEF LINE PRAGMA UNDEF VERSION_TOKEN GARBAGE IDENTIFIER IF_EXPANDED INTEGER INTEGER_STRING LINE_EXPANDED NEWLINE OTHER PLACEHOLDER SPACE PLUS_PLUS MINUS_MINUS
%token PASTE
%type <ival> INTEGER operator SPACE integer_constant
%type <expression_value> expression
-%type <str> IDENTIFIER FUNC_IDENTIFIER OBJ_IDENTIFIER INTEGER_STRING OTHER
+%type <str> IDENTIFIER FUNC_IDENTIFIER OBJ_IDENTIFIER INTEGER_STRING OTHER ERROR_TOKEN PRAGMA
%type <string_list> identifier_list
-%type <token> preprocessing_token conditional_token
-%type <token_list> pp_tokens replacement_list text_line conditional_tokens
+%type <token> preprocessing_token
+%type <token_list> pp_tokens replacement_list text_line
%left OR
%left AND
%left '|'
@@ -184,6 +198,8 @@ add_builtin_define(glcpp_parser_t *parser, const char *name, int value);
%left '*' '/' '%'
%right UNARY
+%debug
+
%%
input:
@@ -192,27 +208,14 @@ input:
;
line:
- control_line {
- ralloc_asprintf_rewrite_tail (&parser->output, &parser->output_length, "\n");
- }
-| HASH_LINE {
- glcpp_parser_resolve_implicit_version(parser);
- } pp_tokens NEWLINE {
-
- if (parser->skip_stack == NULL ||
- parser->skip_stack->type == SKIP_NO_SKIP)
- {
- _glcpp_parser_expand_and_lex_from (parser,
- LINE_EXPANDED, $3);
- }
- }
+ control_line
+| SPACE control_line
| text_line {
_glcpp_parser_print_expanded_token_list (parser, $1);
ralloc_asprintf_rewrite_tail (&parser->output, &parser->output_length, "\n");
ralloc_free ($1);
}
| expanded_line
-| HASH non_directive
;
expanded_line:
@@ -259,29 +262,48 @@ define:
;
control_line:
- HASH_DEFINE {
+ control_line_success {
+ ralloc_asprintf_rewrite_tail (&parser->output, &parser->output_length, "\n");
+ }
+| control_line_error
+| HASH_TOKEN LINE {
+ glcpp_parser_resolve_implicit_version(parser);
+ } pp_tokens NEWLINE {
+
+ if (parser->skip_stack == NULL ||
+ parser->skip_stack->type == SKIP_NO_SKIP)
+ {
+ _glcpp_parser_expand_and_lex_from (parser,
+ LINE_EXPANDED, $4,
+ EXPANSION_MODE_IGNORE_DEFINED);
+ }
+ }
+;
+
+control_line_success:
+ HASH_TOKEN DEFINE_TOKEN {
glcpp_parser_resolve_implicit_version(parser);
} define
-| HASH_UNDEF {
+| HASH_TOKEN UNDEF {
glcpp_parser_resolve_implicit_version(parser);
} IDENTIFIER NEWLINE {
macro_t *macro;
- if (strcmp("__LINE__", $3) == 0
- || strcmp("__FILE__", $3) == 0
- || strcmp("__VERSION__", $3) == 0)
+ if (strcmp("__LINE__", $4) == 0
+ || strcmp("__FILE__", $4) == 0
+ || strcmp("__VERSION__", $4) == 0)
glcpp_error(& @1, parser, "Built-in (pre-defined)"
" macro names can not be undefined.");
- macro = hash_table_find (parser->defines, $3);
+ macro = hash_table_find (parser->defines, $4);
if (macro) {
- hash_table_remove (parser->defines, $3);
+ hash_table_remove (parser->defines, $4);
ralloc_free (macro);
}
- ralloc_free ($3);
+ ralloc_free ($4);
}
-| HASH_IF {
+| HASH_TOKEN IF {
glcpp_parser_resolve_implicit_version(parser);
- } conditional_tokens NEWLINE {
+ } pp_tokens NEWLINE {
/* Be careful to only evaluate the 'if' expression if
* we are not skipping. When we are skipping, we
* simply push a new 0-valued 'if' onto the skip
@@ -293,7 +315,8 @@ control_line:
parser->skip_stack->type == SKIP_NO_SKIP)
{
_glcpp_parser_expand_and_lex_from (parser,
- IF_EXPANDED, $3);
+ IF_EXPANDED, $4,
+ EXPANSION_MODE_EVALUATE_DEFINED);
}
else
{
@@ -301,7 +324,7 @@ control_line:
parser->skip_stack->type = SKIP_TO_ENDIF;
}
}
-| HASH_IF NEWLINE {
+| HASH_TOKEN IF NEWLINE {
/* #if without an expression is only an error if we
* are not skipping */
if (parser->skip_stack == NULL ||
@@ -311,21 +334,21 @@ control_line:
}
_glcpp_parser_skip_stack_push_if (parser, & @1, 0);
}
-| HASH_IFDEF {
+| HASH_TOKEN IFDEF {
glcpp_parser_resolve_implicit_version(parser);
} IDENTIFIER junk NEWLINE {
- macro_t *macro = hash_table_find (parser->defines, $3);
- ralloc_free ($3);
+ macro_t *macro = hash_table_find (parser->defines, $4);
+ ralloc_free ($4);
_glcpp_parser_skip_stack_push_if (parser, & @1, macro != NULL);
}
-| HASH_IFNDEF {
+| HASH_TOKEN IFNDEF {
glcpp_parser_resolve_implicit_version(parser);
} IDENTIFIER junk NEWLINE {
- macro_t *macro = hash_table_find (parser->defines, $3);
- ralloc_free ($3);
- _glcpp_parser_skip_stack_push_if (parser, & @2, macro == NULL);
+ macro_t *macro = hash_table_find (parser->defines, $4);
+ ralloc_free ($4);
+ _glcpp_parser_skip_stack_push_if (parser, & @3, macro == NULL);
}
-| HASH_ELIF conditional_tokens NEWLINE {
+| HASH_TOKEN ELIF pp_tokens NEWLINE {
/* Be careful to only evaluate the 'elif' expression
* if we are not skipping. When we are skipping, we
* simply change to a 0-valued 'elif' on the skip
@@ -337,7 +360,8 @@ control_line:
parser->skip_stack->type == SKIP_TO_ELSE)
{
_glcpp_parser_expand_and_lex_from (parser,
- ELIF_EXPANDED, $2);
+ ELIF_EXPANDED, $3,
+ EXPANSION_MODE_EVALUATE_DEFINED);
}
else if (parser->skip_stack &&
parser->skip_stack->has_else)
@@ -350,7 +374,7 @@ control_line:
"elif", 0);
}
}
-| HASH_ELIF NEWLINE {
+| HASH_TOKEN ELIF NEWLINE {
/* #elif without an expression is an error unless we
* are skipping. */
if (parser->skip_stack &&
@@ -370,7 +394,7 @@ control_line:
glcpp_warning(& @1, parser, "ignoring illegal #elif without expression");
}
}
-| HASH_ELSE { parser->lexing_directive = 1; } NEWLINE {
+| HASH_TOKEN ELSE { parser->lexing_directive = 1; } NEWLINE {
if (parser->skip_stack &&
parser->skip_stack->has_else)
{
@@ -383,24 +407,39 @@ control_line:
parser->skip_stack->has_else = true;
}
}
-| HASH_ENDIF {
+| HASH_TOKEN ENDIF {
_glcpp_parser_skip_stack_pop (parser, & @1);
} NEWLINE
-| HASH_VERSION integer_constant NEWLINE {
+| HASH_TOKEN VERSION_TOKEN integer_constant NEWLINE {
if (parser->version_resolved) {
glcpp_error(& @1, parser, "#version must appear on the first line");
}
- _glcpp_parser_handle_version_declaration(parser, $2, NULL, true);
+ _glcpp_parser_handle_version_declaration(parser, $3, NULL, true);
}
-| HASH_VERSION integer_constant IDENTIFIER NEWLINE {
+| HASH_TOKEN VERSION_TOKEN integer_constant IDENTIFIER NEWLINE {
if (parser->version_resolved) {
glcpp_error(& @1, parser, "#version must appear on the first line");
}
- _glcpp_parser_handle_version_declaration(parser, $2, $3, true);
+ _glcpp_parser_handle_version_declaration(parser, $3, $4, true);
}
-| HASH NEWLINE {
+| HASH_TOKEN NEWLINE {
glcpp_parser_resolve_implicit_version(parser);
}
+| HASH_TOKEN PRAGMA NEWLINE {
+ ralloc_asprintf_rewrite_tail (&parser->output, &parser->output_length, "#%s", $2);
+ }
+;
+
+control_line_error:
+ HASH_TOKEN ERROR_TOKEN NEWLINE {
+ glcpp_error(& @1, parser, "#%s", $2);
+ }
+| HASH_TOKEN DEFINE_TOKEN NEWLINE {
+ glcpp_error (& @1, parser, "#define without macro name");
+ }
+| HASH_TOKEN GARBAGE pp_tokens NEWLINE {
+ glcpp_error (& @1, parser, "Illegal non-directive after #");
+ }
;
integer_constant:
@@ -612,12 +651,6 @@ text_line:
| pp_tokens NEWLINE
;
-non_directive:
- pp_tokens NEWLINE {
- yyerror (& @1, parser, "Invalid tokens after #");
- }
-;
-
replacement_list:
/* empty */ { $$ = NULL; }
| pp_tokens
@@ -630,31 +663,6 @@ junk:
}
;
-conditional_token:
- /* Handle "defined" operator */
- DEFINED IDENTIFIER {
- int v = hash_table_find (parser->defines, $2) ? 1 : 0;
- $$ = _token_create_ival (parser, INTEGER, v);
- }
-| DEFINED '(' IDENTIFIER ')' {
- int v = hash_table_find (parser->defines, $3) ? 1 : 0;
- $$ = _token_create_ival (parser, INTEGER, v);
- }
-| preprocessing_token
-;
-
-conditional_tokens:
- /* Exactly the same as pp_tokens, but using conditional_token */
- conditional_token {
- $$ = _token_list_create (parser);
- _token_list_append ($$, $1);
- }
-| conditional_tokens conditional_token {
- $$ = $1;
- _token_list_append ($$, $2);
- }
-;
-
pp_tokens:
preprocessing_token {
parser->space_tokens = 1;
@@ -680,6 +688,10 @@ preprocessing_token:
$$ = _token_create_ival (parser, $1, $1);
$$->location = yylloc;
}
+| DEFINED {
+ $$ = _token_create_ival (parser, DEFINED, DEFINED);
+ $$->location = yylloc;
+ }
| OTHER {
$$ = _token_create_str (parser, OTHER, $1);
$$->location = yylloc;
@@ -722,6 +734,8 @@ operator:
| ',' { $$ = ','; }
| '=' { $$ = '='; }
| PASTE { $$ = PASTE; }
+| PLUS_PLUS { $$ = PLUS_PLUS; }
+| MINUS_MINUS { $$ = MINUS_MINUS; }
;
%%
@@ -777,6 +791,25 @@ _string_list_contains (string_list_t *list, const char *member, int *index)
return 0;
}
+/* Return duplicate string in list (if any), NULL otherwise. */
+const char *
+_string_list_has_duplicate (string_list_t *list)
+{
+ string_node_t *node, *dup;
+
+ if (list == NULL)
+ return NULL;
+
+ for (node = list->head; node; node = node->next) {
+ for (dup = node->next; dup; dup = dup->next) {
+ if (strcmp (node->str, dup->str) == 0)
+ return node->str;
+ }
+ }
+
+ return NULL;
+}
+
int
_string_list_length (string_list_t *list)
{
@@ -1123,14 +1156,21 @@ _token_print (char **out, size_t *len, token_t *token)
case PASTE:
ralloc_asprintf_rewrite_tail (out, len, "##");
break;
- case COMMA_FINAL:
- ralloc_asprintf_rewrite_tail (out, len, ",");
+ case PLUS_PLUS:
+ ralloc_asprintf_rewrite_tail (out, len, "++");
+ break;
+ case MINUS_MINUS:
+ ralloc_asprintf_rewrite_tail (out, len, "--");
+ break;
+ case DEFINED:
+ ralloc_asprintf_rewrite_tail (out, len, "defined");
break;
case PLACEHOLDER:
/* Nothing to print. */
break;
default:
assert(!"Error: Don't know how to print token.");
+
break;
}
}
@@ -1308,12 +1348,16 @@ glcpp_parser_create (const struct gl_extensions *extensions, gl_api api)
parser->active = NULL;
parser->lexing_directive = 0;
parser->space_tokens = 1;
+ parser->last_token_was_newline = 0;
+ parser->last_token_was_space = 0;
+ parser->first_non_space_token_this_line = 1;
parser->newline_as_space = 0;
parser->in_control_line = 0;
parser->paren_count = 0;
parser->commented_newlines = 0;
parser->skip_stack = NULL;
+ parser->skipping = 0;
parser->lex_from_list = NULL;
parser->lex_from_node = NULL;
@@ -1459,15 +1503,143 @@ _token_list_create_with_one_integer (void *ctx, int ival)
return _token_list_create_with_one_ival (ctx, INTEGER, ival);
}
+/* Evaluate a DEFINED token node (based on subsequent tokens in the list).
+ *
+ * Note: This function must only be called when "node" is a DEFINED token,
+ * (and will abort with an assertion failure otherwise).
+ *
+ * If "node" is followed, (ignoring any SPACE tokens), by an IDENTIFIER token
+ * (optionally preceded and followed by '(' and ')' tokens) then the following
+ * occurs:
+ *
+ * If the identifier is a defined macro, this function returns 1.
+ *
+ * If the identifier is not a defined macro, this function returns 0.
+ *
+ * In either case, *last will be updated to the last node in the list
+ * consumed by the evaluation, (either the token of the identifier or the
+ * token of the closing parenthesis).
+ *
+ * In all other cases, (such as "node is the final node of the list", or
+ * "missing closing parenthesis", etc.), this function generates a
+ * preprocessor error, returns -1 and *last will not be set.
+ */
+static int
+_glcpp_parser_evaluate_defined (glcpp_parser_t *parser,
+ token_node_t *node,
+ token_node_t **last)
+{
+ token_node_t *argument, *defined = node;
+
+ assert (node->token->type == DEFINED);
+
+ node = node->next;
+
+ /* Ignore whitespace after DEFINED token. */
+ while (node && node->token->type == SPACE)
+ node = node->next;
+
+ if (node == NULL)
+ goto FAIL;
+
+ if (node->token->type == IDENTIFIER || node->token->type == OTHER) {
+ argument = node;
+ } else if (node->token->type == '(') {
+ node = node->next;
+
+ /* Ignore whitespace after '(' token. */
+ while (node && node->token->type == SPACE)
+ node = node->next;
+
+ if (node == NULL || (node->token->type != IDENTIFIER &&
+ node->token->type != OTHER))
+ {
+ goto FAIL;
+ }
+
+ argument = node;
+
+ node = node->next;
+
+ /* Ignore whitespace after identifier, before ')' token. */
+ while (node && node->token->type == SPACE)
+ node = node->next;
+
+ if (node == NULL || node->token->type != ')')
+ goto FAIL;
+ } else {
+ goto FAIL;
+ }
+
+ *last = node;
+
+ return hash_table_find (parser->defines,
+ argument->token->value.str) ? 1 : 0;
+
+FAIL:
+ glcpp_error (&defined->token->location, parser,
+ "\"defined\" not followed by an identifier");
+ return -1;
+}
+
+/* Evaluate all DEFINED nodes in a given list, modifying the list in place.
+ */
+static void
+_glcpp_parser_evaluate_defined_in_list (glcpp_parser_t *parser,
+ token_list_t *list)
+{
+ token_node_t *node, *node_prev, *replacement, *last = NULL;
+ int value;
+
+ if (list == NULL)
+ return;
+
+ node_prev = NULL;
+ node = list->head;
+
+ while (node) {
+
+ if (node->token->type != DEFINED)
+ goto NEXT;
+
+ value = _glcpp_parser_evaluate_defined (parser, node, &last);
+ if (value == -1)
+ goto NEXT;
+
+ replacement = ralloc (list, token_node_t);
+ replacement->token = _token_create_ival (list, INTEGER, value);
+
+ /* Splice replacement node into list, replacing from "node"
+ * through "last". */
+ if (node_prev)
+ node_prev->next = replacement;
+ else
+ list->head = replacement;
+ replacement->next = last->next;
+ if (last == list->tail)
+ list->tail = replacement;
+
+ node = replacement;
+
+ NEXT:
+ node_prev = node;
+ node = node->next;
+ }
+}
+
/* Perform macro expansion on 'list', placing the resulting tokens
* into a new list which is initialized with a first token of type
* 'head_token_type'. Then begin lexing from the resulting list,
* (return to the current lexing source when this list is exhausted).
+ *
+ * See the documentation of _glcpp_parser_expand_token_list for a description
+ * of the "mode" parameter.
*/
static void
_glcpp_parser_expand_and_lex_from (glcpp_parser_t *parser,
int head_token_type,
- token_list_t *list)
+ token_list_t *list,
+ expansion_mode_t mode)
{
token_list_t *expanded;
token_t *token;
@@ -1475,7 +1647,7 @@ _glcpp_parser_expand_and_lex_from (glcpp_parser_t *parser,
expanded = _token_list_create (parser);
token = _token_create_ival (parser, head_token_type, head_token_type);
_token_list_append (expanded, token);
- _glcpp_parser_expand_token_list (parser, list);
+ _glcpp_parser_expand_token_list (parser, list, mode);
_token_list_append_list (expanded, list);
glcpp_parser_lex_from (parser, expanded);
}
@@ -1538,12 +1710,15 @@ _glcpp_parser_apply_pastes (glcpp_parser_t *parser, token_list_t *list)
* *last to the last node in the list that was consumed by the
* expansion. Specifically, *last will be set as follows: as the
* token of the closing right parenthesis.
+ *
+ * See the documentation of _glcpp_parser_expand_token_list for a description
+ * of the "mode" parameter.
*/
static token_list_t *
_glcpp_parser_expand_function (glcpp_parser_t *parser,
token_node_t *node,
- token_node_t **last)
-
+ token_node_t **last,
+ expansion_mode_t mode)
{
macro_t *macro;
const char *identifier;
@@ -1612,7 +1787,8 @@ _glcpp_parser_expand_function (glcpp_parser_t *parser,
expanded_argument = _token_list_copy (parser,
argument);
_glcpp_parser_expand_token_list (parser,
- expanded_argument);
+ expanded_argument,
+ mode);
_token_list_append_list (substituted,
expanded_argument);
} else {
@@ -1652,11 +1828,15 @@ _glcpp_parser_expand_function (glcpp_parser_t *parser,
*
* As the token of the closing right parenthesis in the case of
* function-like macro expansion.
+ *
+ * See the documentation of _glcpp_parser_expand_token_list for a description
+ * of the "mode" parameter.
*/
static token_list_t *
_glcpp_parser_expand_node (glcpp_parser_t *parser,
token_node_t *node,
- token_node_t **last)
+ token_node_t **last,
+ expansion_mode_t mode)
{
token_t *token = node->token;
const char *identifier;
@@ -1664,14 +1844,6 @@ _glcpp_parser_expand_node (glcpp_parser_t *parser,
/* We only expand identifiers */
if (token->type != IDENTIFIER) {
- /* We change any COMMA into a COMMA_FINAL to prevent
- * it being mistaken for an argument separator
- * later. */
- if (token->type == ',') {
- token->type = COMMA_FINAL;
- token->value.ival = COMMA_FINAL;
- }
-
return NULL;
}
@@ -1723,7 +1895,7 @@ _glcpp_parser_expand_node (glcpp_parser_t *parser,
return replacement;
}
- return _glcpp_parser_expand_function (parser, node, last);
+ return _glcpp_parser_expand_function (parser, node, last, mode);
}
/* Push a new identifier onto the parser's active list.
@@ -1782,11 +1954,28 @@ _parser_active_list_contains (glcpp_parser_t *parser, const char *identifier)
/* Walk over the token list replacing nodes with their expansion.
* Whenever nodes are expanded the walking will walk over the new
* nodes, continuing to expand as necessary. The results are placed in
- * 'list' itself;
+ * 'list' itself.
+ *
+ * The "mode" argument controls the handling of any DEFINED tokens that
+ * result from expansion as follows:
+ *
+ * EXPANSION_MODE_IGNORE_DEFINED: Any resulting DEFINED tokens will be
+ * left in the final list, unevaluated. This is the correct mode
+ * for expanding any list in any context other than a
+ * preprocessor conditional, (#if or #elif).
+ *
+ * EXPANSION_MODE_EVALUATE_DEFINED: Any resulting DEFINED tokens will be
+ * evaluated to 0 or 1 tokens depending on whether the following
+ * token is the name of a defined macro. If the DEFINED token is
+ * not followed by an (optionally parenthesized) identifier, then
+ * an error will be generated. This the correct mode for
+ * expanding any list in the context of a preprocessor
+ * conditional, (#if or #elif).
*/
static void
_glcpp_parser_expand_token_list (glcpp_parser_t *parser,
- token_list_t *list)
+ token_list_t *list,
+ expansion_mode_t mode)
{
token_node_t *node_prev;
token_node_t *node, *last = NULL;
@@ -1801,15 +1990,23 @@ _glcpp_parser_expand_token_list (glcpp_parser_t *parser,
node_prev = NULL;
node = list->head;
+ if (mode == EXPANSION_MODE_EVALUATE_DEFINED)
+ _glcpp_parser_evaluate_defined_in_list (parser, list);
+
while (node) {
while (parser->active && parser->active->marker == node)
_parser_active_list_pop (parser);
- expansion = _glcpp_parser_expand_node (parser, node, &last);
+ expansion = _glcpp_parser_expand_node (parser, node, &last, mode);
if (expansion) {
token_node_t *n;
+ if (mode == EXPANSION_MODE_EVALUATE_DEFINED) {
+ _glcpp_parser_evaluate_defined_in_list (parser,
+ expansion);
+ }
+
for (n = node; n != last->next; n = n->next)
while (parser->active &&
parser->active->marker == n)
@@ -1862,7 +2059,7 @@ _glcpp_parser_print_expanded_token_list (glcpp_parser_t *parser,
if (list == NULL)
return;
- _glcpp_parser_expand_token_list (parser, list);
+ _glcpp_parser_expand_token_list (parser, list, EXPANSION_MODE_IGNORE_DEFINED);
_token_list_trim_trailing_space (list);
@@ -1923,6 +2120,10 @@ _define_object_macro (glcpp_parser_t *parser,
{
macro_t *macro, *previous;
+ /* We define pre-defined macros before we've started parsing the
+ * actual file. So if there's no location defined yet, that's what
+ * were doing and we don't want to generate an error for using the
+ * reserved names. */
if (loc != NULL)
_check_for_reserved_macro_name(parser, loc, identifier);
@@ -1955,9 +2156,16 @@ _define_function_macro (glcpp_parser_t *parser,
token_list_t *replacements)
{
macro_t *macro, *previous;
+ const char *dup;
_check_for_reserved_macro_name(parser, loc, identifier);
+ /* Check for any duplicate parameter names. */
+ if ((dup = _string_list_has_duplicate (parameters)) != NULL) {
+ glcpp_error (loc, parser, "Duplicate macro parameter \"%s\"",
+ dup);
+ }
+
macro = ralloc (parser, macro_t);
ralloc_steal (macro, parameters);
ralloc_steal (macro, replacements);
@@ -2020,11 +2228,11 @@ glcpp_parser_lex (YYSTYPE *yylval, YYLTYPE *yylloc, glcpp_parser_t *parser)
if (ret == NEWLINE)
parser->in_control_line = 0;
}
- else if (ret == HASH_DEFINE ||
- ret == HASH_UNDEF || ret == HASH_IF ||
- ret == HASH_IFDEF || ret == HASH_IFNDEF ||
- ret == HASH_ELIF || ret == HASH_ELSE ||
- ret == HASH_ENDIF || ret == HASH)
+ else if (ret == DEFINE_TOKEN ||
+ ret == UNDEF || ret == IF ||
+ ret == IFDEF || ret == IFNDEF ||
+ ret == ELIF || ret == ELSE ||
+ ret == ENDIF || ret == HASH_TOKEN)
{
parser->in_control_line = 1;
}
@@ -2117,7 +2325,7 @@ _glcpp_parser_skip_stack_change_if (glcpp_parser_t *parser, YYLTYPE *loc,
const char *type, int condition)
{
if (parser->skip_stack == NULL) {
- glcpp_error (loc, parser, "%s without #if\n", type);
+ glcpp_error (loc, parser, "#%s without #if\n", type);
return;
}
@@ -2170,6 +2378,8 @@ _glcpp_parser_handle_version_declaration(glcpp_parser_t *parser, intmax_t versio
if (extensions != NULL) {
if (extensions->OES_EGL_image_external)
add_builtin_define(parser, "GL_OES_EGL_image_external", 1);
+ if (extensions->OES_standard_derivatives)
+ add_builtin_define(parser, "GL_OES_standard_derivatives", 1);
}
} else {
add_builtin_define(parser, "GL_ARB_draw_buffers", 1);
diff --git a/mesalib/src/glsl/glcpp/glcpp.c b/mesalib/src/glsl/glcpp/glcpp.c
index 0144be85b..1a4b8b4f0 100644
--- a/mesalib/src/glsl/glcpp/glcpp.c
+++ b/mesalib/src/glsl/glcpp/glcpp.c
@@ -132,6 +132,7 @@ enum {
const static struct option
long_options[] = {
{"disable-line-continuations", no_argument, 0, DISABLE_LINE_CONTINUATIONS_OPT },
+ {"debug", no_argument, 0, 'd'},
{0, 0, 0, 0 }
};
@@ -148,11 +149,14 @@ main (int argc, char *argv[])
init_fake_gl_context (&gl_ctx);
- while ((c = getopt_long(argc, argv, "", long_options, NULL)) != -1) {
+ while ((c = getopt_long(argc, argv, "d", long_options, NULL)) != -1) {
switch (c) {
case DISABLE_LINE_CONTINUATIONS_OPT:
gl_ctx.Const.DisableGLSLLineContinuations = true;
break;
+ case 'd':
+ glcpp_parser_debug = 1;
+ break;
default:
usage ();
exit (1);
diff --git a/mesalib/src/glsl/glcpp/glcpp.h b/mesalib/src/glsl/glcpp/glcpp.h
index 64b487202..70aa14b6e 100644
--- a/mesalib/src/glsl/glcpp/glcpp.h
+++ b/mesalib/src/glsl/glcpp/glcpp.h
@@ -29,7 +29,7 @@
#include "main/mtypes.h"
-#include "../ralloc.h"
+#include "util/ralloc.h"
#include "program/hash_table.h"
@@ -177,11 +177,15 @@ struct glcpp_parser {
active_list_t *active;
int lexing_directive;
int space_tokens;
+ int last_token_was_newline;
+ int last_token_was_space;
+ int first_non_space_token_this_line;
int newline_as_space;
int in_control_line;
int paren_count;
int commented_newlines;
skip_node_t *skip_stack;
+ int skipping;
token_list_t *lex_from_list;
token_node_t *lex_from_node;
char *output;
diff --git a/mesalib/src/glsl/glcpp/pp.c b/mesalib/src/glsl/glcpp/pp.c
index 4a623f81e..a54bcbe16 100644
--- a/mesalib/src/glsl/glcpp/pp.c
+++ b/mesalib/src/glsl/glcpp/pp.c
@@ -70,6 +70,42 @@ glcpp_warning (YYLTYPE *locp, glcpp_parser_t *parser, const char *fmt, ...)
&parser->info_log_length, "\n");
}
+/* Given str, (that's expected to start with a newline terminator of some
+ * sort), return a pointer to the first character in str after the newline.
+ *
+ * A newline terminator can be any of the following sequences:
+ *
+ * "\r\n"
+ * "\n\r"
+ * "\n"
+ * "\r"
+ *
+ * And the longest such sequence will be skipped.
+ */
+static const char *
+skip_newline (const char *str)
+{
+ const char *ret = str;
+
+ if (ret == NULL)
+ return ret;
+
+ if (*ret == '\0')
+ return ret;
+
+ if (*ret == '\r') {
+ ret++;
+ if (*ret && *ret == '\n')
+ ret++;
+ } else if (*ret == '\n') {
+ ret++;
+ if (*ret && *ret == '\r')
+ ret++;
+ }
+
+ return ret;
+}
+
/* Remove any line continuation characters in the shader, (whether in
* preprocessing directives or in GLSL code).
*/
@@ -78,10 +114,49 @@ remove_line_continuations(glcpp_parser_t *ctx, const char *shader)
{
char *clean = ralloc_strdup(ctx, "");
const char *backslash, *newline, *search_start;
+ const char *cr, *lf;
+ char newline_separator[3];
int collapsed_newlines = 0;
search_start = shader;
+ /* Determine what flavor of newlines this shader is using. GLSL
+ * provides for 4 different possible ways to separate lines, (using
+ * one or two characters):
+ *
+ * "\n" (line-feed, like Linux, Unix, and new Mac OS)
+ * "\r" (carriage-return, like old Mac files)
+ * "\r\n" (carriage-return + line-feed, like DOS files)
+ * "\n\r" (line-feed + carriage-return, like nothing, really)
+ *
+ * This code explicitly supports a shader that uses a mixture of
+ * newline terminators and will properly handle line continuation
+ * backslashes followed by any of the above.
+ *
+ * But, since we must also insert additional newlines in the output
+ * (for any collapsed lines) we attempt to maintain consistency by
+ * examining the first encountered newline terminator, and using the
+ * same terminator for any newlines we insert.
+ */
+ cr = strchr(search_start, '\r');
+ lf = strchr(search_start, '\n');
+
+ newline_separator[0] = '\n';
+ newline_separator[1] = '\0';
+ newline_separator[2] = '\0';
+
+ if (cr == NULL) {
+ /* Nothing to do. */
+ } else if (lf == NULL) {
+ newline_separator[0] = '\r';
+ } else if (lf == cr + 1) {
+ newline_separator[0] = '\r';
+ newline_separator[1] = '\n';
+ } else if (cr == lf + 1) {
+ newline_separator[0] = '\n';
+ newline_separator[1] = '\r';
+ }
+
while (true) {
backslash = strchr(search_start, '\\');
@@ -91,17 +166,24 @@ remove_line_continuations(glcpp_parser_t *ctx, const char *shader)
* line numbers.
*/
if (collapsed_newlines) {
- newline = strchr(search_start, '\n');
+ cr = strchr (search_start, '\r');
+ lf = strchr (search_start, '\n');
+ if (cr && lf)
+ newline = cr < lf ? cr : lf;
+ else if (cr)
+ newline = cr;
+ else
+ newline = lf;
if (newline &&
(backslash == NULL || newline < backslash))
{
ralloc_strncat(&clean, shader,
newline - shader + 1);
while (collapsed_newlines) {
- ralloc_strcat(&clean, "\n");
+ ralloc_strcat(&clean, newline_separator);
collapsed_newlines--;
}
- shader = newline + 1;
+ shader = skip_newline (newline);
search_start = shader;
}
}
@@ -116,15 +198,11 @@ remove_line_continuations(glcpp_parser_t *ctx, const char *shader)
* advance the shader pointer to the character after the
* newline.
*/
- if (backslash[1] == '\n' ||
- (backslash[1] == '\r' && backslash[2] == '\n'))
+ if (backslash[1] == '\r' || backslash[1] == '\n')
{
collapsed_newlines++;
ralloc_strncat(&clean, shader, backslash - shader);
- if (backslash[1] == '\n')
- shader = backslash + 2;
- else
- shader = backslash + 3;
+ shader = skip_newline (backslash + 1);
search_start = shader;
}
}
diff --git a/mesalib/src/glsl/glsl_lexer.ll b/mesalib/src/glsl/glsl_lexer.ll
index db7b1d179..b7c4aad3a 100644
--- a/mesalib/src/glsl/glsl_lexer.ll
+++ b/mesalib/src/glsl/glsl_lexer.ll
@@ -152,7 +152,11 @@ literal_integer(char *text, int len, struct _mesa_glsl_parse_state *state,
%option never-interactive
%option prefix="_mesa_glsl_lexer_"
%option extra-type="struct _mesa_glsl_parse_state *"
+%option warn nodefault
+ /* Note: When adding any start conditions to this list, you must also
+ * update the "Internal compiler error" catch-all rule near the end of
+ * this file. */
%x PP PRAGMA
DEC_INT [1-9][0-9]*
@@ -236,6 +240,7 @@ HASH ^{SPC}#{SPC}
return INTCONSTANT;
}
<PP>\n { BEGIN 0; yylineno++; yycolumn = 0; return EOL; }
+<PP>. { return yytext[0]; }
\n { yylineno++; yycolumn = 0; }
diff --git a/mesalib/src/glsl/glsl_parser_extras.cpp b/mesalib/src/glsl/glsl_parser_extras.cpp
index 890123ad1..2d94d3554 100644
--- a/mesalib/src/glsl/glsl_parser_extras.cpp
+++ b/mesalib/src/glsl/glsl_parser_extras.cpp
@@ -31,7 +31,7 @@ extern "C" {
#include "main/shaderobj.h"
}
-#include "ralloc.h"
+#include "util/ralloc.h"
#include "ast.h"
#include "glsl_parser_extras.h"
#include "glsl_parser.h"
@@ -1487,7 +1487,7 @@ _mesa_glsl_compile_shader(struct gl_context *ctx, struct gl_shader *shader,
if (shader->InfoLog)
ralloc_free(shader->InfoLog);
- shader->symbols = state->symbols;
+ shader->symbols = new(shader->ir) glsl_symbol_table;
shader->CompileStatus = !state->error;
shader->InfoLog = state->info_log;
shader->Version = state->language_version;
@@ -1500,6 +1500,30 @@ _mesa_glsl_compile_shader(struct gl_context *ctx, struct gl_shader *shader,
/* Retain any live IR, but trash the rest. */
reparent_ir(shader->ir, shader->ir);
+ /* Destroy the symbol table. Create a new symbol table that contains only
+ * the variables and functions that still exist in the IR. The symbol
+ * table will be used later during linking.
+ *
+ * There must NOT be any freed objects still referenced by the symbol
+ * table. That could cause the linker to dereference freed memory.
+ *
+ * We don't have to worry about types or interface-types here because those
+ * are fly-weights that are looked up by glsl_type.
+ */
+ foreach_in_list (ir_instruction, ir, shader->ir) {
+ switch (ir->ir_type) {
+ case ir_type_function:
+ shader->symbols->add_function((ir_function *) ir);
+ break;
+ case ir_type_variable:
+ shader->symbols->add_variable((ir_variable *) ir);
+ break;
+ default:
+ break;
+ }
+ }
+
+ delete state->symbols;
ralloc_free(state);
}
diff --git a/mesalib/src/glsl/glsl_types.cpp b/mesalib/src/glsl/glsl_types.cpp
index f9cd258fe..66e9b1330 100644
--- a/mesalib/src/glsl/glsl_types.cpp
+++ b/mesalib/src/glsl/glsl_types.cpp
@@ -108,7 +108,7 @@ glsl_type::glsl_type(const glsl_struct_field *fields, unsigned num_fields,
this->fields.structure[i].interpolation = fields[i].interpolation;
this->fields.structure[i].centroid = fields[i].centroid;
this->fields.structure[i].sample = fields[i].sample;
- this->fields.structure[i].row_major = fields[i].row_major;
+ this->fields.structure[i].matrix_layout = fields[i].matrix_layout;
}
}
@@ -136,7 +136,7 @@ glsl_type::glsl_type(const glsl_struct_field *fields, unsigned num_fields,
this->fields.structure[i].interpolation = fields[i].interpolation;
this->fields.structure[i].centroid = fields[i].centroid;
this->fields.structure[i].sample = fields[i].sample;
- this->fields.structure[i].row_major = fields[i].row_major;
+ this->fields.structure[i].matrix_layout = fields[i].matrix_layout;
}
}
@@ -496,8 +496,8 @@ glsl_type::record_compare(const glsl_type *b) const
if (strcmp(this->fields.structure[i].name,
b->fields.structure[i].name) != 0)
return false;
- if (this->fields.structure[i].row_major
- != b->fields.structure[i].row_major)
+ if (this->fields.structure[i].matrix_layout
+ != b->fields.structure[i].matrix_layout)
return false;
if (this->fields.structure[i].location
!= b->fields.structure[i].location)
@@ -826,9 +826,18 @@ glsl_type::std140_base_alignment(bool row_major) const
if (this->is_record()) {
unsigned base_alignment = 16;
for (unsigned i = 0; i < this->length; i++) {
+ bool field_row_major = row_major;
+ const enum glsl_matrix_layout matrix_layout =
+ glsl_matrix_layout(this->fields.structure[i].matrix_layout);
+ if (matrix_layout == GLSL_MATRIX_LAYOUT_ROW_MAJOR) {
+ field_row_major = true;
+ } else if (matrix_layout == GLSL_MATRIX_LAYOUT_COLUMN_MAJOR) {
+ field_row_major = false;
+ }
+
const struct glsl_type *field_type = this->fields.structure[i].type;
base_alignment = MAX2(base_alignment,
- field_type->std140_base_alignment(row_major));
+ field_type->std140_base_alignment(field_row_major));
}
return base_alignment;
}
@@ -872,8 +881,7 @@ glsl_type::std140_size(bool row_major) const
* and <R> rows, the matrix is stored identically to a row of <S>*<R>
* row vectors with <C> components each, according to rule (4).
*/
- if (this->is_matrix() || (this->is_array() &&
- this->fields.array->is_matrix())) {
+ if (this->without_array()->is_matrix()) {
const struct glsl_type *element_type;
const struct glsl_type *vec_type;
unsigned int array_len;
@@ -935,14 +943,29 @@ glsl_type::std140_size(bool row_major) const
*/
if (this->is_record()) {
unsigned size = 0;
+ unsigned max_align = 0;
+
for (unsigned i = 0; i < this->length; i++) {
+ bool field_row_major = row_major;
+ const enum glsl_matrix_layout matrix_layout =
+ glsl_matrix_layout(this->fields.structure[i].matrix_layout);
+ if (matrix_layout == GLSL_MATRIX_LAYOUT_ROW_MAJOR) {
+ field_row_major = true;
+ } else if (matrix_layout == GLSL_MATRIX_LAYOUT_COLUMN_MAJOR) {
+ field_row_major = false;
+ }
+
const struct glsl_type *field_type = this->fields.structure[i].type;
- unsigned align = field_type->std140_base_alignment(row_major);
+ unsigned align = field_type->std140_base_alignment(field_row_major);
size = glsl_align(size, align);
- size += field_type->std140_size(row_major);
+ size += field_type->std140_size(field_row_major);
+
+ max_align = MAX2(align, max_align);
+
+ if (field_type->is_record() && (i + 1 < this->length))
+ size = glsl_align(size, 16);
}
- size = glsl_align(size,
- this->fields.structure[0].type->std140_base_alignment(row_major));
+ size = glsl_align(size, max_align);
return size;
}
diff --git a/mesalib/src/glsl/glsl_types.h b/mesalib/src/glsl/glsl_types.h
index 0b63d4850..d545533dc 100644
--- a/mesalib/src/glsl/glsl_types.h
+++ b/mesalib/src/glsl/glsl_types.h
@@ -79,9 +79,30 @@ enum glsl_interface_packing {
GLSL_INTERFACE_PACKING_PACKED
};
+enum glsl_matrix_layout {
+ /**
+ * The layout of the matrix is inherited from the object containing the
+ * matrix (the top level structure or the uniform block).
+ */
+ GLSL_MATRIX_LAYOUT_INHERITED,
+
+ /**
+ * Explicit column-major layout
+ *
+ * If a uniform block doesn't have an explicit layout set, it will default
+ * to this layout.
+ */
+ GLSL_MATRIX_LAYOUT_COLUMN_MAJOR,
+
+ /**
+ * Row-major layout
+ */
+ GLSL_MATRIX_LAYOUT_ROW_MAJOR
+};
+
#ifdef __cplusplus
#include "GL/gl.h"
-#include "ralloc.h"
+#include "util/ralloc.h"
struct glsl_type {
GLenum gl_type;
@@ -465,6 +486,18 @@ struct glsl_type {
}
/**
+ * Get the type stripped of any arrays
+ *
+ * \return
+ * Pointer to the type of elements of the first non-array type for array
+ * types, or pointer to itself for non-array types.
+ */
+ const glsl_type *without_array() const
+ {
+ return this->is_array() ? this->fields.array : this;
+ }
+
+ /**
* Return the amount of atomic counter storage required for a type.
*/
unsigned atomic_size() const
@@ -643,7 +676,6 @@ private:
struct glsl_struct_field {
const struct glsl_type *type;
const char *name;
- bool row_major;
/**
* For interface blocks, gl_varying_slot corresponding to the input/output
@@ -673,6 +705,11 @@ struct glsl_struct_field {
unsigned sample:1;
/**
+ * Layout of the matrix. Uses glsl_matrix_layout values.
+ */
+ unsigned matrix_layout:2;
+
+ /**
* For interface blocks, it has a value if this variable uses multiple vertex
* streams (as in ir_variable::stream). -1 otherwise.
*/
diff --git a/mesalib/src/glsl/ir.h b/mesalib/src/glsl/ir.h
index ea19924ab..31c354556 100644
--- a/mesalib/src/glsl/ir.h
+++ b/mesalib/src/glsl/ir.h
@@ -29,7 +29,7 @@
#include <stdio.h>
#include <stdlib.h>
-#include "ralloc.h"
+#include "util/ralloc.h"
#include "glsl_types.h"
#include "list.h"
#include "ir_visitor.h"
@@ -660,6 +660,11 @@ public:
unsigned location_frac:2;
/**
+ * Layout of the matrix. Uses glsl_matrix_layout values.
+ */
+ unsigned matrix_layout:2;
+
+ /**
* Non-zero if this variable was created by lowering a named interface
* block which was not an array.
*
@@ -974,6 +979,7 @@ public:
*/
ir_function_signature *matching_signature(_mesa_glsl_parse_state *state,
const exec_list *actual_param,
+ bool allow_builtins,
bool *match_is_exact);
/**
@@ -981,7 +987,8 @@ public:
* conversions into account.
*/
ir_function_signature *matching_signature(_mesa_glsl_parse_state *state,
- const exec_list *actual_param);
+ const exec_list *actual_param,
+ bool allow_builtins);
/**
* Find a signature that exactly matches a set of actual parameters without
diff --git a/mesalib/src/glsl/ir_function.cpp b/mesalib/src/glsl/ir_function.cpp
index 7d6c2f451..98bec45ce 100644
--- a/mesalib/src/glsl/ir_function.cpp
+++ b/mesalib/src/glsl/ir_function.cpp
@@ -281,15 +281,18 @@ choose_best_inexact_overload(_mesa_glsl_parse_state *state,
ir_function_signature *
ir_function::matching_signature(_mesa_glsl_parse_state *state,
- const exec_list *actual_parameters)
+ const exec_list *actual_parameters,
+ bool allow_builtins)
{
bool is_exact;
- return matching_signature(state, actual_parameters, &is_exact);
+ return matching_signature(state, actual_parameters, allow_builtins,
+ &is_exact);
}
ir_function_signature *
ir_function::matching_signature(_mesa_glsl_parse_state *state,
const exec_list *actual_parameters,
+ bool allow_builtins,
bool *is_exact)
{
ir_function_signature **inexact_matches = NULL;
@@ -308,7 +311,8 @@ ir_function::matching_signature(_mesa_glsl_parse_state *state,
*/
foreach_in_list(ir_function_signature, sig, &this->signatures) {
/* Skip over any built-ins that aren't available in this shader. */
- if (sig->is_builtin() && !sig->is_builtin_available(state))
+ if (sig->is_builtin() && (!allow_builtins ||
+ !sig->is_builtin_available(state)))
continue;
switch (parameter_lists_match(state, & sig->parameters, actual_parameters)) {
diff --git a/mesalib/src/glsl/ir_reader.cpp b/mesalib/src/glsl/ir_reader.cpp
index e3566e1d6..ae00e7934 100644
--- a/mesalib/src/glsl/ir_reader.cpp
+++ b/mesalib/src/glsl/ir_reader.cpp
@@ -677,7 +677,8 @@ ir_reader::read_call(s_expression *expr)
return NULL;
}
- ir_function_signature *callee = f->matching_signature(state, &parameters);
+ ir_function_signature *callee =
+ f->matching_signature(state, &parameters, true);
if (callee == NULL) {
ir_read_error(expr, "couldn't find matching signature for function "
"%s", name->value());
diff --git a/mesalib/src/glsl/ir_variable_refcount.cpp b/mesalib/src/glsl/ir_variable_refcount.cpp
index 923eb1a82..f67fe6784 100644
--- a/mesalib/src/glsl/ir_variable_refcount.cpp
+++ b/mesalib/src/glsl/ir_variable_refcount.cpp
@@ -33,7 +33,7 @@
#include "ir_visitor.h"
#include "ir_variable_refcount.h"
#include "glsl_types.h"
-#include "main/hash_table.h"
+#include "util/hash_table.h"
ir_variable_refcount_visitor::ir_variable_refcount_visitor()
{
diff --git a/mesalib/src/glsl/link_functions.cpp b/mesalib/src/glsl/link_functions.cpp
index 2ce9609b5..f86aec689 100644
--- a/mesalib/src/glsl/link_functions.cpp
+++ b/mesalib/src/glsl/link_functions.cpp
@@ -307,7 +307,7 @@ find_matching_signature(const char *name, const exec_list *actual_parameters,
continue;
ir_function_signature *sig =
- f->matching_signature(NULL, actual_parameters);
+ f->matching_signature(NULL, actual_parameters, use_builtin);
if ((sig == NULL) ||
(!sig->is_defined && !sig->is_intrinsic))
diff --git a/mesalib/src/glsl/link_uniform_block_active_visitor.cpp b/mesalib/src/glsl/link_uniform_block_active_visitor.cpp
index 854309f9b..9da6a4bba 100644
--- a/mesalib/src/glsl/link_uniform_block_active_visitor.cpp
+++ b/mesalib/src/glsl/link_uniform_block_active_visitor.cpp
@@ -73,6 +73,45 @@ process_block(void *mem_ctx, struct hash_table *ht, ir_variable *var)
}
ir_visitor_status
+link_uniform_block_active_visitor::visit(ir_variable *var)
+{
+ if (!var->is_in_uniform_block())
+ return visit_continue;
+
+ const glsl_type *const block_type = var->is_interface_instance()
+ ? var->type : var->get_interface_type();
+
+ /* Section 2.11.6 (Uniform Variables) of the OpenGL ES 3.0.3 spec says:
+ *
+ * "All members of a named uniform block declared with a shared or
+ * std140 layout qualifier are considered active, even if they are not
+ * referenced in any shader in the program. The uniform block itself is
+ * also considered active, even if no member of the block is
+ * referenced."
+ */
+ if (block_type->interface_packing == GLSL_INTERFACE_PACKING_PACKED)
+ return visit_continue;
+
+ /* Process the block. Bail if there was an error.
+ */
+ link_uniform_block_active *const b =
+ process_block(this->mem_ctx, this->ht, var);
+ if (b == NULL) {
+ linker_error(this->prog,
+ "uniform block `%s' has mismatching definitions",
+ var->get_interface_type()->name);
+ this->success = false;
+ return visit_stop;
+ }
+
+ assert(b->num_array_elements == 0);
+ assert(b->array_elements == NULL);
+ assert(b->type != NULL);
+
+ return visit_continue;
+}
+
+ir_visitor_status
link_uniform_block_active_visitor::visit_enter(ir_dereference_array *ir)
{
ir_dereference_variable *const d = ir->array->as_dereference_variable();
diff --git a/mesalib/src/glsl/link_uniform_block_active_visitor.h b/mesalib/src/glsl/link_uniform_block_active_visitor.h
index 524cd6b91..e5ea50155 100644
--- a/mesalib/src/glsl/link_uniform_block_active_visitor.h
+++ b/mesalib/src/glsl/link_uniform_block_active_visitor.h
@@ -26,7 +26,7 @@
#define LINK_UNIFORM_BLOCK_ACTIVE_VISITOR_H
#include "ir.h"
-#include "main/hash_table.h"
+#include "util/hash_table.h"
struct link_uniform_block_active {
const glsl_type *type;
@@ -51,6 +51,7 @@ public:
virtual ir_visitor_status visit_enter(ir_dereference_array *);
virtual ir_visitor_status visit(ir_dereference_variable *);
+ virtual ir_visitor_status visit(ir_variable *);
bool success;
diff --git a/mesalib/src/glsl/link_uniform_blocks.cpp b/mesalib/src/glsl/link_uniform_blocks.cpp
index fef3626bf..536fcd458 100644
--- a/mesalib/src/glsl/link_uniform_blocks.cpp
+++ b/mesalib/src/glsl/link_uniform_blocks.cpp
@@ -26,7 +26,7 @@
#include "linker.h"
#include "ir_uniform.h"
#include "link_uniform_block_active_visitor.h"
-#include "main/hash_table.h"
+#include "util/hash_table.h"
#include "program.h"
namespace {
@@ -68,7 +68,8 @@ private:
}
virtual void visit_field(const glsl_type *type, const char *name,
- bool row_major, const glsl_type *record_type)
+ bool row_major, const glsl_type *record_type,
+ bool last_field)
{
assert(this->index < this->num_variables);
@@ -76,7 +77,7 @@ private:
v->Name = ralloc_strdup(mem_ctx, name);
v->Type = type;
- v->RowMajor = row_major;
+ v->RowMajor = type->without_array()->is_matrix() && row_major;
if (this->is_array_instance) {
v->IndexName = ralloc_strdup(mem_ctx, name);
@@ -103,7 +104,20 @@ private:
this->offset = glsl_align(this->offset, alignment);
v->Offset = this->offset;
+
+ /* If this is the last field of a structure, apply rule #9. The
+ * GL_ARB_uniform_buffer_object spec says:
+ *
+ * "The structure may have padding at the end; the base offset of
+ * the member following the sub-structure is rounded up to the next
+ * multiple of the base alignment of the structure."
+ *
+ * last_field won't be set if this is the last field of a UBO that is
+ * not a named instance.
+ */
this->offset += size;
+ if (last_field)
+ this->offset = glsl_align(this->offset, 16);
/* From the GL_ARB_uniform_buffer_object spec:
*
diff --git a/mesalib/src/glsl/link_uniforms.cpp b/mesalib/src/glsl/link_uniforms.cpp
index 0e6eb50ef..a127ee7f5 100644
--- a/mesalib/src/glsl/link_uniforms.cpp
+++ b/mesalib/src/glsl/link_uniforms.cpp
@@ -59,13 +59,11 @@ values_for_type(const glsl_type *type)
void
program_resource_visitor::process(const glsl_type *type, const char *name)
{
- assert(type->is_record()
- || (type->is_array() && type->fields.array->is_record())
- || type->is_interface()
- || (type->is_array() && type->fields.array->is_interface()));
+ assert(type->without_array()->is_record()
+ || type->without_array()->is_interface());
char *name_copy = ralloc_strdup(NULL, name);
- recursion(type, &name_copy, strlen(name), false, NULL);
+ recursion(type, &name_copy, strlen(name), false, NULL, false);
ralloc_free(name_copy);
}
@@ -73,6 +71,8 @@ void
program_resource_visitor::process(ir_variable *var)
{
const glsl_type *t = var->type;
+ const bool row_major =
+ var->data.matrix_layout == GLSL_MATRIX_LAYOUT_ROW_MAJOR;
/* false is always passed for the row_major parameter to the other
* processing functions because no information is available to do
@@ -110,7 +110,7 @@ program_resource_visitor::process(ir_variable *var)
* lowering is only applied to non-uniform interface blocks, so we
* can safely pass false for row_major.
*/
- recursion(var->type, &name, new_length, false, NULL);
+ recursion(var->type, &name, new_length, row_major, NULL, false);
}
ralloc_free(name);
} else if (var->data.from_named_ifc_block_nonarray) {
@@ -134,29 +134,30 @@ program_resource_visitor::process(ir_variable *var)
* is only applied to non-uniform interface blocks, so we can safely
* pass false for row_major.
*/
- recursion(var->type, &name, strlen(name), false, NULL);
+ recursion(var->type, &name, strlen(name), row_major, NULL, false);
ralloc_free(name);
- } else if (t->is_record() || (t->is_array() && t->fields.array->is_record())) {
+ } else if (t->without_array()->is_record()) {
char *name = ralloc_strdup(NULL, var->name);
- recursion(var->type, &name, strlen(name), false, NULL);
+ recursion(var->type, &name, strlen(name), row_major, NULL, false);
ralloc_free(name);
} else if (t->is_interface()) {
char *name = ralloc_strdup(NULL, var->type->name);
- recursion(var->type, &name, strlen(name), false, NULL);
+ recursion(var->type, &name, strlen(name), row_major, NULL, false);
ralloc_free(name);
} else if (t->is_array() && t->fields.array->is_interface()) {
char *name = ralloc_strdup(NULL, var->type->fields.array->name);
- recursion(var->type, &name, strlen(name), false, NULL);
+ recursion(var->type, &name, strlen(name), row_major, NULL, false);
ralloc_free(name);
} else {
- this->visit_field(t, var->name, false, NULL);
+ this->visit_field(t, var->name, row_major, NULL, false);
}
}
void
program_resource_visitor::recursion(const glsl_type *t, char **name,
size_t name_length, bool row_major,
- const glsl_type *record_type)
+ const glsl_type *record_type,
+ bool last_field)
{
/* Records need to have each field processed individually.
*
@@ -182,8 +183,25 @@ program_resource_visitor::recursion(const glsl_type *t, char **name,
ralloc_asprintf_rewrite_tail(name, &new_length, ".%s", field);
}
+ /* The layout of structures at the top level of the block is set
+ * during parsing. For matrices contained in multiple levels of
+ * structures in the block, the inner structures have no layout.
+ * These cases must potentially inherit the layout from the outer
+ * levels.
+ */
+ bool field_row_major = row_major;
+ const enum glsl_matrix_layout matrix_layout =
+ glsl_matrix_layout(t->fields.structure[i].matrix_layout);
+ if (matrix_layout == GLSL_MATRIX_LAYOUT_ROW_MAJOR) {
+ field_row_major = true;
+ } else if (matrix_layout == GLSL_MATRIX_LAYOUT_COLUMN_MAJOR) {
+ field_row_major = false;
+ }
+
recursion(t->fields.structure[i].type, name, new_length,
- t->fields.structure[i].row_major, record_type);
+ field_row_major,
+ record_type,
+ (i + 1) == t->length);
/* Only the first leaf-field of the record gets called with the
* record type pointer.
@@ -202,7 +220,8 @@ program_resource_visitor::recursion(const glsl_type *t, char **name,
ralloc_asprintf_rewrite_tail(name, &new_length, "[%u]", i);
recursion(t->fields.array, name, new_length, row_major,
- record_type);
+ record_type,
+ (i + 1) == t->length);
/* Only the first leaf-field of the record gets called with the
* record type pointer.
@@ -210,14 +229,15 @@ program_resource_visitor::recursion(const glsl_type *t, char **name,
record_type = NULL;
}
} else {
- this->visit_field(t, *name, row_major, record_type);
+ this->visit_field(t, *name, row_major, record_type, last_field);
}
}
void
program_resource_visitor::visit_field(const glsl_type *type, const char *name,
bool row_major,
- const glsl_type *)
+ const glsl_type *,
+ bool /* last_field */)
{
visit_field(type, name, row_major);
}
@@ -299,10 +319,8 @@ private:
virtual void visit_field(const glsl_type *type, const char *name,
bool row_major)
{
- assert(!type->is_record());
- assert(!(type->is_array() && type->fields.array->is_record()));
- assert(!type->is_interface());
- assert(!(type->is_array() && type->fields.array->is_interface()));
+ assert(!type->without_array()->is_record());
+ assert(!type->without_array()->is_interface());
(void) row_major;
@@ -427,7 +445,6 @@ public:
*/
if (var->is_interface_instance()) {
ubo_byte_offset = 0;
- ubo_row_major = false;
} else {
const struct gl_uniform_block *const block =
&prog->UniformBlocks[ubo_block_index];
@@ -437,7 +454,6 @@ public:
const struct gl_uniform_buffer_variable *const ubo_var =
&block->Uniforms[var->data.location];
- ubo_row_major = ubo_var->RowMajor;
ubo_byte_offset = ubo_var->Offset;
}
@@ -452,7 +468,6 @@ public:
int ubo_block_index;
int ubo_byte_offset;
- bool ubo_row_major;
gl_shader_stage shader_type;
private:
@@ -512,14 +527,11 @@ private:
}
virtual void visit_field(const glsl_type *type, const char *name,
- bool row_major, const glsl_type *record_type)
+ bool row_major, const glsl_type *record_type,
+ bool last_field)
{
- assert(!type->is_record());
- assert(!(type->is_array() && type->fields.array->is_record()));
- assert(!type->is_interface());
- assert(!(type->is_array() && type->fields.array->is_interface()));
-
- (void) row_major;
+ assert(!type->without_array()->is_record());
+ assert(!type->without_array()->is_interface());
unsigned id;
bool found = this->map->get(id, name);
@@ -577,23 +589,25 @@ private:
this->uniforms[id].block_index = this->ubo_block_index;
const unsigned alignment = record_type
- ? record_type->std140_base_alignment(ubo_row_major)
- : type->std140_base_alignment(ubo_row_major);
+ ? record_type->std140_base_alignment(row_major)
+ : type->std140_base_alignment(row_major);
this->ubo_byte_offset = glsl_align(this->ubo_byte_offset, alignment);
this->uniforms[id].offset = this->ubo_byte_offset;
- this->ubo_byte_offset += type->std140_size(ubo_row_major);
+ this->ubo_byte_offset += type->std140_size(row_major);
+
+ if (last_field)
+ this->ubo_byte_offset = glsl_align(this->ubo_byte_offset, 16);
if (type->is_array()) {
this->uniforms[id].array_stride =
- glsl_align(type->fields.array->std140_size(ubo_row_major), 16);
+ glsl_align(type->fields.array->std140_size(row_major), 16);
} else {
this->uniforms[id].array_stride = 0;
}
- if (type->is_matrix() ||
- (type->is_array() && type->fields.array->is_matrix())) {
+ if (type->without_array()->is_matrix()) {
this->uniforms[id].matrix_stride = 16;
- this->uniforms[id].row_major = ubo_row_major;
+ this->uniforms[id].row_major = row_major;
} else {
this->uniforms[id].matrix_stride = 0;
this->uniforms[id].row_major = false;
diff --git a/mesalib/src/glsl/link_varyings.cpp b/mesalib/src/glsl/link_varyings.cpp
index a3fc2ae34..1438a4b16 100644
--- a/mesalib/src/glsl/link_varyings.cpp
+++ b/mesalib/src/glsl/link_varyings.cpp
@@ -1068,10 +1068,8 @@ private:
virtual void visit_field(const glsl_type *type, const char *name,
bool row_major)
{
- assert(!type->is_record());
- assert(!(type->is_array() && type->fields.array->is_record()));
- assert(!type->is_interface());
- assert(!(type->is_array() && type->fields.array->is_interface()));
+ assert(!type->without_array()->is_record());
+ assert(!type->without_array()->is_interface());
(void) row_major;
diff --git a/mesalib/src/glsl/linker.cpp b/mesalib/src/glsl/linker.cpp
index d588bc63e..0096fb023 100644
--- a/mesalib/src/glsl/linker.cpp
+++ b/mesalib/src/glsl/linker.cpp
@@ -1129,7 +1129,8 @@ get_main_function_signature(gl_shader *sh)
* We don't have to check for multiple definitions of main (in multiple
* shaders) because that would have already been caught above.
*/
- ir_function_signature *sig = f->matching_signature(NULL, &void_parameters);
+ ir_function_signature *sig =
+ f->matching_signature(NULL, &void_parameters, false);
if ((sig != NULL) && sig->is_defined) {
return sig;
}
diff --git a/mesalib/src/glsl/linker.h b/mesalib/src/glsl/linker.h
index 130915db4..8851da6c8 100644
--- a/mesalib/src/glsl/linker.h
+++ b/mesalib/src/glsl/linker.h
@@ -138,11 +138,15 @@ protected:
* \param name Fully qualified name of the field.
* \param row_major For a matrix type, is it stored row-major.
* \param record_type Type of the record containing the field.
+ * \param last_field Set if \c name is the last field of the structure
+ * containing it. This will always be false for items
+ * not contained in a structure or interface block.
*
* The default implementation just calls the other \c visit_field method.
*/
virtual void visit_field(const glsl_type *type, const char *name,
- bool row_major, const glsl_type *record_type);
+ bool row_major, const glsl_type *record_type,
+ bool last_field);
/**
* Method invoked for each leaf of the variable
@@ -168,9 +172,13 @@ private:
/**
* \param name_length Length of the current name \b not including the
* terminating \c NUL character.
+ * \param last_field Set if \c name is the last field of the structure
+ * containing it. This will always be false for items
+ * not contained in a structure or interface block.
*/
void recursion(const glsl_type *t, char **name, size_t name_length,
- bool row_major, const glsl_type *record_type);
+ bool row_major, const glsl_type *record_type,
+ bool last_field);
};
void
diff --git a/mesalib/src/glsl/list.h b/mesalib/src/glsl/list.h
index 500a85717..b40764cae 100644
--- a/mesalib/src/glsl/list.h
+++ b/mesalib/src/glsl/list.h
@@ -69,7 +69,7 @@
#endif
#include <assert.h>
-#include "ralloc.h"
+#include "util/ralloc.h"
struct exec_node {
struct exec_node *next;
diff --git a/mesalib/src/glsl/loop_controls.cpp b/mesalib/src/glsl/loop_controls.cpp
index 36b49eb46..1c1d34fef 100644
--- a/mesalib/src/glsl/loop_controls.cpp
+++ b/mesalib/src/glsl/loop_controls.cpp
@@ -123,9 +123,20 @@ calculate_iterations(ir_rvalue *from, ir_rvalue *to, ir_rvalue *increment,
bool valid_loop = false;
for (unsigned i = 0; i < Elements(bias); i++) {
- iter = (increment->type->is_integer())
- ? new(mem_ctx) ir_constant(iter_value + bias[i])
- : new(mem_ctx) ir_constant(float(iter_value + bias[i]));
+ /* Increment may be of type int, uint or float. */
+ switch (increment->type->base_type) {
+ case GLSL_TYPE_INT:
+ iter = new(mem_ctx) ir_constant(iter_value + bias[i]);
+ break;
+ case GLSL_TYPE_UINT:
+ iter = new(mem_ctx) ir_constant(unsigned(iter_value + bias[i]));
+ break;
+ case GLSL_TYPE_FLOAT:
+ iter = new(mem_ctx) ir_constant(float(iter_value + bias[i]));
+ break;
+ default:
+ unreachable(!"Unsupported type for loop iterator.");
+ }
ir_expression *const mul =
new(mem_ctx) ir_expression(ir_binop_mul, increment->type, iter,
diff --git a/mesalib/src/glsl/lower_packed_varyings.cpp b/mesalib/src/glsl/lower_packed_varyings.cpp
index c72b80a32..780148315 100644
--- a/mesalib/src/glsl/lower_packed_varyings.cpp
+++ b/mesalib/src/glsl/lower_packed_varyings.cpp
@@ -655,7 +655,7 @@ lower_packed_varyings(void *mem_ctx, unsigned locations_used,
ir_function *main_func = shader->symbols->get_function("main");
exec_list void_parameters;
ir_function_signature *main_func_sig
- = main_func->matching_signature(NULL, &void_parameters);
+ = main_func->matching_signature(NULL, &void_parameters, false);
exec_list new_instructions;
lower_packed_varyings_visitor visitor(mem_ctx, locations_used, mode,
gs_input_vertices, &new_instructions);
diff --git a/mesalib/src/glsl/lower_ubo_reference.cpp b/mesalib/src/glsl/lower_ubo_reference.cpp
index 67b752d3d..3cdfc04ac 100644
--- a/mesalib/src/glsl/lower_ubo_reference.cpp
+++ b/mesalib/src/glsl/lower_ubo_reference.cpp
@@ -40,6 +40,96 @@
using namespace ir_builder;
+/**
+ * Determine if a thing being dereferenced is row-major
+ *
+ * There is some trickery here.
+ *
+ * If the thing being dereferenced is a member of uniform block \b without an
+ * instance name, then the name of the \c ir_variable is the field name of an
+ * interface type. If this field is row-major, then the thing referenced is
+ * row-major.
+ *
+ * If the thing being dereferenced is a member of uniform block \b with an
+ * instance name, then the last dereference in the tree will be an
+ * \c ir_dereference_record. If that record field is row-major, then the
+ * thing referenced is row-major.
+ */
+static bool
+is_dereferenced_thing_row_major(const ir_dereference *deref)
+{
+ bool matrix = false;
+ const ir_rvalue *ir = deref;
+
+ while (true) {
+ matrix = matrix || ir->type->without_array()->is_matrix();
+
+ switch (ir->ir_type) {
+ case ir_type_dereference_array: {
+ const ir_dereference_array *const array_deref =
+ (const ir_dereference_array *) ir;
+
+ ir = array_deref->array;
+ break;
+ }
+
+ case ir_type_dereference_record: {
+ const ir_dereference_record *const record_deref =
+ (const ir_dereference_record *) ir;
+
+ ir = record_deref->record;
+
+ const int idx = ir->type->field_index(record_deref->field);
+ assert(idx >= 0);
+
+ const enum glsl_matrix_layout matrix_layout =
+ glsl_matrix_layout(ir->type->fields.structure[idx].matrix_layout);
+
+ switch (matrix_layout) {
+ case GLSL_MATRIX_LAYOUT_INHERITED:
+ break;
+ case GLSL_MATRIX_LAYOUT_COLUMN_MAJOR:
+ return false;
+ case GLSL_MATRIX_LAYOUT_ROW_MAJOR:
+ return matrix || deref->type->without_array()->is_record();
+ }
+
+ break;
+ }
+
+ case ir_type_dereference_variable: {
+ const ir_dereference_variable *const var_deref =
+ (const ir_dereference_variable *) ir;
+
+ const enum glsl_matrix_layout matrix_layout =
+ glsl_matrix_layout(var_deref->var->data.matrix_layout);
+
+ switch (matrix_layout) {
+ case GLSL_MATRIX_LAYOUT_INHERITED:
+ assert(!matrix);
+ return false;
+ case GLSL_MATRIX_LAYOUT_COLUMN_MAJOR:
+ return false;
+ case GLSL_MATRIX_LAYOUT_ROW_MAJOR:
+ return matrix || deref->type->is_record();
+ }
+
+ unreachable("invalid matrix layout");
+ break;
+ }
+
+ default:
+ return false;
+ }
+ }
+
+ /* The tree must have ended with a dereference that wasn't an
+ * ir_dereference_variable. That is invalid, and it should be impossible.
+ */
+ unreachable("invalid dereference tree");
+ return false;
+}
+
namespace {
class lower_ubo_reference_visitor : public ir_rvalue_enter_visitor {
public:
@@ -50,7 +140,7 @@ public:
void handle_rvalue(ir_rvalue **rvalue);
void emit_ubo_loads(ir_dereference *deref, ir_variable *base_offset,
- unsigned int deref_offset);
+ unsigned int deref_offset, bool row_major);
ir_expression *ubo_load(const struct glsl_type *type,
ir_rvalue *offset);
@@ -174,7 +264,7 @@ lower_ubo_reference_visitor::handle_rvalue(ir_rvalue **rvalue)
ir_rvalue *offset = new(mem_ctx) ir_constant(0u);
unsigned const_offset = 0;
- bool row_major = ubo_var->RowMajor;
+ bool row_major = is_dereferenced_thing_row_major(deref);
/* Calculate the offset to the start of the region of the UBO
* dereferenced by *rvalue. This may be a variable offset if an
@@ -219,7 +309,8 @@ lower_ubo_reference_visitor::handle_rvalue(ir_rvalue **rvalue)
if (array_index->type->base_type == GLSL_TYPE_INT)
array_index = i2u(array_index);
- ir_constant *const_index = array_index->as_constant();
+ ir_constant *const_index =
+ array_index->constant_expression_value(NULL);
if (const_index) {
const_offset += array_stride * const_index->value.u[0];
} else {
@@ -236,20 +327,27 @@ lower_ubo_reference_visitor::handle_rvalue(ir_rvalue **rvalue)
const glsl_type *struct_type = deref_record->record->type;
unsigned intra_struct_offset = 0;
- unsigned max_field_align = 16;
for (unsigned int i = 0; i < struct_type->length; i++) {
const glsl_type *type = struct_type->fields.structure[i].type;
- unsigned field_align = type->std140_base_alignment(row_major);
- max_field_align = MAX2(field_align, max_field_align);
+
+ ir_dereference_record *field_deref =
+ new(mem_ctx) ir_dereference_record(deref_record->record,
+ struct_type->fields.structure[i].name);
+ const bool field_row_major =
+ is_dereferenced_thing_row_major(field_deref);
+
+ ralloc_free(field_deref);
+
+ unsigned field_align = type->std140_base_alignment(field_row_major);
+
intra_struct_offset = glsl_align(intra_struct_offset, field_align);
if (strcmp(struct_type->fields.structure[i].name,
deref_record->field) == 0)
break;
- intra_struct_offset += type->std140_size(row_major);
+ intra_struct_offset += type->std140_size(field_row_major);
}
- const_offset = glsl_align(const_offset, max_field_align);
const_offset += intra_struct_offset;
deref = deref_record->record->as_dereference();
@@ -278,7 +376,7 @@ lower_ubo_reference_visitor::handle_rvalue(ir_rvalue **rvalue)
base_ir->insert_before(assign(load_offset, offset));
deref = new(mem_ctx) ir_dereference_variable(load_var);
- emit_ubo_loads(deref, load_offset, const_offset);
+ emit_ubo_loads(deref, load_offset, const_offset, row_major);
*rvalue = deref;
progress = true;
@@ -308,7 +406,8 @@ lower_ubo_reference_visitor::ubo_load(const glsl_type *type,
void
lower_ubo_reference_visitor::emit_ubo_loads(ir_dereference *deref,
ir_variable *base_offset,
- unsigned int deref_offset)
+ unsigned int deref_offset,
+ bool row_major)
{
if (deref->type->is_record()) {
unsigned int field_offset = 0;
@@ -322,18 +421,19 @@ lower_ubo_reference_visitor::emit_ubo_loads(ir_dereference *deref,
field_offset =
glsl_align(field_offset,
- field->type->std140_base_alignment(ubo_var->RowMajor));
+ field->type->std140_base_alignment(row_major));
- emit_ubo_loads(field_deref, base_offset, deref_offset + field_offset);
+ emit_ubo_loads(field_deref, base_offset, deref_offset + field_offset,
+ row_major);
- field_offset += field->type->std140_size(ubo_var->RowMajor);
+ field_offset += field->type->std140_size(row_major);
}
return;
}
if (deref->type->is_array()) {
unsigned array_stride =
- glsl_align(deref->type->fields.array->std140_size(ubo_var->RowMajor),
+ glsl_align(deref->type->fields.array->std140_size(row_major),
16);
for (unsigned i = 0; i < deref->type->length; i++) {
@@ -342,7 +442,8 @@ lower_ubo_reference_visitor::emit_ubo_loads(ir_dereference *deref,
new(mem_ctx) ir_dereference_array(deref->clone(mem_ctx, NULL),
element);
emit_ubo_loads(element_deref, base_offset,
- deref_offset + i * array_stride);
+ deref_offset + i * array_stride,
+ row_major);
}
return;
}
@@ -354,10 +455,19 @@ lower_ubo_reference_visitor::emit_ubo_loads(ir_dereference *deref,
new(mem_ctx) ir_dereference_array(deref->clone(mem_ctx, NULL),
col);
- /* std140 always rounds the stride of arrays (and matrices)
- * to a vec4, so matrices are always 16 between columns/rows.
- */
- emit_ubo_loads(col_deref, base_offset, deref_offset + i * 16);
+ if (row_major) {
+ /* For a row-major matrix, the next column starts at the next
+ * element.
+ */
+ emit_ubo_loads(col_deref, base_offset, deref_offset + i * 4,
+ row_major);
+ } else {
+ /* std140 always rounds the stride of arrays (and matrices) to a
+ * vec4, so matrices are always 16 between columns/rows.
+ */
+ emit_ubo_loads(col_deref, base_offset, deref_offset + i * 16,
+ row_major);
+ }
}
return;
}
@@ -365,7 +475,7 @@ lower_ubo_reference_visitor::emit_ubo_loads(ir_dereference *deref,
assert(deref->type->is_scalar() ||
deref->type->is_vector());
- if (!ubo_var->RowMajor) {
+ if (!row_major) {
ir_rvalue *offset = add(base_offset,
new(mem_ctx) ir_constant(deref_offset));
base_ir->insert_before(assign(deref->clone(mem_ctx, NULL),
diff --git a/mesalib/src/glsl/opt_dead_code.cpp b/mesalib/src/glsl/opt_dead_code.cpp
index da90bfb40..f45bf5dfd 100644
--- a/mesalib/src/glsl/opt_dead_code.cpp
+++ b/mesalib/src/glsl/opt_dead_code.cpp
@@ -31,7 +31,7 @@
#include "ir_visitor.h"
#include "ir_variable_refcount.h"
#include "glsl_types.h"
-#include "main/hash_table.h"
+#include "util/hash_table.h"
static bool debug = false;
@@ -99,10 +99,31 @@ do_dead_code(exec_list *instructions, bool uniform_locations_assigned)
* stage. Also, once uniform locations have been assigned, the
* declaration cannot be deleted.
*/
- if (entry->var->data.mode == ir_var_uniform &&
- (uniform_locations_assigned ||
- entry->var->constant_value))
- continue;
+ if (entry->var->data.mode == ir_var_uniform) {
+ if (uniform_locations_assigned || entry->var->constant_value)
+ continue;
+
+ /* Section 2.11.6 (Uniform Variables) of the OpenGL ES 3.0.3 spec
+ * says:
+ *
+ * "All members of a named uniform block declared with a
+ * shared or std140 layout qualifier are considered active,
+ * even if they are not referenced in any shader in the
+ * program. The uniform block itself is also considered
+ * active, even if no member of the block is referenced."
+ *
+ * If the variable is in a uniform block with one of those
+ * layouts, do not eliminate it.
+ */
+ if (entry->var->is_in_uniform_block()) {
+ const glsl_type *const block_type =
+ entry->var->is_interface_instance()
+ ? entry->var->type : entry->var->get_interface_type();
+
+ if (block_type->interface_packing != GLSL_INTERFACE_PACKING_PACKED)
+ continue;
+ }
+ }
entry->var->remove();
progress = true;
diff --git a/mesalib/src/glsl/standalone_scaffolding.cpp b/mesalib/src/glsl/standalone_scaffolding.cpp
index 809732c7e..abdd83a44 100644
--- a/mesalib/src/glsl/standalone_scaffolding.cpp
+++ b/mesalib/src/glsl/standalone_scaffolding.cpp
@@ -31,7 +31,7 @@
#include <assert.h>
#include <string.h>
-#include "ralloc.h"
+#include "util/ralloc.h"
void
_mesa_warning(struct gl_context *ctx, const char *fmt, ...)
diff --git a/mesalib/src/loader/Makefile.am b/mesalib/src/loader/Makefile.am
index c02de6f59..16b9f8f70 100755
--- a/mesalib/src/loader/Makefile.am
+++ b/mesalib/src/loader/Makefile.am
@@ -26,6 +26,7 @@ noinst_LTLIBRARIES = libloader.la
libloader_la_CPPFLAGS = \
$(DEFINES) \
-I$(top_srcdir)/include \
+ -I$(top_srcdir)/src \
$(VISIBILITY_CFLAGS) \
$(LIBUDEV_CFLAGS)
diff --git a/mesalib/src/mapi/glapi/gen/ARB_copy_image.xml b/mesalib/src/mapi/glapi/gen/ARB_copy_image.xml
new file mode 100644
index 000000000..2fbd84557
--- /dev/null
+++ b/mesalib/src/mapi/glapi/gen/ARB_copy_image.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0"?>
+<!DOCTYPE OpenGLAPI SYSTEM "gl_API.dtd">
+
+<OpenGLAPI>
+
+<category name="GL_ARB_copy_image" number="123">
+
+ <function name="CopyImageSubData" offset="assign">
+ <param name="srcName" type="GLuint"/>
+ <param name="srcTarget" type="GLenum"/>
+ <param name="srcLevel" type="GLint"/>
+ <param name="srcX" type="GLint"/>
+ <param name="srcY" type="GLint"/>
+ <param name="srcZ" type="GLint"/>
+ <param name="dstName" type="GLuint"/>
+ <param name="dstTarget" type="GLenum"/>
+ <param name="dstLevel" type="GLint"/>
+ <param name="dstX" type="GLint"/>
+ <param name="dstY" type="GLint"/>
+ <param name="dstZ" type="GLint"/>
+ <param name="srcWidth" type="GLsizei"/>
+ <param name="srcHeight" type="GLsizei"/>
+ <param name="srcDepth" type="GLsizei"/>
+ </function>
+
+</category>
+
+</OpenGLAPI>
diff --git a/mesalib/src/mapi/glapi/gen/GL4x.xml b/mesalib/src/mapi/glapi/gen/GL4x.xml
index 8efef0b91..848316e9e 100644
--- a/mesalib/src/mapi/glapi/gen/GL4x.xml
+++ b/mesalib/src/mapi/glapi/gen/GL4x.xml
@@ -12,6 +12,32 @@
<function name="MinSampleShading" offset="assign">
<param name="value" type="GLfloat"/>
</function>
+
+ <function name="BlendFunci" static_dispatch="false" alias="BlendFunciARB">
+ <param name="buf" type="GLuint"/>
+ <param name="sfactor" type="GLenum"/>
+ <param name="dfactor" type="GLenum"/>
+ </function>
+
+ <function name="BlendFuncSeparatei" static_dispatch="false" alias="BlendFuncSeparateiARB">
+ <param name="buf" type="GLuint"/>
+ <param name="sfactorRGB" type="GLenum"/>
+ <param name="dfactorRGB" type="GLenum"/>
+ <param name="sfactorAlpha" type="GLenum"/>
+ <param name="dfactorAlpha" type="GLenum"/>
+ </function>
+
+ <function name="BlendEquationi" static_dispatch="false" alias="BlendEquationiARB">
+ <param name="buf" type="GLuint"/>
+ <param name="mode" type="GLenum"/>
+ </function>
+
+ <function name="BlendEquationSeparatei" static_dispatch="false" alias="BlendEquationSeparateiARB" >
+ <param name="buf" type="GLuint"/>
+ <param name="modeRGB" type="GLenum"/>
+ <param name="modeA" type="GLenum"/>
+ </function>
+
</category>
<category name="4.3">
diff --git a/mesalib/src/mapi/glapi/gen/Makefile.am b/mesalib/src/mapi/glapi/gen/Makefile.am
index 212731fa4..645def4ef 100644
--- a/mesalib/src/mapi/glapi/gen/Makefile.am
+++ b/mesalib/src/mapi/glapi/gen/Makefile.am
@@ -117,6 +117,7 @@ API_XML = \
ARB_compressed_texture_pixel_storage.xml \
ARB_compute_shader.xml \
ARB_copy_buffer.xml \
+ ARB_copy_image.xml \
ARB_debug_output.xml \
ARB_depth_buffer_float.xml \
ARB_depth_clamp.xml \
diff --git a/mesalib/src/mapi/glapi/gen/gl_API.xml b/mesalib/src/mapi/glapi/gen/gl_API.xml
index c38086fd9..4dd0707f6 100755
--- a/mesalib/src/mapi/glapi/gen/gl_API.xml
+++ b/mesalib/src/mapi/glapi/gen/gl_API.xml
@@ -8302,7 +8302,7 @@
<xi:include href="ARB_compute_shader.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
-<!-- ARB extension #123 -->
+<xi:include href="ARB_copy_image.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
<xi:include href="ARB_texture_view.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
diff --git a/mesalib/src/mapi/glapi/gen/gl_genexec.py b/mesalib/src/mapi/glapi/gen/gl_genexec.py
index 460919397..d479e66da 100644
--- a/mesalib/src/mapi/glapi/gen/gl_genexec.py
+++ b/mesalib/src/mapi/glapi/gen/gl_genexec.py
@@ -62,6 +62,7 @@ header = """/**
#include "main/condrender.h"
#include "main/context.h"
#include "main/convolve.h"
+#include "main/copyimage.h"
#include "main/depth.h"
#include "main/dlist.h"
#include "main/drawpix.h"
diff --git a/mesalib/src/mapi/glapi/gen/gl_gentable.py b/mesalib/src/mapi/glapi/gen/gl_gentable.py
index cac7bf9e6..f71e06fe4 100755
--- a/mesalib/src/mapi/glapi/gen/gl_gentable.py
+++ b/mesalib/src/mapi/glapi/gen/gl_gentable.py
@@ -42,7 +42,7 @@ header = """/* GLXEXT is the define used in the xserver when the GLX extension i
#endif
#if (defined(GLXEXT) && defined(HAVE_BACKTRACE)) \\
- || (!defined(GLXEXT) && defined(DEBUG) && !defined(_WIN32_WCE) && !defined(__CYGWIN__) && !defined(__MINGW32__) && !defined(__OpenBSD__) && !defined(__NetBSD__))
+ || (!defined(GLXEXT) && defined(DEBUG) && !defined(_WIN32_WCE) && !defined(__CYGWIN__) && !defined(__MINGW32__) && !defined(__OpenBSD__) && !defined(__NetBSD__) && !defined(__DragonFly__))
#define USE_BACKTRACE
#endif
diff --git a/mesalib/src/mesa/Makefile.am b/mesalib/src/mesa/Makefile.am
index 88eeff9ee..57c1e4a57 100644
--- a/mesalib/src/mesa/Makefile.am
+++ b/mesalib/src/mesa/Makefile.am
@@ -64,6 +64,7 @@ include Makefile.sources
BUILT_SOURCES = \
main/get_hash.h \
+ main/format_info.c \
$(BUILDDIR)main/git_sha1.h \
$(BUILDDIR)program/program_parse.tab.c \
$(BUILDDIR)program/lex.yy.c
@@ -81,6 +82,15 @@ main/get_hash.h: $(GLAPI)/gl_and_es_API.xml main/get_hash_params.py \
-f $< > $@.tmp; \
mv $@.tmp $@;
+main/format_info.c: main/formats.csv \
+ main/format_parser.py main/format_info.py
+ $(AM_V_GEN)set -e; \
+ $(PYTHON2) $(PYTHON_FLAGS) $(srcdir)/main/format_info.py \
+ $< > $@.tmp; \
+ mv $@.tmp $@;
+
+main/formats.c: main/format_info.c
+
noinst_LTLIBRARIES = $(ARCH_LIBS)
if NEED_LIBMESA
noinst_LTLIBRARIES += libmesa.la
diff --git a/mesalib/src/mesa/Makefile.sources b/mesalib/src/mesa/Makefile.sources
index f4904fbbd..594565771 100644
--- a/mesalib/src/mesa/Makefile.sources
+++ b/mesalib/src/mesa/Makefile.sources
@@ -3,6 +3,9 @@
# This file is among different build systems. SRCDIR must be defined with
# a trailing slash because the Android build system leaves it undefined.
+SRCDIR = $(top_srcdir)/src/mesa/
+BUILDDIR = $(top_builddir)/src/mesa/
+
# this is part of MAIN_FILES
MAIN_ES_FILES = \
$(SRCDIR)main/es1_conversion.c
@@ -28,6 +31,7 @@ MAIN_FILES = \
$(SRCDIR)main/condrender.c \
$(SRCDIR)main/context.c \
$(SRCDIR)main/convolve.c \
+ $(SRCDIR)main/copyimage.c \
$(SRCDIR)main/cpuinfo.c \
$(SRCDIR)main/debug.c \
$(SRCDIR)main/depth.c \
@@ -48,13 +52,13 @@ MAIN_FILES = \
$(SRCDIR)main/formats.c \
$(SRCDIR)main/format_pack.c \
$(SRCDIR)main/format_unpack.c \
+ $(SRCDIR)main/format_utils.c \
$(SRCDIR)main/framebuffer.c \
$(SRCDIR)main/get.c \
$(SRCDIR)main/genmipmap.c \
$(SRCDIR)main/getstring.c \
$(SRCDIR)main/glformats.c \
$(SRCDIR)main/hash.c \
- $(SRCDIR)main/hash_table.c \
$(SRCDIR)main/hint.c \
$(SRCDIR)main/histogram.c \
$(SRCDIR)main/image.c \
@@ -321,6 +325,7 @@ SPARC_FILES = \
COMMON_DRIVER_FILES = \
$(SRCDIR)drivers/common/driverfuncs.c \
$(SRCDIR)drivers/common/meta_blit.c \
+ $(SRCDIR)drivers/common/meta_copy_image.c \
$(SRCDIR)drivers/common/meta_generate_mipmap.c \
$(SRCDIR)drivers/common/meta.c
@@ -349,6 +354,7 @@ MESA_GALLIUM_FILES = \
INCLUDE_DIRS = \
-I$(top_srcdir)/include \
+ -I$(top_srcdir)/src \
-I$(top_srcdir)/src/glsl \
-I$(top_builddir)/src/glsl \
-I$(top_srcdir)/src/glsl/glcpp \
diff --git a/mesalib/src/mesa/SConscript b/mesalib/src/mesa/SConscript
index f56578672..e7c4f5ca1 100644
--- a/mesalib/src/mesa/SConscript
+++ b/mesalib/src/mesa/SConscript
@@ -11,6 +11,7 @@ from sys import executable as python_cmd
env = env.Clone()
env.Append(CPPPATH = [
+ '#/src',
'#/src/mapi',
'#/src/glsl',
'#/src/mesa',
@@ -31,316 +32,22 @@ else:
('HAVE_DLOPEN', '1'),
])
-#
-# Source files
-#
-
-main_sources = [
- 'main/api_arrayelt.c',
- 'main/api_exec.c',
- 'main/api_loopback.c',
- 'main/api_validate.c',
- 'main/accum.c',
- 'main/arbprogram.c',
- 'main/atifragshader.c',
- 'main/attrib.c',
- 'main/arrayobj.c',
- 'main/blend.c',
- 'main/blit.c',
- 'main/bufferobj.c',
- 'main/buffers.c',
- 'main/clear.c',
- 'main/clip.c',
- 'main/colortab.c',
- 'main/compute.c',
- 'main/condrender.c',
- 'main/context.c',
- 'main/convolve.c',
- 'main/cpuinfo.c',
- 'main/debug.c',
- 'main/depth.c',
- 'main/dlist.c',
- 'main/drawpix.c',
- 'main/drawtex.c',
- 'main/enable.c',
- 'main/enums.c',
- 'main/errors.c',
- 'main/es1_conversion.c',
- 'main/eval.c',
- 'main/execmem.c',
- 'main/extensions.c',
- 'main/fbobject.c',
- 'main/feedback.c',
- 'main/ff_fragment_shader.cpp',
- 'main/ffvertex_prog.c',
- 'main/fog.c',
- 'main/formatquery.c',
- 'main/formats.c',
- 'main/format_pack.c',
- 'main/format_unpack.c',
- 'main/framebuffer.c',
- 'main/genmipmap.c',
- 'main/getstring.c',
- 'main/glformats.c',
- 'main/hash.c',
- 'main/hash_table.c',
- 'main/hint.c',
- 'main/histogram.c',
- 'main/image.c',
- 'main/imports.c',
- 'main/light.c',
- 'main/lines.c',
- 'main/matrix.c',
- 'main/mipmap.c',
- 'main/mm.c',
- 'main/multisample.c',
- 'main/objectlabel.c',
- 'main/pack.c',
- 'main/pbo.c',
- 'main/performance_monitor.c',
- 'main/pipelineobj.c',
- 'main/pixel.c',
- 'main/pixelstore.c',
- 'main/pixeltransfer.c',
- 'main/points.c',
- 'main/polygon.c',
- 'main/querymatrix.c',
- 'main/queryobj.c',
- 'main/rastpos.c',
- 'main/readpix.c',
- 'main/remap.c',
- 'main/renderbuffer.c',
- 'main/samplerobj.c',
- 'main/scissor.c',
- 'main/set.c',
- 'main/shaderapi.c',
- 'main/shaderimage.c',
- 'main/shaderobj.c',
- 'main/shader_query.cpp',
- 'main/shared.c',
- 'main/state.c',
- 'main/stencil.c',
- 'main/syncobj.c',
- 'main/texcompress.c',
- 'main/texcompress_cpal.c',
- 'main/texcompress_rgtc.c',
- 'main/texcompress_s3tc.c',
- 'main/texcompress_fxt1.c',
- 'main/texcompress_etc.c',
- 'main/texenv.c',
- 'main/texformat.c',
- 'main/texgen.c',
- 'main/texgetimage.c',
- 'main/teximage.c',
- 'main/texobj.c',
- 'main/texparam.c',
- 'main/texstate.c',
- 'main/texstorage.c',
- 'main/texstore.c',
- 'main/texturebarrier.c',
- 'main/textureview.c',
- 'main/transformfeedback.c',
- 'main/uniform_query.cpp',
- 'main/uniforms.c',
- 'main/varray.c',
- 'main/vdpau.c',
- 'main/version.c',
- 'main/viewport.c',
- 'main/vtxfmt.c',
-]
-
-glget_sources = [
- 'main/get.c',
-]
-
-math_sources = [
- 'math/m_debug_clip.c',
- 'math/m_debug_norm.c',
- 'math/m_debug_xform.c',
- 'math/m_eval.c',
- 'math/m_matrix.c',
- 'math/m_translate.c',
- 'math/m_vector.c',
- 'math/m_xform.c',
-]
-
-swrast_sources = [
- 'swrast/s_aaline.c',
- 'swrast/s_aatriangle.c',
- 'swrast/s_alpha.c',
- 'swrast/s_atifragshader.c',
- 'swrast/s_bitmap.c',
- 'swrast/s_blend.c',
- 'swrast/s_blit.c',
- 'swrast/s_clear.c',
- 'swrast/s_copypix.c',
- 'swrast/s_context.c',
- 'swrast/s_depth.c',
- 'swrast/s_drawpix.c',
- 'swrast/s_feedback.c',
- 'swrast/s_fog.c',
- 'swrast/s_fragprog.c',
- 'swrast/s_lines.c',
- 'swrast/s_logic.c',
- 'swrast/s_masking.c',
- 'swrast/s_points.c',
- 'swrast/s_renderbuffer.c',
- 'swrast/s_span.c',
- 'swrast/s_stencil.c',
- 'swrast/s_texcombine.c',
- 'swrast/s_texfetch.c',
- 'swrast/s_texfilter.c',
- 'swrast/s_texrender.c',
- 'swrast/s_texture.c',
- 'swrast/s_triangle.c',
- 'swrast/s_zoom.c',
-]
-
-swrast_setup_sources = [
- 'swrast_setup/ss_context.c',
- 'swrast_setup/ss_triangle.c',
-]
-
-tnl_sources = [
- 'tnl/t_context.c',
- 'tnl/t_pipeline.c',
- 'tnl/t_draw.c',
- 'tnl/t_rasterpos.c',
- 'tnl/t_vb_program.c',
- 'tnl/t_vb_render.c',
- 'tnl/t_vb_texgen.c',
- 'tnl/t_vb_texmat.c',
- 'tnl/t_vb_vertex.c',
- 'tnl/t_vb_fog.c',
- 'tnl/t_vb_light.c',
- 'tnl/t_vb_normals.c',
- 'tnl/t_vb_points.c',
- 'tnl/t_vp_build.c',
- 'tnl/t_vertex.c',
- 'tnl/t_vertex_sse.c',
- 'tnl/t_vertex_generic.c',
-]
-
-vbo_sources = [
- 'vbo/vbo_context.c',
- 'vbo/vbo_exec.c',
- 'vbo/vbo_exec_api.c',
- 'vbo/vbo_exec_array.c',
- 'vbo/vbo_exec_draw.c',
- 'vbo/vbo_exec_eval.c',
- 'vbo/vbo_noop.c',
- 'vbo/vbo_primitive_restart.c',
- 'vbo/vbo_rebase.c',
- 'vbo/vbo_split.c',
- 'vbo/vbo_split_copy.c',
- 'vbo/vbo_split_inplace.c',
- 'vbo/vbo_save.c',
- 'vbo/vbo_save_api.c',
- 'vbo/vbo_save_draw.c',
- 'vbo/vbo_save_loopback.c',
-]
-
-statetracker_sources = [
- 'state_tracker/st_atom.c',
- 'state_tracker/st_atom_array.c',
- 'state_tracker/st_atom_blend.c',
- 'state_tracker/st_atom_clip.c',
- 'state_tracker/st_atom_constbuf.c',
- 'state_tracker/st_atom_depth.c',
- 'state_tracker/st_atom_framebuffer.c',
- 'state_tracker/st_atom_msaa.c',
- 'state_tracker/st_atom_pixeltransfer.c',
- 'state_tracker/st_atom_sampler.c',
- 'state_tracker/st_atom_scissor.c',
- 'state_tracker/st_atom_shader.c',
- 'state_tracker/st_atom_rasterizer.c',
- 'state_tracker/st_atom_stipple.c',
- 'state_tracker/st_atom_texture.c',
- 'state_tracker/st_atom_viewport.c',
- 'state_tracker/st_cb_bitmap.c',
- 'state_tracker/st_cb_blit.c',
- 'state_tracker/st_cb_bufferobjects.c',
- 'state_tracker/st_cb_clear.c',
- 'state_tracker/st_cb_condrender.c',
- 'state_tracker/st_cb_flush.c',
- 'state_tracker/st_cb_drawpixels.c',
- 'state_tracker/st_cb_drawtex.c',
- 'state_tracker/st_cb_eglimage.c',
- 'state_tracker/st_cb_fbo.c',
- 'state_tracker/st_cb_feedback.c',
- 'state_tracker/st_cb_msaa.c',
- 'state_tracker/st_cb_program.c',
- 'state_tracker/st_cb_queryobj.c',
- 'state_tracker/st_cb_rasterpos.c',
- 'state_tracker/st_cb_readpixels.c',
- 'state_tracker/st_cb_syncobj.c',
- 'state_tracker/st_cb_strings.c',
- 'state_tracker/st_cb_texture.c',
- 'state_tracker/st_cb_texturebarrier.c',
- 'state_tracker/st_cb_viewport.c',
- 'state_tracker/st_cb_xformfb.c',
- 'state_tracker/st_context.c',
- 'state_tracker/st_debug.c',
- 'state_tracker/st_draw.c',
- 'state_tracker/st_draw_feedback.c',
- 'state_tracker/st_extensions.c',
- 'state_tracker/st_format.c',
- 'state_tracker/st_glsl_to_tgsi.cpp',
- 'state_tracker/st_gen_mipmap.c',
- 'state_tracker/st_manager.c',
- 'state_tracker/st_mesa_to_tgsi.c',
- 'state_tracker/st_program.c',
- 'state_tracker/st_texture.c',
- 'state_tracker/st_vdpau.c',
-]
+# parse Makefile.sources
+source_lists = env.ParseSourceList('Makefile.sources')
env.Append(YACCFLAGS = '-d -p "_mesa_program_"')
program_lex = env.CFile('program/lex.yy.c', 'program/program_lexer.l')
program_parse = env.CFile('program/program_parse.tab.c',
'program/program_parse.y')
-
-program_sources = [
- 'program/arbprogparse.c',
- 'program/prog_hash_table.c',
- 'program/ir_to_mesa.cpp',
- 'program/program.c',
- 'program/program_parse_extra.c',
- 'program/prog_cache.c',
- 'program/prog_execute.c',
- 'program/prog_instruction.c',
- 'program/prog_noise.c',
- 'program/prog_optimize.c',
- 'program/prog_opt_constant_fold.c',
- 'program/prog_parameter.c',
- 'program/prog_parameter_layout.c',
- 'program/prog_print.c',
- 'program/prog_statevars.c',
- 'program/programopt.c',
- 'program/sampler.cpp',
- 'program/symbol_table.c',
- 'program/string_to_uint_map.cpp',
+program_sources = source_lists['PROGRAM_FILES'] + [
program_lex,
program_parse[0],
]
-common_driver_sources = [
- 'drivers/common/driverfuncs.c',
- 'drivers/common/meta.c',
- 'drivers/common/meta_blit.c',
- 'drivers/common/meta_generate_mipmap.c'
-]
-
mesa_sources = (
- main_sources +
- glget_sources +
- math_sources +
+ source_lists['MESA_FILES'] +
program_sources +
- vbo_sources +
- tnl_sources +
- swrast_sources +
- swrast_setup_sources +
- common_driver_sources +
- statetracker_sources
+ source_lists['STATETRACKER_FILES']
)
GLAPI = '#src/mapi/glapi/'
@@ -352,6 +59,13 @@ get_hash_header = env.CodeGenerate(
command = python_cmd + ' $SCRIPT ' + ' -f $SOURCE > $TARGET'
)
+format_info = env.CodeGenerate(
+ target = 'main/format_info.c',
+ script = 'main/format_info.py',
+ source = 'main/formats.csv',
+ command = python_cmd + ' $SCRIPT ' + ' $SOURCE > $TARGET'
+)
+
#
# Assembly sources
#
@@ -364,45 +78,14 @@ if (env['gcc'] or env['clang']) and \
'USE_3DNOW_ASM',
'USE_SSE_ASM',
])
- mesa_sources += [
- 'x86/common_x86.c',
- 'x86/x86_xform.c',
- 'x86/3dnow.c',
- 'x86/sse.c',
- 'x86/common_x86_asm.S',
- 'x86/x86_xform2.S',
- 'x86/x86_xform3.S',
- 'x86/x86_xform4.S',
- 'x86/x86_cliptest.S',
- 'x86/mmx_blend.S',
- 'x86/3dnow_xform1.S',
- 'x86/3dnow_xform2.S',
- 'x86/3dnow_xform3.S',
- 'x86/3dnow_xform4.S',
- 'x86/3dnow_normal.S',
- 'x86/sse_xform1.S',
- 'x86/sse_xform2.S',
- 'x86/sse_xform3.S',
- 'x86/sse_xform4.S',
- 'x86/sse_normal.S',
- 'x86/read_rgba_span_x86.S',
- ]
+ mesa_sources += source_lists['X86_FILES']
elif env['machine'] == 'x86_64':
env.Append(CPPDEFINES = [
'USE_X86_64_ASM',
])
- mesa_sources += [
- 'x86/common_x86.c',
- 'x86-64/x86-64.c',
- 'x86-64/xform4.S',
- ]
+ mesa_sources += source_lists['X86_64_FILES']
elif env['machine'] == 'sparc':
- mesa_sources += [
- 'sparc/sparc.c',
- 'sparc/sparc_clip.S',
- 'sparc/norm.S',
- 'sparc/xform.S',
- ]
+ mesa_sources += source_lists['SPARC_FILES']
else:
pass
diff --git a/mesalib/src/mesa/drivers/common/meta.c b/mesalib/src/mesa/drivers/common/meta.c
index b12898f26..a1d06d412 100644
--- a/mesalib/src/mesa/drivers/common/meta.c
+++ b/mesalib/src/mesa/drivers/common/meta.c
@@ -84,7 +84,7 @@
#include "drivers/common/meta.h"
#include "main/enums.h"
#include "main/glformats.h"
-#include "../glsl/ralloc.h"
+#include "util/ralloc.h"
/** Return offset in bytes of the field within a vertex struct */
#define OFFSET(FIELD) ((void *) offsetof(struct vertex, FIELD))
@@ -101,18 +101,18 @@ static void meta_decompress_cleanup(struct decompress_state *decompress);
static void meta_drawpix_cleanup(struct drawpix_state *drawpix);
void
-_mesa_meta_bind_fbo_image(GLenum attachment,
+_mesa_meta_bind_fbo_image(GLenum fboTarget, GLenum attachment,
struct gl_texture_image *texImage, GLuint layer)
{
struct gl_texture_object *texObj = texImage->TexObject;
int level = texImage->Level;
- GLenum target = texObj->Target;
+ GLenum texTarget = texObj->Target;
- switch (target) {
+ switch (texTarget) {
case GL_TEXTURE_1D:
- _mesa_FramebufferTexture1D(GL_FRAMEBUFFER,
+ _mesa_FramebufferTexture1D(fboTarget,
attachment,
- target,
+ texTarget,
texObj->Name,
level);
break;
@@ -121,19 +121,19 @@ _mesa_meta_bind_fbo_image(GLenum attachment,
case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
case GL_TEXTURE_CUBE_MAP_ARRAY:
case GL_TEXTURE_3D:
- _mesa_FramebufferTextureLayer(GL_FRAMEBUFFER,
+ _mesa_FramebufferTextureLayer(fboTarget,
attachment,
texObj->Name,
level,
layer);
break;
default: /* 2D / cube */
- if (target == GL_TEXTURE_CUBE_MAP)
- target = GL_TEXTURE_CUBE_MAP_POSITIVE_X + texImage->Face;
+ if (texTarget == GL_TEXTURE_CUBE_MAP)
+ texTarget = GL_TEXTURE_CUBE_MAP_POSITIVE_X + texImage->Face;
- _mesa_FramebufferTexture2D(GL_FRAMEBUFFER,
+ _mesa_FramebufferTexture2D(fboTarget,
attachment,
- target,
+ texTarget,
texObj->Name,
level);
}
@@ -2732,9 +2732,9 @@ _mesa_meta_blit_shader_table_cleanup(struct blit_shader_table *table)
static GLenum
get_temp_image_type(struct gl_context *ctx, mesa_format format)
{
- GLenum baseFormat;
-
- baseFormat = _mesa_get_format_base_format(format);
+ const GLenum baseFormat = _mesa_get_format_base_format(format);
+ const GLenum datatype = _mesa_get_format_datatype(format);
+ const GLint format_red_bits = _mesa_get_format_bits(format, GL_RED_BITS);
switch (baseFormat) {
case GL_RGBA:
@@ -2745,30 +2745,24 @@ get_temp_image_type(struct gl_context *ctx, mesa_format format)
case GL_LUMINANCE:
case GL_LUMINANCE_ALPHA:
case GL_INTENSITY:
- if (ctx->DrawBuffer->Visual.redBits <= 8) {
+ if (datatype == GL_INT || datatype == GL_UNSIGNED_INT) {
+ return datatype;
+ } else if (format_red_bits <= 8) {
return GL_UNSIGNED_BYTE;
- } else if (ctx->DrawBuffer->Visual.redBits <= 16) {
+ } else if (format_red_bits <= 16) {
return GL_UNSIGNED_SHORT;
- } else {
- GLenum datatype = _mesa_get_format_datatype(format);
- if (datatype == GL_INT || datatype == GL_UNSIGNED_INT)
- return datatype;
- return GL_FLOAT;
}
- case GL_DEPTH_COMPONENT: {
- GLenum datatype = _mesa_get_format_datatype(format);
+ return GL_FLOAT;
+ case GL_DEPTH_COMPONENT:
if (datatype == GL_FLOAT)
return GL_FLOAT;
else
return GL_UNSIGNED_INT;
- }
- case GL_DEPTH_STENCIL: {
- GLenum datatype = _mesa_get_format_datatype(format);
+ case GL_DEPTH_STENCIL:
if (datatype == GL_FLOAT)
return GL_FLOAT_32_UNSIGNED_INT_24_8_REV;
else
return GL_UNSIGNED_INT_24_8;
- }
default:
_mesa_problem(ctx, "Unexpected format %d in get_temp_image_type()",
baseFormat);
@@ -2808,17 +2802,20 @@ copytexsubimage_using_blit_framebuffer(struct gl_context *ctx, GLuint dims,
if (rb->_BaseFormat == GL_DEPTH_STENCIL ||
rb->_BaseFormat == GL_DEPTH_COMPONENT) {
- _mesa_meta_bind_fbo_image(GL_DEPTH_ATTACHMENT, texImage, zoffset);
+ _mesa_meta_bind_fbo_image(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
+ texImage, zoffset);
mask = GL_DEPTH_BUFFER_BIT;
if (rb->_BaseFormat == GL_DEPTH_STENCIL &&
texImage->_BaseFormat == GL_DEPTH_STENCIL) {
- _mesa_meta_bind_fbo_image(GL_STENCIL_ATTACHMENT, texImage, zoffset);
+ _mesa_meta_bind_fbo_image(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
+ texImage, zoffset);
mask |= GL_STENCIL_BUFFER_BIT;
}
_mesa_DrawBuffer(GL_NONE);
} else {
- _mesa_meta_bind_fbo_image(GL_COLOR_ATTACHMENT0, texImage, zoffset);
+ _mesa_meta_bind_fbo_image(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
+ texImage, zoffset);
mask = GL_COLOR_BUFFER_BIT;
_mesa_DrawBuffer(GL_COLOR_ATTACHMENT0);
}
@@ -3362,7 +3359,8 @@ cleartexsubimage_color(struct gl_context *ctx,
GLenum datatype;
GLenum status;
- _mesa_meta_bind_fbo_image(GL_COLOR_ATTACHMENT0, texImage, zoffset);
+ _mesa_meta_bind_fbo_image(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
+ texImage, zoffset);
status = _mesa_CheckFramebufferStatus(GL_DRAW_FRAMEBUFFER);
if (status != GL_FRAMEBUFFER_COMPLETE)
@@ -3408,10 +3406,12 @@ cleartexsubimage_depth_stencil(struct gl_context *ctx,
GLfloat depthValue;
GLenum status;
- _mesa_meta_bind_fbo_image(GL_DEPTH_ATTACHMENT, texImage, zoffset);
+ _mesa_meta_bind_fbo_image(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
+ texImage, zoffset);
if (texImage->_BaseFormat == GL_DEPTH_STENCIL)
- _mesa_meta_bind_fbo_image(GL_STENCIL_ATTACHMENT, texImage, zoffset);
+ _mesa_meta_bind_fbo_image(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
+ texImage, zoffset);
status = _mesa_CheckFramebufferStatus(GL_DRAW_FRAMEBUFFER);
if (status != GL_FRAMEBUFFER_COMPLETE)
diff --git a/mesalib/src/mesa/drivers/common/meta.h b/mesalib/src/mesa/drivers/common/meta.h
index b269dceed..e2da2f427 100644
--- a/mesalib/src/mesa/drivers/common/meta.h
+++ b/mesalib/src/mesa/drivers/common/meta.h
@@ -440,6 +440,14 @@ _mesa_meta_and_swrast_BlitFramebuffer(struct gl_context *ctx,
GLint dstX1, GLint dstY1,
GLbitfield mask, GLenum filter);
+bool
+_mesa_meta_CopyImageSubData_uncompressed(struct gl_context *ctx,
+ struct gl_texture_image *src_tex_image,
+ int src_x, int src_y, int src_z,
+ struct gl_texture_image *dst_tex_image,
+ int dst_x, int dst_y, int dst_z,
+ int src_width, int src_height);
+
extern void
_mesa_meta_Clear(struct gl_context *ctx, GLbitfield buffers);
@@ -570,7 +578,7 @@ void
_mesa_meta_glsl_generate_mipmap_cleanup(struct gen_mipmap_state *mipmap);
void
-_mesa_meta_bind_fbo_image(GLenum attachment,
+_mesa_meta_bind_fbo_image(GLenum target, GLenum attachment,
struct gl_texture_image *texImage, GLuint layer);
#endif /* META_H */
diff --git a/mesalib/src/mesa/drivers/common/meta_blit.c b/mesalib/src/mesa/drivers/common/meta_blit.c
index bbf0c3c45..955e73f57 100644
--- a/mesalib/src/mesa/drivers/common/meta_blit.c
+++ b/mesalib/src/mesa/drivers/common/meta_blit.c
@@ -49,7 +49,7 @@
#include "main/viewport.h"
#include "swrast/swrast.h"
#include "drivers/common/meta.h"
-#include "../glsl/ralloc.h"
+#include "util/ralloc.h"
/** Return offset in bytes of the field within a vertex struct */
#define OFFSET(FIELD) ((void *) offsetof(struct vertex, FIELD))
@@ -709,6 +709,9 @@ _mesa_meta_BlitFramebuffer(struct gl_context *ctx,
*/
_mesa_meta_begin(ctx, MESA_META_ALL & ~MESA_META_DRAW_BUFFERS);
+ /* Dithering shouldn't be performed for glBlitFramebuffer */
+ _mesa_set_enable(ctx, GL_DITHER, GL_FALSE);
+
/* If the clipping earlier changed the destination rect at all, then
* enable the scissor to clip to it.
*/
diff --git a/mesalib/src/mesa/drivers/common/meta_copy_image.c b/mesalib/src/mesa/drivers/common/meta_copy_image.c
new file mode 100644
index 000000000..c40c2f011
--- /dev/null
+++ b/mesalib/src/mesa/drivers/common/meta_copy_image.c
@@ -0,0 +1,199 @@
+/*
+ * Mesa 3-D graphics library
+ *
+ * Copyright (C) 2014 Intel Corporation. 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 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.
+ */
+
+#include "glheader.h"
+#include "context.h"
+#include "enums.h"
+#include "imports.h"
+#include "macros.h"
+#include "teximage.h"
+#include "texobj.h"
+#include "fbobject.h"
+#include "buffers.h"
+#include "state.h"
+#include "mtypes.h"
+#include "meta.h"
+
+/* This function makes a texture view without bothering with all of the API
+ * checks. Most of them are the same for CopyTexSubImage so checking would
+ * be redundant. The one major difference is that we don't check for
+ * whether the texture is immutable or not. However, since the view will
+ * be created and then immediately destroyed, this should not be a problem.
+ */
+static bool
+make_view(struct gl_context *ctx, struct gl_texture_image *tex_image,
+ struct gl_texture_image **view_tex_image, GLuint *view_tex_name,
+ GLenum internal_format)
+{
+ struct gl_texture_object *tex_obj = tex_image->TexObject;
+ struct gl_texture_object *view_tex_obj;
+ mesa_format tex_format;
+
+ /* Set up the new texture object */
+ _mesa_GenTextures(1, view_tex_name);
+ view_tex_obj = _mesa_lookup_texture(ctx, *view_tex_name);
+ if (!view_tex_obj)
+ return false;
+
+ tex_format = _mesa_choose_texture_format(ctx, view_tex_obj, tex_obj->Target,
+ 0, internal_format,
+ GL_NONE, GL_NONE);
+
+ if (!ctx->Driver.TestProxyTexImage(ctx, tex_obj->Target, 0, tex_format,
+ tex_image->Width, tex_image->Height,
+ tex_image->Depth, 0)) {
+ return false;
+ }
+
+ view_tex_obj->Target = tex_obj->Target;
+
+ *view_tex_image = _mesa_get_tex_image(ctx, view_tex_obj, tex_obj->Target, 0);
+ _mesa_init_teximage_fields(ctx, *view_tex_image,
+ tex_image->Width, tex_image->Height,
+ tex_image->Depth,
+ 0, internal_format, tex_format);
+
+ view_tex_obj->MinLevel = 0;
+ view_tex_obj->NumLevels = 1;
+ view_tex_obj->MinLayer = tex_obj->MinLayer;
+ view_tex_obj->NumLayers = tex_obj->NumLayers;
+ view_tex_obj->Immutable = tex_obj->Immutable;
+ view_tex_obj->ImmutableLevels = tex_obj->ImmutableLevels;
+ view_tex_obj->Target = tex_obj->Target;
+
+ if (ctx->Driver.TextureView != NULL &&
+ !ctx->Driver.TextureView(ctx, view_tex_obj, tex_obj)) {
+ _mesa_DeleteTextures(1, view_tex_name);
+ *view_tex_name = 0;
+ return false; /* driver recorded error */
+ }
+
+ return true;
+}
+
+/** A partial implementation of glCopyImageSubData
+ *
+ * This is a partial implementation of glCopyImageSubData that works only
+ * if both textures are uncompressed and the destination texture is
+ * renderable. It uses a slight abuse of a texture view (see make_view) to
+ * turn the source texture into the destination texture type and then uses
+ * _mesa_meta_BlitFramebuffers to do the copy.
+ */
+bool
+_mesa_meta_CopyImageSubData_uncompressed(struct gl_context *ctx,
+ struct gl_texture_image *src_tex_image,
+ int src_x, int src_y, int src_z,
+ struct gl_texture_image *dst_tex_image,
+ int dst_x, int dst_y, int dst_z,
+ int src_width, int src_height)
+{
+ GLuint src_view_texture = 0;
+ struct gl_texture_image *src_view_tex_image;
+ GLuint fbos[2];
+ bool success = false;
+ GLbitfield mask;
+ GLenum status, attachment;
+
+ if (_mesa_is_format_compressed(dst_tex_image->TexFormat))
+ return false;
+
+ if (_mesa_is_format_compressed(src_tex_image->TexFormat))
+ return false;
+
+ if (src_tex_image->InternalFormat == dst_tex_image->InternalFormat) {
+ src_view_tex_image = src_tex_image;
+ } else {
+ if (!make_view(ctx, src_tex_image, &src_view_tex_image, &src_view_texture,
+ dst_tex_image->InternalFormat))
+ goto cleanup;
+ }
+
+ /* We really only need to stash the bound framebuffers. */
+ _mesa_meta_begin(ctx, 0);
+
+ _mesa_GenFramebuffers(2, fbos);
+ _mesa_BindFramebuffer(GL_READ_FRAMEBUFFER, fbos[0]);
+ _mesa_BindFramebuffer(GL_DRAW_FRAMEBUFFER, fbos[1]);
+
+ switch (_mesa_get_format_base_format(src_tex_image->TexFormat)) {
+ case GL_DEPTH_COMPONENT:
+ attachment = GL_DEPTH_ATTACHMENT;
+ mask = GL_DEPTH_BUFFER_BIT;
+ break;
+ case GL_DEPTH_STENCIL:
+ attachment = GL_DEPTH_STENCIL_ATTACHMENT;
+ mask = GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT;
+ break;
+ case GL_STENCIL_INDEX:
+ attachment = GL_STENCIL_ATTACHMENT;
+ mask = GL_STENCIL_BUFFER_BIT;
+ break;
+ default:
+ attachment = GL_COLOR_ATTACHMENT0;
+ mask = GL_COLOR_BUFFER_BIT;
+ _mesa_DrawBuffer(GL_COLOR_ATTACHMENT0);
+ _mesa_ReadBuffer(GL_COLOR_ATTACHMENT0);
+ }
+
+ _mesa_meta_bind_fbo_image(GL_READ_FRAMEBUFFER, attachment,
+ src_view_tex_image, src_z);
+
+ status = _mesa_CheckFramebufferStatus(GL_READ_FRAMEBUFFER);
+ if (status != GL_FRAMEBUFFER_COMPLETE)
+ goto meta_end;
+
+ _mesa_meta_bind_fbo_image(GL_DRAW_FRAMEBUFFER, attachment,
+ dst_tex_image, dst_z);
+
+ status = _mesa_CheckFramebufferStatus(GL_DRAW_FRAMEBUFFER);
+ if (status != GL_FRAMEBUFFER_COMPLETE)
+ goto meta_end;
+
+ /* Since we've bound a new draw framebuffer, we need to update its
+ * derived state -- _Xmin, etc -- for BlitFramebuffer's clipping to
+ * be correct.
+ */
+ _mesa_update_state(ctx);
+
+ /* We skip the core BlitFramebuffer checks for format consistency.
+ * We have already created views to ensure that the texture formats
+ * match.
+ */
+ ctx->Driver.BlitFramebuffer(ctx, src_x, src_y,
+ src_x + src_width, src_y + src_height,
+ dst_x, dst_y,
+ dst_x + src_width, dst_y + src_height,
+ mask, GL_NEAREST);
+
+ success = true;
+
+meta_end:
+ _mesa_DeleteFramebuffers(2, fbos);
+ _mesa_meta_end(ctx);
+
+cleanup:
+ _mesa_DeleteTextures(1, &src_view_texture);
+
+ return success;
+}
diff --git a/mesalib/src/mesa/drivers/common/meta_generate_mipmap.c b/mesalib/src/mesa/drivers/common/meta_generate_mipmap.c
index 4b1718df9..8ffd8da3b 100644
--- a/mesalib/src/mesa/drivers/common/meta_generate_mipmap.c
+++ b/mesalib/src/mesa/drivers/common/meta_generate_mipmap.c
@@ -104,7 +104,7 @@ fallback_required(struct gl_context *ctx, GLenum target,
_mesa_GenFramebuffers(1, &mipmap->FBO);
_mesa_BindFramebuffer(GL_FRAMEBUFFER_EXT, mipmap->FBO);
- _mesa_meta_bind_fbo_image(GL_COLOR_ATTACHMENT0, baseImage, 0);
+ _mesa_meta_bind_fbo_image(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, baseImage, 0);
status = _mesa_CheckFramebufferStatus(GL_FRAMEBUFFER_EXT);
@@ -327,7 +327,7 @@ _mesa_meta_GenerateMipmap(struct gl_context *ctx, GLenum target,
_mesa_BufferData(GL_ARRAY_BUFFER_ARB, sizeof(verts),
verts, GL_DYNAMIC_DRAW_ARB);
- _mesa_meta_bind_fbo_image(GL_COLOR_ATTACHMENT0, dstImage, layer);
+ _mesa_meta_bind_fbo_image(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, dstImage, layer);
/* sanity check */
if (_mesa_CheckFramebufferStatus(GL_FRAMEBUFFER) !=
diff --git a/mesalib/src/mesa/drivers/dri/common/SConscript b/mesalib/src/mesa/drivers/dri/common/SConscript
index d003139bf..0bee1b41f 100644
--- a/mesalib/src/mesa/drivers/dri/common/SConscript
+++ b/mesalib/src/mesa/drivers/dri/common/SConscript
@@ -10,6 +10,7 @@ drienv.Replace(CPPPATH = [
xmlpool_options.dir.dir, # Dir to generated xmlpool/options.h
'#include',
'#include/GL/internal',
+ '#src',
'#src/mapi',
'#src/gallium/include',
'#src/gallium/auxiliary',
diff --git a/mesalib/src/mesa/drivers/dri/common/xmlconfig.c b/mesalib/src/mesa/drivers/dri/common/xmlconfig.c
index b129979d2..d11ba4e4b 100644
--- a/mesalib/src/mesa/drivers/dri/common/xmlconfig.c
+++ b/mesalib/src/mesa/drivers/dri/common/xmlconfig.c
@@ -45,6 +45,8 @@
extern char *program_invocation_name, *program_invocation_short_name;
# endif
# define GET_PROGRAM_NAME() program_invocation_short_name
+#elif defined(__CYGWIN__)
+# define GET_PROGRAM_NAME() program_invocation_short_name
#elif defined(__FreeBSD__) && (__FreeBSD__ >= 2)
# include <osreldate.h>
# if (__FreeBSD_version >= 440000)
diff --git a/mesalib/src/mesa/drivers/dri/common/xmlconfig.h b/mesalib/src/mesa/drivers/dri/common/xmlconfig.h
index 59a67b328..8969843bd 100644..100755
--- a/mesalib/src/mesa/drivers/dri/common/xmlconfig.h
+++ b/mesalib/src/mesa/drivers/dri/common/xmlconfig.h
@@ -58,7 +58,7 @@ typedef struct driOptionInfo {
char *name; /**< \brief Name */
driOptionType type; /**< \brief Type */
driOptionRange *ranges; /**< \brief Array of ranges */
- unsigned int nRanges; /**< \brief Number of ranges */
+ unsigned int nRanges; /**< \brief Number of ranges */
} driOptionInfo;
/** \brief Option cache
diff --git a/mesalib/src/mesa/drivers/windows/gdi/SConscript b/mesalib/src/mesa/drivers/windows/gdi/SConscript
index 10a7eeaa1..1f4d7e1fa 100644
--- a/mesalib/src/mesa/drivers/windows/gdi/SConscript
+++ b/mesalib/src/mesa/drivers/windows/gdi/SConscript
@@ -3,6 +3,7 @@ Import('*')
env = env.Clone()
env.Prepend(CPPPATH = [
+ '#src',
'#src/mapi',
'#src/mesa',
])
@@ -16,6 +17,7 @@ if not env['gles']:
env.Append(CPPDEFINES = ['_GLAPI_NO_EXPORTS'])
env.Prepend(LIBS = [
+ mesautil,
glapi,
mesa,
glsl,
diff --git a/mesalib/src/mesa/main/.gitignore b/mesalib/src/mesa/main/.gitignore
index b1b83f102..328aaf570 100644..100755
--- a/mesalib/src/mesa/main/.gitignore
+++ b/mesalib/src/mesa/main/.gitignore
@@ -8,4 +8,5 @@ git_sha1.h.tmp
remap_helper.h
get_hash.h
get_hash.h.tmp
+format_info.c
glapitable.h
diff --git a/mesalib/src/mesa/main/bufferobj.c b/mesalib/src/mesa/main/bufferobj.c
index 2a5ffc3e6..c29a8c777 100644
--- a/mesalib/src/mesa/main/bufferobj.c
+++ b/mesalib/src/mesa/main/bufferobj.c
@@ -31,6 +31,7 @@
*/
#include <stdbool.h>
+#include <inttypes.h> /* for PRId64 macro */
#include "glheader.h"
#include "enums.h"
#include "hash.h"
@@ -832,6 +833,9 @@ _mesa_init_buffer_objects( struct gl_context *ctx )
_mesa_reference_buffer_object(ctx, &ctx->UniformBuffer,
ctx->Shared->NullBufferObj);
+ _mesa_reference_buffer_object(ctx, &ctx->AtomicBuffer,
+ ctx->Shared->NullBufferObj);
+
_mesa_reference_buffer_object(ctx, &ctx->DrawIndirectBuffer,
ctx->Shared->NullBufferObj);
@@ -842,6 +846,14 @@ _mesa_init_buffer_objects( struct gl_context *ctx )
ctx->UniformBufferBindings[i].Offset = -1;
ctx->UniformBufferBindings[i].Size = -1;
}
+
+ for (i = 0; i < MAX_COMBINED_ATOMIC_BUFFERS; i++) {
+ _mesa_reference_buffer_object(ctx,
+ &ctx->AtomicBufferBindings[i].BufferObject,
+ ctx->Shared->NullBufferObj);
+ ctx->AtomicBufferBindings[i].Offset = -1;
+ ctx->AtomicBufferBindings[i].Size = -1;
+ }
}
@@ -857,6 +869,8 @@ _mesa_free_buffer_objects( struct gl_context *ctx )
_mesa_reference_buffer_object(ctx, &ctx->UniformBuffer, NULL);
+ _mesa_reference_buffer_object(ctx, &ctx->AtomicBuffer, NULL);
+
_mesa_reference_buffer_object(ctx, &ctx->DrawIndirectBuffer, NULL);
for (i = 0; i < MAX_COMBINED_UNIFORM_BUFFERS; i++) {
@@ -864,6 +878,13 @@ _mesa_free_buffer_objects( struct gl_context *ctx )
&ctx->UniformBufferBindings[i].BufferObject,
NULL);
}
+
+ for (i = 0; i < MAX_COMBINED_ATOMIC_BUFFERS; i++) {
+ _mesa_reference_buffer_object(ctx,
+ &ctx->AtomicBufferBindings[i].BufferObject,
+ NULL);
+ }
+
}
bool
@@ -1200,6 +1221,17 @@ _mesa_DeleteBuffers(GLsizei n, const GLuint *ids)
_mesa_BindBuffer( GL_UNIFORM_BUFFER, 0 );
}
+ /* unbind Atomci Buffer binding points */
+ for (j = 0; j < ctx->Const.MaxAtomicBufferBindings; j++) {
+ if (ctx->AtomicBufferBindings[j].BufferObject == bufObj) {
+ _mesa_BindBufferBase( GL_ATOMIC_COUNTER_BUFFER, j, 0 );
+ }
+ }
+
+ if (ctx->UniformBuffer == bufObj) {
+ _mesa_BindBuffer( GL_ATOMIC_COUNTER_BUFFER, 0 );
+ }
+
/* unbind any pixel pack/unpack pointers bound to this buffer */
if (ctx->Pack.BufferObj == bufObj) {
_mesa_BindBuffer( GL_PIXEL_PACK_BUFFER_EXT, 0 );
@@ -2793,8 +2825,8 @@ bind_buffers_check_offset_and_size(struct gl_context *ctx,
* value in <offsets> is less than zero (per binding)."
*/
_mesa_error(ctx, GL_INVALID_VALUE,
- "glBindBuffersRange(offsets[%u]=%lld < 0)",
- index, (long long int) offsets[index]);
+ "glBindBuffersRange(offsets[%u]=%" PRId64 " < 0)",
+ index, (int64_t) offsets[index]);
return false;
}
@@ -2805,8 +2837,8 @@ bind_buffers_check_offset_and_size(struct gl_context *ctx,
* value in <sizes> is less than or equal to zero (per binding)."
*/
_mesa_error(ctx, GL_INVALID_VALUE,
- "glBindBuffersRange(sizes[%u]=%lld <= 0)",
- index, (long long int) sizes[index]);
+ "glBindBuffersRange(sizes[%u]=%" PRId64 " <= 0)",
+ index, (int64_t) sizes[index]);
return false;
}
@@ -3001,11 +3033,11 @@ bind_uniform_buffers_range(struct gl_context *ctx, GLuint first, GLsizei count,
*/
if (offsets[i] & (ctx->Const.UniformBufferOffsetAlignment - 1)) {
_mesa_error(ctx, GL_INVALID_VALUE,
- "glBindBuffersRange(offsets[%u]=%lld is misaligned; "
- "it must be a multiple of the value of "
+ "glBindBuffersRange(offsets[%u]=%" PRId64
+ " is misaligned; it must be a multiple of the value of "
"GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT=%u when "
"target=GL_UNIFORM_BUFFER)",
- i, (long long int) offsets[i],
+ i, (int64_t) offsets[i],
ctx->Const.UniformBufferOffsetAlignment);
continue;
}
@@ -3239,19 +3271,19 @@ bind_xfb_buffers_range(struct gl_context *ctx,
*/
if (offsets[i] & 0x3) {
_mesa_error(ctx, GL_INVALID_VALUE,
- "glBindBuffersRange(offsets[%u]=%lld is misaligned; "
- "it must be a multiple of 4 when "
+ "glBindBuffersRange(offsets[%u]=%" PRId64
+ " is misaligned; it must be a multiple of 4 when "
"target=GL_TRANSFORM_FEEDBACK_BUFFER)",
- i, (long long int) offsets[i]);
+ i, (int64_t) offsets[i]);
continue;
}
if (sizes[i] & 0x3) {
_mesa_error(ctx, GL_INVALID_VALUE,
- "glBindBuffersRange(sizes[%u]=%lld is misaligned; "
- "it must be a multiple of 4 when "
+ "glBindBuffersRange(sizes[%u]=%" PRId64
+ " is misaligned; it must be a multiple of 4 when "
"target=GL_TRANSFORM_FEEDBACK_BUFFER)",
- i, (long long int) sizes[i]);
+ i, (int64_t) sizes[i]);
continue;
}
@@ -3457,10 +3489,10 @@ bind_atomic_buffers_range(struct gl_context *ctx,
*/
if (offsets[i] & (ATOMIC_COUNTER_SIZE - 1)) {
_mesa_error(ctx, GL_INVALID_VALUE,
- "glBindBuffersRange(offsets[%u]=%lld is misaligned; "
- "it must be a multiple of %d when "
+ "glBindBuffersRange(offsets[%u]=%" PRId64
+ " is misaligned; it must be a multiple of %d when "
"target=GL_ATOMIC_COUNTER_BUFFER)",
- i, (long long int) offsets[i], ATOMIC_COUNTER_SIZE);
+ i, (int64_t) offsets[i], ATOMIC_COUNTER_SIZE);
continue;
}
diff --git a/mesalib/src/mesa/main/buffers.c b/mesalib/src/mesa/main/buffers.c
index b13a7af65..140cf6e82 100644
--- a/mesalib/src/mesa/main/buffers.c
+++ b/mesalib/src/mesa/main/buffers.c
@@ -494,10 +494,11 @@ _mesa_drawbuffers(struct gl_context *ctx, GLuint n, const GLenum *buffers,
}
/*
- * If n==1, destMask[0] may have up to four bits set.
+ * destMask[0] may have up to four bits set
+ * (ex: glDrawBuffer(GL_FRONT_AND_BACK)).
* Otherwise, destMask[x] can only have one bit set.
*/
- if (n == 1) {
+ if (_mesa_bitcount(destMask[0]) > 1) {
GLuint count = 0, destMask0 = destMask[0];
while (destMask0) {
GLint bufIndex = ffs(destMask0) - 1;
@@ -566,16 +567,11 @@ _mesa_drawbuffers(struct gl_context *ctx, GLuint n, const GLenum *buffers,
void
_mesa_update_draw_buffers(struct gl_context *ctx)
{
- GLenum buffers[MAX_DRAW_BUFFERS];
- GLuint i;
-
/* should be a window system FBO */
assert(_mesa_is_winsys_fbo(ctx->DrawBuffer));
- for (i = 0; i < ctx->Const.MaxDrawBuffers; i++)
- buffers[i] = ctx->Color.DrawBuffer[i];
-
- _mesa_drawbuffers(ctx, ctx->Const.MaxDrawBuffers, buffers, NULL);
+ _mesa_drawbuffers(ctx, ctx->Const.MaxDrawBuffers,
+ ctx->Color.DrawBuffer, NULL);
}
diff --git a/mesalib/src/mesa/main/compiler.h b/mesalib/src/mesa/main/compiler.h
index 79d8740e5..35160223e 100644
--- a/mesalib/src/mesa/main/compiler.h
+++ b/mesalib/src/mesa/main/compiler.h
@@ -44,6 +44,8 @@
#include <float.h>
#include <stdarg.h>
+#include "util/macros.h"
+
#include "c99_compat.h" /* inline, __func__, etc. */
@@ -130,23 +132,6 @@ extern "C" {
#endif
-/**
- * __builtin_expect macros
- */
-#if !defined(__GNUC__)
-# define __builtin_expect(x, y) (x)
-#endif
-
-#ifndef likely
-# ifdef __GNUC__
-# define likely(x) __builtin_expect(!!(x), 1)
-# define unlikely(x) __builtin_expect(!!(x), 0)
-# else
-# define likely(x) (x)
-# define unlikely(x) (x)
-# endif
-#endif
-
/* XXX: Use standard `__func__` instead */
#ifndef __FUNCTION__
# define __FUNCTION__ __func__
@@ -238,65 +223,16 @@ static INLINE GLuint CPU_TO_LE32(GLuint x)
#endif
-/**
- * Static (compile-time) assertion.
- * Basically, use COND to dimension an array. If COND is false/zero the
- * array size will be -1 and we'll get a compilation error.
- */
-#define STATIC_ASSERT(COND) \
- do { \
- (void) sizeof(char [1 - 2*!(COND)]); \
- } while (0)
-
-/**
- * Unreachable macro. Useful for suppressing "control reaches end of non-void
- * function" warnings.
- */
-#if __GNUC__ >= 4 && __GNUC_MINOR__ >= 5
-#define unreachable(str) \
-do { \
- assert(!str); \
- __builtin_unreachable(); \
-} while (0)
-#elif (defined(__clang__) && defined(__has_builtin))
-# if __has_builtin(__builtin_unreachable)
-# define unreachable(str) \
-do { \
- assert(!str); \
- __builtin_unreachable(); \
-} while (0)
-# endif
-#endif
-
-#ifndef unreachable
-#define unreachable(str)
-#endif
-
/*
* A trick to suppress uninitialized variable warning without generating any
* code
*/
#define uninitialized_var(x) x = x
-#if (__GNUC__ >= 3)
-#define PRINTFLIKE(f, a) __attribute__ ((format(__printf__, f, a)))
-#else
-#define PRINTFLIKE(f, a)
-#endif
-
#ifndef NULL
#define NULL 0
#endif
-/* Used to optionally mark structures with misaligned elements or size as
- * packed, to trade off performance for space.
- */
-#if (__GNUC__ >= 3)
-#define PACKED __attribute__((__packed__))
-#else
-#define PACKED
-#endif
-
/**
* LONGSTRING macro
@@ -329,25 +265,7 @@ do { \
#define FLT_MAX_EXP 128
#endif
-
-/**
- * USE_IEEE: Determine if we're using IEEE floating point
- */
-#if defined(__i386__) || defined(__386__) || defined(__sparc__) || \
- defined(__s390__) || defined(__s390x__) || defined(__powerpc__) || \
- defined(__x86_64__) || \
- defined(__m68k__) || \
- defined(ia64) || defined(__ia64__) || \
- defined(__hppa__) || defined(hpux) || \
- defined(__mips) || defined(_MIPS_ARCH) || \
- defined(__arm__) || defined(__aarch64__) || \
- defined(__sh__) || defined(__m32r__) || \
- (defined(__sun) && defined(_IEEE_754)) || \
- defined(__alpha__)
-#define USE_IEEE
#define IEEE_ONE 0x3f800000
-#endif
-
/**
* START/END_FAST_MATH macros:
@@ -433,30 +351,6 @@ do { \
#endif
#ifdef __cplusplus
-/**
- * Macro function that evaluates to true if T is a trivially
- * destructible type -- that is, if its (non-virtual) destructor
- * performs no action and all member variables and base classes are
- * trivially destructible themselves.
- */
-# if defined(__GNUC__)
-# if ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3)))
-# define HAS_TRIVIAL_DESTRUCTOR(T) __has_trivial_destructor(T)
-# endif
-# elif (defined(__clang__) && defined(__has_feature))
-# if __has_feature(has_trivial_destructor)
-# define HAS_TRIVIAL_DESTRUCTOR(T) __has_trivial_destructor(T)
-# endif
-# endif
-# ifndef HAS_TRIVIAL_DESTRUCTOR
- /* It's always safe (if inefficient) to assume that a
- * destructor is non-trivial.
- */
-# define HAS_TRIVIAL_DESTRUCTOR(T) (false)
-# endif
-#endif
-
-#ifdef __cplusplus
}
#endif
diff --git a/mesalib/src/mesa/main/copyimage.c b/mesalib/src/mesa/main/copyimage.c
new file mode 100644
index 000000000..dcbc83de6
--- /dev/null
+++ b/mesalib/src/mesa/main/copyimage.c
@@ -0,0 +1,356 @@
+/*
+ * Mesa 3-D graphics library
+ *
+ * Copyright (C) 2014 Intel Corporation. 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 shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ * Jason Ekstrand <jason.ekstrand@intel.com>
+ */
+
+#include "glheader.h"
+#include "errors.h"
+#include "enums.h"
+#include "copyimage.h"
+#include "teximage.h"
+#include "texobj.h"
+#include "fbobject.h"
+#include "textureview.h"
+
+static bool
+prepare_target(struct gl_context *ctx, GLuint name, GLenum *target, int level,
+ struct gl_texture_object **tex_obj,
+ struct gl_texture_image **tex_image, GLuint *tmp_tex,
+ const char *dbg_prefix)
+{
+ struct gl_renderbuffer *rb;
+
+ if (name == 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glCopyImageSubData(%sName = %d)", dbg_prefix, name);
+ return false;
+ }
+
+ /*
+ * INVALID_ENUM is generated
+ * * if either <srcTarget> or <dstTarget>
+ * - is not RENDERBUFFER or a valid non-proxy texture target
+ * - is TEXTURE_BUFFER, or
+ * - is one of the cubemap face selectors described in table 3.17,
+ */
+ switch (*target) {
+ case GL_RENDERBUFFER:
+ /* Not a texture target, but valid */
+ case GL_TEXTURE_1D:
+ case GL_TEXTURE_1D_ARRAY:
+ case GL_TEXTURE_2D:
+ case GL_TEXTURE_3D:
+ case GL_TEXTURE_CUBE_MAP:
+ case GL_TEXTURE_RECTANGLE:
+ case GL_TEXTURE_2D_ARRAY:
+ case GL_TEXTURE_CUBE_MAP_ARRAY:
+ case GL_TEXTURE_2D_MULTISAMPLE:
+ case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
+ /* These are all valid */
+ break;
+ case GL_TEXTURE_EXTERNAL_OES:
+ /* Only exists in ES */
+ case GL_TEXTURE_BUFFER:
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glCopyImageSubData(%sTarget = %s)", dbg_prefix,
+ _mesa_lookup_enum_by_nr(*target));
+ return false;
+ }
+
+ if (*target == GL_RENDERBUFFER) {
+ rb = _mesa_lookup_renderbuffer(ctx, name);
+ if (!rb) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glCopyImageSubData(%sName = %u)", dbg_prefix, name);
+ return false;
+ }
+
+ if (!rb->Name) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glCopyImageSubData(%sName incomplete)", dbg_prefix);
+ return false;
+ }
+
+ if (level != 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glCopyImageSubData(%sLevel = %u)", dbg_prefix, level);
+ return false;
+ }
+
+ if (rb->NumSamples > 1)
+ *target = GL_TEXTURE_2D_MULTISAMPLE;
+ else
+ *target = GL_TEXTURE_2D;
+
+ *tmp_tex = 0;
+ _mesa_GenTextures(1, tmp_tex);
+ if (*tmp_tex == 0)
+ return false; /* Error already set by GenTextures */
+
+ _mesa_BindTexture(*target, *tmp_tex);
+ *tex_obj = _mesa_lookup_texture(ctx, *tmp_tex);
+ *tex_image = _mesa_get_tex_image(ctx, *tex_obj, *target, 0);
+
+ if (!ctx->Driver.BindRenderbufferTexImage(ctx, rb, *tex_image)) {
+ _mesa_problem(ctx, "Failed to create texture from renderbuffer");
+ return false;
+ }
+
+ if (ctx->Driver.FinishRenderTexture && !rb->NeedsFinishRenderTexture) {
+ rb->NeedsFinishRenderTexture = true;
+ ctx->Driver.FinishRenderTexture(ctx, rb);
+ }
+ } else {
+ *tex_obj = _mesa_lookup_texture(ctx, name);
+ if (!*tex_obj) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glCopyImageSubData(%sName = %u)", dbg_prefix, name);
+ return false;
+ }
+
+ _mesa_test_texobj_completeness(ctx, *tex_obj);
+ if (!(*tex_obj)->_BaseComplete ||
+ (level != 0 && !(*tex_obj)->_MipmapComplete)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glCopyImageSubData(%sName incomplete)", dbg_prefix);
+ return false;
+ }
+
+ if ((*tex_obj)->Target != *target) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glCopyImageSubData(%sTarget = %s)", dbg_prefix,
+ _mesa_lookup_enum_by_nr(*target));
+ return false;
+ }
+
+ if (level < 0 || level >= MAX_TEXTURE_LEVELS) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glCopyImageSubData(%sLevel = %d)", dbg_prefix, level);
+ return false;
+ }
+
+ *tex_image = _mesa_select_tex_image(ctx, *tex_obj, *target, level);
+ if (!*tex_image) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glCopyImageSubData(%sLevel = %u)", dbg_prefix, level);
+ return false;
+ }
+ }
+
+ return true;
+}
+
+static bool
+check_region_bounds(struct gl_context *ctx, struct gl_texture_image *tex_image,
+ int x, int y, int z, int width, int height, int depth,
+ const char *dbg_prefix)
+{
+ if (width < 0 || height < 0 || depth < 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glCopyImageSubData(%sWidth, %sHeight, or %sDepth is negative)",
+ dbg_prefix, dbg_prefix, dbg_prefix);
+ return false;
+ }
+
+ if (x < 0 || y < 0 || z < 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glCopyImageSubData(%sX, %sY, or %sZ is negative)",
+ dbg_prefix, dbg_prefix, dbg_prefix);
+ return false;
+ }
+
+ if (x + width > tex_image->Width) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glCopyImageSubData(%sX or %sWidth exceeds image bounds)",
+ dbg_prefix, dbg_prefix);
+ return false;
+ }
+
+ switch (tex_image->TexObject->Target) {
+ case GL_TEXTURE_1D:
+ case GL_TEXTURE_1D_ARRAY:
+ if (y != 0 || height != 1) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glCopyImageSubData(%sY or %sHeight exceeds image bounds)",
+ dbg_prefix, dbg_prefix);
+ return false;
+ }
+ break;
+ default:
+ if (y + height > tex_image->Height) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glCopyImageSubData(%sY or %sHeight exceeds image bounds)",
+ dbg_prefix, dbg_prefix);
+ return false;
+ }
+ break;
+ }
+
+ switch (tex_image->TexObject->Target) {
+ case GL_TEXTURE_1D:
+ case GL_TEXTURE_2D:
+ case GL_TEXTURE_2D_MULTISAMPLE:
+ case GL_TEXTURE_RECTANGLE:
+ if (z != 0 || depth != 1) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glCopyImageSubData(%sZ or %sDepth exceeds image bounds)",
+ dbg_prefix, dbg_prefix);
+ return false;
+ }
+ break;
+ case GL_TEXTURE_CUBE_MAP:
+ if (z < 0 || z + depth > 6) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glCopyImageSubData(%sZ or %sDepth exceeds image bounds)",
+ dbg_prefix, dbg_prefix);
+ return false;
+ }
+ break;
+ case GL_TEXTURE_1D_ARRAY:
+ if (z < 0 || z + depth > tex_image->Height) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glCopyImageSubData(%sZ or %sDepth exceeds image bounds)",
+ dbg_prefix, dbg_prefix);
+ return false;
+ }
+ break;
+ case GL_TEXTURE_CUBE_MAP_ARRAY:
+ case GL_TEXTURE_2D_ARRAY:
+ case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
+ case GL_TEXTURE_3D:
+ if (z < 0 || z + depth > tex_image->Depth) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glCopyImageSubData(%sZ or %sDepth exceeds image bounds)",
+ dbg_prefix, dbg_prefix);
+ return false;
+ }
+ break;
+ }
+
+ return true;
+}
+
+void GLAPIENTRY
+_mesa_CopyImageSubData(GLuint srcName, GLenum srcTarget, GLint srcLevel,
+ GLint srcX, GLint srcY, GLint srcZ,
+ GLuint dstName, GLenum dstTarget, GLint dstLevel,
+ GLint dstX, GLint dstY, GLint dstZ,
+ GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLuint tmpTexNames[2] = { 0, 0 };
+ struct gl_texture_object *srcTexObj, *dstTexObj;
+ struct gl_texture_image *srcTexImage, *dstTexImage;
+ GLuint src_bw, src_bh, dst_bw, dst_bh;
+ int i, srcNewZ, dstNewZ, Bpt;
+
+ if (MESA_VERBOSE & VERBOSE_API)
+ _mesa_debug(ctx, "glCopyImageSubData(%u, %s, %d, %d, %d, %d, "
+ "%u, %s, %d, %d, %d, %d, "
+ "%d, %d, %d)\n",
+ srcName, _mesa_lookup_enum_by_nr(srcTarget), srcLevel,
+ srcX, srcY, srcZ,
+ dstName, _mesa_lookup_enum_by_nr(dstTarget), dstLevel,
+ dstX, dstY, dstZ,
+ srcWidth, srcHeight, srcWidth);
+
+ if (!prepare_target(ctx, srcName, &srcTarget, srcLevel,
+ &srcTexObj, &srcTexImage, &tmpTexNames[0], "src"))
+ goto cleanup;
+
+ if (!prepare_target(ctx, dstName, &dstTarget, dstLevel,
+ &dstTexObj, &dstTexImage, &tmpTexNames[1], "dst"))
+ goto cleanup;
+
+ _mesa_get_format_block_size(srcTexImage->TexFormat, &src_bw, &src_bh);
+ if ((srcX % src_bw != 0) || (srcY % src_bh != 0) ||
+ (srcWidth % src_bw != 0) || (srcHeight % src_bh != 0)) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glCopyImageSubData(unaligned src rectangle)");
+ goto cleanup;
+ }
+
+ _mesa_get_format_block_size(dstTexImage->TexFormat, &dst_bw, &dst_bh);
+ if ((dstX % dst_bw != 0) || (dstY % dst_bh != 0)) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glCopyImageSubData(unaligned dst rectangle)");
+ goto cleanup;
+ }
+
+ /* Very simple sanity check. This is sufficient if one of the textures
+ * is compressed. */
+ Bpt = _mesa_get_format_bytes(srcTexImage->TexFormat);
+ if (_mesa_get_format_bytes(dstTexImage->TexFormat) != Bpt) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glCopyImageSubData(internalFormat mismatch)");
+ goto cleanup;
+ }
+
+ if (!check_region_bounds(ctx, srcTexImage, srcX, srcY, srcZ,
+ srcWidth, srcHeight, srcDepth, "src"))
+ goto cleanup;
+
+ if (!check_region_bounds(ctx, dstTexImage, dstX, dstY, dstZ,
+ (srcWidth / src_bw) * dst_bw,
+ (srcHeight / src_bh) * dst_bh, srcDepth, "dst"))
+ goto cleanup;
+
+ if (_mesa_is_format_compressed(srcTexImage->TexFormat)) {
+ /* XXX: Technically, we should probaby do some more specific checking
+ * here. However, this should be sufficient for all compressed
+ * formats that mesa supports since it is a direct memory copy.
+ */
+ } else if (_mesa_is_format_compressed(dstTexImage->TexFormat)) {
+ } else if (_mesa_texture_view_compatible_format(ctx,
+ srcTexImage->InternalFormat,
+ dstTexImage->InternalFormat)) {
+ } else {
+ return; /* Error loged by _mesa_texture_view_compatible_format */
+ }
+
+ for (i = 0; i < srcDepth; ++i) {
+ if (srcTexObj->Target == GL_TEXTURE_CUBE_MAP) {
+ srcTexImage = srcTexObj->Image[i + srcZ][srcLevel];
+ srcNewZ = 0;
+ } else {
+ srcNewZ = srcZ + i;
+ }
+
+ if (dstTexObj->Target == GL_TEXTURE_CUBE_MAP) {
+ dstTexImage = dstTexObj->Image[i + dstZ][dstLevel];
+ dstNewZ = 0;
+ } else {
+ dstNewZ = dstZ + i;
+ }
+
+ ctx->Driver.CopyImageSubData(ctx, srcTexImage, srcX, srcY, srcNewZ,
+ dstTexImage, dstX, dstY, dstNewZ,
+ srcWidth, srcHeight);
+ }
+
+cleanup:
+ _mesa_DeleteTextures(2, tmpTexNames);
+}
diff --git a/mesalib/src/mesa/main/copyimage.h b/mesalib/src/mesa/main/copyimage.h
new file mode 100644
index 000000000..40e95b663
--- /dev/null
+++ b/mesalib/src/mesa/main/copyimage.h
@@ -0,0 +1,49 @@
+/*
+ * Mesa 3-D graphics library
+ *
+ * Copyright (C) 2014 Intel Corporation. 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 shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ * Jason Ekstrand <jason.ekstrand@intel.com>
+ */
+
+
+#ifndef COPYIMAGE_H
+#define COPYIMAGE_H
+
+#include "mtypes.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern void GLAPIENTRY
+_mesa_CopyImageSubData(GLuint srcName, GLenum srcTarget, GLint srcLevel,
+ GLint srcX, GLint srcY, GLint srcZ,
+ GLuint destName, GLenum destTarget, GLint destLevel,
+ GLint destX, GLint destY, GLint destZ,
+ GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* COPYIMAGE_H */
diff --git a/mesalib/src/mesa/main/dd.h b/mesalib/src/mesa/main/dd.h
index 89765351e..c130b14a5 100644
--- a/mesalib/src/mesa/main/dd.h
+++ b/mesalib/src/mesa/main/dd.h
@@ -269,6 +269,22 @@ struct dd_function_table {
GLsizei width, GLsizei height);
/**
+ * Called by glCopyImageSubData().
+ *
+ * This function should copy one 2-D slice from srcTexImage to
+ * dstTexImage. If one of the textures is 3-D or is a 1-D or 2-D array
+ * texture, this function will be called multiple times: once for each
+ * slice. If one of the textures is a cube map, this function will be
+ * called once for each face to be copied.
+ */
+ void (*CopyImageSubData)(struct gl_context *ctx,
+ struct gl_texture_image *src_image,
+ int src_x, int src_y, int src_z,
+ struct gl_texture_image *dstTexImage,
+ int dst_x, int dst_y, int dst_z,
+ int src_width, int src_height);
+
+ /**
* Called by glGenerateMipmap() or when GL_GENERATE_MIPMAP_SGIS is enabled.
* Note that if the texture is a cube map, the <target> parameter will
* indicate which cube face to generate (GL_POSITIVE/NEGATIVE_X/Y/Z).
diff --git a/mesalib/src/mesa/main/enable.c b/mesalib/src/mesa/main/enable.c
index 0f3bcf0a9..417548a3c 100644
--- a/mesalib/src/mesa/main/enable.c
+++ b/mesalib/src/mesa/main/enable.c
@@ -313,7 +313,7 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state)
}
}
break;
- case GL_CLIP_DISTANCE0:
+ case GL_CLIP_DISTANCE0: /* aka GL_CLIP_PLANE0 */
case GL_CLIP_DISTANCE1:
case GL_CLIP_DISTANCE2:
case GL_CLIP_DISTANCE3:
@@ -1202,7 +1202,7 @@ _mesa_IsEnabled( GLenum cap )
return ctx->Eval.AutoNormal;
case GL_BLEND:
return ctx->Color.BlendEnabled & 1; /* return state for buffer[0] */
- case GL_CLIP_DISTANCE0:
+ case GL_CLIP_DISTANCE0: /* aka GL_CLIP_PLANE0 */
case GL_CLIP_DISTANCE1:
case GL_CLIP_DISTANCE2:
case GL_CLIP_DISTANCE3:
diff --git a/mesalib/src/mesa/main/errors.c b/mesalib/src/mesa/main/errors.c
index aa0ff50ac..9cde1e020 100644
--- a/mesalib/src/mesa/main/errors.c
+++ b/mesalib/src/mesa/main/errors.c
@@ -36,7 +36,7 @@
#include "hash.h"
#include "mtypes.h"
#include "version.h"
-#include "hash_table.h"
+#include "util/hash_table.h"
static mtx_t DynamicIDMutex = _MTX_INITIALIZER_NP;
static GLuint NextDynamicID = 1;
diff --git a/mesalib/src/mesa/main/extensions.c b/mesalib/src/mesa/main/extensions.c
index 9ac8377a4..d60838a1c 100644
--- a/mesalib/src/mesa/main/extensions.c
+++ b/mesalib/src/mesa/main/extensions.c
@@ -95,6 +95,7 @@ static const struct extension extension_table[] = {
{ "GL_ARB_compressed_texture_pixel_storage", o(dummy_true), GL, 2011 },
{ "GL_ARB_compute_shader", o(ARB_compute_shader), GL, 2012 },
{ "GL_ARB_copy_buffer", o(dummy_true), GL, 2008 },
+ { "GL_ARB_copy_image", o(ARB_copy_image), GL, 2012 },
{ "GL_ARB_conservative_depth", o(ARB_conservative_depth), GL, 2011 },
{ "GL_ARB_debug_output", o(dummy_true), GL, 2009 },
{ "GL_ARB_depth_buffer_float", o(ARB_depth_buffer_float), GL, 2008 },
diff --git a/mesalib/src/mesa/main/format_info.py b/mesalib/src/mesa/main/format_info.py
new file mode 100644
index 000000000..448bd0055
--- /dev/null
+++ b/mesalib/src/mesa/main/format_info.py
@@ -0,0 +1,192 @@
+#!/usr/bin/env python
+#
+# 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, sub license, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice (including the
+# next paragraph) shall be included in all copies or substantial portions
+# of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+# IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
+# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+import format_parser as parser
+import sys
+
+def get_gl_base_format(fmat):
+ if fmat.name == 'MESA_FORMAT_NONE':
+ return 'GL_NONE'
+ elif fmat.name in ['MESA_FORMAT_YCBCR', 'MESA_FORMAT_YCBCR_REV']:
+ return 'GL_YCBCR_MESA'
+ elif fmat.has_channel('r'):
+ if fmat.has_channel('g'):
+ if fmat.has_channel('b'):
+ if fmat.has_channel('a'):
+ return 'GL_RGBA'
+ else:
+ return 'GL_RGB'
+ else:
+ return 'GL_RG'
+ else:
+ return 'GL_RED'
+ elif fmat.has_channel('l'):
+ if fmat.has_channel('a'):
+ return 'GL_LUMINANCE_ALPHA'
+ else:
+ return 'GL_LUMINANCE'
+ elif fmat.has_channel('a') and fmat.num_channels() == 1:
+ return 'GL_ALPHA'
+ elif fmat.has_channel('z'):
+ if fmat.has_channel('s'):
+ return 'GL_DEPTH_STENCIL'
+ else:
+ return 'GL_DEPTH_COMPONENT'
+ elif fmat.has_channel('s'):
+ return 'GL_STENCIL_INDEX'
+ elif fmat.has_channel('i') and fmat.num_channels() == 1:
+ return 'GL_INTENSITY'
+ else:
+ assert False
+
+def get_gl_data_type(fmat):
+ if fmat.is_compressed():
+ if 'SIGNED' in fmat.name or 'SNORM' in fmat.name:
+ return 'GL_SIGNED_NORMALIZED'
+ else:
+ return 'GL_UNSIGNED_NORMALIZED'
+ elif fmat.name in ['MESA_FORMAT_YCBCR', 'MESA_FORMAT_YCBCR_REV']:
+ return 'GL_UNSIGNED_NORMALIZED'
+
+ channel = None
+ for chan in fmat.channels:
+ if chan.type == 'x' and len(fmat.channels) > 1:
+ continue # We can do better
+ elif chan.name == 's' and fmat.has_channel('z'):
+ continue # We'll use the type from the depth instead
+
+ channel = chan
+ break;
+
+ if channel.type == parser.UNSIGNED:
+ if channel.norm:
+ return 'GL_UNSIGNED_NORMALIZED'
+ else:
+ return 'GL_UNSIGNED_INT'
+ elif channel.type == parser.SIGNED:
+ if channel.norm:
+ return 'GL_SIGNED_NORMALIZED'
+ else:
+ return 'GL_INT'
+ elif channel.type == parser.FLOAT:
+ return 'GL_FLOAT'
+ elif channel.type == parser.VOID:
+ return 'GL_NONE'
+ else:
+ assert False
+
+def get_mesa_layout(fmat):
+ if fmat.layout == 'array':
+ return 'MESA_FORMAT_LAYOUT_ARRAY'
+ elif fmat.layout == 'packed':
+ return 'MESA_FORMAT_LAYOUT_PACKED'
+ else:
+ return 'MESA_FORMAT_LAYOUT_OTHER'
+
+def get_channel_bits(fmat, chan_name):
+ if fmat.is_compressed():
+ # These values are pretty-much bogus, but OpenGL requires that we
+ # return an "approximate" number of bits.
+ if fmat.layout == 's3tc':
+ return 4 if fmat.has_channel(chan_name) else 0
+ elif fmat.layout == 'fxt1':
+ if chan_name in 'rgb':
+ return 4
+ elif chan_name == 'a':
+ return 1 if fmat.has_channel('a') else 0
+ else:
+ return 0
+ elif fmat.layout == 'rgtc':
+ return 8 if fmat.has_channel(chan_name) else 0
+ elif fmat.layout in ('etc1', 'etc2'):
+ if fmat.name.endswith('_ALPHA1') and chan_name == 'a':
+ return 1
+
+ bits = 11 if fmat.name.endswith('11_EAC') else 8
+ return bits if fmat.has_channel(chan_name) else 0
+ else:
+ assert False
+ else:
+ # Uncompressed textures
+ for chan in fmat.channels:
+ if chan.name == chan_name:
+ return chan.size
+ return 0
+
+formats = parser.parse(sys.argv[1])
+
+print '''
+/*
+ * Mesa 3-D graphics library
+ *
+ * Copyright (c) 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 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.
+ */
+
+ /*
+ * This file is AUTOGENERATED by format_info.py. Do not edit it
+ * manually or commit it into version control.
+ */
+
+static struct gl_format_info format_info[MESA_FORMAT_COUNT] =
+{
+'''
+
+for fmat in formats:
+ print ' {'
+ print ' {0},'.format(fmat.name)
+ print ' "{0}",'.format(fmat.name)
+ print ' {0},'.format(get_mesa_layout(fmat))
+ print ' {0},'.format(get_gl_base_format(fmat))
+ print ' {0},'.format(get_gl_data_type(fmat))
+
+ bits = [ get_channel_bits(fmat, name) for name in ['r', 'g', 'b', 'a']]
+ print ' {0},'.format(', '.join(map(str, bits)))
+ bits = [ get_channel_bits(fmat, name) for name in ['l', 'i', 'z', 's']]
+ print ' {0},'.format(', '.join(map(str, bits)))
+
+ print ' {0}, {1}, {2},'.format(fmat.block_width, fmat.block_height,
+ int(fmat.block_size() / 8))
+
+ print ' {{ {0} }},'.format(', '.join(map(str, fmat.swizzle)))
+ print ' },'
+
+print '};'
diff --git a/mesalib/src/mesa/main/format_pack.c b/mesalib/src/mesa/main/format_pack.c
index c97c05297..6cbf8593b 100644
--- a/mesalib/src/mesa/main/format_pack.c
+++ b/mesalib/src/mesa/main/format_pack.c
@@ -41,6 +41,7 @@
#include "macros.h"
#include "../../gallium/auxiliary/util/u_format_rgb9e5.h"
#include "../../gallium/auxiliary/util/u_format_r11g11b10f.h"
+#include "util/format_srgb.h"
/** Helper struct for MESA_FORMAT_Z32_FLOAT_S8X24_UINT */
@@ -58,39 +59,6 @@ typedef void (*pack_float_rgba_row_func)(GLuint n,
const GLfloat src[][4], void *dst);
-
-static inline GLfloat
-linear_to_srgb(GLfloat cl)
-{
- if (cl < 0.0f)
- return 0.0f;
- else if (cl < 0.0031308f)
- return 12.92f * cl;
- else if (cl < 1.0f)
- return 1.055f * powf(cl, 0.41666f) - 0.055f;
- else
- return 1.0f;
-}
-
-
-static inline GLubyte
-linear_float_to_srgb_ubyte(GLfloat cl)
-{
- GLubyte res = FLOAT_TO_UBYTE(linear_to_srgb(cl));
- return res;
-}
-
-
-static inline GLubyte
-linear_ubyte_to_srgb_ubyte(GLubyte cl)
-{
- GLubyte res = FLOAT_TO_UBYTE(linear_to_srgb(cl / 255.0f));
- return res;
-}
-
-
-
-
/*
* MESA_FORMAT_A8B8G8R8_UNORM
*/
@@ -1043,18 +1011,18 @@ static void
pack_ubyte_BGR_SRGB8(const GLubyte src[4], void *dst)
{
GLubyte *d = ((GLubyte *) dst);
- d[2] = linear_ubyte_to_srgb_ubyte(src[RCOMP]);
- d[1] = linear_ubyte_to_srgb_ubyte(src[GCOMP]);
- d[0] = linear_ubyte_to_srgb_ubyte(src[BCOMP]);
+ d[2] = util_format_linear_to_srgb_8unorm(src[RCOMP]);
+ d[1] = util_format_linear_to_srgb_8unorm(src[GCOMP]);
+ d[0] = util_format_linear_to_srgb_8unorm(src[BCOMP]);
}
static void
pack_float_BGR_SRGB8(const GLfloat src[4], void *dst)
{
GLubyte *d = ((GLubyte *) dst);
- d[2] = linear_float_to_srgb_ubyte(src[RCOMP]);
- d[1] = linear_float_to_srgb_ubyte(src[GCOMP]);
- d[0] = linear_float_to_srgb_ubyte(src[BCOMP]);
+ d[2] = util_format_linear_float_to_srgb_8unorm(src[RCOMP]);
+ d[1] = util_format_linear_float_to_srgb_8unorm(src[GCOMP]);
+ d[0] = util_format_linear_float_to_srgb_8unorm(src[BCOMP]);
}
@@ -1064,9 +1032,9 @@ static void
pack_ubyte_A8B8G8R8_SRGB(const GLubyte src[4], void *dst)
{
GLuint *d = ((GLuint *) dst);
- GLubyte r = linear_ubyte_to_srgb_ubyte(src[RCOMP]);
- GLubyte g = linear_ubyte_to_srgb_ubyte(src[GCOMP]);
- GLubyte b = linear_ubyte_to_srgb_ubyte(src[BCOMP]);
+ 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(r, g, b, src[ACOMP]);
}
@@ -1075,9 +1043,9 @@ pack_float_A8B8G8R8_SRGB(const GLfloat src[4], void *dst)
{
GLuint *d = ((GLuint *) dst);
GLubyte r, g, b, a;
- r = linear_float_to_srgb_ubyte(src[RCOMP]);
- g = linear_float_to_srgb_ubyte(src[GCOMP]);
- b = linear_float_to_srgb_ubyte(src[BCOMP]);
+ 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(r, g, b, a);
}
@@ -1089,9 +1057,9 @@ static void
pack_ubyte_B8G8R8A8_SRGB(const GLubyte src[4], void *dst)
{
GLuint *d = ((GLuint *) dst);
- GLubyte r = linear_ubyte_to_srgb_ubyte(src[RCOMP]);
- GLubyte g = linear_ubyte_to_srgb_ubyte(src[GCOMP]);
- GLubyte b = linear_ubyte_to_srgb_ubyte(src[BCOMP]);
+ 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(src[ACOMP], r, g, b);
}
@@ -1100,9 +1068,9 @@ pack_float_B8G8R8A8_SRGB(const GLfloat src[4], void *dst)
{
GLuint *d = ((GLuint *) dst);
GLubyte r, g, b, a;
- r = linear_float_to_srgb_ubyte(src[RCOMP]);
- g = linear_float_to_srgb_ubyte(src[GCOMP]);
- b = linear_float_to_srgb_ubyte(src[BCOMP]);
+ 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(a, r, g, b);
}
@@ -1114,9 +1082,9 @@ static void
pack_ubyte_R8G8B8A8_SRGB(const GLubyte src[4], void *dst)
{
GLuint *d = ((GLuint *) dst);
- GLubyte r = linear_ubyte_to_srgb_ubyte(src[RCOMP]);
- GLubyte g = linear_ubyte_to_srgb_ubyte(src[GCOMP]);
- GLubyte b = linear_ubyte_to_srgb_ubyte(src[BCOMP]);
+ 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(src[ACOMP], b, g, r);
}
@@ -1125,9 +1093,9 @@ pack_float_R8G8B8A8_SRGB(const GLfloat src[4], void *dst)
{
GLuint *d = ((GLuint *) dst);
GLubyte r, g, b, a;
- r = linear_float_to_srgb_ubyte(src[RCOMP]);
- g = linear_float_to_srgb_ubyte(src[GCOMP]);
- b = linear_float_to_srgb_ubyte(src[BCOMP]);
+ 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(a, b, g, r);
}
@@ -1139,14 +1107,14 @@ static void
pack_ubyte_L_SRGB8(const GLubyte src[4], void *dst)
{
GLubyte *d = ((GLubyte *) dst);
- *d = linear_ubyte_to_srgb_ubyte(src[RCOMP]);
+ *d = util_format_linear_to_srgb_8unorm(src[RCOMP]);
}
static void
pack_float_L_SRGB8(const GLfloat src[4], void *dst)
{
GLubyte *d = ((GLubyte *) dst);
- GLubyte l = linear_float_to_srgb_ubyte(src[RCOMP]);
+ GLubyte l = util_format_linear_float_to_srgb_8unorm(src[RCOMP]);
*d = l;
}
@@ -1157,7 +1125,7 @@ static void
pack_ubyte_L8A8_SRGB(const GLubyte src[4], void *dst)
{
GLushort *d = ((GLushort *) dst);
- GLubyte l = linear_ubyte_to_srgb_ubyte(src[RCOMP]);
+ GLubyte l = util_format_linear_to_srgb_8unorm(src[RCOMP]);
*d = PACK_COLOR_88(src[ACOMP], l);
}
@@ -1165,7 +1133,7 @@ static void
pack_float_L8A8_SRGB(const GLfloat src[4], void *dst)
{
GLushort *d = ((GLushort *) dst);
- GLubyte a, l = linear_float_to_srgb_ubyte(src[RCOMP]);
+ GLubyte a, l = util_format_linear_float_to_srgb_8unorm(src[RCOMP]);
CLAMPED_FLOAT_TO_UBYTE(a, src[ACOMP]);
*d = PACK_COLOR_88(a, l);
}
@@ -1742,9 +1710,9 @@ static void
pack_float_R8G8B8X8_SRGB(const GLfloat src[4], void *dst)
{
GLuint *d = (GLuint *) dst;
- GLubyte r = linear_float_to_srgb_ubyte(src[RCOMP]);
- GLubyte g = linear_float_to_srgb_ubyte(src[GCOMP]);
- GLubyte b = linear_float_to_srgb_ubyte(src[BCOMP]);
+ 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);
}
@@ -1892,9 +1860,9 @@ static void
pack_float_B8G8R8X8_SRGB(const GLfloat src[4], void *dst)
{
GLuint *d = (GLuint *) dst;
- GLubyte r = linear_float_to_srgb_ubyte(src[RCOMP]);
- GLubyte g = linear_float_to_srgb_ubyte(src[GCOMP]);
- GLubyte b = linear_float_to_srgb_ubyte(src[BCOMP]);
+ 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, r, g, b);
}
diff --git a/mesalib/src/mesa/main/format_parser.py b/mesalib/src/mesa/main/format_parser.py
new file mode 100644
index 000000000..5e45c74de
--- /dev/null
+++ b/mesalib/src/mesa/main/format_parser.py
@@ -0,0 +1,521 @@
+#!/usr/bin/env python
+#
+# Copyright 2009 VMware, Inc.
+# Copyright 2014 Intel Corporation
+# All Rights Reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sub license, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice (including the
+# next paragraph) shall be included in all copies or substantial portions
+# of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+# IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
+# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+VOID = 'x'
+UNSIGNED = 'u'
+SIGNED = 's'
+FLOAT = 'f'
+
+ARRAY = 'array'
+PACKED = 'packed'
+OTHER = 'other'
+
+RGB = 'rgb'
+SRGB = 'srgb'
+YUV = 'yuv'
+ZS = 'zs'
+
+def is_power_of_two(x):
+ return not bool(x & (x - 1))
+
+VERY_LARGE = 99999999999999999999999
+
+class Channel:
+ """Describes a color channel."""
+
+ def __init__(self, type, norm, size):
+ self.type = type
+ self.norm = norm
+ self.size = size
+ self.sign = type in (SIGNED, FLOAT)
+ self.name = None # Set when the channels are added to the format
+ self.shift = -1 # Set when the channels are added to the format
+ self.index = -1 # Set when the channels are added to the format
+
+ def __str__(self):
+ s = str(self.type)
+ if self.norm:
+ s += 'n'
+ s += str(self.size)
+ return s
+
+ def __eq__(self, other):
+ return self.type == other.type and self.norm == other.norm and self.size == other.size
+
+ def max(self):
+ """Returns the maximum representable number."""
+ if self.type == FLOAT:
+ return VERY_LARGE
+ if self.norm:
+ return 1
+ if self.type == UNSIGNED:
+ return (1 << self.size) - 1
+ if self.type == SIGNED:
+ return (1 << (self.size - 1)) - 1
+ assert False
+
+ def min(self):
+ """Returns the minimum representable number."""
+ if self.type == FLOAT:
+ return -VERY_LARGE
+ if self.type == UNSIGNED:
+ return 0
+ if self.norm:
+ return -1
+ if self.type == SIGNED:
+ return -(1 << (self.size - 1))
+ assert False
+
+ def one(self):
+ """Returns the value that represents 1.0f."""
+ if self.type == UNSIGNED:
+ return (1 << self.size) - 1
+ if self.type == SIGNED:
+ return (1 << (self.size - 1)) - 1
+ else:
+ return 1
+
+ def is_power_of_two(self):
+ """Returns true if the size of this channel is a power of two."""
+ return is_power_of_two(self.size)
+
+class Swizzle:
+ """Describes a swizzle operation.
+
+ A Swizzle is a mapping from one set of channels in one format to the
+ channels in another. Each channel in the destination format is
+ associated with one of the following constants:
+
+ * SWIZZLE_X: The first channel in the source format
+ * SWIZZLE_Y: The second channel in the source format
+ * SWIZZLE_Z: The third channel in the source format
+ * SWIZZLE_W: The fourth channel in the source format
+ * SWIZZLE_ZERO: The numeric constant 0
+ * SWIZZLE_ONE: THe numeric constant 1
+ * SWIZZLE_NONE: No data available for this channel
+
+ Sometimes a Swizzle is represented by a 4-character string. In this
+ case, the source channels are represented by the characters "x", "y",
+ "z", and "w"; the numeric constants are represented as "0" and "1"; and
+ no mapping is represented by "_". For instance, the map from
+ luminance-alpha to rgba is given by "xxxy" because each of the three rgb
+ channels maps to the first luminance-alpha channel and the alpha channel
+ maps to second luminance-alpha channel. The mapping from bgr to rgba is
+ given by "zyx1" because the first three colors are reversed and alpha is
+ always 1.
+ """
+
+ __identity_str = 'xyzw01_'
+
+ SWIZZLE_X = 0
+ SWIZZLE_Y = 1
+ SWIZZLE_Z = 2
+ SWIZZLE_W = 3
+ SWIZZLE_ZERO = 4
+ SWIZZLE_ONE = 5
+ SWIZZLE_NONE = 6
+
+ def __init__(self, swizzle):
+ """Creates a Swizzle object from a string or array."""
+ if isinstance(swizzle, str):
+ swizzle = [Swizzle.__identity_str.index(c) for c in swizzle]
+ else:
+ swizzle = list(swizzle)
+ for s in swizzle:
+ assert isinstance(s, int) and 0 <= s and s <= Swizzle.SWIZZLE_NONE
+
+ assert len(swizzle) <= 4
+
+ self.__list = swizzle + [Swizzle.SWIZZLE_NONE] * (4 - len(swizzle))
+ assert len(self.__list) == 4
+
+ def __iter__(self):
+ """Returns an iterator that iterates over this Swizzle.
+
+ The values that the iterator produces are described by the SWIZZLE_*
+ constants.
+ """
+ return self.__list.__iter__()
+
+ def __str__(self):
+ """Returns a string representation of this Swizzle."""
+ return ''.join(Swizzle.__identity_str[i] for i in self.__list)
+
+ def __getitem__(self, idx):
+ """Returns the SWIZZLE_* constant for the given destination channel.
+
+ Valid values for the destination channel include any of the SWIZZLE_*
+ constants or any of the following single-character strings: "x", "y",
+ "z", "w", "r", "g", "b", "a", "z" "s".
+ """
+
+ if isinstance(idx, int):
+ assert idx >= Swizzle.SWIZZLE_X and idx <= Swizzle.SWIZZLE_NONE
+ if idx <= Swizzle.SWIZZLE_W:
+ return self.__list.__getitem__(idx)
+ else:
+ return idx
+ elif isinstance(idx, str):
+ if idx in 'xyzw':
+ idx = 'xyzw'.find(idx)
+ elif idx in 'rgba':
+ idx = 'rgba'.find(idx)
+ elif idx in 'zs':
+ idx = 'zs'.find(idx)
+ else:
+ assert False
+ return self.__list.__getitem__(idx)
+ else:
+ assert False
+
+ def __mul__(self, other):
+ """Returns the composition of this Swizzle with another Swizzle.
+
+ The resulting swizzle is such that, for any valid input to
+ __getitem__, (a * b)[i] = a[b[i]].
+ """
+ assert isinstance(other, Swizzle)
+ return Swizzle(self[x] for x in other)
+
+ def inverse(self):
+ """Returns a pseudo-inverse of this swizzle.
+
+ Since swizzling isn't necisaraly a bijection, a Swizzle can never
+ be truely inverted. However, the swizzle returned is *almost* the
+ inverse of this swizzle in the sense that, for each i in range(3),
+ a[a.inverse()[i]] is either i or SWIZZLE_NONE. If swizzle is just
+ a permutation with no channels added or removed, then this
+ function returns the actual inverse.
+
+ This "pseudo-inverse" idea can be demonstrated by mapping from
+ luminance-alpha to rgba that is given by "xxxy". To get from rgba
+ to lumanence-alpha, we use Swizzle("xxxy").inverse() or "xw__".
+ This maps the first component in the lumanence-alpha texture is
+ the red component of the rgba image and the second to the alpha
+ component, exactly as you would expect.
+ """
+ rev = [Swizzle.SWIZZLE_NONE] * 4
+ for i in xrange(4):
+ for j in xrange(4):
+ if self.__list[j] == i and rev[i] == Swizzle.SWIZZLE_NONE:
+ rev[i] = j
+ return Swizzle(rev)
+
+
+class Format:
+ """Describes a pixel format."""
+
+ def __init__(self, name, layout, block_width, block_height, channels, swizzle, colorspace):
+ """Constructs a Format from some metadata and a list of channels.
+
+ The channel objects must be unique to this Format and should not be
+ re-used to construct another Format. This is because certain channel
+ information such as shift, offset, and the channel name are set when
+ the Format is created and are calculated based on the entire list of
+ channels.
+
+ Arguments:
+ name -- Name of the format such as 'MESA_FORMAT_A8R8G8B8'
+ layout -- One of 'array', 'packed' 'other', or a compressed layout
+ block_width -- The block width if the format is compressed, 1 otherwise
+ block_height -- The block height if the format is compressed, 1 otherwise
+ channels -- A list of Channel objects
+ swizzle -- A Swizzle from this format to rgba
+ colorspace -- one of 'rgb', 'srgb', 'yuv', or 'zs'
+ """
+ self.name = name
+ self.layout = layout
+ self.block_width = block_width
+ self.block_height = block_height
+ self.channels = channels
+ assert isinstance(swizzle, Swizzle)
+ self.swizzle = swizzle
+ self.name = name
+ assert colorspace in (RGB, SRGB, YUV, ZS)
+ self.colorspace = colorspace
+
+ # Name the channels
+ chan_names = ['']*4
+ if self.colorspace in (RGB, SRGB):
+ for (i, s) in enumerate(swizzle):
+ if s < 4:
+ chan_names[s] += 'rgba'[i]
+ elif colorspace == ZS:
+ for (i, s) in enumerate(swizzle):
+ if s < 4:
+ chan_names[s] += 'zs'[i]
+ else:
+ chan_names = ['x', 'y', 'z', 'w']
+
+ for c, name in zip(self.channels, chan_names):
+ assert c.name is None
+ if name == 'rgb':
+ c.name = 'l'
+ elif name == 'rgba':
+ c.name = 'i'
+ elif name == '':
+ c.name = 'x'
+ else:
+ c.name = name
+
+ # Set indices and offsets
+ if self.layout == PACKED:
+ shift = 0
+ for channel in self.channels:
+ assert channel.shift == -1
+ channel.shift = shift
+ shift += channel.size
+ for idx, channel in enumerate(self.channels):
+ assert channel.index == -1
+ channel.index = idx
+ else:
+ pass # Shift means nothing here
+
+ def __str__(self):
+ return self.name
+
+ def short_name(self):
+ """Returns a short name for a format.
+
+ The short name should be suitable to be used as suffix in function
+ names.
+ """
+
+ name = self.name
+ if name.startswith('MESA_FORMAT_'):
+ name = name[len('MESA_FORMAT_'):]
+ name = name.lower()
+ return name
+
+ def block_size(self):
+ """Returns the block size (in bits) of the format."""
+ size = 0
+ for channel in self.channels:
+ size += channel.size
+ return size
+
+ def num_channels(self):
+ """Returns the number of channels in the format."""
+ nr_channels = 0
+ for channel in self.channels:
+ if channel.size:
+ nr_channels += 1
+ return nr_channels
+
+ def array_element(self):
+ """Returns a non-void channel if this format is an array, otherwise None.
+
+ If the returned channel is not None, then this format can be
+ considered to be an array of num_channels() channels identical to the
+ returned channel.
+ """
+ if self.layout == ARRAY:
+ return self.channels[0]
+ elif self.layout == PACKED:
+ ref_channel = self.channels[0]
+ if ref_channel.type == VOID:
+ ref_channel = self.channels[1]
+ for channel in self.channels:
+ if channel.size == 0 or channel.type == VOID:
+ continue
+ if channel.size != ref_channel.size or channel.size % 8 != 0:
+ return None
+ if channel.type != ref_channel.type:
+ return None
+ if channel.norm != ref_channel.norm:
+ return None
+ return ref_channel
+ else:
+ return None
+
+ def is_array(self):
+ """Returns true if this format can be considered an array format.
+
+ This function will return true if self.layout == 'array'. However,
+ some formats, such as MESA_FORMAT_A8G8B8R8, can be considered as
+ array formats even though they are technically packed.
+ """
+ return self.array_element() != None
+
+ def is_compressed(self):
+ """Returns true if this is a compressed format."""
+ return self.block_width != 1 or self.block_height != 1
+
+ def is_int(self):
+ """Returns true if this format is an integer format.
+
+ See also: is_norm()
+ """
+ if self.layout not in (ARRAY, PACKED):
+ return False
+ for channel in self.channels:
+ if channel.type not in (VOID, UNSIGNED, SIGNED):
+ return False
+ return True
+
+ def is_float(self):
+ """Returns true if this format is an floating-point format."""
+ if self.layout not in (ARRAY, PACKED):
+ return False
+ for channel in self.channels:
+ if channel.type not in (VOID, FLOAT):
+ return False
+ return True
+
+ def channel_type(self):
+ """Returns the type of the channels in this format."""
+ _type = VOID
+ for c in self.channels:
+ if c.type == VOID:
+ continue
+ if _type == VOID:
+ _type = c.type
+ assert c.type == _type
+ return _type
+
+ def channel_size(self):
+ """Returns the size (in bits) of the channels in this format.
+
+ This function should only be called if all of the channels have the
+ same size. This is always the case if is_array() returns true.
+ """
+ size = None
+ for c in self.channels:
+ if c.type == VOID:
+ continue
+ if size is None:
+ size = c.size
+ assert c.size == size
+ return size
+
+ def max_channel_size(self):
+ """Returns the size of the largest channel."""
+ size = 0
+ for c in self.channels:
+ if c.type == VOID:
+ continue
+ size = max(size, c.size)
+ return size
+
+ def is_normalized(self):
+ """Returns true if this format is normalized.
+
+ While only integer formats can be normalized, not all integer formats
+ are normalized. Normalized integer formats are those where the
+ integer value is re-interpreted as a fixed point value in the range
+ [0, 1].
+ """
+ norm = None
+ for c in self.channels:
+ if c.type == VOID:
+ continue
+ if norm is None:
+ norm = c.norm
+ assert c.norm == norm
+ return norm
+
+ def has_channel(self, name):
+ """Returns true if this format has the given channel."""
+ if self.is_compressed():
+ # Compressed formats are a bit tricky because the list of channels
+ # contains a single channel of type void. Since we don't have any
+ # channel information there, we pull it from the swizzle.
+ if str(self.swizzle) == 'xxxx':
+ return name == 'i'
+ elif str(self.swizzle)[0:3] in ('xxx', 'yyy'):
+ if name == 'l':
+ return True
+ elif name == 'a':
+ return self.swizzle['a'] <= Swizzle.SWIZZLE_W
+ else:
+ return False
+ elif name in 'rgba':
+ return self.swizzle[name] <= Swizzle.SWIZZLE_W
+ else:
+ return False
+ else:
+ for channel in self.channels:
+ if channel.name == name:
+ return True
+ return False
+
+ def get_channel(self, name):
+ """Returns the channel with the given name if it exists."""
+ for channel in self.channels:
+ if channel.name == name:
+ return channel
+ return None
+
+def _parse_channels(fields, layout, colorspace, swizzle):
+ channels = []
+ for field in fields:
+ if not field:
+ continue
+
+ type = field[0] if field[0] else 'x'
+
+ if field[1] == 'n':
+ norm = True
+ size = int(field[2:])
+ else:
+ norm = False
+ size = int(field[1:])
+
+ channel = Channel(type, norm, size)
+ channels.append(channel)
+
+ return channels
+
+def parse(filename):
+ """Parse a format descrition in CSV format.
+
+ This function parses the given CSV file and returns an iterable of
+ channels."""
+
+ with open(filename) as stream:
+ for line in stream:
+ try:
+ comment = line.index('#')
+ except ValueError:
+ pass
+ else:
+ line = line[:comment]
+ line = line.strip()
+ if not line:
+ continue
+
+ fields = [field.strip() for field in line.split(',')]
+
+ name = fields[0]
+ layout = fields[1]
+ block_width = int(fields[2])
+ block_height = int(fields[3])
+ colorspace = fields[9]
+
+ swizzle = Swizzle(fields[8])
+ channels = _parse_channels(fields[4:8], layout, colorspace, swizzle)
+
+ yield Format(name, layout, block_width, block_height, channels, swizzle, colorspace)
diff --git a/mesalib/src/mesa/main/format_unpack.c b/mesalib/src/mesa/main/format_unpack.c
index ad5ea4cd1..b84ed0248 100644
--- a/mesalib/src/mesa/main/format_unpack.c
+++ b/mesalib/src/mesa/main/format_unpack.c
@@ -28,6 +28,7 @@
#include "macros.h"
#include "../../gallium/auxiliary/util/u_format_rgb9e5.h"
#include "../../gallium/auxiliary/util/u_format_r11g11b10f.h"
+#include "util/format_srgb.h"
/** Helper struct for MESA_FORMAT_Z32_FLOAT_S8X24_UINT */
@@ -53,34 +54,6 @@ struct z32f_x24s8
#define EXPAND_6_8(X) ( ((X) << 2) | ((X) >> 4) )
-/**
- * Convert an 8-bit sRGB value from non-linear space to a
- * linear RGB value in [0, 1].
- * Implemented with a 256-entry lookup table.
- */
-GLfloat
-_mesa_nonlinear_to_linear(GLubyte cs8)
-{
- static GLfloat table[256];
- static GLboolean tableReady = GL_FALSE;
- if (!tableReady) {
- /* compute lookup table now */
- GLuint i;
- for (i = 0; i < 256; i++) {
- const GLfloat cs = UBYTE_TO_FLOAT(i);
- if (cs <= 0.04045) {
- table[i] = cs / 12.92f;
- }
- else {
- table[i] = (GLfloat) pow((cs + 0.055) / 1.055, 2.4);
- }
- }
- tableReady = GL_TRUE;
- }
- return table[cs8];
-}
-
-
/**********************************************************************/
/* Unpack, returning GLfloat colors */
/**********************************************************************/
@@ -763,9 +736,9 @@ unpack_BGR_SRGB8(const void *src, GLfloat dst[][4], GLuint n)
const GLubyte *s = (const GLubyte *) src;
GLuint i;
for (i = 0; i < n; i++) {
- dst[i][RCOMP] = _mesa_nonlinear_to_linear(s[i*3+2]);
- dst[i][GCOMP] = _mesa_nonlinear_to_linear(s[i*3+1]);
- dst[i][BCOMP] = _mesa_nonlinear_to_linear(s[i*3+0]);
+ dst[i][RCOMP] = util_format_srgb_8unorm_to_linear_float(s[i*3+2]);
+ dst[i][GCOMP] = util_format_srgb_8unorm_to_linear_float(s[i*3+1]);
+ dst[i][BCOMP] = util_format_srgb_8unorm_to_linear_float(s[i*3+0]);
dst[i][ACOMP] = 1.0F;
}
}
@@ -776,9 +749,9 @@ unpack_A8B8G8R8_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] = _mesa_nonlinear_to_linear( (s[i] >> 24) );
- dst[i][GCOMP] = _mesa_nonlinear_to_linear( (s[i] >> 16) & 0xff );
- dst[i][BCOMP] = _mesa_nonlinear_to_linear( (s[i] >> 8) & 0xff );
+ dst[i][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] = UBYTE_TO_FLOAT( s[i] & 0xff ); /* linear! */
}
}
@@ -789,9 +762,9 @@ unpack_B8G8R8A8_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] = _mesa_nonlinear_to_linear( (s[i] >> 16) & 0xff );
- dst[i][GCOMP] = _mesa_nonlinear_to_linear( (s[i] >> 8) & 0xff );
- dst[i][BCOMP] = _mesa_nonlinear_to_linear( (s[i] ) & 0xff );
+ dst[i][RCOMP] = util_format_srgb_8unorm_to_linear_float( (s[i] >> 16) & 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] ) & 0xff );
dst[i][ACOMP] = UBYTE_TO_FLOAT( s[i] >> 24 ); /* linear! */
}
}
@@ -802,9 +775,9 @@ unpack_R8G8B8A8_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] = _mesa_nonlinear_to_linear( (s[i] ) & 0xff );
- dst[i][GCOMP] = _mesa_nonlinear_to_linear( (s[i] >> 8) & 0xff );
- dst[i][BCOMP] = _mesa_nonlinear_to_linear( (s[i] >> 16) & 0xff );
+ 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! */
}
}
@@ -817,7 +790,7 @@ unpack_L_SRGB8(const void *src, GLfloat dst[][4], GLuint n)
for (i = 0; i < n; i++) {
dst[i][RCOMP] =
dst[i][GCOMP] =
- dst[i][BCOMP] = _mesa_nonlinear_to_linear(s[i]);
+ dst[i][BCOMP] = util_format_srgb_8unorm_to_linear_float(s[i]);
dst[i][ACOMP] = 1.0F;
}
}
@@ -830,7 +803,7 @@ unpack_L8A8_SRGB(const void *src, GLfloat dst[][4], GLuint n)
for (i = 0; i < n; i++) {
dst[i][RCOMP] =
dst[i][GCOMP] =
- dst[i][BCOMP] = _mesa_nonlinear_to_linear(s[i] & 0xff);
+ dst[i][BCOMP] = util_format_srgb_8unorm_to_linear_float(s[i] & 0xff);
dst[i][ACOMP] = UBYTE_TO_FLOAT(s[i] >> 8); /* linear! */
}
}
@@ -2124,9 +2097,9 @@ unpack_R8G8B8X8_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] = _mesa_nonlinear_to_linear( (s[i] ) & 0xff );
- dst[i][GCOMP] = _mesa_nonlinear_to_linear( (s[i] >> 8) & 0xff );
- dst[i][BCOMP] = _mesa_nonlinear_to_linear( (s[i] >> 16) & 0xff );
+ 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! */
}
}
@@ -2319,9 +2292,9 @@ unpack_B8G8R8X8_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] = _mesa_nonlinear_to_linear( (s[i] >> 16) & 0xff );
- dst[i][GCOMP] = _mesa_nonlinear_to_linear( (s[i] >> 8) & 0xff );
- dst[i][BCOMP] = _mesa_nonlinear_to_linear( (s[i] ) & 0xff );
+ dst[i][RCOMP] = util_format_srgb_8unorm_to_linear_float( (s[i] >> 16) & 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] ) & 0xff );
dst[i][ACOMP] = 1.0F;
}
}
diff --git a/mesalib/src/mesa/main/format_unpack.h b/mesalib/src/mesa/main/format_unpack.h
index 51f97df4d..eba3c6650 100644
--- a/mesalib/src/mesa/main/format_unpack.h
+++ b/mesalib/src/mesa/main/format_unpack.h
@@ -25,9 +25,6 @@
#ifndef FORMAT_UNPACK_H
#define FORMAT_UNPACK_H
-extern GLfloat
-_mesa_nonlinear_to_linear(GLubyte cs8);
-
extern void
_mesa_unpack_rgba_row(mesa_format format, GLuint n,
const void *src, GLfloat dst[][4]);
diff --git a/mesalib/src/mesa/main/format_utils.c b/mesalib/src/mesa/main/format_utils.c
new file mode 100644
index 000000000..240e3bc0c
--- /dev/null
+++ b/mesalib/src/mesa/main/format_utils.c
@@ -0,0 +1,977 @@
+/*
+ * Mesa 3-D graphics library
+ *
+ * Copyright (C) 2014 Intel Corporation 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 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.
+ */
+
+#include "format_utils.h"
+#include "glformats.h"
+
+static const uint8_t map_identity[7] = { 0, 1, 2, 3, 4, 5, 6 };
+static const uint8_t map_3210[7] = { 3, 2, 1, 0, 4, 5, 6 };
+static const uint8_t map_1032[7] = { 1, 0, 3, 2, 4, 5, 6 };
+
+/**
+ * Describes a format as an array format, if possible
+ *
+ * A helper function for figuring out if a (possibly packed) format is
+ * actually an array format and, if so, what the array parameters are.
+ *
+ * \param[in] format the mesa format
+ * \param[out] type the GL type of the array (GL_BYTE, etc.)
+ * \param[out] num_components the number of components in the array
+ * \param[out] swizzle a swizzle describing how to get from the
+ * given format to RGBA
+ * \param[out] normalized for integer formats, this represents whether
+ * the format is a normalized integer or a
+ * regular integer
+ * \return true if this format is an array format, false otherwise
+ */
+bool
+_mesa_format_to_array(mesa_format format, GLenum *type, int *num_components,
+ uint8_t swizzle[4], bool *normalized)
+{
+ int i;
+ GLuint format_components;
+ uint8_t packed_swizzle[4];
+ const uint8_t *endian;
+
+ if (_mesa_is_format_compressed(format))
+ return false;
+
+ *normalized = !_mesa_is_format_integer(format);
+
+ _mesa_format_to_type_and_comps(format, type, &format_components);
+
+ switch (_mesa_get_format_layout(format)) {
+ case MESA_FORMAT_LAYOUT_ARRAY:
+ *num_components = format_components;
+ _mesa_get_format_swizzle(format, swizzle);
+ return true;
+ case MESA_FORMAT_LAYOUT_PACKED:
+ switch (*type) {
+ case GL_UNSIGNED_BYTE:
+ case GL_BYTE:
+ if (_mesa_get_format_max_bits(format) != 8)
+ return false;
+ *num_components = _mesa_get_format_bytes(format);
+ switch (*num_components) {
+ case 1:
+ endian = map_identity;
+ break;
+ case 2:
+ endian = _mesa_little_endian() ? map_identity : map_1032;
+ break;
+ case 4:
+ endian = _mesa_little_endian() ? map_identity : map_3210;
+ break;
+ default:
+ endian = map_identity;
+ assert(!"Invalid number of components");
+ }
+ break;
+ case GL_UNSIGNED_SHORT:
+ case GL_SHORT:
+ case GL_HALF_FLOAT:
+ if (_mesa_get_format_max_bits(format) != 16)
+ return false;
+ *num_components = _mesa_get_format_bytes(format) / 2;
+ switch (*num_components) {
+ case 1:
+ endian = map_identity;
+ break;
+ case 2:
+ endian = _mesa_little_endian() ? map_identity : map_1032;
+ break;
+ default:
+ endian = map_identity;
+ assert(!"Invalid number of components");
+ }
+ break;
+ case GL_UNSIGNED_INT:
+ case GL_INT:
+ case GL_FLOAT:
+ /* This isn't packed. At least not really. */
+ assert(format_components == 1);
+ if (_mesa_get_format_max_bits(format) != 32)
+ return false;
+ *num_components = format_components;
+ endian = map_identity;
+ break;
+ default:
+ return false;
+ }
+
+ _mesa_get_format_swizzle(format, packed_swizzle);
+
+ for (i = 0; i < 4; ++i)
+ swizzle[i] = endian[packed_swizzle[i]];
+
+ return true;
+ case MESA_FORMAT_LAYOUT_OTHER:
+ default:
+ return false;
+ }
+}
+
+/* A bunch of format conversion macros and helper functions used below */
+
+/* Only guaranteed to work for BITS <= 32 */
+#define MAX_UINT(BITS) ((BITS) == 32 ? UINT32_MAX : ((1u << (BITS)) - 1))
+#define MAX_INT(BITS) ((int)MAX_UINT((BITS) - 1))
+
+/* Extends an integer of size SRC_BITS to one of size DST_BITS linearly */
+#define EXTEND_NORMALIZED_INT(X, SRC_BITS, DST_BITS) \
+ (((X) * (int)(MAX_UINT(DST_BITS) / MAX_UINT(SRC_BITS))) + \
+ ((DST_BITS % SRC_BITS) ? ((X) >> (SRC_BITS - DST_BITS % SRC_BITS)) : 0))
+
+static inline float
+unorm_to_float(unsigned x, unsigned src_bits)
+{
+ return x * (1.0f / (float)MAX_UINT(src_bits));
+}
+
+static inline float
+snorm_to_float(int x, unsigned src_bits)
+{
+ if (x == -MAX_INT(src_bits))
+ return -1.0f;
+ else
+ return x * (1.0f / (float)MAX_INT(src_bits));
+}
+
+static inline uint16_t
+unorm_to_half(unsigned x, unsigned src_bits)
+{
+ return _mesa_float_to_half(unorm_to_float(x, src_bits));
+}
+
+static inline uint16_t
+snorm_to_half(int x, unsigned src_bits)
+{
+ return _mesa_float_to_half(snorm_to_float(x, src_bits));
+}
+
+static inline unsigned
+float_to_unorm(float x, unsigned dst_bits)
+{
+ if (x < 0.0f)
+ return 0;
+ else if (x > 1.0f)
+ return MAX_UINT(dst_bits);
+ else
+ return F_TO_I(x * MAX_UINT(dst_bits));
+}
+
+static inline unsigned
+half_to_unorm(uint16_t x, unsigned dst_bits)
+{
+ return float_to_unorm(_mesa_half_to_float(x), dst_bits);
+}
+
+static inline unsigned
+unorm_to_unorm(unsigned x, unsigned src_bits, unsigned dst_bits)
+{
+ if (src_bits < dst_bits)
+ return EXTEND_NORMALIZED_INT(x, src_bits, dst_bits);
+ else
+ return x >> (src_bits - dst_bits);
+}
+
+static inline unsigned
+snorm_to_unorm(int x, unsigned src_bits, unsigned dst_bits)
+{
+ if (x < 0)
+ return 0;
+ else
+ return unorm_to_unorm(x, src_bits - 1, dst_bits);
+}
+
+static inline int
+float_to_snorm(float x, unsigned dst_bits)
+{
+ if (x < -1.0f)
+ return -MAX_INT(dst_bits);
+ else if (x > 1.0f)
+ return MAX_INT(dst_bits);
+ else
+ return F_TO_I(x * MAX_INT(dst_bits));
+}
+
+static inline int
+half_to_snorm(uint16_t x, unsigned dst_bits)
+{
+ return float_to_snorm(_mesa_half_to_float(x), dst_bits);
+}
+
+static inline int
+unorm_to_snorm(unsigned x, unsigned src_bits, unsigned dst_bits)
+{
+ return unorm_to_unorm(x, src_bits, dst_bits - 1);
+}
+
+static inline int
+snorm_to_snorm(int x, unsigned src_bits, unsigned dst_bits)
+{
+ if (x < -MAX_INT(src_bits))
+ return -MAX_INT(dst_bits);
+ else if (src_bits < dst_bits)
+ return EXTEND_NORMALIZED_INT(x, src_bits - 1, dst_bits - 1);
+ else
+ return x >> (src_bits - dst_bits);
+}
+
+static inline unsigned
+float_to_uint(float x)
+{
+ if (x < 0.0f)
+ return 0;
+ else
+ return x;
+}
+
+static inline unsigned
+half_to_uint(uint16_t x)
+{
+ if (_mesa_half_is_negative(x))
+ return 0;
+ else
+ return _mesa_float_to_half(x);
+}
+
+/**
+ * Attempts to perform the given swizzle-and-convert operation with memcpy
+ *
+ * This function determines if the given swizzle-and-convert operation can
+ * be done with a simple memcpy and, if so, does the memcpy. If not, it
+ * returns false and we fall back to the standard version below.
+ *
+ * The arguments are exactly the same as for _mesa_swizzle_and_convert
+ *
+ * \return true if it successfully performed the swizzle-and-convert
+ * operation with memcpy, false otherwise
+ */
+static bool
+swizzle_convert_try_memcpy(void *dst, GLenum dst_type, int num_dst_channels,
+ const void *src, GLenum src_type, int num_src_channels,
+ const uint8_t swizzle[4], bool normalized, int count)
+{
+ int i;
+
+ if (src_type != dst_type)
+ return false;
+ if (num_src_channels != num_dst_channels)
+ return false;
+
+ for (i = 0; i < num_dst_channels; ++i)
+ if (swizzle[i] != i && swizzle[i] != MESA_FORMAT_SWIZZLE_NONE)
+ return false;
+
+ memcpy(dst, src, count * num_src_channels * _mesa_sizeof_type(src_type));
+
+ return true;
+}
+
+/**
+ * Represents a single instance of the standard swizzle-and-convert loop
+ *
+ * Any swizzle-and-convert operation simply loops through the pixels and
+ * performs the transformation operation one pixel at a time. This macro
+ * embodies one instance of the conversion loop. This way we can do all
+ * control flow outside of the loop and allow the compiler to unroll
+ * everything inside the loop.
+ *
+ * Note: This loop is carefully crafted for performance. Be careful when
+ * changing it and run some benchmarks to ensure no performance regressions
+ * if you do.
+ *
+ * \param DST_TYPE the C datatype of the destination
+ * \param DST_CHANS the number of destination channels
+ * \param SRC_TYPE the C datatype of the source
+ * \param SRC_CHANS the number of source channels
+ * \param CONV an expression for converting from the source data,
+ * storred in the variable "src", to the destination
+ * 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; \
+ } \
+
+/**
+ * Represents a single swizzle-and-convert operation
+ *
+ * This macro represents everything done in a single swizzle-and-convert
+ * operation. The actual work is done by the SWIZZLE_CONVERT_LOOP macro.
+ * This macro acts as a wrapper that uses a nested switch to ensure that
+ * all looping parameters get unrolled.
+ *
+ * This macro makes assumptions about variables etc. in the calling
+ * function. Changes to _mesa_swizzle_and_convert may require changes to
+ * this macro.
+ *
+ * \param DST_TYPE the C datatype of the destination
+ * \param SRC_TYPE the C datatype of the source
+ * \param CONV an expression for converting from the source data,
+ * storred in the variable "src", to the destination
+ * format
+ */
+#define SWIZZLE_CONVERT(DST_TYPE, SRC_TYPE, CONV) \
+ do { \
+ const SRC_TYPE *typed_src = void_src; \
+ DST_TYPE *typed_dst = void_dst; \
+ DST_TYPE tmp[7]; \
+ tmp[4] = 0; \
+ tmp[5] = one; \
+ switch (num_dst_channels) { \
+ case 1: \
+ switch (num_src_channels) { \
+ case 1: \
+ SWIZZLE_CONVERT_LOOP(DST_TYPE, 1, SRC_TYPE, 1, CONV) \
+ break; \
+ case 2: \
+ SWIZZLE_CONVERT_LOOP(DST_TYPE, 1, SRC_TYPE, 2, CONV) \
+ break; \
+ case 3: \
+ SWIZZLE_CONVERT_LOOP(DST_TYPE, 1, SRC_TYPE, 3, CONV) \
+ break; \
+ case 4: \
+ 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) \
+ break; \
+ case 2: \
+ SWIZZLE_CONVERT_LOOP(DST_TYPE, 2, SRC_TYPE, 2, CONV) \
+ break; \
+ case 3: \
+ SWIZZLE_CONVERT_LOOP(DST_TYPE, 2, SRC_TYPE, 3, CONV) \
+ break; \
+ case 4: \
+ 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) \
+ break; \
+ case 2: \
+ SWIZZLE_CONVERT_LOOP(DST_TYPE, 3, SRC_TYPE, 2, CONV) \
+ break; \
+ case 3: \
+ SWIZZLE_CONVERT_LOOP(DST_TYPE, 3, SRC_TYPE, 3, CONV) \
+ break; \
+ case 4: \
+ 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) \
+ break; \
+ case 2: \
+ SWIZZLE_CONVERT_LOOP(DST_TYPE, 4, SRC_TYPE, 2, CONV) \
+ break; \
+ case 3: \
+ SWIZZLE_CONVERT_LOOP(DST_TYPE, 4, SRC_TYPE, 3, CONV) \
+ break; \
+ case 4: \
+ SWIZZLE_CONVERT_LOOP(DST_TYPE, 4, SRC_TYPE, 4, CONV) \
+ break; \
+ } \
+ break; \
+ } \
+ } while (0);
+
+/**
+ * Convert between array-based color formats.
+ *
+ * Most format conversion operations required by GL can be performed by
+ * converting one channel at a time, shuffling the channels around, and
+ * optionally filling missing channels with zeros and ones. This function
+ * does just that in a general, yet efficient, way.
+ *
+ * The swizzle parameter is an array of 4 numbers (see
+ * _mesa_get_format_swizzle) that describes where each channel in the
+ * destination should come from in the source. If swizzle[i] < 4 then it
+ * means that dst[i] = CONVERT(src[swizzle[i]]). If swizzle[i] is
+ * MESA_FORMAT_SWIZZLE_ZERO or MESA_FORMAT_SWIZZLE_ONE, the corresponding
+ * dst[i] will be filled with the appropreate representation of zero or one
+ * respectively.
+ *
+ * Under most circumstances, the source and destination images must be
+ * different as no care is taken not to clobber one with the other.
+ * However, if they have the same number of bits per pixel, it is safe to
+ * do an in-place conversion.
+ *
+ * \param[out] dst pointer to where the converted data should
+ * be stored
+ *
+ * \param[in] dst_type the destination GL type of the converted
+ * data (GL_BYTE, etc.)
+ *
+ * \param[in] num_dst_channels the number of channels in the converted
+ * data
+ *
+ * \param[in] src pointer to the source data
+ *
+ * \param[in] src_type the GL type of the source data (GL_BYTE,
+ * etc.)
+ *
+ * \param[in] num_src_channels the number of channels in the source data
+ * (the number of channels total, not just
+ * the number used)
+ *
+ * \param[in] swizzle describes how to get the destination data
+ * from the source data.
+ *
+ * \param[in] normalized for integer types, this indicates whether
+ * the data should be considered as integers
+ * or as normalized integers;
+ *
+ * \param[in] count the number of pixels to convert
+ */
+void
+_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;
+ 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;
+ 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;
+ 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;
+ 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;
+ 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;
+ 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;
+ 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;
+ default:
+ assert(!"Invalid channel type");
+ }
+}
diff --git a/mesalib/src/mesa/main/format_utils.h b/mesalib/src/mesa/main/format_utils.h
new file mode 100644
index 000000000..9f778e377
--- /dev/null
+++ b/mesalib/src/mesa/main/format_utils.h
@@ -0,0 +1,45 @@
+/**
+ * \file format_utils.h
+ * A collection of format conversion utility functions.
+ */
+
+/*
+ * Mesa 3-D graphics library
+ *
+ * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
+ * Copyright (C) 2014 Intel Corporation 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 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 FORMAT_UTILS_H
+#define FORMAT_UTILS_H
+
+#include "imports.h"
+
+bool
+_mesa_format_to_array(mesa_format, GLenum *type, int *num_components,
+ uint8_t swizzle[4], bool *normalized);
+
+void
+_mesa_swizzle_and_convert(void *dst, GLenum dst_type, int num_dst_channels,
+ const void *src, GLenum src_type, int num_src_channels,
+ const uint8_t swizzle[4], bool normalized, int count);
+
+#endif
diff --git a/mesalib/src/mesa/main/formats.c b/mesalib/src/mesa/main/formats.c
index 1f20a9a6a..f03425e41 100644
--- a/mesalib/src/mesa/main/formats.c
+++ b/mesalib/src/mesa/main/formats.c
@@ -40,6 +40,8 @@ struct gl_format_info
/** text name for debugging */
const char *StrName;
+ enum mesa_format_layout Layout;
+
/**
* Base format is one of GL_RED, GL_RG, GL_RGB, GL_RGBA, GL_ALPHA,
* GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_INTENSITY, GL_YCBCR_MESA,
@@ -59,7 +61,6 @@ struct gl_format_info
GLubyte AlphaBits;
GLubyte LuminanceBits;
GLubyte IntensityBits;
- GLubyte IndexBits;
GLubyte DepthBits;
GLubyte StencilBits;
@@ -68,1745 +69,11 @@ struct gl_format_info
*/
GLubyte BlockWidth, BlockHeight;
GLubyte BytesPerBlock;
-};
-
-/**
- * Info about each format.
- * These must be in the same order as the MESA_FORMAT_* enums so that
- * we can do lookups without searching.
- */
-static struct gl_format_info format_info[MESA_FORMAT_COUNT] =
-{
- /* Packed unorm formats */
- {
- MESA_FORMAT_NONE, /* Name */
- "MESA_FORMAT_NONE", /* StrName */
- GL_NONE, /* BaseFormat */
- GL_NONE, /* DataType */
- 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
- 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
- 0, 0, 0 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_A8B8G8R8_UNORM, /* Name */
- "MESA_FORMAT_A8B8G8R8_UNORM",/* StrName */
- GL_RGBA, /* BaseFormat */
- GL_UNSIGNED_NORMALIZED, /* DataType */
- 8, 8, 8, 8, /* Red/Green/Blue/AlphaBits */
- 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 4 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_X8B8G8R8_UNORM, /* Name */
- "MESA_FORMAT_X8B8G8R8_UNORM",/* StrName */
- GL_RGB, /* BaseFormat */
- GL_UNSIGNED_NORMALIZED, /* DataType */
- 8, 8, 8, 0, /* Red/Green/Blue/AlphaBits */
- 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 4 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_R8G8B8A8_UNORM, /* Name */
- "MESA_FORMAT_R8G8B8A8_UNORM",/* StrName */
- GL_RGBA, /* BaseFormat */
- GL_UNSIGNED_NORMALIZED, /* DataType */
- 8, 8, 8, 8, /* Red/Green/Blue/AlphaBits */
- 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 4 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_R8G8B8X8_UNORM, /* Name */
- "MESA_FORMAT_R8G8B8X8_UNORM",/* StrName */
- GL_RGB, /* BaseFormat */
- GL_UNSIGNED_NORMALIZED, /* DataType */
- 8, 8, 8, 0, /* Red/Green/Blue/AlphaBits */
- 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 4 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_B8G8R8A8_UNORM, /* Name */
- "MESA_FORMAT_B8G8R8A8_UNORM",/* StrName */
- GL_RGBA, /* BaseFormat */
- GL_UNSIGNED_NORMALIZED, /* DataType */
- 8, 8, 8, 8, /* Red/Green/Blue/AlphaBits */
- 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 4 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_B8G8R8X8_UNORM, /* Name */
- "MESA_FORMAT_B8G8R8X8_UNORM",/* StrName */
- GL_RGB, /* BaseFormat */
- GL_UNSIGNED_NORMALIZED, /* DataType */
- 8, 8, 8, 0, /* Red/Green/Blue/AlphaBits */
- 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 4 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_A8R8G8B8_UNORM, /* Name */
- "MESA_FORMAT_A8R8G8B8_UNORM",/* StrName */
- GL_RGBA, /* BaseFormat */
- GL_UNSIGNED_NORMALIZED, /* DataType */
- 8, 8, 8, 8, /* Red/Green/Blue/AlphaBits */
- 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 4 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_X8R8G8B8_UNORM, /* Name */
- "MESA_FORMAT_X8R8G8B8_UNORM",/* StrName */
- GL_RGB, /* BaseFormat */
- GL_UNSIGNED_NORMALIZED, /* DataType */
- 8, 8, 8, 0, /* Red/Green/Blue/AlphaBits */
- 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 4 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_L16A16_UNORM, /* Name */
- "MESA_FORMAT_L16A16_UNORM", /* StrName */
- GL_LUMINANCE_ALPHA, /* BaseFormat */
- GL_UNSIGNED_NORMALIZED, /* DataType */
- 0, 0, 0, 16, /* Red/Green/Blue/AlphaBits */
- 16, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 4 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_A16L16_UNORM, /* Name */
- "MESA_FORMAT_A16L16_UNORM", /* StrName */
- GL_LUMINANCE_ALPHA, /* BaseFormat */
- GL_UNSIGNED_NORMALIZED, /* DataType */
- 0, 0, 0, 16, /* Red/Green/Blue/AlphaBits */
- 16, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 4 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_B5G6R5_UNORM, /* Name */
- "MESA_FORMAT_B5G6R5_UNORM", /* StrName */
- GL_RGB, /* BaseFormat */
- GL_UNSIGNED_NORMALIZED, /* DataType */
- 5, 6, 5, 0, /* Red/Green/Blue/AlphaBits */
- 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 2 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_R5G6B5_UNORM, /* Name */
- "MESA_FORMAT_R5G6B5_UNORM", /* StrName */
- GL_RGB, /* BaseFormat */
- GL_UNSIGNED_NORMALIZED, /* DataType */
- 5, 6, 5, 0, /* Red/Green/Blue/AlphaBits */
- 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 2 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_B4G4R4A4_UNORM, /* Name */
- "MESA_FORMAT_B4G4R4A4_UNORM",/* StrName */
- GL_RGBA, /* BaseFormat */
- GL_UNSIGNED_NORMALIZED, /* DataType */
- 4, 4, 4, 4, /* Red/Green/Blue/AlphaBits */
- 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 2 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_B4G4R4X4_UNORM,
- "MESA_FORMAT_B4G4R4X4_UNORM",
- GL_RGB,
- GL_UNSIGNED_NORMALIZED,
- 4, 4, 4, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 2
- },
- {
- MESA_FORMAT_A4R4G4B4_UNORM, /* Name */
- "MESA_FORMAT_A4R4G4B4_UNORM",/* StrName */
- GL_RGBA, /* BaseFormat */
- GL_UNSIGNED_NORMALIZED, /* DataType */
- 4, 4, 4, 4, /* Red/Green/Blue/AlphaBits */
- 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 2 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_A1B5G5R5_UNORM, /* Name */
- "MESA_FORMAT_A1B5G5R5_UNORM",/* StrName */
- GL_RGBA, /* BaseFormat */
- GL_UNSIGNED_NORMALIZED, /* DataType */
- 5, 5, 5, 1, /* Red/Green/Blue/AlphaBits */
- 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 2 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_B5G5R5A1_UNORM, /* Name */
- "MESA_FORMAT_B5G5R5A1_UNORM",/* StrName */
- GL_RGBA, /* BaseFormat */
- GL_UNSIGNED_NORMALIZED, /* DataType */
- 5, 5, 5, 1, /* Red/Green/Blue/AlphaBits */
- 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 2 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_B5G5R5X1_UNORM,
- "MESA_FORMAT_B5G5R5X1_UNORM",
- GL_RGB,
- GL_UNSIGNED_NORMALIZED,
- 5, 5, 5, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 2
- },
- {
- MESA_FORMAT_A1R5G5B5_UNORM, /* Name */
- "MESA_FORMAT_A1R5G5B5_UNORM",/* StrName */
- GL_RGBA, /* BaseFormat */
- GL_UNSIGNED_NORMALIZED, /* DataType */
- 5, 5, 5, 1, /* Red/Green/Blue/AlphaBits */
- 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 2 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_L8A8_UNORM, /* Name */
- "MESA_FORMAT_L8A8_UNORM", /* StrName */
- GL_LUMINANCE_ALPHA, /* BaseFormat */
- GL_UNSIGNED_NORMALIZED, /* DataType */
- 0, 0, 0, 8, /* Red/Green/Blue/AlphaBits */
- 8, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 2 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_A8L8_UNORM, /* Name */
- "MESA_FORMAT_A8L8_UNORM", /* StrName */
- GL_LUMINANCE_ALPHA, /* BaseFormat */
- GL_UNSIGNED_NORMALIZED, /* DataType */
- 0, 0, 0, 8, /* Red/Green/Blue/AlphaBits */
- 8, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 2 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_R8G8_UNORM,
- "MESA_FORMAT_R8G8_UNORM",
- GL_RG,
- GL_UNSIGNED_NORMALIZED,
- 8, 8, 0, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 2
- },
- {
- MESA_FORMAT_G8R8_UNORM,
- "MESA_FORMAT_G8R8_UNORM",
- GL_RG,
- GL_UNSIGNED_NORMALIZED,
- 8, 8, 0, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 2
- },
- {
- MESA_FORMAT_L4A4_UNORM, /* Name */
- "MESA_FORMAT_L4A4_UNORM", /* StrName */
- GL_LUMINANCE_ALPHA, /* BaseFormat */
- GL_UNSIGNED_NORMALIZED, /* DataType */
- 0, 0, 0, 4, /* Red/Green/Blue/AlphaBits */
- 4, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 1 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_B2G3R3_UNORM, /* Name */
- "MESA_FORMAT_B2G3R3_UNORM", /* StrName */
- GL_RGB, /* BaseFormat */
- GL_UNSIGNED_NORMALIZED, /* DataType */
- 3, 3, 2, 0, /* Red/Green/Blue/AlphaBits */
- 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 1 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_R16G16_UNORM,
- "MESA_FORMAT_R16G16_UNORM",
- GL_RG,
- GL_UNSIGNED_NORMALIZED,
- 16, 16, 0, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 4
- },
- {
- MESA_FORMAT_G16R16_UNORM,
- "MESA_FORMAT_G16R16_UNORM",
- GL_RG,
- GL_UNSIGNED_NORMALIZED,
- 16, 16, 0, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 4
- },
- {
- MESA_FORMAT_B10G10R10A2_UNORM,
- "MESA_FORMAT_B10G10R10A2_UNORM",
- GL_RGBA,
- GL_UNSIGNED_NORMALIZED,
- 10, 10, 10, 2,
- 0, 0, 0, 0, 0,
- 1, 1, 4
- },
- {
- MESA_FORMAT_B10G10R10X2_UNORM,
- "MESA_FORMAT_B10G10R10X2_UNORM",
- GL_RGB,
- GL_UNSIGNED_NORMALIZED,
- 10, 10, 10, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 4
- },
- {
- MESA_FORMAT_R10G10B10A2_UNORM,
- "MESA_FORMAT_R10G10B10A2_UNORM",
- GL_RGBA,
- GL_UNSIGNED_NORMALIZED,
- 10, 10, 10, 2,
- 0, 0, 0, 0, 0,
- 1, 1, 4
- },
- {
- MESA_FORMAT_S8_UINT_Z24_UNORM, /* Name */
- "MESA_FORMAT_S8_UINT_Z24_UNORM", /* StrName */
- GL_DEPTH_STENCIL, /* BaseFormat */
- GL_UNSIGNED_NORMALIZED, /* DataType */
- 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
- 0, 0, 0, 24, 8, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 4 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_X8_UINT_Z24_UNORM, /* Name */
- "MESA_FORMAT_X8_UINT_Z24_UNORM", /* StrName */
- GL_DEPTH_COMPONENT, /* BaseFormat */
- GL_UNSIGNED_NORMALIZED, /* DataType */
- 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
- 0, 0, 0, 24, 0, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 4 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_Z24_UNORM_S8_UINT, /* Name */
- "MESA_FORMAT_Z24_UNORM_S8_UINT", /* StrName */
- GL_DEPTH_STENCIL, /* BaseFormat */
- GL_UNSIGNED_NORMALIZED, /* DataType */
- 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
- 0, 0, 0, 24, 8, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 4 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_Z24_UNORM_X8_UINT, /* Name */
- "MESA_FORMAT_Z24_UNORM_X8_UINT", /* StrName */
- GL_DEPTH_COMPONENT, /* BaseFormat */
- GL_UNSIGNED_NORMALIZED, /* DataType */
- 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
- 0, 0, 0, 24, 0, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 4 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_YCBCR, /* Name */
- "MESA_FORMAT_YCBCR", /* StrName */
- GL_YCBCR_MESA, /* BaseFormat */
- GL_UNSIGNED_NORMALIZED, /* DataType */
- 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
- 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 2 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_YCBCR_REV, /* Name */
- "MESA_FORMAT_YCBCR_REV", /* StrName */
- GL_YCBCR_MESA, /* BaseFormat */
- GL_UNSIGNED_NORMALIZED, /* DataType */
- 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
- 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 2 /* BlockWidth/Height,Bytes */
- },
-
- /* Array unorm formats */
- {
- MESA_FORMAT_A_UNORM8, /* Name */
- "MESA_FORMAT_A_UNORM8", /* StrName */
- GL_ALPHA, /* BaseFormat */
- GL_UNSIGNED_NORMALIZED, /* DataType */
- 0, 0, 0, 8, /* Red/Green/Blue/AlphaBits */
- 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 1 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_A_UNORM16, /* Name */
- "MESA_FORMAT_A_UNORM16", /* StrName */
- GL_ALPHA, /* BaseFormat */
- GL_UNSIGNED_NORMALIZED, /* DataType */
- 0, 0, 0, 16, /* Red/Green/Blue/AlphaBits */
- 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 2 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_L_UNORM8, /* Name */
- "MESA_FORMAT_L_UNORM8", /* StrName */
- GL_LUMINANCE, /* BaseFormat */
- GL_UNSIGNED_NORMALIZED, /* DataType */
- 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
- 8, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 1 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_L_UNORM16, /* Name */
- "MESA_FORMAT_L_UNORM16", /* StrName */
- GL_LUMINANCE, /* BaseFormat */
- GL_UNSIGNED_NORMALIZED, /* DataType */
- 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
- 16, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 2 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_I_UNORM8, /* Name */
- "MESA_FORMAT_I_UNORM8", /* StrName */
- GL_INTENSITY, /* BaseFormat */
- GL_UNSIGNED_NORMALIZED, /* DataType */
- 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
- 0, 8, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 1 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_I_UNORM16, /* Name */
- "MESA_FORMAT_I_UNORM16", /* StrName */
- GL_INTENSITY, /* BaseFormat */
- GL_UNSIGNED_NORMALIZED, /* DataType */
- 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
- 0, 16, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 2 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_R_UNORM8,
- "MESA_FORMAT_R_UNORM8",
- GL_RED,
- GL_UNSIGNED_NORMALIZED,
- 8, 0, 0, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 1
- },
- {
- MESA_FORMAT_R_UNORM16,
- "MESA_FORMAT_R_UNORM16",
- GL_RED,
- GL_UNSIGNED_NORMALIZED,
- 16, 0, 0, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 2
- },
- {
- MESA_FORMAT_BGR_UNORM8, /* Name */
- "MESA_FORMAT_BGR_UNORM8", /* StrName */
- GL_RGB, /* BaseFormat */
- GL_UNSIGNED_NORMALIZED, /* DataType */
- 8, 8, 8, 0, /* Red/Green/Blue/AlphaBits */
- 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 3 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_RGB_UNORM8, /* Name */
- "MESA_FORMAT_RGB_UNORM8", /* StrName */
- GL_RGB, /* BaseFormat */
- GL_UNSIGNED_NORMALIZED, /* DataType */
- 8, 8, 8, 0, /* Red/Green/Blue/AlphaBits */
- 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 3 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_RGBA_UNORM16,
- "MESA_FORMAT_RGBA_UNORM16",
- GL_RGBA,
- GL_UNSIGNED_NORMALIZED,
- 16, 16, 16, 16,
- 0, 0, 0, 0, 0,
- 1, 1, 8
- },
- {
- MESA_FORMAT_RGBX_UNORM16,
- "MESA_FORMAT_RGBX_UNORM16",
- GL_RGB,
- GL_UNSIGNED_NORMALIZED,
- 16, 16, 16, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 8
- },
- {
- MESA_FORMAT_Z_UNORM16, /* Name */
- "MESA_FORMAT_Z_UNORM16", /* StrName */
- GL_DEPTH_COMPONENT, /* BaseFormat */
- GL_UNSIGNED_NORMALIZED, /* DataType */
- 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
- 0, 0, 0, 16, 0, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 2 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_Z_UNORM32, /* Name */
- "MESA_FORMAT_Z_UNORM32", /* StrName */
- GL_DEPTH_COMPONENT, /* BaseFormat */
- GL_UNSIGNED_NORMALIZED, /* DataType */
- 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
- 0, 0, 0, 32, 0, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 4 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_S_UINT8, /* Name */
- "MESA_FORMAT_S_UINT8", /* StrName */
- GL_STENCIL_INDEX, /* BaseFormat */
- GL_UNSIGNED_INT, /* DataType */
- 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
- 0, 0, 0, 0, 8, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 1 /* BlockWidth/Height,Bytes */
- },
-
- /* Packed signed/normalized formats */
- {
- MESA_FORMAT_A8B8G8R8_SNORM,
- "MESA_FORMAT_A8B8G8R8_SNORM",
- GL_RGBA,
- GL_SIGNED_NORMALIZED,
- 8, 8, 8, 8,
- 0, 0, 0, 0, 0,
- 1, 1, 4
- },
- {
- MESA_FORMAT_X8B8G8R8_SNORM,
- "MESA_FORMAT_X8B8G8R8_SNORM",
- GL_RGB,
- GL_SIGNED_NORMALIZED,
- 8, 8, 8, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 4 /* 4 bpp, but no alpha */
- },
- {
- MESA_FORMAT_R8G8B8A8_SNORM,
- "MESA_FORMAT_R8G8B8A8_SNORM",
- GL_RGBA,
- GL_SIGNED_NORMALIZED,
- 8, 8, 8, 8,
- 0, 0, 0, 0, 0,
- 1, 1, 4
- },
- {
- MESA_FORMAT_R8G8B8X8_SNORM,
- "MESA_FORMAT_R8G8B8X8_SNORM",
- GL_RGB,
- GL_SIGNED_NORMALIZED,
- 8, 8, 8, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 4
- },
- {
- MESA_FORMAT_R16G16_SNORM,
- "MESA_FORMAT_R16G16_SNORM",
- GL_RG,
- GL_SIGNED_NORMALIZED,
- 16, 16, 0, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 4
- },
- {
- MESA_FORMAT_G16R16_SNORM,
- "MESA_FORMAT_G16R16_SNORM",
- GL_RG,
- GL_SIGNED_NORMALIZED,
- 16, 16, 0, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 4
- },
- {
- MESA_FORMAT_R8G8_SNORM,
- "MESA_FORMAT_R8G8_SNORM",
- GL_RG,
- GL_SIGNED_NORMALIZED,
- 8, 8, 0, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 2
- },
- {
- MESA_FORMAT_G8R8_SNORM,
- "MESA_FORMAT_G8R8_SNORM",
- GL_RG,
- GL_SIGNED_NORMALIZED,
- 8, 8, 0, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 2
- },
- {
- MESA_FORMAT_L8A8_SNORM,
- "MESA_FORMAT_L8A8_SNORM",
- GL_LUMINANCE_ALPHA,
- GL_SIGNED_NORMALIZED,
- 0, 0, 0, 8,
- 8, 0, 0, 0, 0,
- 1, 1, 2
- },
-
- /* Array signed/normalized formats */
- {
- MESA_FORMAT_A_SNORM8,
- "MESA_FORMAT_A_SNORM8",
- GL_ALPHA,
- GL_SIGNED_NORMALIZED,
- 0, 0, 0, 8,
- 0, 0, 0, 0, 0,
- 1, 1, 1
- },
- {
- MESA_FORMAT_A_SNORM16,
- "MESA_FORMAT_A_SNORM16",
- GL_ALPHA,
- GL_SIGNED_NORMALIZED,
- 0, 0, 0, 16,
- 0, 0, 0, 0, 0,
- 1, 1, 2
- },
- {
- MESA_FORMAT_L_SNORM8,
- "MESA_FORMAT_L_SNORM8",
- GL_LUMINANCE,
- GL_SIGNED_NORMALIZED,
- 0, 0, 0, 0,
- 8, 0, 0, 0, 0,
- 1, 1, 1
- },
- {
- MESA_FORMAT_L_SNORM16,
- "MESA_FORMAT_L_SNORM16",
- GL_LUMINANCE,
- GL_SIGNED_NORMALIZED,
- 0, 0, 0, 0,
- 16, 0, 0, 0, 0,
- 1, 1, 2
- },
- {
- MESA_FORMAT_I_SNORM8,
- "MESA_FORMAT_I_SNORM8",
- GL_INTENSITY,
- GL_SIGNED_NORMALIZED,
- 0, 0, 0, 0,
- 0, 8, 0, 0, 0,
- 1, 1, 1
- },
- {
- MESA_FORMAT_I_SNORM16,
- "MESA_FORMAT_I_SNORM16",
- GL_INTENSITY,
- GL_SIGNED_NORMALIZED,
- 0, 0, 0, 0,
- 0, 16, 0, 0, 0,
- 1, 1, 2
- },
- {
- MESA_FORMAT_R_SNORM8, /* Name */
- "MESA_FORMAT_R_SNORM8", /* StrName */
- GL_RED, /* BaseFormat */
- GL_SIGNED_NORMALIZED, /* DataType */
- 8, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
- 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 1 /* BlockWidth/Height,Bytes */
- },
- {
- MESA_FORMAT_R_SNORM16,
- "MESA_FORMAT_R_SNORM16",
- GL_RED,
- GL_SIGNED_NORMALIZED,
- 16, 0, 0, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 2
- },
- {
- MESA_FORMAT_LA_SNORM16,
- "MESA_FORMAT_LA_SNORM16",
- GL_LUMINANCE_ALPHA,
- GL_SIGNED_NORMALIZED,
- 0, 0, 0, 16,
- 16, 0, 0, 0, 0,
- 1, 1, 4
- },
- {
- MESA_FORMAT_RGB_SNORM16,
- "MESA_FORMAT_RGB_SNORM16",
- GL_RGB,
- GL_SIGNED_NORMALIZED,
- 16, 16, 16, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 6
- },
- {
- MESA_FORMAT_RGBA_SNORM16,
- "MESA_FORMAT_RGBA_SNORM16",
- GL_RGBA,
- GL_SIGNED_NORMALIZED,
- 16, 16, 16, 16,
- 0, 0, 0, 0, 0,
- 1, 1, 8
- },
- {
- MESA_FORMAT_RGBX_SNORM16,
- "MESA_FORMAT_RGBX_SNORM16",
- GL_RGB,
- GL_SIGNED_NORMALIZED,
- 16, 16, 16, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 8
- },
-
- /* Packed sRGB formats */
- {
- MESA_FORMAT_A8B8G8R8_SRGB,
- "MESA_FORMAT_A8B8G8R8_SRGB",
- GL_RGBA,
- GL_UNSIGNED_NORMALIZED,
- 8, 8, 8, 8,
- 0, 0, 0, 0, 0,
- 1, 1, 4
- },
- {
- MESA_FORMAT_B8G8R8A8_SRGB,
- "MESA_FORMAT_B8G8R8A8_SRGB",
- GL_RGBA,
- GL_UNSIGNED_NORMALIZED,
- 8, 8, 8, 8,
- 0, 0, 0, 0, 0,
- 1, 1, 4
- },
- {
- MESA_FORMAT_B8G8R8X8_SRGB,
- "MESA_FORMAT_B8G8R8X8_SRGB",
- GL_RGB,
- GL_UNSIGNED_NORMALIZED,
- 8, 8, 8, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 4
- },
- {
- MESA_FORMAT_R8G8B8A8_SRGB,
- "MESA_FORMAT_R8G8B8A8_SRGB",
- GL_RGBA,
- GL_UNSIGNED_NORMALIZED,
- 8, 8, 8, 8,
- 0, 0, 0, 0, 0,
- 1, 1, 4
- },
- {
- MESA_FORMAT_R8G8B8X8_SRGB,
- "MESA_FORMAT_R8G8B8X8_SRGB",
- GL_RGB,
- GL_UNSIGNED_NORMALIZED,
- 8, 8, 8, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 4
- },
- {
- MESA_FORMAT_L8A8_SRGB,
- "MESA_FORMAT_L8A8_SRGB",
- GL_LUMINANCE_ALPHA,
- GL_UNSIGNED_NORMALIZED,
- 0, 0, 0, 8,
- 8, 0, 0, 0, 0,
- 1, 1, 2
- },
-
- /* Array sRGB formats */
- {
- MESA_FORMAT_L_SRGB8,
- "MESA_FORMAT_L_SRGB8",
- GL_LUMINANCE,
- GL_UNSIGNED_NORMALIZED,
- 0, 0, 0, 0,
- 8, 0, 0, 0, 0,
- 1, 1, 1
- },
- {
- MESA_FORMAT_BGR_SRGB8,
- "MESA_FORMAT_BGR_SRGB8",
- GL_RGB,
- GL_UNSIGNED_NORMALIZED,
- 8, 8, 8, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 3
- },
-
- /* Packed float formats */
- {
- MESA_FORMAT_R9G9B9E5_FLOAT,
- "MESA_FORMAT_RGB9_E5",
- GL_RGB,
- GL_FLOAT,
- 9, 9, 9, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 4
- },
- {
- MESA_FORMAT_R11G11B10_FLOAT,
- "MESA_FORMAT_R11G11B10_FLOAT",
- GL_RGB,
- GL_FLOAT,
- 11, 11, 10, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 4
- },
- {
- MESA_FORMAT_Z32_FLOAT_S8X24_UINT, /* Name */
- "MESA_FORMAT_Z32_FLOAT_S8X24_UINT", /* StrName */
- GL_DEPTH_STENCIL, /* BaseFormat */
- /* DataType here is used to answer GL_TEXTURE_DEPTH_TYPE queries, and is
- * never used for stencil because stencil is always GL_UNSIGNED_INT.
- */
- GL_FLOAT, /* DataType */
- 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
- 0, 0, 0, 32, 8, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 8 /* BlockWidth/Height,Bytes */
- },
-
- /* Array float formats */
- {
- MESA_FORMAT_A_FLOAT16,
- "MESA_FORMAT_A_FLOAT16",
- GL_ALPHA,
- GL_FLOAT,
- 0, 0, 0, 16,
- 0, 0, 0, 0, 0,
- 1, 1, 2
- },
- {
- MESA_FORMAT_A_FLOAT32,
- "MESA_FORMAT_A_FLOAT32",
- GL_ALPHA,
- GL_FLOAT,
- 0, 0, 0, 32,
- 0, 0, 0, 0, 0,
- 1, 1, 4
- },
- {
- MESA_FORMAT_L_FLOAT16,
- "MESA_FORMAT_L_FLOAT16",
- GL_LUMINANCE,
- GL_FLOAT,
- 0, 0, 0, 0,
- 16, 0, 0, 0, 0,
- 1, 1, 2
- },
- {
- MESA_FORMAT_L_FLOAT32,
- "MESA_FORMAT_L_FLOAT32",
- GL_LUMINANCE,
- GL_FLOAT,
- 0, 0, 0, 0,
- 32, 0, 0, 0, 0,
- 1, 1, 4
- },
- {
- MESA_FORMAT_LA_FLOAT16,
- "MESA_FORMAT_LA_FLOAT16",
- GL_LUMINANCE_ALPHA,
- GL_FLOAT,
- 0, 0, 0, 16,
- 16, 0, 0, 0, 0,
- 1, 1, 4
- },
- {
- MESA_FORMAT_LA_FLOAT32,
- "MESA_FORMAT_LA_FLOAT32",
- GL_LUMINANCE_ALPHA,
- GL_FLOAT,
- 0, 0, 0, 32,
- 32, 0, 0, 0, 0,
- 1, 1, 8
- },
- {
- MESA_FORMAT_I_FLOAT16,
- "MESA_FORMAT_I_FLOAT16",
- GL_INTENSITY,
- GL_FLOAT,
- 0, 0, 0, 0,
- 0, 16, 0, 0, 0,
- 1, 1, 2
- },
- {
- MESA_FORMAT_I_FLOAT32,
- "MESA_FORMAT_I_FLOAT32",
- GL_INTENSITY,
- GL_FLOAT,
- 0, 0, 0, 0,
- 0, 32, 0, 0, 0,
- 1, 1, 4
- },
- {
- MESA_FORMAT_R_FLOAT16,
- "MESA_FORMAT_R_FLOAT16",
- GL_RED,
- GL_FLOAT,
- 16, 0, 0, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 2
- },
- {
- MESA_FORMAT_R_FLOAT32,
- "MESA_FORMAT_R_FLOAT32",
- GL_RED,
- GL_FLOAT,
- 32, 0, 0, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 4
- },
- {
- MESA_FORMAT_RG_FLOAT16,
- "MESA_FORMAT_RG_FLOAT16",
- GL_RG,
- GL_FLOAT,
- 16, 16, 0, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 4
- },
- {
- MESA_FORMAT_RG_FLOAT32,
- "MESA_FORMAT_RG_FLOAT32",
- GL_RG,
- GL_FLOAT,
- 32, 32, 0, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 8
- },
- {
- MESA_FORMAT_RGB_FLOAT16,
- "MESA_FORMAT_RGB_FLOAT16",
- GL_RGB,
- GL_FLOAT,
- 16, 16, 16, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 6
- },
- {
- MESA_FORMAT_RGB_FLOAT32,
- "MESA_FORMAT_RGB_FLOAT32",
- GL_RGB,
- GL_FLOAT,
- 32, 32, 32, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 12
- },
- {
- MESA_FORMAT_RGBA_FLOAT16,
- "MESA_FORMAT_RGBA_FLOAT16",
- GL_RGBA,
- GL_FLOAT,
- 16, 16, 16, 16,
- 0, 0, 0, 0, 0,
- 1, 1, 8
- },
- {
- MESA_FORMAT_RGBA_FLOAT32,
- "MESA_FORMAT_RGBA_FLOAT32",
- GL_RGBA,
- GL_FLOAT,
- 32, 32, 32, 32,
- 0, 0, 0, 0, 0,
- 1, 1, 16
- },
- {
- MESA_FORMAT_RGBX_FLOAT16,
- "MESA_FORMAT_RGBX_FLOAT16",
- GL_RGB,
- GL_FLOAT,
- 16, 16, 16, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 8
- },
- {
- MESA_FORMAT_RGBX_FLOAT32,
- "MESA_FORMAT_RGBX_FLOAT32",
- GL_RGB,
- GL_FLOAT,
- 32, 32, 32, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 16
- },
- {
- MESA_FORMAT_Z_FLOAT32, /* Name */
- "MESA_FORMAT_Z_FLOAT32", /* StrName */
- GL_DEPTH_COMPONENT, /* BaseFormat */
- GL_FLOAT, /* DataType */
- 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
- 0, 0, 0, 32, 0, /* Lum/Int/Index/Depth/StencilBits */
- 1, 1, 4 /* BlockWidth/Height,Bytes */
- },
-
- /* Packed signed/unsigned non-normalized integer formats */
- {
- MESA_FORMAT_B10G10R10A2_UINT,
- "MESA_FORMAT_B10G10R10A2_UINT",
- GL_RGBA,
- GL_UNSIGNED_INT,
- 10, 10, 10, 2,
- 0, 0, 0, 0, 0,
- 1, 1, 4
- },
- {
- MESA_FORMAT_R10G10B10A2_UINT,
- "MESA_FORMAT_R10G10B10A2_UINT",
- GL_RGBA,
- GL_UNSIGNED_INT,
- 10, 10, 10, 2,
- 0, 0, 0, 0, 0,
- 1, 1, 4
- },
-
- /* Array signed/unsigned non-normalized integer formats */
- {
- MESA_FORMAT_A_UINT8,
- "MESA_FORMAT_A_UINT8",
- GL_ALPHA,
- GL_UNSIGNED_INT,
- 0, 0, 0, 8,
- 0, 0, 0, 0, 0,
- 1, 1, 1
- },
- {
- MESA_FORMAT_A_UINT16,
- "MESA_FORMAT_A_UINT16",
- GL_ALPHA,
- GL_UNSIGNED_INT,
- 0, 0, 0, 16,
- 0, 0, 0, 0, 0,
- 1, 1, 2
- },
- {
- MESA_FORMAT_A_UINT32,
- "MESA_FORMAT_A_UINT32",
- GL_ALPHA,
- GL_UNSIGNED_INT,
- 0, 0, 0, 32,
- 0, 0, 0, 0, 0,
- 1, 1, 4
- },
- {
- MESA_FORMAT_A_SINT8,
- "MESA_FORMAT_A_SINT8",
- GL_ALPHA,
- GL_INT,
- 0, 0, 0, 8,
- 0, 0, 0, 0, 0,
- 1, 1, 1
- },
- {
- MESA_FORMAT_A_SINT16,
- "MESA_FORMAT_A_SINT16",
- GL_ALPHA,
- GL_INT,
- 0, 0, 0, 16,
- 0, 0, 0, 0, 0,
- 1, 1, 2
- },
- {
- MESA_FORMAT_A_SINT32,
- "MESA_FORMAT_A_SINT32",
- GL_ALPHA,
- GL_INT,
- 0, 0, 0, 32,
- 0, 0, 0, 0, 0,
- 1, 1, 4
- },
- {
- MESA_FORMAT_I_UINT8,
- "MESA_FORMAT_I_UINT8",
- GL_INTENSITY,
- GL_UNSIGNED_INT,
- 0, 0, 0, 0,
- 0, 8, 0, 0, 0,
- 1, 1, 1
- },
- {
- MESA_FORMAT_I_UINT16,
- "MESA_FORMAT_I_UINT16",
- GL_INTENSITY,
- GL_UNSIGNED_INT,
- 0, 0, 0, 0,
- 0, 16, 0, 0, 0,
- 1, 1, 2
- },
- {
- MESA_FORMAT_I_UINT32,
- "MESA_FORMAT_I_UINT32",
- GL_INTENSITY,
- GL_UNSIGNED_INT,
- 0, 0, 0, 0,
- 0, 32, 0, 0, 0,
- 1, 1, 4
- },
- {
- MESA_FORMAT_I_SINT8,
- "MESA_FORMAT_I_SINT8",
- GL_INTENSITY,
- GL_INT,
- 0, 0, 0, 0,
- 0, 8, 0, 0, 0,
- 1, 1, 1
- },
- {
- MESA_FORMAT_I_SINT16,
- "MESA_FORMAT_I_SINT16",
- GL_INTENSITY,
- GL_INT,
- 0, 0, 0, 0,
- 0, 16, 0, 0, 0,
- 1, 1, 2
- },
- {
- MESA_FORMAT_I_SINT32,
- "MESA_FORMAT_I_SINT32",
- GL_INTENSITY,
- GL_INT,
- 0, 0, 0, 0,
- 0, 32, 0, 0, 0,
- 1, 1, 4
- },
- {
- MESA_FORMAT_L_UINT8,
- "MESA_FORMAT_L_UINT8",
- GL_LUMINANCE,
- GL_UNSIGNED_INT,
- 0, 0, 0, 0,
- 8, 0, 0, 0, 0,
- 1, 1, 1
- },
- {
- MESA_FORMAT_L_UINT16,
- "MESA_FORMAT_L_UINT16",
- GL_LUMINANCE,
- GL_UNSIGNED_INT,
- 0, 0, 0, 0,
- 16, 0, 0, 0, 0,
- 1, 1, 2
- },
- {
- MESA_FORMAT_L_UINT32,
- "MESA_FORMAT_L_UINT32",
- GL_LUMINANCE,
- GL_UNSIGNED_INT,
- 0, 0, 0, 0,
- 32, 0, 0, 0, 0,
- 1, 1, 4
- },
- {
- MESA_FORMAT_L_SINT8,
- "MESA_FORMAT_L_SINT8",
- GL_LUMINANCE,
- GL_INT,
- 0, 0, 0, 0,
- 8, 0, 0, 0, 0,
- 1, 1, 1
- },
- {
- MESA_FORMAT_L_SINT16,
- "MESA_FORMAT_L_SINT16",
- GL_LUMINANCE,
- GL_INT,
- 0, 0, 0, 0,
- 16, 0, 0, 0, 0,
- 1, 1, 2
- },
- {
- MESA_FORMAT_L_SINT32,
- "MESA_FORMAT_L_SINT32",
- GL_LUMINANCE,
- GL_INT,
- 0, 0, 0, 0,
- 32, 0, 0, 0, 0,
- 1, 1, 4
- },
- {
- MESA_FORMAT_LA_UINT8,
- "MESA_FORMAT_LA_UINT8",
- GL_LUMINANCE_ALPHA,
- GL_UNSIGNED_INT,
- 0, 0, 0, 8,
- 8, 0, 0, 0, 0,
- 1, 1, 2
- },
- {
- MESA_FORMAT_LA_UINT16,
- "MESA_FORMAT_LA_UINT16",
- GL_LUMINANCE_ALPHA,
- GL_UNSIGNED_INT,
- 0, 0, 0, 16,
- 16, 0, 0, 0, 0,
- 1, 1, 4
- },
- {
- MESA_FORMAT_LA_UINT32,
- "MESA_FORMAT_LA_UINT32",
- GL_LUMINANCE_ALPHA,
- GL_UNSIGNED_INT,
- 0, 0, 0, 32,
- 32, 0, 0, 0, 0,
- 1, 1, 8
- },
- {
- MESA_FORMAT_LA_SINT8,
- "MESA_FORMAT_LA_SINT8",
- GL_LUMINANCE_ALPHA,
- GL_INT,
- 0, 0, 0, 8,
- 8, 0, 0, 0, 0,
- 1, 1, 2
- },
- {
- MESA_FORMAT_LA_SINT16,
- "MESA_FORMAT_LA_SINT16",
- GL_LUMINANCE_ALPHA,
- GL_INT,
- 0, 0, 0, 16,
- 16, 0, 0, 0, 0,
- 1, 1, 4
- },
- {
- MESA_FORMAT_LA_SINT32,
- "MESA_FORMAT_LA_SINT32",
- GL_LUMINANCE_ALPHA,
- GL_INT,
- 0, 0, 0, 32,
- 32, 0, 0, 0, 0,
- 1, 1, 8
- },
- {
- MESA_FORMAT_R_UINT8,
- "MESA_FORMAT_R_UINT8",
- GL_RED,
- GL_UNSIGNED_INT,
- 8, 0, 0, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 1
- },
- {
- MESA_FORMAT_R_UINT16,
- "MESA_FORMAT_R_UINT16",
- GL_RED,
- GL_UNSIGNED_INT,
- 16, 0, 0, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 2
- },
- {
- MESA_FORMAT_R_UINT32,
- "MESA_FORMAT_R_UINT32",
- GL_RED,
- GL_UNSIGNED_INT,
- 32, 0, 0, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 4
- },
- {
- MESA_FORMAT_R_SINT8,
- "MESA_FORMAT_R_SINT8",
- GL_RED,
- GL_INT,
- 8, 0, 0, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 1
- },
- {
- MESA_FORMAT_R_SINT16,
- "MESA_FORMAT_R_SINT16",
- GL_RED,
- GL_INT,
- 16, 0, 0, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 2
- },
- {
- MESA_FORMAT_R_SINT32,
- "MESA_FORMAT_R_SINT32",
- GL_RED,
- GL_INT,
- 32, 0, 0, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 4
- },
- {
- MESA_FORMAT_RG_UINT8,
- "MESA_FORMAT_RG_UINT8",
- GL_RG,
- GL_UNSIGNED_INT,
- 8, 8, 0, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 2
- },
- {
- MESA_FORMAT_RG_UINT16,
- "MESA_FORMAT_RG_UINT16",
- GL_RG,
- GL_UNSIGNED_INT,
- 16, 16, 0, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 4
- },
- {
- MESA_FORMAT_RG_UINT32,
- "MESA_FORMAT_RG_UINT32",
- GL_RG,
- GL_UNSIGNED_INT,
- 32, 32, 0, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 8
- },
- {
- MESA_FORMAT_RG_SINT8,
- "MESA_FORMAT_RG_SINT8",
- GL_RG,
- GL_INT,
- 8, 8, 0, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 2
- },
- {
- MESA_FORMAT_RG_SINT16,
- "MESA_FORMAT_RG_SINT16",
- GL_RG,
- GL_INT,
- 16, 16, 0, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 4
- },
- {
- MESA_FORMAT_RG_SINT32,
- "MESA_FORMAT_RG_SINT32",
- GL_RG,
- GL_INT,
- 32, 32, 0, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 8
- },
- {
- MESA_FORMAT_RGB_UINT8,
- "MESA_FORMAT_RGB_UINT8",
- GL_RGB,
- GL_UNSIGNED_INT,
- 8, 8, 8, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 3
- },
- {
- MESA_FORMAT_RGB_UINT16,
- "MESA_FORMAT_RGB_UINT16",
- GL_RGB,
- GL_UNSIGNED_INT,
- 16, 16, 16, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 6
- },
- {
- MESA_FORMAT_RGB_UINT32,
- "MESA_FORMAT_RGB_UINT32",
- GL_RGB,
- GL_UNSIGNED_INT,
- 32, 32, 32, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 12
- },
- {
- MESA_FORMAT_RGB_SINT8,
- "MESA_FORMAT_RGB_SINT8",
- GL_RGB,
- GL_INT,
- 8, 8, 8, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 3
- },
- {
- MESA_FORMAT_RGB_SINT16,
- "MESA_FORMAT_RGB_SINT16",
- GL_RGB,
- GL_INT,
- 16, 16, 16, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 6
- },
- {
- MESA_FORMAT_RGB_SINT32,
- "MESA_FORMAT_RGB_SINT32",
- GL_RGB,
- GL_INT,
- 32, 32, 32, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 12
- },
- {
- MESA_FORMAT_RGBA_UINT8,
- "MESA_FORMAT_RGBA_UINT8",
- GL_RGBA,
- GL_UNSIGNED_INT,
- 8, 8, 8, 8,
- 0, 0, 0, 0, 0,
- 1, 1, 4
- },
- {
- MESA_FORMAT_RGBA_UINT16,
- "MESA_FORMAT_RGBA_UINT16",
- GL_RGBA,
- GL_UNSIGNED_INT,
- 16, 16, 16, 16,
- 0, 0, 0, 0, 0,
- 1, 1, 8
- },
- {
- MESA_FORMAT_RGBA_UINT32,
- "MESA_FORMAT_RGBA_UINT32",
- GL_RGBA,
- GL_UNSIGNED_INT,
- 32, 32, 32, 32,
- 0, 0, 0, 0, 0,
- 1, 1, 16
- },
- {
- MESA_FORMAT_RGBA_SINT8,
- "MESA_FORMAT_RGBA_SINT8",
- GL_RGBA,
- GL_INT,
- 8, 8, 8, 8,
- 0, 0, 0, 0, 0,
- 1, 1, 4
- },
- {
- MESA_FORMAT_RGBA_SINT16,
- "MESA_FORMAT_RGBA_SINT16",
- GL_RGBA,
- GL_INT,
- 16, 16, 16, 16,
- 0, 0, 0, 0, 0,
- 1, 1, 8
- },
- {
- MESA_FORMAT_RGBA_SINT32,
- "MESA_FORMAT_RGBA_SINT32",
- GL_RGBA,
- GL_INT,
- 32, 32, 32, 32,
- 0, 0, 0, 0, 0,
- 1, 1, 16
- },
- {
- MESA_FORMAT_RGBX_UINT8,
- "MESA_FORMAT_RGBX_UINT8",
- GL_RGB,
- GL_UNSIGNED_INT,
- 8, 8, 8, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 4
- },
- {
- MESA_FORMAT_RGBX_UINT16,
- "MESA_FORMAT_RGBX_UINT16",
- GL_RGB,
- GL_UNSIGNED_INT,
- 16, 16, 16, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 8
- },
- {
- MESA_FORMAT_RGBX_UINT32,
- "MESA_FORMAT_RGBX_UINT32",
- GL_RGB,
- GL_UNSIGNED_INT,
- 32, 32, 32, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 16
- },
- {
- MESA_FORMAT_RGBX_SINT8,
- "MESA_FORMAT_RGBX_SINT8",
- GL_RGB,
- GL_INT,
- 8, 8, 8, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 4
- },
- {
- MESA_FORMAT_RGBX_SINT16,
- "MESA_FORMAT_RGBX_SINT16",
- GL_RGB,
- GL_INT,
- 16, 16, 16, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 8
- },
- {
- MESA_FORMAT_RGBX_SINT32,
- "MESA_FORMAT_RGBX_SINT32",
- GL_RGB,
- GL_INT,
- 32, 32, 32, 0,
- 0, 0, 0, 0, 0,
- 1, 1, 16
- },
-
- /* DXT compressed formats */
- {
- MESA_FORMAT_RGB_DXT1, /* Name */
- "MESA_FORMAT_RGB_DXT1", /* StrName */
- GL_RGB, /* BaseFormat */
- GL_UNSIGNED_NORMALIZED, /* DataType */
- 4, 4, 4, 0, /* approx Red/Green/Blue/AlphaBits */
- 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
- 4, 4, 8 /* 8 bytes per 4x4 block */
- },
- {
- MESA_FORMAT_RGBA_DXT1,
- "MESA_FORMAT_RGBA_DXT1",
- GL_RGBA,
- GL_UNSIGNED_NORMALIZED,
- 4, 4, 4, 4,
- 0, 0, 0, 0, 0,
- 4, 4, 8 /* 8 bytes per 4x4 block */
- },
- {
- MESA_FORMAT_RGBA_DXT3,
- "MESA_FORMAT_RGBA_DXT3",
- GL_RGBA,
- GL_UNSIGNED_NORMALIZED,
- 4, 4, 4, 4,
- 0, 0, 0, 0, 0,
- 4, 4, 16 /* 16 bytes per 4x4 block */
- },
- {
- MESA_FORMAT_RGBA_DXT5,
- "MESA_FORMAT_RGBA_DXT5",
- GL_RGBA,
- GL_UNSIGNED_NORMALIZED,
- 4, 4, 4, 4,
- 0, 0, 0, 0, 0,
- 4, 4, 16 /* 16 bytes per 4x4 block */
- },
-
- /* DXT sRGB compressed formats */
- {
- MESA_FORMAT_SRGB_DXT1, /* Name */
- "MESA_FORMAT_SRGB_DXT1", /* StrName */
- GL_RGB, /* BaseFormat */
- GL_UNSIGNED_NORMALIZED, /* DataType */
- 4, 4, 4, 0, /* approx Red/Green/Blue/AlphaBits */
- 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
- 4, 4, 8 /* 8 bytes per 4x4 block */
- },
- {
- MESA_FORMAT_SRGBA_DXT1,
- "MESA_FORMAT_SRGBA_DXT1",
- GL_RGBA,
- GL_UNSIGNED_NORMALIZED,
- 4, 4, 4, 4,
- 0, 0, 0, 0, 0,
- 4, 4, 8 /* 8 bytes per 4x4 block */
- },
- {
- MESA_FORMAT_SRGBA_DXT3,
- "MESA_FORMAT_SRGBA_DXT3",
- GL_RGBA,
- GL_UNSIGNED_NORMALIZED,
- 4, 4, 4, 4,
- 0, 0, 0, 0, 0,
- 4, 4, 16 /* 16 bytes per 4x4 block */
- },
- {
- MESA_FORMAT_SRGBA_DXT5,
- "MESA_FORMAT_SRGBA_DXT5",
- GL_RGBA,
- GL_UNSIGNED_NORMALIZED,
- 4, 4, 4, 4,
- 0, 0, 0, 0, 0,
- 4, 4, 16 /* 16 bytes per 4x4 block */
- },
-
- /* FXT1 compressed formats */
- {
- MESA_FORMAT_RGB_FXT1,
- "MESA_FORMAT_RGB_FXT1",
- GL_RGB,
- GL_UNSIGNED_NORMALIZED,
- 4, 4, 4, 0, /* approx Red/Green/BlueBits */
- 0, 0, 0, 0, 0,
- 8, 4, 16 /* 16 bytes per 8x4 block */
- },
- {
- MESA_FORMAT_RGBA_FXT1,
- "MESA_FORMAT_RGBA_FXT1",
- GL_RGBA,
- GL_UNSIGNED_NORMALIZED,
- 4, 4, 4, 1, /* approx Red/Green/Blue/AlphaBits */
- 0, 0, 0, 0, 0,
- 8, 4, 16 /* 16 bytes per 8x4 block */
- },
-
- /* RGTC compressed formats */
- {
- MESA_FORMAT_R_RGTC1_UNORM,
- "MESA_FORMAT_R_RGTC1_UNORM",
- GL_RED,
- GL_UNSIGNED_NORMALIZED,
- 8, 0, 0, 0,
- 0, 0, 0, 0, 0,
- 4, 4, 8 /* 8 bytes per 4x4 block */
- },
- {
- MESA_FORMAT_R_RGTC1_SNORM,
- "MESA_FORMAT_R_RGTC1_SNORM",
- GL_RED,
- GL_SIGNED_NORMALIZED,
- 8, 0, 0, 0,
- 0, 0, 0, 0, 0,
- 4, 4, 8 /* 8 bytes per 4x4 block */
- },
- {
- MESA_FORMAT_RG_RGTC2_UNORM,
- "MESA_FORMAT_RG_RGTC2_UNORM",
- GL_RG,
- GL_UNSIGNED_NORMALIZED,
- 8, 8, 0, 0,
- 0, 0, 0, 0, 0,
- 4, 4, 16 /* 16 bytes per 4x4 block */
- },
- {
- MESA_FORMAT_RG_RGTC2_SNORM,
- "MESA_FORMAT_RG_RGTC2_SNORM",
- GL_RG,
- GL_SIGNED_NORMALIZED,
- 8, 8, 0, 0,
- 0, 0, 0, 0, 0,
- 4, 4, 16 /* 16 bytes per 4x4 block */
- },
-
- /* LATC1/2 compressed formats */
- {
- MESA_FORMAT_L_LATC1_UNORM,
- "MESA_FORMAT_L_LATC1_UNORM",
- GL_LUMINANCE,
- GL_UNSIGNED_NORMALIZED,
- 0, 0, 0, 0,
- 4, 0, 0, 0, 0,
- 4, 4, 8 /* 8 bytes per 4x4 block */
- },
- {
- MESA_FORMAT_L_LATC1_SNORM,
- "MESA_FORMAT_L_LATC1_SNORM",
- GL_LUMINANCE,
- GL_SIGNED_NORMALIZED,
- 0, 0, 0, 0,
- 4, 0, 0, 0, 0,
- 4, 4, 8 /* 8 bytes per 4x4 block */
- },
- {
- MESA_FORMAT_LA_LATC2_UNORM,
- "MESA_FORMAT_LA_LATC2_UNORM",
- GL_LUMINANCE_ALPHA,
- GL_UNSIGNED_NORMALIZED,
- 0, 0, 0, 4,
- 4, 0, 0, 0, 0,
- 4, 4, 16 /* 16 bytes per 4x4 block */
- },
- {
- MESA_FORMAT_LA_LATC2_SNORM,
- "MESA_FORMAT_LA_LATC2_SNORM",
- GL_LUMINANCE_ALPHA,
- GL_SIGNED_NORMALIZED,
- 0, 0, 0, 4,
- 4, 0, 0, 0, 0,
- 4, 4, 16 /* 16 bytes per 4x4 block */
- },
-
- /* ETC1/2 compressed formats */
- {
- MESA_FORMAT_ETC1_RGB8,
- "MESA_FORMAT_ETC1_RGB8",
- GL_RGB,
- GL_UNSIGNED_NORMALIZED,
- 8, 8, 8, 0,
- 0, 0, 0, 0, 0,
- 4, 4, 8 /* 8 bytes per 4x4 block */
- },
- {
- MESA_FORMAT_ETC2_RGB8,
- "MESA_FORMAT_ETC2_RGB8",
- GL_RGB,
- GL_UNSIGNED_NORMALIZED,
- 8, 8, 8, 0,
- 0, 0, 0, 0, 0,
- 4, 4, 8 /* 8 bytes per 4x4 block */
- },
- {
- MESA_FORMAT_ETC2_SRGB8,
- "MESA_FORMAT_ETC2_SRGB8",
- GL_RGB,
- GL_UNSIGNED_NORMALIZED,
- 8, 8, 8, 0,
- 0, 0, 0, 0, 0,
- 4, 4, 8 /* 8 bytes per 4x4 block */
- },
- {
- MESA_FORMAT_ETC2_RGBA8_EAC,
- "MESA_FORMAT_ETC2_RGBA8_EAC",
- GL_RGBA,
- GL_UNSIGNED_NORMALIZED,
- 8, 8, 8, 8,
- 0, 0, 0, 0, 0,
- 4, 4, 16 /* 16 bytes per 4x4 block */
- },
- {
- MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC,
- "MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC",
- GL_RGBA,
- GL_UNSIGNED_NORMALIZED,
- 8, 8, 8, 8,
- 0, 0, 0, 0, 0,
- 4, 4, 16 /* 16 bytes per 4x4 block */
- },
- {
- MESA_FORMAT_ETC2_R11_EAC,
- "MESA_FORMAT_ETC2_R11_EAC",
- GL_RED,
- GL_UNSIGNED_NORMALIZED,
- 11, 0, 0, 0,
- 0, 0, 0, 0, 0,
- 4, 4, 8 /* 8 bytes per 4x4 block */
- },
- {
- MESA_FORMAT_ETC2_RG11_EAC,
- "MESA_FORMAT_ETC2_RG11_EAC",
- GL_RG,
- GL_UNSIGNED_NORMALIZED,
- 11, 11, 0, 0,
- 0, 0, 0, 0, 0,
- 4, 4, 16 /* 16 bytes per 4x4 block */
- },
- {
- MESA_FORMAT_ETC2_SIGNED_R11_EAC,
- "MESA_FORMAT_ETC2_SIGNED_R11_EAC",
- GL_RED,
- GL_SIGNED_NORMALIZED,
- 11, 0, 0, 0,
- 0, 0, 0, 0, 0,
- 4, 4, 8 /* 8 bytes per 4x4 block */
- },
- {
- MESA_FORMAT_ETC2_SIGNED_RG11_EAC,
- "MESA_FORMAT_ETC2_SIGNED_RG11_EAC",
- GL_RG,
- GL_SIGNED_NORMALIZED,
- 11, 11, 0, 0,
- 0, 0, 0, 0, 0,
- 4, 4, 16 /* 16 bytes per 4x4 block */
- },
- {
- MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1,
- "MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1",
- GL_RGBA,
- GL_UNSIGNED_NORMALIZED,
- 8, 8, 8, 1,
- 0, 0, 0, 0, 0,
- 4, 4, 8 /* 8 bytes per 4x4 block */
- },
- {
- MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1,
- "MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1",
- GL_RGBA,
- GL_UNSIGNED_NORMALIZED,
- 8, 8, 8, 1,
- 0, 0, 0, 0, 0,
- 4, 4, 8 /* 8 bytes per 4x4 block */
- },
+ uint8_t Swizzle[4];
};
-
+#include "format_info.c"
static const struct gl_format_info *
_mesa_get_format_info(mesa_format format)
@@ -1881,7 +148,7 @@ _mesa_get_format_bits(mesa_format format, GLenum pname)
case GL_TEXTURE_LUMINANCE_SIZE:
return info->LuminanceBits;
case GL_INDEX_BITS:
- return info->IndexBits;
+ return 0;
case GL_DEPTH_BITS:
case GL_TEXTURE_DEPTH_SIZE_ARB:
case GL_RENDERBUFFER_DEPTH_SIZE_EXT:
@@ -1915,6 +182,21 @@ _mesa_get_format_max_bits(mesa_format format)
/**
+ * Return the layout type of the given format.
+ * The return value will be one of:
+ * MESA_FORMAT_LAYOUT_ARRAY
+ * MESA_FORMAT_LAYOUT_PACKED
+ * MESA_FORMAT_LAYOUT_OTHER
+ */
+extern enum mesa_format_layout
+_mesa_get_format_layout(mesa_format format)
+{
+ const struct gl_format_info *info = _mesa_get_format_info(format);
+ return info->Layout;
+}
+
+
+/**
* Return the data type (or more specifically, the data representation)
* for the given format.
* The return value will be one of:
@@ -1961,6 +243,33 @@ _mesa_get_format_block_size(mesa_format format, GLuint *bw, GLuint *bh)
}
+/**
+ * Returns the an array of four numbers representing the transformation
+ * from the RGBA or SZ colorspace to the given format. For array formats,
+ * the i'th RGBA component is given by:
+ *
+ * if (swizzle[i] <= MESA_FORMAT_SWIZZLE_W)
+ * comp = data[swizzle[i]];
+ * else if (swizzle[i] == MESA_FORMAT_SWIZZLE_ZERO)
+ * comp = 0;
+ * else if (swizzle[i] == MESA_FORMAT_SWIZZLE_ONE)
+ * comp = 1;
+ * else if (swizzle[i] == MESA_FORMAT_SWIZZLE_NONE)
+ * // data does not contain a channel of this format
+ *
+ * For packed formats, the swizzle gives the number of components left of
+ * the least significant bit.
+ *
+ * Compressed formats have no swizzle.
+ */
+void
+_mesa_get_format_swizzle(mesa_format format, uint8_t swizzle_out[4])
+{
+ const struct gl_format_info *info = _mesa_get_format_info(format);
+ memcpy(swizzle_out, info->Swizzle, sizeof(info->Swizzle));
+}
+
+
/** Is the given format a compressed format? */
GLboolean
_mesa_is_format_compressed(mesa_format format)
@@ -2331,7 +640,6 @@ check_format_to_type_and_comps(void)
}
}
-
/**
* Do sanity checking of the format info table.
*/
diff --git a/mesalib/src/mesa/main/formats.csv b/mesalib/src/mesa/main/formats.csv
new file mode 100644
index 000000000..eade6facd
--- /dev/null
+++ b/mesalib/src/mesa/main/formats.csv
@@ -0,0 +1,282 @@
+###########################################################################
+#
+# Copyright 2009-2010 VMware, Inc.
+# Copyright 2014 Intel Corporation
+# All Rights Reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sub license, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice (including the
+# next paragraph) shall be included in all copies or substantial portions
+# of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+# IN NO EVENT SHALL THE AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR
+# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+###########################################################################
+
+# This CSV file has the input data for gen_format.h and gen_format.c
+#
+# Each format entry contains:
+# - name, per enum mesa_format
+# - layout
+# - pixel block's width
+# - pixel block's height
+# - channel encoding (only meaningful for array or packed layout), containing for each
+# channel the following information:
+# - type, one of
+# - 'x': void
+# - 'u': unsigned
+# - 's': signed
+# - 'h': fixed
+# - 'f': FLOAT
+# - optionally followed by 'n' if it is normalized
+# - number of bits
+# - channel swizzle
+# - color space: rgb, srgb, yub, sz
+
+# None
+# Described as regular uint_8 bytes, i.e. MESA_FORMAT_R8_USCALED
+MESA_FORMAT_NONE , other , 1, 1, x8 , , , , 0001, rgb
+
+# Packed unorm formats
+MESA_FORMAT_A8B8G8R8_UNORM , packed, 1, 1, un8 , un8 , un8 , un8 , wzyx, rgb
+MESA_FORMAT_X8B8G8R8_UNORM , packed, 1, 1, x8 , un8 , un8 , un8 , wzy1, rgb
+MESA_FORMAT_R8G8B8A8_UNORM , packed, 1, 1, un8 , un8 , un8 , un8 , xyzw, rgb
+MESA_FORMAT_R8G8B8X8_UNORM , packed, 1, 1, un8 , un8 , un8 , x8 , xyz1, rgb
+MESA_FORMAT_B8G8R8A8_UNORM , packed, 1, 1, un8 , un8 , un8 , un8 , zyxw, rgb
+MESA_FORMAT_B8G8R8X8_UNORM , packed, 1, 1, un8 , un8 , un8 , x8 , zyx1, rgb
+MESA_FORMAT_A8R8G8B8_UNORM , packed, 1, 1, un8 , un8 , un8 , un8 , yzwx, rgb
+MESA_FORMAT_X8R8G8B8_UNORM , packed, 1, 1, x8 , un8 , un8 , un8 , yzw1, rgb
+MESA_FORMAT_L16A16_UNORM , packed, 1, 1, un16, un16, , , xxxy, rgb
+MESA_FORMAT_A16L16_UNORM , packed, 1, 1, un16, un16, , , yyyx, rgb
+MESA_FORMAT_B5G6R5_UNORM , packed, 1, 1, un5 , un6 , un5 , , zyx1, rgb
+MESA_FORMAT_R5G6B5_UNORM , packed, 1, 1, un5 , un6 , un5 , , xyz1, rgb
+MESA_FORMAT_B4G4R4A4_UNORM , packed, 1, 1, un4 , un4 , un4 , un4 , zyxw, rgb
+MESA_FORMAT_B4G4R4X4_UNORM , packed, 1, 1, un4 , un4 , un4 , x4 , zyx1, rgb
+MESA_FORMAT_A4R4G4B4_UNORM , packed, 1, 1, un4 , un4 , un4 , un4 , yzwx, rgb
+MESA_FORMAT_A1B5G5R5_UNORM , packed, 1, 1, un1 , un5 , un5 , un5 , wzyx, rgb
+MESA_FORMAT_B5G5R5A1_UNORM , packed, 1, 1, un5 , un5 , un5 , un1 , zyxw, rgb
+MESA_FORMAT_B5G5R5X1_UNORM , packed, 1, 1, un5 , un5 , un5 , x1 , zyx1, rgb
+MESA_FORMAT_A1R5G5B5_UNORM , packed, 1, 1, un1 , un5 , un5 , un5 , yzwx, rgb
+MESA_FORMAT_L8A8_UNORM , packed, 1, 1, un8 , un8 , , , xxxy, rgb
+MESA_FORMAT_A8L8_UNORM , packed, 1, 1, un8 , un8 , , , yyyx, rgb
+MESA_FORMAT_R8G8_UNORM , packed, 1, 1, un8 , un8 , , , xy01, rgb
+MESA_FORMAT_G8R8_UNORM , packed, 1, 1, un8 , un8 , , , yx01, rgb
+MESA_FORMAT_L4A4_UNORM , packed, 1, 1, un4 , un4 , , , xxxy, rgb
+
+MESA_FORMAT_B2G3R3_UNORM , packed, 1, 1, un2 , un3 , un3 , , zyx1, rgb
+MESA_FORMAT_R16G16_UNORM , packed, 1, 1, un16, un16, , , xy01, rgb
+MESA_FORMAT_G16R16_UNORM , packed, 1, 1, un16, un16, , , yx01, rgb
+MESA_FORMAT_B10G10R10A2_UNORM , packed, 1, 1, un10, un10, un10, un2 , zyxw, rgb
+MESA_FORMAT_B10G10R10X2_UNORM , packed, 1, 1, un10, un10, un10, x2 , zyx1, rgb
+MESA_FORMAT_R10G10B10A2_UNORM , packed, 1, 1, un10, un10, un10, un2 , xyzw, rgb
+
+MESA_FORMAT_S8_UINT_Z24_UNORM , packed, 1, 1, un24, u8 , , , xy__, zs
+MESA_FORMAT_X8_UINT_Z24_UNORM , packed, 1, 1, un24, x8 , , , x___, zs
+MESA_FORMAT_Z24_UNORM_S8_UINT , packed, 1, 1, u8 , un24, , , yx__, zs
+MESA_FORMAT_Z24_UNORM_X8_UINT , packed, 1, 1, x8 , un24, , , y___, zs
+
+MESA_FORMAT_YCBCR , other , 1, 1, x16 , , , , xyzw, yuv
+MESA_FORMAT_YCBCR_REV , other , 1, 1, x16 , , , , xyzw, yuv
+
+# Array normalized formats
+MESA_FORMAT_A_UNORM8 , array , 1, 1, un8 , , , , 000x, rgb
+MESA_FORMAT_A_UNORM16 , array , 1, 1, un16, , , , 000x, rgb
+MESA_FORMAT_L_UNORM8 , array , 1, 1, un8 , , , , xxx1, rgb
+MESA_FORMAT_L_UNORM16 , array , 1, 1, un16, , , , xxx1, rgb
+MESA_FORMAT_I_UNORM8 , array , 1, 1, un8 , , , , xxxx, rgb
+MESA_FORMAT_I_UNORM16 , array , 1, 1, un16, , , , xxxx, rgb
+MESA_FORMAT_R_UNORM8 , array , 1, 1, un8 , , , , x001, rgb
+MESA_FORMAT_R_UNORM16 , array , 1, 1, un16, , , , x001, rgb
+MESA_FORMAT_BGR_UNORM8 , array , 1, 1, un8 , un8 , un8 , , zyx1, rgb
+MESA_FORMAT_RGB_UNORM8 , array , 1, 1, un8 , un8 , un8 , , xyz1, rgb
+MESA_FORMAT_RGBA_UNORM16 , array , 1, 1, un16, un16, un16, un16, xyzw, rgb
+MESA_FORMAT_RGBX_UNORM16 , array , 1, 1, un16, un16, un16, x16 , xyz1, rgb
+
+MESA_FORMAT_Z_UNORM16 , array , 1, 1, un16, , , , x___, zs
+MESA_FORMAT_Z_UNORM32 , array , 1, 1, un32, , , , x___, zs
+MESA_FORMAT_S_UINT8 , array , 1, 1, u8 , , , , _x__, zs
+
+# Packed signed formats
+MESA_FORMAT_A8B8G8R8_SNORM , packed, 1, 1, sn8 , sn8 , sn8 , sn8 , wzyx, rgb
+MESA_FORMAT_X8B8G8R8_SNORM , packed, 1, 1, x8 , sn8 , sn8 , sn8 , wzy1, rgb
+MESA_FORMAT_R8G8B8A8_SNORM , packed, 1, 1, sn8 , sn8 , sn8 , sn8 , xyzw, rgb
+MESA_FORMAT_R8G8B8X8_SNORM , packed, 1, 1, sn8 , sn8 , sn8 , x8 , xyz1, rgb
+MESA_FORMAT_R16G16_SNORM , packed, 1, 1, sn16, sn16, , , xy01, rgb
+MESA_FORMAT_G16R16_SNORM , packed, 1, 1, sn16, sn16, , , yx01, rgb
+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
+
+# Array signed/normalized formats
+MESA_FORMAT_A_SNORM8 , array , 1, 1, sn8 , , , , 000x, rgb
+MESA_FORMAT_A_SNORM16 , array , 1, 1, sn16, , , , 000x, rgb
+MESA_FORMAT_L_SNORM8 , array , 1, 1, sn8 , , , , xxx1, rgb
+MESA_FORMAT_L_SNORM16 , array , 1, 1, sn16, , , , xxx1, rgb
+MESA_FORMAT_I_SNORM8 , array , 1, 1, sn8 , , , , xxxx, rgb
+MESA_FORMAT_I_SNORM16 , array , 1, 1, sn16, , , , xxxx, rgb
+MESA_FORMAT_R_SNORM8 , array , 1, 1, sn8 , , , , x001, rgb
+MESA_FORMAT_R_SNORM16 , array , 1, 1, sn16, , , , x001, rgb
+MESA_FORMAT_LA_SNORM16 , array , 1, 1, sn16, sn16, , , xxxy, rgb
+MESA_FORMAT_RGB_SNORM16 , array , 1, 1, sn16, sn16, sn16, , xyz1, rgb
+MESA_FORMAT_RGBA_SNORM16 , array , 1, 1, sn16, sn16, sn16, sn16, xyzw, rgb
+MESA_FORMAT_RGBX_SNORM16 , array , 1, 1, sn16, sn16, sn16, x16 , xyz1, rgb
+
+# 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_B8G8R8X8_SRGB , packed, 1, 1, un8 , un8 , un8 , x8 , zyx1, 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_L8A8_SRGB , packed, 1, 1, un8 , un8 , , , xxxy, srgb
+
+# Array sRGB formats
+MESA_FORMAT_L_SRGB8 , array , 1, 1, un8 , , , , xxx1, srgb
+MESA_FORMAT_BGR_SRGB8 , array , 1, 1, un8 , un8 , un8 , , zyx1, srgb
+
+# Packed float formats
+MESA_FORMAT_R9G9B9E5_FLOAT , other , 1, 1, f9 , f9 , f9 , x5 , xyz1, rgb
+MESA_FORMAT_R11G11B10_FLOAT , packed, 1, 1, f11 , f11 , f10 , , xyz1, rgb
+MESA_FORMAT_Z32_FLOAT_S8X24_UINT , packed, 1, 1, u8 , x24 , f32 , , zx__, zs
+
+# Array float formats
+MESA_FORMAT_A_FLOAT16 , array , 1, 1, f16 , , , , 000x, rgb
+MESA_FORMAT_A_FLOAT32 , array , 1, 1, f32 , , , , 000x, rgb
+MESA_FORMAT_L_FLOAT16 , array , 1, 1, f16 , , , , xxx1, rgb
+MESA_FORMAT_L_FLOAT32 , array , 1, 1, f32 , , , , xxx1, rgb
+MESA_FORMAT_LA_FLOAT16 , array , 1, 1, f16 , f16 , , , xxxy, rgb
+MESA_FORMAT_LA_FLOAT32 , array , 1, 1, f32 , f32 , , , xxxy, rgb
+MESA_FORMAT_I_FLOAT16 , array , 1, 1, f16 , , , , xxxx, rgb
+MESA_FORMAT_I_FLOAT32 , array , 1, 1, f32 , , , , xxxx, rgb
+MESA_FORMAT_R_FLOAT16 , array , 1, 1, f16 , , , , x001, rgb
+MESA_FORMAT_R_FLOAT32 , array , 1, 1, f32 , , , , x001, rgb
+MESA_FORMAT_RG_FLOAT16 , array , 1, 1, f16 , f16 , , , xy01, rgb
+MESA_FORMAT_RG_FLOAT32 , array , 1, 1, f32 , f32 , , , xy01, rgb
+MESA_FORMAT_RGB_FLOAT16 , array , 1, 1, f16 , f16 , f16 , , xyz1, rgb
+MESA_FORMAT_RGB_FLOAT32 , array , 1, 1, f32 , f32 , f32 , , xyz1, rgb
+MESA_FORMAT_RGBA_FLOAT16 , array , 1, 1, f16 , f16 , f16 , f16 , xyzw, rgb
+MESA_FORMAT_RGBA_FLOAT32 , array , 1, 1, f32 , f32 , f32 , f32 , xyzw, rgb
+MESA_FORMAT_RGBX_FLOAT16 , array , 1, 1, f16 , f16 , f16 , x16 , xyz1, rgb
+MESA_FORMAT_RGBX_FLOAT32 , array , 1, 1, f32 , f32 , f32 , x32 , xyz1, rgb
+MESA_FORMAT_Z_FLOAT32 , array , 1, 1, f32 , , , , x___, zs
+
+# Packed signed/unsigned non-normalized integer formats
+MESA_FORMAT_B10G10R10A2_UINT , packed, 1, 1, u10 , u10 , u10 , u2 , zyxw, rgb
+MESA_FORMAT_R10G10B10A2_UINT , packed, 1, 1, u10 , u10 , u10 , u2 , xyzw, rgb
+
+# Array signed/unsigned non-normalized integer formats
+MESA_FORMAT_A_UINT8 , array , 1, 1, u8 , , , , 000x, rgb
+MESA_FORMAT_A_UINT16 , array , 1, 1, u16 , , , , 000x, rgb
+MESA_FORMAT_A_UINT32 , array , 1, 1, u32 , , , , 000x, rgb
+MESA_FORMAT_A_SINT8 , array , 1, 1, s8 , , , , 000x, rgb
+MESA_FORMAT_A_SINT16 , array , 1, 1, s16 , , , , 000x, rgb
+MESA_FORMAT_A_SINT32 , array , 1, 1, s32 , , , , 000x, rgb
+
+MESA_FORMAT_I_UINT8 , array , 1, 1, u8 , , , , xxxx, rgb
+MESA_FORMAT_I_UINT16 , array , 1, 1, u16 , , , , xxxx, rgb
+MESA_FORMAT_I_UINT32 , array , 1, 1, u32 , , , , xxxx, rgb
+MESA_FORMAT_I_SINT8 , array , 1, 1, s8 , , , , xxxx, rgb
+MESA_FORMAT_I_SINT16 , array , 1, 1, s16 , , , , xxxx, rgb
+MESA_FORMAT_I_SINT32 , array , 1, 1, s32 , , , , xxxx, rgb
+
+MESA_FORMAT_L_UINT8 , array , 1, 1, u8 , , , , xxx1, rgb
+MESA_FORMAT_L_UINT16 , array , 1, 1, u16 , , , , xxx1, rgb
+MESA_FORMAT_L_UINT32 , array , 1, 1, u32 , , , , xxx1, rgb
+MESA_FORMAT_L_SINT8 , array , 1, 1, s8 , , , , xxx1, rgb
+MESA_FORMAT_L_SINT16 , array , 1, 1, s16 , , , , xxx1, rgb
+MESA_FORMAT_L_SINT32 , array , 1, 1, s32 , , , , xxx1, rgb
+
+MESA_FORMAT_LA_UINT8 , array , 1, 1, u8 , u8 , , , xxxy, rgb
+MESA_FORMAT_LA_UINT16 , array , 1, 1, u16 , u16 , , , xxxy, rgb
+MESA_FORMAT_LA_UINT32 , array , 1, 1, u32 , u32 , , , xxxy, rgb
+MESA_FORMAT_LA_SINT8 , array , 1, 1, s8 , s8 , , , xxxy, rgb
+MESA_FORMAT_LA_SINT16 , array , 1, 1, s16 , s16 , , , xxxy, rgb
+MESA_FORMAT_LA_SINT32 , array , 1, 1, s32 , s32 , , , xxxy, rgb
+
+MESA_FORMAT_R_UINT8 , array , 1, 1, u8 , , , , x001, rgb
+MESA_FORMAT_R_UINT16 , array , 1, 1, u16 , , , , x001, rgb
+MESA_FORMAT_R_UINT32 , array , 1, 1, u32 , , , , x001, rgb
+MESA_FORMAT_R_SINT8 , array , 1, 1, s8 , , , , x001, rgb
+MESA_FORMAT_R_SINT16 , array , 1, 1, s16 , , , , x001, rgb
+MESA_FORMAT_R_SINT32 , array , 1, 1, s32 , , , , x001, rgb
+
+MESA_FORMAT_RG_UINT8 , array , 1, 1, u8 , u8 , , , xy01, rgb
+MESA_FORMAT_RG_UINT16 , array , 1, 1, u16 , u16 , , , xy01, rgb
+MESA_FORMAT_RG_UINT32 , array , 1, 1, u32 , u32 , , , xy01, rgb
+MESA_FORMAT_RG_SINT8 , array , 1, 1, s8 , s8 , , , xy01, rgb
+MESA_FORMAT_RG_SINT16 , array , 1, 1, s16 , s16 , , , xy01, rgb
+MESA_FORMAT_RG_SINT32 , array , 1, 1, s32 , s32 , , , xy01, rgb
+
+MESA_FORMAT_RGB_UINT8 , array , 1, 1, u8 , u8 , u8 , , xyz1, rgb
+MESA_FORMAT_RGB_UINT16 , array , 1, 1, u16 , u16 , u16 , , xyz1, rgb
+MESA_FORMAT_RGB_UINT32 , array , 1, 1, u32 , u32 , u32 , , xyz1, rgb
+MESA_FORMAT_RGB_SINT8 , array , 1, 1, s8 , s8 , s8 , , xyz1, rgb
+MESA_FORMAT_RGB_SINT16 , array , 1, 1, s16 , s16 , s16 , , xyz1, rgb
+MESA_FORMAT_RGB_SINT32 , array , 1, 1, s32 , s32 , s32 , , xyz1, rgb
+
+MESA_FORMAT_RGBA_UINT8 , array , 1, 1, u8 , u8 , u8 , u8 , xyzw, rgb
+MESA_FORMAT_RGBA_UINT16 , array , 1, 1, u16 , u16 , u16 , u16 , xyzw, rgb
+MESA_FORMAT_RGBA_UINT32 , array , 1, 1, u32 , u32 , u32 , u32 , xyzw, rgb
+MESA_FORMAT_RGBA_SINT8 , array , 1, 1, s8 , s8 , s8 , s8 , xyzw, rgb
+MESA_FORMAT_RGBA_SINT16 , array , 1, 1, s16 , s16 , s16 , s16 , xyzw, rgb
+MESA_FORMAT_RGBA_SINT32 , array , 1, 1, s32 , s32 , s32 , s32 , xyzw, rgb
+
+MESA_FORMAT_RGBX_UINT8 , array , 1, 1, u8 , u8 , u8 , x8 , xyz1, rgb
+MESA_FORMAT_RGBX_UINT16 , array , 1, 1, u16 , u16 , u16 , x16 , xyz1, rgb
+MESA_FORMAT_RGBX_UINT32 , array , 1, 1, u32 , u32 , u32 , x32 , xyz1, rgb
+MESA_FORMAT_RGBX_SINT8 , array , 1, 1, s8 , s8 , s8 , x8 , xyz1, rgb
+MESA_FORMAT_RGBX_SINT16 , array , 1, 1, s16 , s16 , s16 , x16 , xyz1, rgb
+MESA_FORMAT_RGBX_SINT32 , array , 1, 1, s32 , s32 , s32 , x32 , xyz1, rgb
+
+# DTX compressed formats
+MESA_FORMAT_RGB_DXT1 , s3tc , 4, 4, x64 , , , , xyz1, rgb
+MESA_FORMAT_RGBA_DXT1 , s3tc , 4, 4, x64 , , , , xyzw, rgb
+MESA_FORMAT_RGBA_DXT3 , s3tc , 4, 4, x128, , , , xyzw, rgb
+MESA_FORMAT_RGBA_DXT5 , s3tc , 4, 4, x128, , , , xyzw, rgb
+
+# DTX sRGB compressed formats
+MESA_FORMAT_SRGB_DXT1 , s3tc , 4, 4, x64 , , , , xyz1, srgb
+MESA_FORMAT_SRGBA_DXT1 , s3tc , 4, 4, x64 , , , , xyzw, srgb
+MESA_FORMAT_SRGBA_DXT3 , s3tc , 4, 4, x128, , , , xyzw, srgb
+MESA_FORMAT_SRGBA_DXT5 , s3tc , 4, 4, x128, , , , xyzw, srgb
+
+# FXT1 compressed formats
+MESA_FORMAT_RGB_FXT1 , fxt1 , 8, 4, x128, , , , xyz1, rgb
+MESA_FORMAT_RGBA_FXT1 , fxt1 , 8, 4, x128, , , , xyzw, rgb
+
+# RGTC compressed formats
+MESA_FORMAT_R_RGTC1_UNORM , rgtc , 4, 4, x64 , , , , x001, rgb
+MESA_FORMAT_R_RGTC1_SNORM , rgtc , 4, 4, x64 , , , , x001, rgb
+MESA_FORMAT_RG_RGTC2_UNORM , rgtc , 4, 4, x128, , , , xy01, rgb
+MESA_FORMAT_RG_RGTC2_SNORM , rgtc , 4, 4, x128, , , , xy01, rgb
+
+# LATC1/2 compressed formats
+MESA_FORMAT_L_LATC1_UNORM , rgtc , 4, 4, x64 , , , , xxx1, rgb
+MESA_FORMAT_L_LATC1_SNORM , rgtc , 4, 4, x64 , , , , xxx1, rgb
+MESA_FORMAT_LA_LATC2_UNORM , rgtc , 4, 4, x128, , , , xxxy, rgb
+MESA_FORMAT_LA_LATC2_SNORM , rgtc , 4, 4, x128, , , , xxxy, rgb
+
+# ETC1/2 compressed formats
+MESA_FORMAT_ETC1_RGB8 , etc1 , 4, 4, x64 , , , , xyz1, rgb
+MESA_FORMAT_ETC2_RGB8 , etc2 , 4, 4, x64 , , , , xyz1, rgb
+MESA_FORMAT_ETC2_SRGB8 , etc2 , 4, 4, x64 , , , , xyz1, srgb
+MESA_FORMAT_ETC2_RGBA8_EAC , etc2 , 4, 4, x128, , , , xyzw, rgb
+MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC , etc2 , 4, 4, x128, , , , xyzw, srgb
+MESA_FORMAT_ETC2_R11_EAC , etc2 , 4, 4, x64 , , , , x001, rgb
+MESA_FORMAT_ETC2_RG11_EAC , etc2 , 4, 4, x128, , , , xy01, rgb
+MESA_FORMAT_ETC2_SIGNED_R11_EAC , etc2 , 4, 4, x64 , , , , x001, rgb
+MESA_FORMAT_ETC2_SIGNED_RG11_EAC , etc2 , 4, 4, x128, , , , xy01, rgb
+MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1 , etc2 , 4, 4, x64 , , , , xyzw, rgb
+MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1, etc2 , 4, 4, x64 , , , , xyzw, srgb
diff --git a/mesalib/src/mesa/main/formats.h b/mesalib/src/mesa/main/formats.h
index dc50bc830..457c8abf8 100644
--- a/mesalib/src/mesa/main/formats.h
+++ b/mesalib/src/mesa/main/formats.h
@@ -35,6 +35,7 @@
#include <GL/gl.h>
#include <stdbool.h>
+#include <stdint.h>
#ifdef __cplusplus
@@ -56,6 +57,29 @@ extern "C" {
*/
#define MAX_PIXEL_BYTES 16
+/**
+ * Specifies the layout of a pixel format. See the MESA_FORMAT
+ * documentation below.
+ */
+enum mesa_format_layout {
+ MESA_FORMAT_LAYOUT_ARRAY,
+ MESA_FORMAT_LAYOUT_PACKED,
+ MESA_FORMAT_LAYOUT_OTHER,
+};
+
+/**
+ * An enum representing different possible swizzling values. This is used
+ * to interpret the output of _mesa_get_format_swizzle
+ */
+enum {
+ MESA_FORMAT_SWIZZLE_X = 0,
+ MESA_FORMAT_SWIZZLE_Y = 1,
+ MESA_FORMAT_SWIZZLE_Z = 2,
+ MESA_FORMAT_SWIZZLE_W = 3,
+ MESA_FORMAT_SWIZZLE_ZERO = 4,
+ MESA_FORMAT_SWIZZLE_ONE = 5,
+ MESA_FORMAT_SWIZZLE_NONE = 6,
+};
/**
* Mesa texture/renderbuffer image formats.
@@ -419,6 +443,9 @@ _mesa_get_format_bits(mesa_format format, GLenum pname);
extern GLuint
_mesa_get_format_max_bits(mesa_format format);
+extern enum mesa_format_layout
+_mesa_get_format_layout(mesa_format format);
+
extern GLenum
_mesa_get_format_datatype(mesa_format format);
@@ -428,6 +455,9 @@ _mesa_get_format_base_format(mesa_format format);
extern void
_mesa_get_format_block_size(mesa_format format, GLuint *bw, GLuint *bh);
+extern void
+_mesa_get_format_swizzle(mesa_format format, uint8_t swizzle_out[4]);
+
extern GLboolean
_mesa_is_format_compressed(mesa_format format);
diff --git a/mesalib/src/mesa/main/get_hash_params.py b/mesalib/src/mesa/main/get_hash_params.py
index 35d6172a3..ff858207b 100644
--- a/mesalib/src/mesa/main/get_hash_params.py
+++ b/mesalib/src/mesa/main/get_hash_params.py
@@ -84,6 +84,7 @@ descriptor=[
[ "SAMPLES_ARB", "BUFFER_INT(Visual.samples), extra_new_buffers" ],
# GL_ARB_sample_shading
+ [ "SAMPLE_SHADING_ARB", "CONTEXT_BOOL(Multisample.SampleShading), extra_gl40_ARB_sample_shading" ],
[ "MIN_SAMPLE_SHADING_VALUE_ARB", "CONTEXT_FLOAT(Multisample.MinSampleShadingValue), extra_gl40_ARB_sample_shading" ],
# GL_SGIS_generate_mipmap
diff --git a/mesalib/src/mesa/main/glformats.c b/mesalib/src/mesa/main/glformats.c
index 304d45298..0fb25ba0f 100644
--- a/mesalib/src/mesa/main/glformats.c
+++ b/mesalib/src/mesa/main/glformats.c
@@ -353,6 +353,170 @@ _mesa_bytes_per_vertex_attrib(GLint comps, GLenum type)
}
}
+/**
+ * Test if the given format is unsized.
+ */
+GLboolean
+_mesa_is_enum_format_unsized(GLenum format)
+{
+ switch (format) {
+ case GL_RGBA:
+ case GL_BGRA:
+ case GL_ABGR_EXT:
+ case GL_RGB:
+ case GL_BGR:
+ case GL_RG:
+ case GL_RED:
+ case GL_GREEN:
+ case GL_BLUE:
+ case GL_ALPHA:
+ case GL_INTENSITY:
+ case GL_LUMINANCE:
+ case GL_LUMINANCE_ALPHA:
+
+ case GL_SRGB:
+ case GL_SRGB_ALPHA:
+ case GL_SLUMINANCE:
+ case GL_SLUMINANCE_ALPHA:
+
+ case GL_RGBA_SNORM:
+ case GL_RGB_SNORM:
+ case GL_RG_SNORM:
+ case GL_RED_SNORM:
+ case GL_ALPHA_SNORM:
+ case GL_INTENSITY_SNORM:
+ case GL_LUMINANCE_SNORM:
+ case GL_LUMINANCE_ALPHA_SNORM:
+
+ case GL_RED_INTEGER:
+ case GL_GREEN_INTEGER:
+ case GL_BLUE_INTEGER:
+ case GL_ALPHA_INTEGER:
+ case GL_RGB_INTEGER:
+ case GL_RGBA_INTEGER:
+ case GL_BGR_INTEGER:
+ case GL_BGRA_INTEGER:
+ case GL_RG_INTEGER:
+ case GL_LUMINANCE_INTEGER_EXT:
+ case GL_LUMINANCE_ALPHA_INTEGER_EXT:
+
+ case GL_DEPTH_COMPONENT:
+ case GL_DEPTH_STENCIL:
+ case GL_STENCIL_INDEX:
+ return GL_TRUE;
+ default:
+ return GL_FALSE;
+ }
+}
+
+/**
+ * Test if the given format is a UNORM (unsigned-normalized) format.
+ */
+GLboolean
+_mesa_is_enum_format_unorm(GLenum format)
+{
+ switch(format) {
+ case GL_RED:
+ case GL_GREEN:
+ case GL_BLUE:
+ case GL_ALPHA:
+ case GL_ALPHA4:
+ case GL_ALPHA8:
+ case GL_ALPHA12:
+ case GL_ALPHA16:
+ case 1:
+ case GL_LUMINANCE:
+ case GL_SLUMINANCE:
+ case GL_LUMINANCE4:
+ case GL_LUMINANCE8:
+ case GL_LUMINANCE12:
+ case GL_LUMINANCE16:
+ case 2:
+ case GL_LUMINANCE_ALPHA:
+ case GL_SLUMINANCE_ALPHA:
+ case GL_LUMINANCE4_ALPHA4:
+ case GL_LUMINANCE6_ALPHA2:
+ case GL_LUMINANCE8_ALPHA8:
+ case GL_LUMINANCE12_ALPHA4:
+ case GL_LUMINANCE12_ALPHA12:
+ case GL_LUMINANCE16_ALPHA16:
+ case GL_INTENSITY:
+ case GL_INTENSITY4:
+ case GL_INTENSITY8:
+ case GL_INTENSITY12:
+ case GL_INTENSITY16:
+ case GL_R8:
+ case GL_R16:
+ case GL_RG:
+ case GL_RG8:
+ case GL_RG16:
+ case 3:
+ case GL_RGB:
+ case GL_BGR:
+ case GL_SRGB:
+ case GL_R3_G3_B2:
+ case GL_RGB4:
+ case GL_RGB5:
+ case GL_RGB565:
+ case GL_RGB8:
+ case GL_RGB10:
+ case GL_RGB12:
+ case GL_RGB16:
+ case 4:
+ case GL_ABGR_EXT:
+ case GL_RGBA:
+ case GL_BGRA:
+ case GL_SRGB_ALPHA:
+ case GL_RGBA2:
+ case GL_RGBA4:
+ case GL_RGB5_A1:
+ case GL_RGBA8:
+ case GL_RGB10_A2:
+ case GL_RGBA12:
+ case GL_RGBA16:
+ return GL_TRUE;
+ default:
+ return GL_FALSE;
+ }
+}
+
+/**
+ * Test if the given format is a SNORM (signed-normalized) format.
+ */
+GLboolean
+_mesa_is_enum_format_snorm(GLenum format)
+{
+ switch (format) {
+ /* signed, normalized texture formats */
+ case GL_RED_SNORM:
+ case GL_R8_SNORM:
+ case GL_R16_SNORM:
+ case GL_RG_SNORM:
+ case GL_RG8_SNORM:
+ case GL_RG16_SNORM:
+ case GL_RGB_SNORM:
+ case GL_RGB8_SNORM:
+ case GL_RGB16_SNORM:
+ case GL_RGBA_SNORM:
+ case GL_RGBA8_SNORM:
+ case GL_RGBA16_SNORM:
+ case GL_ALPHA_SNORM:
+ case GL_ALPHA8_SNORM:
+ case GL_ALPHA16_SNORM:
+ case GL_LUMINANCE_SNORM:
+ case GL_LUMINANCE8_SNORM:
+ case GL_LUMINANCE16_SNORM:
+ case GL_LUMINANCE_ALPHA_SNORM:
+ case GL_LUMINANCE8_ALPHA8_SNORM:
+ case GL_LUMINANCE16_ALPHA16_SNORM:
+ case GL_INTENSITY_SNORM:
+ case GL_INTENSITY8_SNORM:
+ case GL_INTENSITY16_SNORM:
+ return GL_TRUE;
+ default:
+ return GL_FALSE;
+ }
+}
/**
* Test if the given format is an integer (non-normalized) format.
diff --git a/mesalib/src/mesa/main/glformats.h b/mesalib/src/mesa/main/glformats.h
index d64114ec9..7b0321570 100644
--- a/mesalib/src/mesa/main/glformats.h
+++ b/mesalib/src/mesa/main/glformats.h
@@ -57,6 +57,15 @@ extern GLboolean
_mesa_is_type_unsigned(GLenum type);
extern GLboolean
+_mesa_is_enum_format_unsized(GLenum format);
+
+extern GLboolean
+_mesa_is_enum_format_unorm(GLenum format);
+
+extern GLboolean
+_mesa_is_enum_format_snorm(GLenum format);
+
+extern GLboolean
_mesa_is_enum_format_integer(GLenum format);
extern GLboolean
diff --git a/mesalib/src/mesa/main/hash.c b/mesalib/src/mesa/main/hash.c
index 674c29d65..52095f7d1 100644
--- a/mesalib/src/mesa/main/hash.c
+++ b/mesalib/src/mesa/main/hash.c
@@ -37,7 +37,7 @@
#include "glheader.h"
#include "imports.h"
#include "hash.h"
-#include "hash_table.h"
+#include "util/hash_table.h"
/**
* Magic GLuint object name that gets stored outside of the struct hash_table.
diff --git a/mesalib/src/mesa/main/imports.h b/mesalib/src/mesa/main/imports.h
index aee495a4c..000fd5b49 100755
--- a/mesalib/src/mesa/main/imports.h
+++ b/mesalib/src/mesa/main/imports.h
@@ -163,7 +163,6 @@ INV_SQRTF(float x)
***/
static inline GLfloat LOG2(GLfloat x)
{
-#ifdef USE_IEEE
#if 0
/* This is pretty fast, but not accurate enough (only 2 fractional bits).
* Based on code from http://www.stereopsis.com/log2.html
@@ -185,13 +184,6 @@ static inline GLfloat LOG2(GLfloat x)
num.i += 127 << 23;
num.f = ((-1.0f/3) * num.f + 2) * num.f - 2.0f/3;
return num.f + log_2;
-#else
- /*
- * NOTE: log_base_2(x) = log(x) / log(2)
- * NOTE: 1.442695 = 1/log(2).
- */
- return (GLfloat) (log(x) * 1.442695F);
-#endif
}
@@ -199,14 +191,7 @@ static inline GLfloat LOG2(GLfloat x)
/***
*** IS_INF_OR_NAN: test if float is infinite or NaN
***/
-#ifdef USE_IEEE
-static inline int IS_INF_OR_NAN( float x )
-{
- fi_type tmp;
- tmp.f = x;
- return !(int)((unsigned int)((tmp.i & 0x7fffffff)-0x7f800000) >> 31);
-}
-#elif defined(isfinite)
+#if defined(isfinite)
#define IS_INF_OR_NAN(x) (!isfinite(x))
#elif defined(finite)
#define IS_INF_OR_NAN(x) (!finite(x))
@@ -320,7 +305,7 @@ static inline int IFLOOR(float f)
__asm__ ("fstps %0" : "=m" (ai) : "t" (af) : "st");
__asm__ ("fstps %0" : "=m" (bi) : "t" (bf) : "st");
return (ai - bi) >> 1;
-#elif defined(USE_IEEE)
+#else
int ai, bi;
double af, bf;
fi_type u;
@@ -329,9 +314,6 @@ static inline int IFLOOR(float f)
u.f = (float) af; ai = u.i;
u.f = (float) bf; bi = u.i;
return (ai - bi) >> 1;
-#else
- int i = IROUND(f);
- return (i > f) ? i - 1 : i;
#endif
}
@@ -355,7 +337,7 @@ static inline int ICEIL(float f)
__asm__ ("fstps %0" : "=m" (ai) : "t" (af) : "st");
__asm__ ("fstps %0" : "=m" (bi) : "t" (bf) : "st");
return (ai - bi + 1) >> 1;
-#elif defined(USE_IEEE)
+#else
int ai, bi;
double af, bf;
fi_type u;
@@ -364,9 +346,6 @@ static inline int ICEIL(float f)
u.f = (float) af; ai = u.i;
u.f = (float) bf; bi = u.i;
return (ai - bi + 1) >> 1;
-#else
- int i = IROUND(f);
- return (i < f) ? i + 1 : i;
#endif
}
@@ -551,6 +530,11 @@ _mesa_float_to_half(float f);
extern float
_mesa_half_to_float(GLhalfARB h);
+static inline bool
+_mesa_half_is_negative(GLhalfARB h)
+{
+ return h & 0x8000;
+}
extern void *
_mesa_bsearch( const void *key, const void *base, size_t nmemb, size_t size,
diff --git a/mesalib/src/mesa/main/macros.h b/mesalib/src/mesa/main/macros.h
index 5228c3a8f..0ba658a9a 100644
--- a/mesalib/src/mesa/main/macros.h
+++ b/mesalib/src/mesa/main/macros.h
@@ -140,7 +140,7 @@ extern GLfloat _mesa_ubyte_to_float_color_tab[256];
*** UNCLAMPED_FLOAT_TO_UBYTE: clamp float to [0,1] and map to ubyte in [0,255]
*** CLAMPED_FLOAT_TO_UBYTE: map float known to be in [0,1] to ubyte in [0,255]
***/
-#if defined(USE_IEEE) && !defined(DEBUG)
+#ifndef DEBUG
/* This function/macro is sensitive to precision. Test very carefully
* if you change it!
*/
@@ -818,7 +818,9 @@ DIFFERENT_SIGNS(GLfloat x, GLfloat y)
#define ENUM_TO_BOOLEAN(E) ((E) ? GL_TRUE : GL_FALSE)
/* Compute the size of an array */
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
+#ifndef ARRAY_SIZE
+# define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
+#endif
/* Stringify */
#define STRINGIFY(x) #x
diff --git a/mesalib/src/mesa/main/mtypes.h b/mesalib/src/mesa/main/mtypes.h
index 3f60a5530..e141ac658 100644
--- a/mesalib/src/mesa/main/mtypes.h
+++ b/mesalib/src/mesa/main/mtypes.h
@@ -1693,6 +1693,9 @@ struct gl_array_attrib
/** One of the DRAW_xxx flags, not consumed by drivers */
gl_draw_method DrawMethod;
+
+ /** Legal array datatypes */
+ GLbitfield LegalTypesMask;
};
@@ -2048,13 +2051,31 @@ typedef enum
*/
typedef enum
{
- SYSTEM_VALUE_FRONT_FACE, /**< Fragment shader only (not done yet) */
- SYSTEM_VALUE_VERTEX_ID, /**< Vertex shader only */
- SYSTEM_VALUE_INSTANCE_ID, /**< Vertex shader only */
- SYSTEM_VALUE_SAMPLE_ID, /**< Fragment shader only */
- SYSTEM_VALUE_SAMPLE_POS, /**< Fragment shader only */
- SYSTEM_VALUE_SAMPLE_MASK_IN, /**< Fragment shader only */
- SYSTEM_VALUE_INVOCATION_ID, /**< Geometry shader only */
+ /**
+ * \name Vertex shader system values
+ */
+ /*@{*/
+ SYSTEM_VALUE_VERTEX_ID,
+ SYSTEM_VALUE_INSTANCE_ID,
+ /*@}*/
+
+ /**
+ * \name Geometry shader system values
+ */
+ /*@{*/
+ SYSTEM_VALUE_INVOCATION_ID,
+ /*@}*/
+
+ /**
+ * \name Fragment shader system values
+ */
+ /*@{*/
+ SYSTEM_VALUE_FRONT_FACE, /**< (not done yet) */
+ SYSTEM_VALUE_SAMPLE_ID,
+ SYSTEM_VALUE_SAMPLE_POS,
+ SYSTEM_VALUE_SAMPLE_MASK_IN,
+ /*@}*/
+
SYSTEM_VALUE_MAX /**< Number of values */
} gl_system_value;
@@ -3531,6 +3552,7 @@ struct gl_extensions
GLboolean ARB_color_buffer_float;
GLboolean ARB_compute_shader;
GLboolean ARB_conservative_depth;
+ GLboolean ARB_copy_image;
GLboolean ARB_depth_buffer_float;
GLboolean ARB_depth_clamp;
GLboolean ARB_depth_texture;
diff --git a/mesalib/src/mesa/main/performance_monitor.c b/mesalib/src/mesa/main/performance_monitor.c
index c26eda4c6..c02910e31 100644
--- a/mesalib/src/mesa/main/performance_monitor.c
+++ b/mesalib/src/mesa/main/performance_monitor.c
@@ -43,7 +43,7 @@
#include "mtypes.h"
#include "performance_monitor.h"
#include "bitset.h"
-#include "ralloc.h"
+#include "util/ralloc.h"
void
_mesa_init_performance_monitors(struct gl_context *ctx)
diff --git a/mesalib/src/mesa/main/pipelineobj.c b/mesalib/src/mesa/main/pipelineobj.c
index 90c1d005f..017d4257e 100644
--- a/mesalib/src/mesa/main/pipelineobj.c
+++ b/mesalib/src/mesa/main/pipelineobj.c
@@ -44,7 +44,7 @@
#include "main/uniforms.h"
#include "program/program.h"
#include "program/prog_parameter.h"
-#include "ralloc.h"
+#include "util/ralloc.h"
#include <stdbool.h>
#include "../glsl/glsl_parser_extras.h"
#include "../glsl/ir_uniform.h"
diff --git a/mesalib/src/mesa/main/set.c b/mesalib/src/mesa/main/set.c
index 989e5dece..52c1dabd8 100644
--- a/mesalib/src/mesa/main/set.c
+++ b/mesalib/src/mesa/main/set.c
@@ -36,7 +36,7 @@
#include "macros.h"
#include "set.h"
-#include "ralloc.h"
+#include "util/ralloc.h"
/*
* From Knuth -- a good choice for hash/rehash values is p, p-2 where
diff --git a/mesalib/src/mesa/main/shaderapi.c b/mesalib/src/mesa/main/shaderapi.c
index 2bbef35d3..b4a5e7050 100644
--- a/mesalib/src/mesa/main/shaderapi.c
+++ b/mesalib/src/mesa/main/shaderapi.c
@@ -42,7 +42,6 @@
#include "main/dispatch.h"
#include "main/enums.h"
#include "main/hash.h"
-#include "main/hash_table.h"
#include "main/mtypes.h"
#include "main/pipelineobj.h"
#include "main/shaderapi.h"
@@ -52,7 +51,8 @@
#include "program/program.h"
#include "program/prog_print.h"
#include "program/prog_parameter.h"
-#include "ralloc.h"
+#include "util/ralloc.h"
+#include "util/hash_table.h"
#include <stdbool.h>
#include "../glsl/glsl_parser_extras.h"
#include "../glsl/ir.h"
diff --git a/mesalib/src/mesa/main/shaderobj.c b/mesalib/src/mesa/main/shaderobj.c
index b9feff4a4..693e9a259 100644
--- a/mesalib/src/mesa/main/shaderobj.c
+++ b/mesalib/src/mesa/main/shaderobj.c
@@ -40,7 +40,7 @@
#include "program/program.h"
#include "program/prog_parameter.h"
#include "program/hash_table.h"
-#include "ralloc.h"
+#include "util/ralloc.h"
/**********************************************************************/
/*** Shader object functions ***/
diff --git a/mesalib/src/mesa/main/shared.c b/mesalib/src/mesa/main/shared.c
index 5ae7014b1..0189dd296 100644
--- a/mesalib/src/mesa/main/shared.c
+++ b/mesalib/src/mesa/main/shared.c
@@ -30,7 +30,6 @@
#include "imports.h"
#include "mtypes.h"
#include "hash.h"
-#include "hash_table.h"
#include "atifragshader.h"
#include "bufferobj.h"
#include "shared.h"
@@ -42,6 +41,7 @@
#include "shaderobj.h"
#include "syncobj.h"
+#include "util/hash_table.h"
/**
* Allocate and initialize a shared context state structure.
diff --git a/mesalib/src/mesa/main/syncobj.c b/mesalib/src/mesa/main/syncobj.c
index 9721b14b4..9a9c572c5 100644
--- a/mesalib/src/mesa/main/syncobj.c
+++ b/mesalib/src/mesa/main/syncobj.c
@@ -64,7 +64,7 @@
#include "dispatch.h"
#include "mtypes.h"
#include "set.h"
-#include "hash_table.h"
+#include "util/hash_table.h"
#include "syncobj.h"
diff --git a/mesalib/src/mesa/main/texcompress_etc.c b/mesalib/src/mesa/main/texcompress_etc.c
index ae973b001..98b4fe201 100644
--- a/mesalib/src/mesa/main/texcompress_etc.c
+++ b/mesalib/src/mesa/main/texcompress_etc.c
@@ -43,6 +43,7 @@
#include "texstore.h"
#include "macros.h"
#include "format_unpack.h"
+#include "util/format_srgb.h"
struct etc2_block {
@@ -1307,9 +1308,9 @@ fetch_etc2_srgb8(const GLubyte *map,
etc2_rgb8_fetch_texel(&block, i % 4, j % 4, dst,
false /* punchthrough_alpha */);
- texel[RCOMP] = _mesa_nonlinear_to_linear(dst[0]);
- texel[GCOMP] = _mesa_nonlinear_to_linear(dst[1]);
- texel[BCOMP] = _mesa_nonlinear_to_linear(dst[2]);
+ texel[RCOMP] = util_format_srgb_8unorm_to_linear_float(dst[0]);
+ texel[GCOMP] = util_format_srgb_8unorm_to_linear_float(dst[1]);
+ texel[BCOMP] = util_format_srgb_8unorm_to_linear_float(dst[2]);
texel[ACOMP] = 1.0f;
}
@@ -1345,9 +1346,9 @@ fetch_etc2_srgb8_alpha8_eac(const GLubyte *map,
etc2_rgba8_parse_block(&block, src);
etc2_rgba8_fetch_texel(&block, i % 4, j % 4, dst);
- texel[RCOMP] = _mesa_nonlinear_to_linear(dst[0]);
- texel[GCOMP] = _mesa_nonlinear_to_linear(dst[1]);
- texel[BCOMP] = _mesa_nonlinear_to_linear(dst[2]);
+ texel[RCOMP] = util_format_srgb_8unorm_to_linear_float(dst[0]);
+ texel[GCOMP] = util_format_srgb_8unorm_to_linear_float(dst[1]);
+ texel[BCOMP] = util_format_srgb_8unorm_to_linear_float(dst[2]);
texel[ACOMP] = UBYTE_TO_FLOAT(dst[3]);
}
@@ -1473,9 +1474,9 @@ fetch_etc2_srgb8_punchthrough_alpha1(const GLubyte *map,
true /* punchthrough alpha */);
etc2_rgb8_fetch_texel(&block, i % 4, j % 4, dst,
true /* punchthrough alpha */);
- texel[RCOMP] = _mesa_nonlinear_to_linear(dst[0]);
- texel[GCOMP] = _mesa_nonlinear_to_linear(dst[1]);
- texel[BCOMP] = _mesa_nonlinear_to_linear(dst[2]);
+ texel[RCOMP] = util_format_srgb_8unorm_to_linear_float(dst[0]);
+ texel[GCOMP] = util_format_srgb_8unorm_to_linear_float(dst[1]);
+ texel[BCOMP] = util_format_srgb_8unorm_to_linear_float(dst[2]);
texel[ACOMP] = UBYTE_TO_FLOAT(dst[3]);
}
diff --git a/mesalib/src/mesa/main/texcompress_s3tc.c b/mesalib/src/mesa/main/texcompress_s3tc.c
index 894c46de1..5b275efe0 100644
--- a/mesalib/src/mesa/main/texcompress_s3tc.c
+++ b/mesalib/src/mesa/main/texcompress_s3tc.c
@@ -44,6 +44,7 @@
#include "texcompress_s3tc.h"
#include "texstore.h"
#include "format_unpack.h"
+#include "util/format_srgb.h"
#if defined(_WIN32) || defined(WIN32)
@@ -419,9 +420,9 @@ fetch_srgb_dxt1(const GLubyte *map,
if (fetch_ext_rgb_dxt1) {
GLubyte tex[4];
fetch_ext_rgb_dxt1(rowStride, map, i, j, tex);
- texel[RCOMP] = _mesa_nonlinear_to_linear(tex[RCOMP]);
- texel[GCOMP] = _mesa_nonlinear_to_linear(tex[GCOMP]);
- texel[BCOMP] = _mesa_nonlinear_to_linear(tex[BCOMP]);
+ texel[RCOMP] = util_format_srgb_8unorm_to_linear_float(tex[RCOMP]);
+ texel[GCOMP] = util_format_srgb_8unorm_to_linear_float(tex[GCOMP]);
+ texel[BCOMP] = util_format_srgb_8unorm_to_linear_float(tex[BCOMP]);
texel[ACOMP] = UBYTE_TO_FLOAT(tex[ACOMP]);
}
else {
@@ -436,9 +437,9 @@ fetch_srgba_dxt1(const GLubyte *map,
if (fetch_ext_rgba_dxt1) {
GLubyte tex[4];
fetch_ext_rgba_dxt1(rowStride, map, i, j, tex);
- texel[RCOMP] = _mesa_nonlinear_to_linear(tex[RCOMP]);
- texel[GCOMP] = _mesa_nonlinear_to_linear(tex[GCOMP]);
- texel[BCOMP] = _mesa_nonlinear_to_linear(tex[BCOMP]);
+ texel[RCOMP] = util_format_srgb_8unorm_to_linear_float(tex[RCOMP]);
+ texel[GCOMP] = util_format_srgb_8unorm_to_linear_float(tex[GCOMP]);
+ texel[BCOMP] = util_format_srgb_8unorm_to_linear_float(tex[BCOMP]);
texel[ACOMP] = UBYTE_TO_FLOAT(tex[ACOMP]);
}
else {
@@ -453,9 +454,9 @@ fetch_srgba_dxt3(const GLubyte *map,
if (fetch_ext_rgba_dxt3) {
GLubyte tex[4];
fetch_ext_rgba_dxt3(rowStride, map, i, j, tex);
- texel[RCOMP] = _mesa_nonlinear_to_linear(tex[RCOMP]);
- texel[GCOMP] = _mesa_nonlinear_to_linear(tex[GCOMP]);
- texel[BCOMP] = _mesa_nonlinear_to_linear(tex[BCOMP]);
+ texel[RCOMP] = util_format_srgb_8unorm_to_linear_float(tex[RCOMP]);
+ texel[GCOMP] = util_format_srgb_8unorm_to_linear_float(tex[GCOMP]);
+ texel[BCOMP] = util_format_srgb_8unorm_to_linear_float(tex[BCOMP]);
texel[ACOMP] = UBYTE_TO_FLOAT(tex[ACOMP]);
}
else {
@@ -470,9 +471,9 @@ fetch_srgba_dxt5(const GLubyte *map,
if (fetch_ext_rgba_dxt5) {
GLubyte tex[4];
fetch_ext_rgba_dxt5(rowStride, map, i, j, tex);
- texel[RCOMP] = _mesa_nonlinear_to_linear(tex[RCOMP]);
- texel[GCOMP] = _mesa_nonlinear_to_linear(tex[GCOMP]);
- texel[BCOMP] = _mesa_nonlinear_to_linear(tex[BCOMP]);
+ texel[RCOMP] = util_format_srgb_8unorm_to_linear_float(tex[RCOMP]);
+ texel[GCOMP] = util_format_srgb_8unorm_to_linear_float(tex[GCOMP]);
+ texel[BCOMP] = util_format_srgb_8unorm_to_linear_float(tex[BCOMP]);
texel[ACOMP] = UBYTE_TO_FLOAT(tex[ACOMP]);
}
else {
diff --git a/mesalib/src/mesa/main/teximage.c b/mesalib/src/mesa/main/teximage.c
index fb2dee7d8..bb050b188 100644
--- a/mesalib/src/mesa/main/teximage.c
+++ b/mesalib/src/mesa/main/teximage.c
@@ -1770,9 +1770,9 @@ compressedteximage_only_format(const struct gl_context *ctx, GLenum format)
* Helper function to determine whether a target and specific compression
* format are supported.
*/
-static GLboolean
-target_can_be_compressed(const struct gl_context *ctx, GLenum target,
- GLenum intFormat)
+GLboolean
+_mesa_target_can_be_compressed(const struct gl_context *ctx, GLenum target,
+ GLenum intFormat)
{
(void) intFormat; /* not used yet */
@@ -1781,6 +1781,7 @@ target_can_be_compressed(const struct gl_context *ctx, GLenum target,
case GL_PROXY_TEXTURE_2D:
return GL_TRUE; /* true for any compressed format so far */
case GL_PROXY_TEXTURE_CUBE_MAP:
+ case GL_TEXTURE_CUBE_MAP:
case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
@@ -2211,7 +2212,7 @@ texture_error_check( struct gl_context *ctx,
/* additional checks for compressed textures */
if (_mesa_is_compressed_format(ctx, internalFormat)) {
- if (!target_can_be_compressed(ctx, target, internalFormat)) {
+ if (!_mesa_target_can_be_compressed(ctx, target, internalFormat)) {
_mesa_error(ctx, GL_INVALID_ENUM,
"glTexImage%dD(target can't be compressed)", dimensions);
return GL_TRUE;
@@ -2297,9 +2298,16 @@ compressed_texture_error_check(struct gl_context *ctx, GLint dimensions,
GLenum error = GL_NO_ERROR;
char *reason = ""; /* no error */
- if (!target_can_be_compressed(ctx, target, internalFormat)) {
+ if (!_mesa_target_can_be_compressed(ctx, target, internalFormat)) {
reason = "target";
- error = GL_INVALID_ENUM;
+ /* From section 3.8.6, page 146 of OpenGL ES 3.0 spec:
+ *
+ * "The ETC2/EAC texture compression algorithm supports only
+ * two-dimensional images. If internalformat is an ETC2/EAC format,
+ * CompressedTexImage3D will generate an INVALID_OPERATION error if
+ * target is not TEXTURE_2D_ARRAY."
+ */
+ error = _mesa_is_desktop_gl(ctx) ? GL_INVALID_ENUM : GL_INVALID_OPERATION;
goto error;
}
@@ -2704,6 +2712,17 @@ copytexture_error_check( struct gl_context *ctx, GLuint dimensions,
"glCopyTexImage%dD(srgb usage mismatch)", dimensions);
return GL_TRUE;
}
+
+ /* Page 139, Table 3.15 of OpenGL ES 3.0 spec does not define ReadPixels
+ * types for SNORM formats. Also, conversion to SNORM formats is not
+ * allowed by Table 3.2 on Page 110.
+ */
+ if(_mesa_is_enum_format_snorm(internalFormat)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glCopyTexImage%dD(internalFormat=%s)", dimensions,
+ _mesa_lookup_enum_by_nr(internalFormat));
+ return GL_TRUE;
+ }
}
if (!_mesa_source_buffer_exists(ctx, baseFormat)) {
@@ -2722,6 +2741,8 @@ copytexture_error_check( struct gl_context *ctx, GLuint dimensions,
if (_mesa_is_color_format(internalFormat)) {
bool is_int = _mesa_is_enum_format_integer(internalFormat);
bool is_rbint = _mesa_is_enum_format_integer(rb_internal_format);
+ bool is_unorm = _mesa_is_enum_format_unorm(internalFormat);
+ bool is_rbunorm = _mesa_is_enum_format_unorm(rb_internal_format);
if (is_int || is_rbint) {
if (is_int != is_rbint) {
_mesa_error(ctx, GL_INVALID_OPERATION,
@@ -2735,10 +2756,23 @@ copytexture_error_check( struct gl_context *ctx, GLuint dimensions,
return GL_TRUE;
}
}
+
+ /* From page 138 of OpenGL ES 3.0 spec:
+ * "The error INVALID_OPERATION is generated if floating-point RGBA
+ * data is required; if signed integer RGBA data is required and the
+ * format of the current color buffer is not signed integer; if
+ * unsigned integer RGBA data is required and the format of the
+ * current color buffer is not unsigned integer; or if fixed-point
+ * RGBA data is required and the format of the current color buffer
+ * is not fixed-point.
+ */
+ if (_mesa_is_gles(ctx) && is_unorm != is_rbunorm)
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glCopyTexImage%dD(unorm vs non-unorm)", dimensions);
}
if (_mesa_is_compressed_format(ctx, internalFormat)) {
- if (!target_can_be_compressed(ctx, target, internalFormat)) {
+ if (!_mesa_target_can_be_compressed(ctx, target, internalFormat)) {
_mesa_error(ctx, GL_INVALID_ENUM,
"glCopyTexImage%dD(target)", dimensions);
return GL_TRUE;
@@ -3608,6 +3642,28 @@ copytexsubimage_by_slice(struct gl_context *ctx,
}
}
+static GLboolean
+formats_differ_in_component_sizes (mesa_format f1,
+ mesa_format f2)
+{
+ GLint f1_r_bits = _mesa_get_format_bits(f1, GL_RED_BITS);
+ GLint f1_g_bits = _mesa_get_format_bits(f1, GL_GREEN_BITS);
+ GLint f1_b_bits = _mesa_get_format_bits(f1, GL_BLUE_BITS);
+ GLint f1_a_bits = _mesa_get_format_bits(f1, GL_ALPHA_BITS);
+
+ GLint f2_r_bits = _mesa_get_format_bits(f2, GL_RED_BITS);
+ GLint f2_g_bits = _mesa_get_format_bits(f2, GL_GREEN_BITS);
+ GLint f2_b_bits = _mesa_get_format_bits(f2, GL_BLUE_BITS);
+ GLint f2_a_bits = _mesa_get_format_bits(f2, GL_ALPHA_BITS);
+
+ if ((f1_r_bits && f2_r_bits && f1_r_bits != f2_r_bits)
+ || (f1_g_bits && f2_g_bits && f1_g_bits != f2_g_bits)
+ || (f1_b_bits && f2_b_bits && f1_b_bits != f2_b_bits)
+ || (f1_a_bits && f2_a_bits && f1_a_bits != f2_a_bits))
+ return GL_TRUE;
+
+ return GL_FALSE;
+}
/**
* Implement the glCopyTexImage1/2D() functions.
@@ -3621,6 +3677,7 @@ copyteximage(struct gl_context *ctx, GLuint dims,
struct gl_texture_image *texImage;
const GLuint face = _mesa_tex_target_to_face(target);
mesa_format texFormat;
+ struct gl_renderbuffer *rb;
FLUSH_VERTICES(ctx, 0);
@@ -3650,6 +3707,40 @@ copyteximage(struct gl_context *ctx, GLuint dims,
texFormat = _mesa_choose_texture_format(ctx, texObj, target, level,
internalFormat, GL_NONE, GL_NONE);
+
+ rb = _mesa_get_read_renderbuffer_for_format(ctx, internalFormat);
+
+ if (_mesa_is_gles3(ctx)) {
+ if (_mesa_is_enum_format_unsized(internalFormat)) {
+ /* Conversion from GL_RGB10_A2 source buffer format is not allowed in
+ * OpenGL ES 3.0. Khronos bug# 9807.
+ */
+ if (rb->InternalFormat == GL_RGB10_A2) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glCopyTexImage%uD(Reading from GL_RGB10_A2 buffer and"
+ " writing to unsized internal format)", dims);
+ return;
+ }
+ }
+ /* From Page 139 of OpenGL ES 3.0 spec:
+ * "If internalformat is sized, the internal format of the new texel
+ * array is internalformat, and this is also the new texel array’s
+ * effective internal format. If the component sizes of internalformat
+ * do not exactly match the corresponding component sizes of the source
+ * buffer’s effective internal format, described below, an
+ * INVALID_OPERATION error is generated. If internalformat is unsized,
+ * the internal format of the new texel array is the effective internal
+ * format of the source buffer, and this is also the new texel array’s
+ * effective internal format.
+ */
+ else if (formats_differ_in_component_sizes (texFormat, rb->Format)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glCopyTexImage%uD(componenet size changed in"
+ " internal format)", dims);
+ return;
+ }
+ }
+
assert(texFormat != MESA_FORMAT_NONE);
if (!ctx->Driver.TestProxyTexImage(ctx, proxy_target(target),
diff --git a/mesalib/src/mesa/main/teximage.h b/mesalib/src/mesa/main/teximage.h
index 42305f44f..52bfa7816 100644
--- a/mesalib/src/mesa/main/teximage.h
+++ b/mesalib/src/mesa/main/teximage.h
@@ -123,6 +123,9 @@ _mesa_test_proxy_teximage(struct gl_context *ctx, GLenum target, GLint level,
mesa_format format,
GLint width, GLint height, GLint depth, GLint border);
+extern GLboolean
+_mesa_target_can_be_compressed(const struct gl_context *ctx, GLenum target,
+ GLenum intFormat);
extern GLuint
_mesa_tex_target_to_face(GLenum target);
diff --git a/mesalib/src/mesa/main/texstorage.c b/mesalib/src/mesa/main/texstorage.c
index 86c8f3c92..897d5891a 100644
--- a/mesalib/src/mesa/main/texstorage.c
+++ b/mesalib/src/mesa/main/texstorage.c
@@ -41,6 +41,7 @@
#include "texstorage.h"
#include "textureview.h"
#include "mtypes.h"
+#include "glformats.h"
@@ -53,6 +54,13 @@
static GLboolean
legal_texobj_target(struct gl_context *ctx, GLuint dims, GLenum target)
{
+ if (_mesa_is_gles3(ctx)
+ && target != GL_TEXTURE_2D
+ && target != GL_TEXTURE_CUBE_MAP
+ && target != GL_TEXTURE_3D
+ && target != GL_TEXTURE_2D_ARRAY)
+ return GL_FALSE;
+
switch (dims) {
case 1:
switch (target) {
@@ -294,6 +302,23 @@ tex_storage_error_check(struct gl_context *ctx, GLuint dims, GLenum target,
return GL_TRUE;
}
+ /* From section 3.8.6, page 146 of OpenGL ES 3.0 spec:
+ *
+ * "The ETC2/EAC texture compression algorithm supports only
+ * two-dimensional images. If internalformat is an ETC2/EAC format,
+ * CompressedTexImage3D will generate an INVALID_OPERATION error if
+ * target is not TEXTURE_2D_ARRAY."
+ *
+ * This should also be applicable for glTexStorage3D().
+ */
+ if (_mesa_is_compressed_format(ctx, internalformat)
+ && !_mesa_target_can_be_compressed(ctx, target, internalformat)) {
+ _mesa_error(ctx, _mesa_is_desktop_gl(ctx)?
+ GL_INVALID_ENUM : GL_INVALID_OPERATION,
+ "glTexStorage3D(internalformat = %s)",
+ _mesa_lookup_enum_by_nr(internalformat));
+ }
+
/* levels check */
if (levels < 1) {
_mesa_error(ctx, GL_INVALID_VALUE, "glTexStorage%uD(levels < 1)",
diff --git a/mesalib/src/mesa/main/texstore.c b/mesalib/src/mesa/main/texstore.c
index aea53f8d1..0e036d9eb 100644
--- a/mesalib/src/mesa/main/texstore.c
+++ b/mesalib/src/mesa/main/texstore.c
@@ -55,6 +55,7 @@
#include "bufferobj.h"
#include "colormac.h"
#include "format_pack.h"
+#include "format_utils.h"
#include "image.h"
#include "macros.h"
#include "mipmap.h"
@@ -87,35 +88,6 @@ enum {
typedef GLboolean (*StoreTexImageFunc)(TEXSTORE_PARAMS);
-/**
- * Return GL_TRUE if the given image format is one that be converted
- * to another format by swizzling.
- */
-static GLboolean
-can_swizzle(GLenum logicalBaseFormat)
-{
- switch (logicalBaseFormat) {
- case GL_RGBA:
- case GL_RGB:
- case GL_LUMINANCE_ALPHA:
- case GL_INTENSITY:
- case GL_ALPHA:
- case GL_LUMINANCE:
- case GL_RED:
- case GL_GREEN:
- case GL_BLUE:
- case GL_BGR:
- case GL_BGRA:
- case GL_ABGR_EXT:
- case GL_RG:
- return GL_TRUE;
- default:
- return GL_FALSE;
- }
-}
-
-
-
enum {
IDX_LUMINANCE = 0,
IDX_ALPHA,
@@ -233,21 +205,44 @@ static int
get_map_idx(GLenum value)
{
switch (value) {
- case GL_LUMINANCE: return IDX_LUMINANCE;
- case GL_ALPHA: return IDX_ALPHA;
- case GL_INTENSITY: return IDX_INTENSITY;
- case GL_LUMINANCE_ALPHA: return IDX_LUMINANCE_ALPHA;
- case GL_RGB: return IDX_RGB;
- case GL_RGBA: return IDX_RGBA;
- case GL_RED: return IDX_RED;
- case GL_GREEN: return IDX_GREEN;
- case GL_BLUE: return IDX_BLUE;
- case GL_BGR: return IDX_BGR;
- case GL_BGRA: return IDX_BGRA;
- case GL_ABGR_EXT: return IDX_ABGR;
- case GL_RG: return IDX_RG;
+ case GL_LUMINANCE:
+ case GL_LUMINANCE_INTEGER_EXT:
+ return IDX_LUMINANCE;
+ case GL_ALPHA:
+ case GL_ALPHA_INTEGER:
+ return IDX_ALPHA;
+ case GL_INTENSITY:
+ return IDX_INTENSITY;
+ case GL_LUMINANCE_ALPHA:
+ case GL_LUMINANCE_ALPHA_INTEGER_EXT:
+ return IDX_LUMINANCE_ALPHA;
+ case GL_RGB:
+ case GL_RGB_INTEGER:
+ return IDX_RGB;
+ case GL_RGBA:
+ case GL_RGBA_INTEGER:
+ return IDX_RGBA;
+ case GL_RED:
+ case GL_RED_INTEGER:
+ return IDX_RED;
+ case GL_GREEN:
+ return IDX_GREEN;
+ case GL_BLUE:
+ return IDX_BLUE;
+ case GL_BGR:
+ case GL_BGR_INTEGER:
+ return IDX_BGR;
+ case GL_BGRA:
+ case GL_BGRA_INTEGER:
+ return IDX_BGRA;
+ case GL_ABGR_EXT:
+ return IDX_ABGR;
+ case GL_RG:
+ case GL_RG_INTEGER:
+ return IDX_RG;
default:
- _mesa_problem(NULL, "Unexpected inFormat");
+ _mesa_problem(NULL, "Unexpected inFormat %s",
+ _mesa_lookup_enum_by_nr(value));
return 0;
}
}
@@ -662,257 +657,9 @@ _mesa_make_temp_ubyte_image(struct gl_context *ctx, GLuint dims,
}
-/**
- * Copy GLubyte pixels from <src> to <dst> with swizzling.
- * \param dst destination pixels
- * \param dstComponents number of color components in destination pixels
- * \param src source pixels
- * \param srcComponents number of color components in source pixels
- * \param map the swizzle mapping. map[X] says where to find the X component
- * in the source image's pixels. For example, if the source image
- * is GL_BGRA and X = red, map[0] yields 2.
- * \param count number of pixels to copy/swizzle.
- */
-static void
-swizzle_copy(GLubyte *dst, GLuint dstComponents, const GLubyte *src,
- GLuint srcComponents, const GLubyte *map, GLuint count)
-{
-#define SWZ_CPY(dst, src, count, dstComps, srcComps) \
- do { \
- GLuint i; \
- for (i = 0; i < count; i++) { \
- GLuint j; \
- if (srcComps == 4) { \
- COPY_4UBV(tmp, src); \
- } \
- else { \
- for (j = 0; j < srcComps; j++) { \
- tmp[j] = src[j]; \
- } \
- } \
- src += srcComps; \
- for (j = 0; j < dstComps; j++) { \
- dst[j] = tmp[map[j]]; \
- } \
- dst += dstComps; \
- } \
- } while (0)
-
- GLubyte tmp[6];
-
- tmp[ZERO] = 0x0;
- tmp[ONE] = 0xff;
-
- ASSERT(srcComponents <= 4);
- ASSERT(dstComponents <= 4);
-
- switch (dstComponents) {
- case 4:
- switch (srcComponents) {
- case 4:
- SWZ_CPY(dst, src, count, 4, 4);
- break;
- case 3:
- SWZ_CPY(dst, src, count, 4, 3);
- break;
- case 2:
- SWZ_CPY(dst, src, count, 4, 2);
- break;
- case 1:
- SWZ_CPY(dst, src, count, 4, 1);
- break;
- default:
- ;
- }
- break;
- case 3:
- switch (srcComponents) {
- case 4:
- SWZ_CPY(dst, src, count, 3, 4);
- break;
- case 3:
- SWZ_CPY(dst, src, count, 3, 3);
- break;
- case 2:
- SWZ_CPY(dst, src, count, 3, 2);
- break;
- case 1:
- SWZ_CPY(dst, src, count, 3, 1);
- break;
- default:
- ;
- }
- break;
- case 2:
- switch (srcComponents) {
- case 4:
- SWZ_CPY(dst, src, count, 2, 4);
- break;
- case 3:
- SWZ_CPY(dst, src, count, 2, 3);
- break;
- case 2:
- SWZ_CPY(dst, src, count, 2, 2);
- break;
- case 1:
- SWZ_CPY(dst, src, count, 2, 1);
- break;
- default:
- ;
- }
- break;
- case 1:
- switch (srcComponents) {
- case 4:
- SWZ_CPY(dst, src, count, 1, 4);
- break;
- case 3:
- SWZ_CPY(dst, src, count, 1, 3);
- break;
- case 2:
- SWZ_CPY(dst, src, count, 1, 2);
- break;
- case 1:
- SWZ_CPY(dst, src, count, 1, 1);
- break;
- default:
- ;
- }
- break;
- default:
- ;
- }
-#undef SWZ_CPY
-}
-
-
-
static const GLubyte map_identity[6] = { 0, 1, 2, 3, ZERO, ONE };
static const GLubyte map_3210[6] = { 3, 2, 1, 0, ZERO, ONE };
-
-
-/**
- * For 1-byte/pixel formats (or 8_8_8_8 packed formats), return a
- * mapping array depending on endianness.
- */
-static const GLubyte *
-type_mapping( GLenum srcType )
-{
- switch (srcType) {
- case GL_BYTE:
- case GL_UNSIGNED_BYTE:
- return map_identity;
- case GL_UNSIGNED_INT_8_8_8_8:
- return _mesa_little_endian() ? map_3210 : map_identity;
- case GL_UNSIGNED_INT_8_8_8_8_REV:
- return _mesa_little_endian() ? map_identity : map_3210;
- default:
- return NULL;
- }
-}
-
-
-/**
- * For 1-byte/pixel formats (or 8_8_8_8 packed formats), return a
- * mapping array depending on pixelstore byte swapping state.
- */
-static const GLubyte *
-byteswap_mapping( GLboolean swapBytes,
- GLenum srcType )
-{
- if (!swapBytes)
- return map_identity;
-
- switch (srcType) {
- case GL_BYTE:
- case GL_UNSIGNED_BYTE:
- return map_identity;
- case GL_UNSIGNED_INT_8_8_8_8:
- case GL_UNSIGNED_INT_8_8_8_8_REV:
- return map_3210;
- default:
- return NULL;
- }
-}
-
-
-
-/**
- * Transfer a GLubyte texture image with component swizzling.
- */
-static void
-_mesa_swizzle_ubyte_image(struct gl_context *ctx,
- GLuint dimensions,
- GLenum srcFormat,
- GLenum srcType,
-
- GLenum baseInternalFormat,
-
- const GLubyte *rgba2dst,
- GLuint dstComponents,
-
- GLint dstRowStride,
- GLubyte **dstSlices,
-
- GLint srcWidth, GLint srcHeight, GLint srcDepth,
- const GLvoid *srcAddr,
- const struct gl_pixelstore_attrib *srcPacking )
-{
- GLint srcComponents = _mesa_components_in_format(srcFormat);
- const GLubyte *srctype2ubyte, *swap;
- GLubyte map[4], src2base[6], base2rgba[6];
- GLint i;
- const GLint srcRowStride =
- _mesa_image_row_stride(srcPacking, srcWidth,
- srcFormat, GL_UNSIGNED_BYTE);
- const GLint srcImageStride
- = _mesa_image_image_stride(srcPacking, srcWidth, srcHeight, srcFormat,
- GL_UNSIGNED_BYTE);
- const GLubyte *srcImage
- = (const GLubyte *) _mesa_image_address(dimensions, srcPacking, srcAddr,
- srcWidth, srcHeight, srcFormat,
- GL_UNSIGNED_BYTE, 0, 0, 0);
-
- (void) ctx;
-
- /* Translate from src->baseInternal->GL_RGBA->dst. This will
- * correctly deal with RGBA->RGB->RGBA conversions where the final
- * A value must be 0xff regardless of the incoming alpha values.
- */
- compute_component_mapping(srcFormat, baseInternalFormat, src2base);
- compute_component_mapping(baseInternalFormat, GL_RGBA, base2rgba);
- swap = byteswap_mapping(srcPacking->SwapBytes, srcType);
- srctype2ubyte = type_mapping(srcType);
-
-
- for (i = 0; i < 4; i++)
- map[i] = srctype2ubyte[swap[src2base[base2rgba[rgba2dst[i]]]]];
-
-/* printf("map %d %d %d %d\n", map[0], map[1], map[2], map[3]); */
-
- if (srcComponents == dstComponents &&
- srcRowStride == dstRowStride &&
- srcRowStride == srcWidth * srcComponents &&
- dimensions < 3) {
- /* 1 and 2D images only */
- GLubyte *dstImage = dstSlices[0];
- swizzle_copy(dstImage, dstComponents, srcImage, srcComponents, map,
- srcWidth * srcHeight);
- }
- else {
- GLint img, row;
- for (img = 0; img < srcDepth; img++) {
- const GLubyte *srcRow = srcImage;
- GLubyte *dstRow = dstSlices[img];
- for (row = 0; row < srcHeight; row++) {
- swizzle_copy(dstRow, dstComponents, srcRow, srcComponents, map, srcWidth);
- dstRow += dstRowStride;
- srcRow += srcRowStride;
- }
- srcImage += srcImageStride;
- }
- }
-}
+static const GLubyte map_1032[6] = { 1, 0, 3, 2, ZERO, ONE };
/**
@@ -988,6 +735,10 @@ store_ubyte_texture(TEXSTORE_PARAMS)
if (!tempImage)
return GL_FALSE;
+ /* This way we will use the RGB versions of the packing functions and it
+ * will work for both RGB and sRGB textures*/
+ dstFormat = _mesa_get_srgb_format_linear(dstFormat);
+
src = tempImage;
for (img = 0; img < srcDepth; img++) {
_mesa_pack_ubyte_rgba_rect(dstFormat, srcWidth, srcHeight,
@@ -1178,845 +929,13 @@ _mesa_texstore_rgb565(TEXSTORE_PARAMS)
dst += dstRowStride;
src += srcRowStride;
}
+ return GL_TRUE;
+ } else {
+ return GL_FALSE;
}
- else {
- return store_ubyte_texture(ctx, dims, baseInternalFormat,
- dstFormat, dstRowStride, dstSlices,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr, srcPacking);
- }
- return GL_TRUE;
-}
-
-
-/**
- * Store a texture in MESA_FORMAT_A8B8G8R8_UNORM or MESA_FORMAT_R8G8B8A8_UNORM.
- */
-static GLboolean
-_mesa_texstore_rgba8888(TEXSTORE_PARAMS)
-{
- const GLboolean littleEndian = _mesa_little_endian();
-
- ASSERT(dstFormat == MESA_FORMAT_A8B8G8R8_UNORM ||
- dstFormat == MESA_FORMAT_R8G8B8A8_UNORM ||
- dstFormat == MESA_FORMAT_X8B8G8R8_UNORM ||
- dstFormat == MESA_FORMAT_R8G8B8X8_UNORM);
- ASSERT(_mesa_get_format_bytes(dstFormat) == 4);
-
- if (!ctx->_ImageTransferState &&
- (srcType == GL_UNSIGNED_BYTE ||
- srcType == GL_UNSIGNED_INT_8_8_8_8 ||
- srcType == GL_UNSIGNED_INT_8_8_8_8_REV) &&
- can_swizzle(baseInternalFormat) &&
- can_swizzle(srcFormat)) {
-
- GLubyte dstmap[4];
-
- /* dstmap - how to swizzle from RGBA to dst format:
- */
- if ((littleEndian && (dstFormat == MESA_FORMAT_A8B8G8R8_UNORM ||
- dstFormat == MESA_FORMAT_X8B8G8R8_UNORM)) ||
- (!littleEndian && (dstFormat == MESA_FORMAT_R8G8B8A8_UNORM ||
- dstFormat == MESA_FORMAT_R8G8B8X8_UNORM))) {
- dstmap[3] = 0;
- dstmap[2] = 1;
- dstmap[1] = 2;
- dstmap[0] = 3;
- }
- else {
- dstmap[3] = 3;
- dstmap[2] = 2;
- dstmap[1] = 1;
- dstmap[0] = 0;
- }
-
- _mesa_swizzle_ubyte_image(ctx, dims,
- srcFormat,
- srcType,
- baseInternalFormat,
- dstmap, 4,
- dstRowStride, dstSlices,
- srcWidth, srcHeight, srcDepth, srcAddr,
- srcPacking);
- }
- else {
- return store_ubyte_texture(ctx, dims, baseInternalFormat,
- dstFormat, dstRowStride, dstSlices,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr, srcPacking);
- }
- return GL_TRUE;
-}
-
-
-static GLboolean
-_mesa_texstore_argb8888(TEXSTORE_PARAMS)
-{
- const GLboolean littleEndian = _mesa_little_endian();
-
- ASSERT(dstFormat == MESA_FORMAT_B8G8R8A8_UNORM ||
- dstFormat == MESA_FORMAT_A8R8G8B8_UNORM ||
- dstFormat == MESA_FORMAT_B8G8R8X8_UNORM ||
- dstFormat == MESA_FORMAT_X8R8G8B8_UNORM );
- ASSERT(_mesa_get_format_bytes(dstFormat) == 4);
-
- if (!ctx->_ImageTransferState &&
- !srcPacking->SwapBytes &&
- (dstFormat == MESA_FORMAT_B8G8R8A8_UNORM ||
- dstFormat == MESA_FORMAT_B8G8R8X8_UNORM) &&
- srcFormat == GL_RGB &&
- (baseInternalFormat == GL_RGBA ||
- baseInternalFormat == GL_RGB) &&
- srcType == GL_UNSIGNED_BYTE) {
- int img, row, col;
- for (img = 0; img < srcDepth; img++) {
- const GLint srcRowStride =
- _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType);
- GLubyte *srcRow = (GLubyte *) _mesa_image_address(dims, srcPacking,
- srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0);
- GLubyte *dstRow = dstSlices[img];
- for (row = 0; row < srcHeight; row++) {
- GLuint *d4 = (GLuint *) dstRow;
- for (col = 0; col < srcWidth; col++) {
- d4[col] = PACK_COLOR_8888(0xff,
- srcRow[col * 3 + RCOMP],
- srcRow[col * 3 + GCOMP],
- srcRow[col * 3 + BCOMP]);
- }
- dstRow += dstRowStride;
- srcRow += srcRowStride;
- }
- }
- }
- else if (!ctx->_ImageTransferState &&
- !srcPacking->SwapBytes &&
- dstFormat == MESA_FORMAT_B8G8R8A8_UNORM &&
- srcFormat == GL_LUMINANCE_ALPHA &&
- baseInternalFormat == GL_RGBA &&
- srcType == GL_UNSIGNED_BYTE) {
- /* special case of storing LA -> ARGB8888 */
- int img, row, col;
- const GLint srcRowStride =
- _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType);
- for (img = 0; img < srcDepth; img++) {
- const GLubyte *srcRow = (const GLubyte *)
- _mesa_image_address(dims, srcPacking, srcAddr, srcWidth,
- srcHeight, srcFormat, srcType, img, 0, 0);
- GLubyte *dstRow = dstSlices[img];
- for (row = 0; row < srcHeight; row++) {
- GLuint *d4 = (GLuint *) dstRow;
- for (col = 0; col < srcWidth; col++) {
- GLubyte l = srcRow[col * 2 + 0], a = srcRow[col * 2 + 1];
- d4[col] = PACK_COLOR_8888(a, l, l, l);
- }
- dstRow += dstRowStride;
- srcRow += srcRowStride;
- }
- }
- }
- else if (!ctx->_ImageTransferState &&
- !srcPacking->SwapBytes &&
- dstFormat == MESA_FORMAT_B8G8R8A8_UNORM &&
- srcFormat == GL_RGBA &&
- baseInternalFormat == GL_RGBA &&
- srcType == GL_UNSIGNED_BYTE) {
- /* same as above case, but src data has alpha too */
- GLint img, row, col;
- /* For some reason, streaming copies to write-combined regions
- * are extremely sensitive to the characteristics of how the
- * source data is retrieved. By reordering the source reads to
- * be in-order, the speed of this operation increases by half.
- * Strangely the same isn't required for the RGB path, above.
- */
- for (img = 0; img < srcDepth; img++) {
- const GLint srcRowStride =
- _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType);
- GLubyte *srcRow = (GLubyte *) _mesa_image_address(dims, srcPacking,
- srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0);
- GLubyte *dstRow = dstSlices[img];
- for (row = 0; row < srcHeight; row++) {
- GLuint *d4 = (GLuint *) dstRow;
- for (col = 0; col < srcWidth; col++) {
- d4[col] = PACK_COLOR_8888(srcRow[col * 4 + ACOMP],
- srcRow[col * 4 + RCOMP],
- srcRow[col * 4 + GCOMP],
- srcRow[col * 4 + BCOMP]);
- }
- dstRow += dstRowStride;
- srcRow += srcRowStride;
- }
- }
- }
- else if (!ctx->_ImageTransferState &&
- (srcType == GL_UNSIGNED_BYTE ||
- srcType == GL_UNSIGNED_INT_8_8_8_8 ||
- srcType == GL_UNSIGNED_INT_8_8_8_8_REV) &&
- can_swizzle(baseInternalFormat) &&
- can_swizzle(srcFormat)) {
-
- GLubyte dstmap[4];
-
- /* dstmap - how to swizzle from RGBA to dst format:
- */
- if ((littleEndian && dstFormat == MESA_FORMAT_B8G8R8A8_UNORM) ||
- (littleEndian && dstFormat == MESA_FORMAT_B8G8R8X8_UNORM) ||
- (!littleEndian && dstFormat == MESA_FORMAT_A8R8G8B8_UNORM) ||
- (!littleEndian && dstFormat == MESA_FORMAT_X8R8G8B8_UNORM)) {
- dstmap[3] = 3; /* alpha */
- dstmap[2] = 0; /* red */
- dstmap[1] = 1; /* green */
- dstmap[0] = 2; /* blue */
- }
- else {
- assert((littleEndian && dstFormat == MESA_FORMAT_A8R8G8B8_UNORM) ||
- (!littleEndian && dstFormat == MESA_FORMAT_B8G8R8A8_UNORM) ||
- (littleEndian && dstFormat == MESA_FORMAT_X8R8G8B8_UNORM) ||
- (!littleEndian && dstFormat == MESA_FORMAT_B8G8R8X8_UNORM));
- dstmap[3] = 2;
- dstmap[2] = 1;
- dstmap[1] = 0;
- dstmap[0] = 3;
- }
-
- _mesa_swizzle_ubyte_image(ctx, dims,
- srcFormat,
- srcType,
- baseInternalFormat,
- dstmap, 4,
- dstRowStride,
- dstSlices,
- srcWidth, srcHeight, srcDepth, srcAddr,
- srcPacking);
- }
- else {
- return store_ubyte_texture(ctx, dims, baseInternalFormat,
- dstFormat, dstRowStride, dstSlices,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr, srcPacking);
- }
- return GL_TRUE;
-}
-
-
-static GLboolean
-_mesa_texstore_rgb888(TEXSTORE_PARAMS)
-{
- ASSERT(dstFormat == MESA_FORMAT_BGR_UNORM8);
- ASSERT(_mesa_get_format_bytes(dstFormat) == 3);
-
- if (!ctx->_ImageTransferState &&
- !srcPacking->SwapBytes &&
- srcFormat == GL_RGBA &&
- srcType == GL_UNSIGNED_BYTE) {
- /* extract RGB from RGBA */
- GLint img, row, col;
- for (img = 0; img < srcDepth; img++) {
- const GLint srcRowStride =
- _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType);
- GLubyte *srcRow = (GLubyte *) _mesa_image_address(dims, srcPacking,
- srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0);
- GLubyte *dstRow = dstSlices[img];
- for (row = 0; row < srcHeight; row++) {
- for (col = 0; col < srcWidth; col++) {
- dstRow[col * 3 + 0] = srcRow[col * 4 + BCOMP];
- dstRow[col * 3 + 1] = srcRow[col * 4 + GCOMP];
- dstRow[col * 3 + 2] = srcRow[col * 4 + RCOMP];
- }
- dstRow += dstRowStride;
- srcRow += srcRowStride;
- }
- }
- }
- else if (!ctx->_ImageTransferState &&
- srcType == GL_UNSIGNED_BYTE &&
- can_swizzle(baseInternalFormat) &&
- can_swizzle(srcFormat)) {
-
- GLubyte dstmap[4];
-
- /* dstmap - how to swizzle from RGBA to dst format:
- */
- dstmap[0] = 2;
- dstmap[1] = 1;
- dstmap[2] = 0;
- dstmap[3] = ONE; /* ? */
-
- _mesa_swizzle_ubyte_image(ctx, dims,
- srcFormat,
- srcType,
- baseInternalFormat,
- dstmap, 3,
- dstRowStride, dstSlices,
- srcWidth, srcHeight, srcDepth, srcAddr,
- srcPacking);
- }
- else {
- return store_ubyte_texture(ctx, dims, baseInternalFormat,
- dstFormat, dstRowStride, dstSlices,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr, srcPacking);
- }
- return GL_TRUE;
-}
-
-
-static GLboolean
-_mesa_texstore_bgr888(TEXSTORE_PARAMS)
-{
- ASSERT(dstFormat == MESA_FORMAT_RGB_UNORM8);
- ASSERT(_mesa_get_format_bytes(dstFormat) == 3);
-
- if (!ctx->_ImageTransferState &&
- !srcPacking->SwapBytes &&
- srcFormat == GL_RGBA &&
- srcType == GL_UNSIGNED_BYTE) {
- /* extract BGR from RGBA */
- int img, row, col;
- for (img = 0; img < srcDepth; img++) {
- const GLint srcRowStride =
- _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType);
- GLubyte *srcRow = (GLubyte *) _mesa_image_address(dims, srcPacking,
- srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0);
- GLubyte *dstRow = dstSlices[img];
- for (row = 0; row < srcHeight; row++) {
- for (col = 0; col < srcWidth; col++) {
- dstRow[col * 3 + 0] = srcRow[col * 4 + RCOMP];
- dstRow[col * 3 + 1] = srcRow[col * 4 + GCOMP];
- dstRow[col * 3 + 2] = srcRow[col * 4 + BCOMP];
- }
- dstRow += dstRowStride;
- srcRow += srcRowStride;
- }
- }
- }
- else if (!ctx->_ImageTransferState &&
- srcType == GL_UNSIGNED_BYTE &&
- can_swizzle(baseInternalFormat) &&
- can_swizzle(srcFormat)) {
-
- GLubyte dstmap[4];
-
- /* dstmap - how to swizzle from RGBA to dst format:
- */
- dstmap[0] = 0;
- dstmap[1] = 1;
- dstmap[2] = 2;
- dstmap[3] = ONE; /* ? */
-
- _mesa_swizzle_ubyte_image(ctx, dims,
- srcFormat,
- srcType,
- baseInternalFormat,
- dstmap, 3,
- dstRowStride, dstSlices,
- srcWidth, srcHeight, srcDepth, srcAddr,
- srcPacking);
- }
- else {
- return store_ubyte_texture(ctx, dims, baseInternalFormat,
- dstFormat, dstRowStride, dstSlices,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr, srcPacking);
- }
- return GL_TRUE;
-}
-
-
-static GLboolean
-_mesa_texstore_argb2101010(TEXSTORE_PARAMS)
-{
- ASSERT(dstFormat == MESA_FORMAT_B10G10R10A2_UNORM ||
- dstFormat == MESA_FORMAT_B10G10R10X2_UNORM);
- ASSERT(_mesa_get_format_bytes(dstFormat) == 4);
-
- {
- /* general path */
- /* Hardcode GL_RGBA as the base format, which forces alpha to 1.0
- * if the internal format is RGB. */
- const GLfloat *tempImage = _mesa_make_temp_float_image(ctx, dims,
- baseInternalFormat,
- GL_RGBA,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr,
- srcPacking,
- ctx->_ImageTransferState);
- const GLfloat *src = tempImage;
- GLint img, row, col;
- if (!tempImage)
- return GL_FALSE;
- for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstSlices[img];
- if (baseInternalFormat == GL_RGBA || baseInternalFormat == GL_RGB) {
- for (row = 0; row < srcHeight; row++) {
- GLuint *dstUI = (GLuint *) dstRow;
- for (col = 0; col < srcWidth; col++) {
- GLushort a,r,g,b;
-
- UNCLAMPED_FLOAT_TO_USHORT(a, src[ACOMP]);
- UNCLAMPED_FLOAT_TO_USHORT(r, src[RCOMP]);
- UNCLAMPED_FLOAT_TO_USHORT(g, src[GCOMP]);
- UNCLAMPED_FLOAT_TO_USHORT(b, src[BCOMP]);
- dstUI[col] = PACK_COLOR_2101010_US(a, r, g, b);
- src += 4;
- }
- dstRow += dstRowStride;
- }
- } else {
- ASSERT(0);
- }
- }
- free((void *) tempImage);
- }
- return GL_TRUE;
-}
-
-
-/**
- * Do texstore for 2-channel, 4-bit/channel, unsigned normalized formats.
- */
-static GLboolean
-_mesa_texstore_unorm44(TEXSTORE_PARAMS)
-{
- const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
-
- ASSERT(dstFormat == MESA_FORMAT_L4A4_UNORM);
- ASSERT(_mesa_get_format_bytes(dstFormat) == 1);
-
- {
- /* general path */
- const GLubyte *tempImage = _mesa_make_temp_ubyte_image(ctx, dims,
- baseInternalFormat,
- baseFormat,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr,
- srcPacking);
- const GLubyte *src = tempImage;
- GLint img, row, col;
- if (!tempImage)
- return GL_FALSE;
- for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstSlices[img];
- for (row = 0; row < srcHeight; row++) {
- GLubyte *dstUS = (GLubyte *) dstRow;
- for (col = 0; col < srcWidth; col++) {
- /* src[0] is luminance, src[1] is alpha */
- dstUS[col] = PACK_COLOR_44( src[1],
- src[0] );
- src += 2;
- }
- dstRow += dstRowStride;
- }
- }
- free((void *) tempImage);
- }
- return GL_TRUE;
-}
-
-
-/**
- * Do texstore for 2-channel, 8-bit/channel, unsigned normalized formats.
- */
-static GLboolean
-_mesa_texstore_unorm88(TEXSTORE_PARAMS)
-{
- const GLboolean littleEndian = _mesa_little_endian();
- const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
-
- ASSERT(dstFormat == MESA_FORMAT_L8A8_UNORM ||
- dstFormat == MESA_FORMAT_A8L8_UNORM ||
- dstFormat == MESA_FORMAT_R8G8_UNORM ||
- dstFormat == MESA_FORMAT_G8R8_UNORM);
- ASSERT(_mesa_get_format_bytes(dstFormat) == 2);
-
- if (!ctx->_ImageTransferState &&
- littleEndian &&
- srcType == GL_UNSIGNED_BYTE &&
- can_swizzle(baseInternalFormat) &&
- can_swizzle(srcFormat)) {
- GLubyte dstmap[4];
-
- /* dstmap - how to swizzle from RGBA to dst format:
- */
- if (dstFormat == MESA_FORMAT_L8A8_UNORM || dstFormat == MESA_FORMAT_A8L8_UNORM) {
- if ((littleEndian && dstFormat == MESA_FORMAT_L8A8_UNORM) ||
- (!littleEndian && dstFormat == MESA_FORMAT_A8L8_UNORM)) {
- dstmap[0] = 0;
- dstmap[1] = 3;
- }
- else {
- dstmap[0] = 3;
- dstmap[1] = 0;
- }
- }
- else {
- if ((littleEndian && dstFormat == MESA_FORMAT_R8G8_UNORM) ||
- (!littleEndian && dstFormat == MESA_FORMAT_G8R8_UNORM)) {
- dstmap[0] = 0;
- dstmap[1] = 1;
- }
- else {
- dstmap[0] = 1;
- dstmap[1] = 0;
- }
- }
- dstmap[2] = ZERO; /* ? */
- dstmap[3] = ONE; /* ? */
-
- _mesa_swizzle_ubyte_image(ctx, dims,
- srcFormat,
- srcType,
- baseInternalFormat,
- dstmap, 2,
- dstRowStride, dstSlices,
- srcWidth, srcHeight, srcDepth, srcAddr,
- srcPacking);
- }
- else {
- /* general path */
- const GLubyte *tempImage = _mesa_make_temp_ubyte_image(ctx, dims,
- baseInternalFormat,
- baseFormat,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr,
- srcPacking);
- const GLubyte *src = tempImage;
- GLint img, row, col;
- if (!tempImage)
- return GL_FALSE;
- for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstSlices[img];
- for (row = 0; row < srcHeight; row++) {
- GLushort *dstUS = (GLushort *) dstRow;
- if (dstFormat == MESA_FORMAT_L8A8_UNORM ||
- dstFormat == MESA_FORMAT_R8G8_UNORM) {
- for (col = 0; col < srcWidth; col++) {
- /* src[0] is luminance (or R), src[1] is alpha (or G) */
- dstUS[col] = PACK_COLOR_88( src[1],
- src[0] );
- src += 2;
- }
- }
- else {
- for (col = 0; col < srcWidth; col++) {
- /* src[0] is luminance (or R), src[1] is alpha (or G) */
- dstUS[col] = PACK_COLOR_88_REV( src[1],
- src[0] );
- src += 2;
- }
- }
- dstRow += dstRowStride;
- }
- }
- free((void *) tempImage);
- }
- return GL_TRUE;
-}
-
-
-/**
- * Do texstore for 2-channel, 16-bit/channel, unsigned normalized formats.
- */
-static GLboolean
-_mesa_texstore_unorm1616(TEXSTORE_PARAMS)
-{
- const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
-
- ASSERT(dstFormat == MESA_FORMAT_L16A16_UNORM ||
- dstFormat == MESA_FORMAT_A16L16_UNORM ||
- dstFormat == MESA_FORMAT_R16G16_UNORM ||
- dstFormat == MESA_FORMAT_G16R16_UNORM);
- ASSERT(_mesa_get_format_bytes(dstFormat) == 4);
-
- {
- /* general path */
- const GLfloat *tempImage = _mesa_make_temp_float_image(ctx, dims,
- baseInternalFormat,
- baseFormat,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr,
- srcPacking,
- ctx->_ImageTransferState);
- const GLfloat *src = tempImage;
- GLint img, row, col;
- if (!tempImage)
- return GL_FALSE;
- for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstSlices[img];
- for (row = 0; row < srcHeight; row++) {
- GLuint *dstUI = (GLuint *) dstRow;
- if (dstFormat == MESA_FORMAT_L16A16_UNORM ||
- dstFormat == MESA_FORMAT_R16G16_UNORM) {
- for (col = 0; col < srcWidth; col++) {
- GLushort l, a;
-
- UNCLAMPED_FLOAT_TO_USHORT(l, src[0]);
- UNCLAMPED_FLOAT_TO_USHORT(a, src[1]);
- dstUI[col] = PACK_COLOR_1616(a, l);
- src += 2;
- }
- }
- else {
- for (col = 0; col < srcWidth; col++) {
- GLushort l, a;
-
- UNCLAMPED_FLOAT_TO_USHORT(l, src[0]);
- UNCLAMPED_FLOAT_TO_USHORT(a, src[1]);
- dstUI[col] = PACK_COLOR_1616_REV(a, l);
- src += 2;
- }
- }
- dstRow += dstRowStride;
- }
- }
- free((void *) tempImage);
- }
- return GL_TRUE;
-}
-
-
-/* Texstore for R16, A16, L16, I16. */
-static GLboolean
-_mesa_texstore_unorm16(TEXSTORE_PARAMS)
-{
- const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
-
- ASSERT(dstFormat == MESA_FORMAT_R_UNORM16 ||
- dstFormat == MESA_FORMAT_A_UNORM16 ||
- dstFormat == MESA_FORMAT_L_UNORM16 ||
- dstFormat == MESA_FORMAT_I_UNORM16);
- ASSERT(_mesa_get_format_bytes(dstFormat) == 2);
-
- {
- /* general path */
- const GLfloat *tempImage = _mesa_make_temp_float_image(ctx, dims,
- baseInternalFormat,
- baseFormat,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr,
- srcPacking,
- ctx->_ImageTransferState);
- const GLfloat *src = tempImage;
- GLint img, row, col;
- if (!tempImage)
- return GL_FALSE;
- for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstSlices[img];
- for (row = 0; row < srcHeight; row++) {
- GLushort *dstUS = (GLushort *) dstRow;
- for (col = 0; col < srcWidth; col++) {
- GLushort r;
-
- UNCLAMPED_FLOAT_TO_USHORT(r, src[0]);
- dstUS[col] = r;
- src += 1;
- }
- dstRow += dstRowStride;
- }
- }
- free((void *) tempImage);
- }
- return GL_TRUE;
-}
-
-
-static GLboolean
-_mesa_texstore_rgba_16(TEXSTORE_PARAMS)
-{
- ASSERT(dstFormat == MESA_FORMAT_RGBA_UNORM16 ||
- dstFormat == MESA_FORMAT_RGBX_UNORM16);
- ASSERT(_mesa_get_format_bytes(dstFormat) == 8);
-
- {
- /* general path */
- /* Hardcode GL_RGBA as the base format, which forces alpha to 1.0
- * if the internal format is RGB. */
- const GLfloat *tempImage = _mesa_make_temp_float_image(ctx, dims,
- baseInternalFormat,
- GL_RGBA,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr,
- srcPacking,
- ctx->_ImageTransferState);
- const GLfloat *src = tempImage;
- GLint img, row, col;
-
- if (!tempImage)
- return GL_FALSE;
-
- for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstSlices[img];
- for (row = 0; row < srcHeight; row++) {
- GLushort *dstUS = (GLushort *) dstRow;
- for (col = 0; col < srcWidth; col++) {
- GLushort r, g, b, a;
-
- UNCLAMPED_FLOAT_TO_USHORT(r, src[0]);
- UNCLAMPED_FLOAT_TO_USHORT(g, src[1]);
- UNCLAMPED_FLOAT_TO_USHORT(b, src[2]);
- UNCLAMPED_FLOAT_TO_USHORT(a, src[3]);
- dstUS[col*4+0] = r;
- dstUS[col*4+1] = g;
- dstUS[col*4+2] = b;
- dstUS[col*4+3] = a;
- src += 4;
- }
- dstRow += dstRowStride;
- }
- }
- free((void *) tempImage);
- }
- return GL_TRUE;
-}
-
-
-static GLboolean
-_mesa_texstore_signed_rgba_16(TEXSTORE_PARAMS)
-{
- const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
-
- ASSERT(dstFormat == MESA_FORMAT_RGB_SNORM16 ||
- dstFormat == MESA_FORMAT_RGBA_SNORM16 ||
- dstFormat == MESA_FORMAT_RGBX_SNORM16);
-
- {
- /* general path */
- const GLfloat *tempImage = _mesa_make_temp_float_image(ctx, dims,
- baseInternalFormat,
- baseFormat,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr,
- srcPacking,
- ctx->_ImageTransferState);
- const GLfloat *src = tempImage;
- const GLuint comps = _mesa_get_format_bytes(dstFormat) / 2;
- GLint img, row, col;
-
- if (!tempImage)
- return GL_FALSE;
-
- /* Note: tempImage is always float[4] / RGBA. We convert to 1, 2,
- * 3 or 4 components/pixel here.
- */
- for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstSlices[img];
- for (row = 0; row < srcHeight; row++) {
- GLshort *dstRowS = (GLshort *) dstRow;
- if (dstFormat == MESA_FORMAT_RGBA_SNORM16) {
- for (col = 0; col < srcWidth; col++) {
- GLuint c;
- for (c = 0; c < comps; c++) {
- GLshort p;
- UNCLAMPED_FLOAT_TO_SHORT(p, src[col * 4 + c]);
- dstRowS[col * comps + c] = p;
- }
- }
- dstRow += dstRowStride;
- src += 4 * srcWidth;
- }
- else if (dstFormat == MESA_FORMAT_RGBX_SNORM16) {
- for (col = 0; col < srcWidth; col++) {
- GLuint c;
-
- for (c = 0; c < 3; c++) {
- GLshort p;
- UNCLAMPED_FLOAT_TO_SHORT(p, src[col * 3 + c]);
- dstRowS[col * comps + c] = p;
- }
- dstRowS[col * comps + 3] = 32767;
- }
- dstRow += dstRowStride;
- src += 3 * srcWidth;
- }
- else {
- for (col = 0; col < srcWidth; col++) {
- GLuint c;
- for (c = 0; c < comps; c++) {
- GLshort p;
- UNCLAMPED_FLOAT_TO_SHORT(p, src[col * 3 + c]);
- dstRowS[col * comps + c] = p;
- }
- }
- dstRow += dstRowStride;
- src += 3 * srcWidth;
- }
- }
- }
- free((void *) tempImage);
- }
- return GL_TRUE;
-}
-
-
-/**
- * Texstore for _mesa_texformat_a8, _mesa_texformat_l8, _mesa_texformat_i8.
- */
-static GLboolean
-_mesa_texstore_unorm8(TEXSTORE_PARAMS)
-{
- const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
-
- ASSERT(dstFormat == MESA_FORMAT_A_UNORM8 ||
- dstFormat == MESA_FORMAT_L_UNORM8 ||
- dstFormat == MESA_FORMAT_I_UNORM8 ||
- dstFormat == MESA_FORMAT_R_UNORM8);
- ASSERT(_mesa_get_format_bytes(dstFormat) == 1);
-
- if (!ctx->_ImageTransferState &&
- srcType == GL_UNSIGNED_BYTE &&
- can_swizzle(baseInternalFormat) &&
- can_swizzle(srcFormat)) {
- GLubyte dstmap[4];
-
- /* dstmap - how to swizzle from RGBA to dst format:
- */
- if (dstFormat == MESA_FORMAT_A_UNORM8) {
- dstmap[0] = 3;
- }
- else {
- dstmap[0] = 0;
- }
- dstmap[1] = ZERO; /* ? */
- dstmap[2] = ZERO; /* ? */
- dstmap[3] = ONE; /* ? */
-
- _mesa_swizzle_ubyte_image(ctx, dims,
- srcFormat,
- srcType,
- baseInternalFormat,
- dstmap, 1,
- dstRowStride, dstSlices,
- srcWidth, srcHeight, srcDepth, srcAddr,
- srcPacking);
- }
- else {
- /* general path */
- const GLubyte *tempImage = _mesa_make_temp_ubyte_image(ctx, dims,
- baseInternalFormat,
- baseFormat,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr,
- srcPacking);
- const GLubyte *src = tempImage;
- GLint img, row, col;
- if (!tempImage)
- return GL_FALSE;
- for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstSlices[img];
- for (row = 0; row < srcHeight; row++) {
- for (col = 0; col < srcWidth; col++) {
- dstRow[col] = src[col];
- }
- dstRow += dstRowStride;
- src += srcWidth;
- }
- }
- free((void *) tempImage);
- }
- return GL_TRUE;
}
-
/**
* Texstore for _mesa_texformat_ycbcr or _mesa_texformat_ycbcr_REV.
*/
@@ -2063,330 +982,6 @@ _mesa_texstore_ycbcr(TEXSTORE_PARAMS)
/**
- * Store a texture in a signed normalized 8-bit format.
- */
-static GLboolean
-_mesa_texstore_snorm8(TEXSTORE_PARAMS)
-{
- const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
-
- ASSERT(dstFormat == MESA_FORMAT_A_SNORM8 ||
- dstFormat == MESA_FORMAT_L_SNORM8 ||
- dstFormat == MESA_FORMAT_I_SNORM8 ||
- dstFormat == MESA_FORMAT_R_SNORM8);
- ASSERT(_mesa_get_format_bytes(dstFormat) == 1);
-
- {
- /* general path */
- const GLfloat *tempImage = _mesa_make_temp_float_image(ctx, dims,
- baseInternalFormat,
- baseFormat,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr,
- srcPacking,
- ctx->_ImageTransferState);
- const GLfloat *src = tempImage;
- GLint img, row, col;
- if (!tempImage)
- return GL_FALSE;
- for (img = 0; img < srcDepth; img++) {
- GLbyte *dstRow = (GLbyte *) dstSlices[img];
- for (row = 0; row < srcHeight; row++) {
- for (col = 0; col < srcWidth; col++) {
- dstRow[col] = FLOAT_TO_BYTE_TEX(src[col]);
- }
- dstRow += dstRowStride;
- src += srcWidth;
- }
- }
- free((void *) tempImage);
- }
- return GL_TRUE;
-}
-
-
-/**
- * Store a texture in a signed normalized two-channel 16-bit format.
- */
-static GLboolean
-_mesa_texstore_snorm88(TEXSTORE_PARAMS)
-{
- const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
-
- ASSERT(dstFormat == MESA_FORMAT_L8A8_SNORM ||
- dstFormat == MESA_FORMAT_G8R8_SNORM ||
- dstFormat == MESA_FORMAT_R8G8_SNORM);
- ASSERT(_mesa_get_format_bytes(dstFormat) == 2);
-
- {
- /* general path */
- const GLfloat *tempImage = _mesa_make_temp_float_image(ctx, dims,
- baseInternalFormat,
- baseFormat,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr,
- srcPacking,
- ctx->_ImageTransferState);
- const GLfloat *src = tempImage;
- GLint img, row, col;
- if (!tempImage)
- return GL_FALSE;
- for (img = 0; img < srcDepth; img++) {
- GLbyte *dstRow = (GLbyte *) dstSlices[img];
- for (row = 0; row < srcHeight; row++) {
- GLushort *dst = (GLushort *) dstRow;
-
- if (dstFormat == MESA_FORMAT_L8A8_SNORM ||
- dstFormat == MESA_FORMAT_R8G8_SNORM) {
- for (col = 0; col < srcWidth; col++) {
- GLubyte l = FLOAT_TO_BYTE_TEX(src[0]);
- GLubyte a = FLOAT_TO_BYTE_TEX(src[1]);
-
- dst[col] = PACK_COLOR_88_REV(l, a);
- src += 2;
- }
- } else {
- for (col = 0; col < srcWidth; col++) {
- GLubyte l = FLOAT_TO_BYTE_TEX(src[0]);
- GLubyte a = FLOAT_TO_BYTE_TEX(src[1]);
-
- dst[col] = PACK_COLOR_88(l, a);
- src += 2;
- }
- }
-
- dstRow += dstRowStride;
- }
- }
- free((void *) tempImage);
- }
- return GL_TRUE;
-}
-
-/* Texstore for signed R16, A16, L16, I16. */
-static GLboolean
-_mesa_texstore_snorm16(TEXSTORE_PARAMS)
-{
- const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
-
- ASSERT(dstFormat == MESA_FORMAT_R_SNORM16 ||
- dstFormat == MESA_FORMAT_A_SNORM16 ||
- dstFormat == MESA_FORMAT_L_SNORM16 ||
- dstFormat == MESA_FORMAT_I_SNORM16);
- ASSERT(_mesa_get_format_bytes(dstFormat) == 2);
-
- {
- /* general path */
- const GLfloat *tempImage = _mesa_make_temp_float_image(ctx, dims,
- baseInternalFormat,
- baseFormat,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr,
- srcPacking,
- ctx->_ImageTransferState);
- const GLfloat *src = tempImage;
- GLint img, row, col;
- if (!tempImage)
- return GL_FALSE;
- for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstSlices[img];
- for (row = 0; row < srcHeight; row++) {
- GLshort *dstUS = (GLshort *) dstRow;
- for (col = 0; col < srcWidth; col++) {
- GLushort r;
-
- UNCLAMPED_FLOAT_TO_SHORT(r, src[0]);
- dstUS[col] = r;
- src += 1;
- }
- dstRow += dstRowStride;
- }
- }
- free((void *) tempImage);
- }
- return GL_TRUE;
-}
-
-/**
- * Do texstore for 2-channel, 16-bit/channel, signed normalized formats.
- */
-static GLboolean
-_mesa_texstore_snorm1616(TEXSTORE_PARAMS)
-{
- const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
-
- ASSERT(dstFormat == MESA_FORMAT_LA_SNORM16 ||
- dstFormat == MESA_FORMAT_G16R16_SNORM ||
- dstFormat == MESA_FORMAT_R16G16_SNORM);
- ASSERT(_mesa_get_format_bytes(dstFormat) == 4);
-
- {
- /* general path */
- const GLfloat *tempImage = _mesa_make_temp_float_image(ctx, dims,
- baseInternalFormat,
- baseFormat,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr,
- srcPacking,
- ctx->_ImageTransferState);
- const GLfloat *src = tempImage;
- GLint img, row, col;
- if (!tempImage)
- return GL_FALSE;
- for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstSlices[img];
- for (row = 0; row < srcHeight; row++) {
- GLuint *dst = (GLuint *) dstRow;
-
- if (dstFormat == MESA_FORMAT_LA_SNORM16 ||
- dstFormat == MESA_FORMAT_R16G16_SNORM) {
- for (col = 0; col < srcWidth; col++) {
- GLushort l, a;
-
- UNCLAMPED_FLOAT_TO_SHORT(l, src[0]);
- UNCLAMPED_FLOAT_TO_SHORT(a, src[1]);
- dst[col] = PACK_COLOR_1616_REV(l, a);
- src += 2;
- }
- } else {
- for (col = 0; col < srcWidth; col++) {
- GLushort l, a;
-
- UNCLAMPED_FLOAT_TO_SHORT(l, src[0]);
- UNCLAMPED_FLOAT_TO_SHORT(a, src[1]);
- dst[col] = PACK_COLOR_1616_REV(l, a);
- src += 2;
- }
- }
-
- dstRow += dstRowStride;
- }
- }
- free((void *) tempImage);
- }
- return GL_TRUE;
-}
-
-/**
- * Store a texture in MESA_FORMAT_X8B8G8R8_SNORM or
- * MESA_FORMAT_R8G8B8X8_SNORM.
- */
-static GLboolean
-_mesa_texstore_signed_rgbx8888(TEXSTORE_PARAMS)
-{
- const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
-
- ASSERT(dstFormat == MESA_FORMAT_X8B8G8R8_SNORM ||
- dstFormat == MESA_FORMAT_R8G8B8X8_SNORM);
- ASSERT(_mesa_get_format_bytes(dstFormat) == 4);
-
- {
- /* general path */
- const GLfloat *tempImage = _mesa_make_temp_float_image(ctx, dims,
- baseInternalFormat,
- baseFormat,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr,
- srcPacking,
- ctx->_ImageTransferState);
- const GLfloat *srcRow = tempImage;
- GLint img, row, col;
- if (!tempImage)
- return GL_FALSE;
- for (img = 0; img < srcDepth; img++) {
- GLbyte *dstRow = (GLbyte *) dstSlices[img];
- for (row = 0; row < srcHeight; row++) {
- GLbyte *dst = dstRow;
- if (dstFormat == MESA_FORMAT_X8B8G8R8_SNORM) {
- for (col = 0; col < srcWidth; col++) {
- dst[3] = FLOAT_TO_BYTE_TEX(srcRow[RCOMP]);
- dst[2] = FLOAT_TO_BYTE_TEX(srcRow[GCOMP]);
- dst[1] = FLOAT_TO_BYTE_TEX(srcRow[BCOMP]);
- dst[0] = 127;
- srcRow += 3;
- dst += 4;
- }
- }
- else {
- for (col = 0; col < srcWidth; col++) {
- dst[0] = FLOAT_TO_BYTE_TEX(srcRow[RCOMP]);
- dst[1] = FLOAT_TO_BYTE_TEX(srcRow[GCOMP]);
- dst[2] = FLOAT_TO_BYTE_TEX(srcRow[BCOMP]);
- dst[3] = 127;
- srcRow += 3;
- dst += 4;
- }
- }
- dstRow += dstRowStride;
- }
- }
- free((void *) tempImage);
- }
- return GL_TRUE;
-}
-
-
-
-/**
- * Store a texture in MESA_FORMAT_A8B8G8R8_SNORM or
- * MESA_FORMAT_R8G8B8A8_SNORM
- */
-static GLboolean
-_mesa_texstore_signed_rgba8888(TEXSTORE_PARAMS)
-{
- const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
-
- ASSERT(dstFormat == MESA_FORMAT_A8B8G8R8_SNORM ||
- dstFormat == MESA_FORMAT_R8G8B8A8_SNORM);
- ASSERT(_mesa_get_format_bytes(dstFormat) == 4);
-
- {
- /* general path */
- const GLfloat *tempImage = _mesa_make_temp_float_image(ctx, dims,
- baseInternalFormat,
- baseFormat,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr,
- srcPacking,
- ctx->_ImageTransferState);
- const GLfloat *srcRow = tempImage;
- GLint img, row, col;
- if (!tempImage)
- return GL_FALSE;
- for (img = 0; img < srcDepth; img++) {
- GLbyte *dstRow = (GLbyte *) dstSlices[img];
- for (row = 0; row < srcHeight; row++) {
- GLbyte *dst = dstRow;
- if (dstFormat == MESA_FORMAT_A8B8G8R8_SNORM) {
- for (col = 0; col < srcWidth; col++) {
- dst[3] = FLOAT_TO_BYTE_TEX(srcRow[RCOMP]);
- dst[2] = FLOAT_TO_BYTE_TEX(srcRow[GCOMP]);
- dst[1] = FLOAT_TO_BYTE_TEX(srcRow[BCOMP]);
- dst[0] = FLOAT_TO_BYTE_TEX(srcRow[ACOMP]);
- srcRow += 4;
- dst += 4;
- }
- }
- else {
- for (col = 0; col < srcWidth; col++) {
- dst[0] = FLOAT_TO_BYTE_TEX(srcRow[RCOMP]);
- dst[1] = FLOAT_TO_BYTE_TEX(srcRow[GCOMP]);
- dst[2] = FLOAT_TO_BYTE_TEX(srcRow[BCOMP]);
- dst[3] = FLOAT_TO_BYTE_TEX(srcRow[ACOMP]);
- srcRow += 4;
- dst += 4;
- }
- }
- dstRow += dstRowStride;
- }
- }
- free((void *) tempImage);
- }
- return GL_TRUE;
-}
-
-
-/**
* Store a combined depth/stencil texture image.
*/
static GLboolean
@@ -2599,742 +1194,6 @@ _mesa_texstore_s8(TEXSTORE_PARAMS)
}
-/**
- * Store an image in any of the formats:
- * _mesa_texformat_rgba_float32
- * _mesa_texformat_rgb_float32
- * _mesa_texformat_alpha_float32
- * _mesa_texformat_luminance_float32
- * _mesa_texformat_luminance_alpha_float32
- * _mesa_texformat_intensity_float32
- */
-static GLboolean
-_mesa_texstore_rgba_float32(TEXSTORE_PARAMS)
-{
- GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
- GLint components = _mesa_components_in_format(baseFormat);
-
- /* this forces alpha to 1 in _mesa_make_temp_float_image */
- if (dstFormat == MESA_FORMAT_RGBX_FLOAT32) {
- baseFormat = GL_RGBA;
- components = 4;
- }
-
- ASSERT(dstFormat == MESA_FORMAT_RGBA_FLOAT32 ||
- dstFormat == MESA_FORMAT_RGB_FLOAT32 ||
- dstFormat == MESA_FORMAT_A_FLOAT32 ||
- dstFormat == MESA_FORMAT_L_FLOAT32 ||
- dstFormat == MESA_FORMAT_LA_FLOAT32 ||
- dstFormat == MESA_FORMAT_I_FLOAT32 ||
- dstFormat == MESA_FORMAT_R_FLOAT32 ||
- dstFormat == MESA_FORMAT_RG_FLOAT32 ||
- dstFormat == MESA_FORMAT_RGBX_FLOAT32);
- ASSERT(baseInternalFormat == GL_RGBA ||
- baseInternalFormat == GL_RGB ||
- baseInternalFormat == GL_ALPHA ||
- baseInternalFormat == GL_LUMINANCE ||
- baseInternalFormat == GL_LUMINANCE_ALPHA ||
- baseInternalFormat == GL_INTENSITY ||
- baseInternalFormat == GL_RED ||
- baseInternalFormat == GL_RG);
- ASSERT(_mesa_get_format_bytes(dstFormat) == components * sizeof(GLfloat));
-
- {
- /* general path */
- const GLfloat *tempImage = _mesa_make_temp_float_image(ctx, dims,
- baseInternalFormat,
- baseFormat,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr,
- srcPacking,
- ctx->_ImageTransferState);
- const GLfloat *srcRow = tempImage;
- GLint bytesPerRow;
- GLint img, row;
- if (!tempImage)
- return GL_FALSE;
- bytesPerRow = srcWidth * components * sizeof(GLfloat);
- for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstSlices[img];
- for (row = 0; row < srcHeight; row++) {
- memcpy(dstRow, srcRow, bytesPerRow);
- dstRow += dstRowStride;
- srcRow += srcWidth * components;
- }
- }
-
- free((void *) tempImage);
- }
- return GL_TRUE;
-}
-
-
-
-/**
- * As above, but store 16-bit floats.
- */
-static GLboolean
-_mesa_texstore_rgba_float16(TEXSTORE_PARAMS)
-{
- GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
- GLint components = _mesa_components_in_format(baseFormat);
-
- /* this forces alpha to 1 in _mesa_make_temp_float_image */
- if (dstFormat == MESA_FORMAT_RGBX_FLOAT16) {
- baseFormat = GL_RGBA;
- components = 4;
- }
-
- ASSERT(dstFormat == MESA_FORMAT_RGBA_FLOAT16 ||
- dstFormat == MESA_FORMAT_RGB_FLOAT16 ||
- dstFormat == MESA_FORMAT_A_FLOAT16 ||
- dstFormat == MESA_FORMAT_L_FLOAT16 ||
- dstFormat == MESA_FORMAT_LA_FLOAT16 ||
- dstFormat == MESA_FORMAT_I_FLOAT16 ||
- dstFormat == MESA_FORMAT_R_FLOAT16 ||
- dstFormat == MESA_FORMAT_RG_FLOAT16 ||
- dstFormat == MESA_FORMAT_RGBX_FLOAT16);
- ASSERT(baseInternalFormat == GL_RGBA ||
- baseInternalFormat == GL_RGB ||
- baseInternalFormat == GL_ALPHA ||
- baseInternalFormat == GL_LUMINANCE ||
- baseInternalFormat == GL_LUMINANCE_ALPHA ||
- baseInternalFormat == GL_INTENSITY ||
- baseInternalFormat == GL_RED ||
- baseInternalFormat == GL_RG);
- ASSERT(_mesa_get_format_bytes(dstFormat) == components * sizeof(GLhalfARB));
-
- {
- /* general path */
- const GLfloat *tempImage = _mesa_make_temp_float_image(ctx, dims,
- baseInternalFormat,
- baseFormat,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr,
- srcPacking,
- ctx->_ImageTransferState);
- const GLfloat *src = tempImage;
- GLint img, row;
- if (!tempImage)
- return GL_FALSE;
- for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstSlices[img];
- for (row = 0; row < srcHeight; row++) {
- GLhalfARB *dstTexel = (GLhalfARB *) dstRow;
- GLint i;
- for (i = 0; i < srcWidth * components; i++) {
- dstTexel[i] = _mesa_float_to_half(src[i]);
- }
- dstRow += dstRowStride;
- src += srcWidth * components;
- }
- }
-
- free((void *) tempImage);
- }
- return GL_TRUE;
-}
-
-
-/* non-normalized, signed int8 */
-static GLboolean
-_mesa_texstore_rgba_int8(TEXSTORE_PARAMS)
-{
- GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
- GLint components = _mesa_components_in_format(baseFormat);
-
- /* this forces alpha to 1 in make_temp_uint_image */
- if (dstFormat == MESA_FORMAT_RGBX_SINT8) {
- baseFormat = GL_RGBA;
- components = 4;
- }
-
- ASSERT(dstFormat == MESA_FORMAT_R_SINT8 ||
- dstFormat == MESA_FORMAT_RG_SINT8 ||
- dstFormat == MESA_FORMAT_RGB_SINT8 ||
- dstFormat == MESA_FORMAT_RGBA_SINT8 ||
- dstFormat == MESA_FORMAT_A_SINT8 ||
- dstFormat == MESA_FORMAT_I_SINT8 ||
- dstFormat == MESA_FORMAT_L_SINT8 ||
- dstFormat == MESA_FORMAT_LA_SINT8 ||
- dstFormat == MESA_FORMAT_RGBX_SINT8);
- ASSERT(baseInternalFormat == GL_RGBA ||
- baseInternalFormat == GL_RGB ||
- baseInternalFormat == GL_RG ||
- baseInternalFormat == GL_RED ||
- baseInternalFormat == GL_ALPHA ||
- baseInternalFormat == GL_LUMINANCE ||
- baseInternalFormat == GL_LUMINANCE_ALPHA ||
- baseInternalFormat == GL_INTENSITY);
- ASSERT(_mesa_get_format_bytes(dstFormat) == components * sizeof(GLbyte));
-
- {
- /* general path */
- const GLuint *tempImage = make_temp_uint_image(ctx, dims,
- baseInternalFormat,
- baseFormat,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType,
- srcAddr,
- srcPacking);
- const GLuint *src = tempImage;
- GLint img, row;
- GLboolean is_unsigned = _mesa_is_type_unsigned(srcType);
- if (!tempImage)
- return GL_FALSE;
- for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstSlices[img];
- for (row = 0; row < srcHeight; row++) {
- GLbyte *dstTexel = (GLbyte *) dstRow;
- GLint i;
- if (is_unsigned) {
- for (i = 0; i < srcWidth * components; i++) {
- dstTexel[i] = (GLbyte) MIN2(src[i], 0x7f);
- }
- } else {
- for (i = 0; i < srcWidth * components; i++) {
- dstTexel[i] = (GLbyte) CLAMP((GLint) src[i], -0x80, 0x7f);
- }
- }
- dstRow += dstRowStride;
- src += srcWidth * components;
- }
- }
-
- free((void *) tempImage);
- }
- return GL_TRUE;
-}
-
-
-/* non-normalized, signed int16 */
-static GLboolean
-_mesa_texstore_rgba_int16(TEXSTORE_PARAMS)
-{
- GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
- GLint components = _mesa_components_in_format(baseFormat);
-
- /* this forces alpha to 1 in make_temp_uint_image */
- if (dstFormat == MESA_FORMAT_RGBX_SINT16) {
- baseFormat = GL_RGBA;
- components = 4;
- }
-
- ASSERT(dstFormat == MESA_FORMAT_R_SINT16 ||
- dstFormat == MESA_FORMAT_RG_SINT16 ||
- dstFormat == MESA_FORMAT_RGB_SINT16 ||
- dstFormat == MESA_FORMAT_RGBA_SINT16 ||
- dstFormat == MESA_FORMAT_A_SINT16 ||
- dstFormat == MESA_FORMAT_L_SINT16 ||
- dstFormat == MESA_FORMAT_I_SINT16 ||
- dstFormat == MESA_FORMAT_LA_SINT16 ||
- dstFormat == MESA_FORMAT_RGBX_SINT16);
- ASSERT(baseInternalFormat == GL_RGBA ||
- baseInternalFormat == GL_RGB ||
- baseInternalFormat == GL_RG ||
- baseInternalFormat == GL_RED ||
- baseInternalFormat == GL_ALPHA ||
- baseInternalFormat == GL_LUMINANCE ||
- baseInternalFormat == GL_LUMINANCE_ALPHA ||
- baseInternalFormat == GL_INTENSITY);
- ASSERT(_mesa_get_format_bytes(dstFormat) == components * sizeof(GLshort));
-
- {
- /* general path */
- const GLuint *tempImage = make_temp_uint_image(ctx, dims,
- baseInternalFormat,
- baseFormat,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType,
- srcAddr,
- srcPacking);
- const GLuint *src = tempImage;
- GLint img, row;
- GLboolean is_unsigned = _mesa_is_type_unsigned(srcType);
- if (!tempImage)
- return GL_FALSE;
- for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstSlices[img];
- for (row = 0; row < srcHeight; row++) {
- GLshort *dstTexel = (GLshort *) dstRow;
- GLint i;
- if (is_unsigned) {
- for (i = 0; i < srcWidth * components; i++) {
- dstTexel[i] = (GLshort) MIN2(src[i], 0x7fff);
- }
- } else {
- for (i = 0; i < srcWidth * components; i++) {
- dstTexel[i] = (GLshort)CLAMP((GLint) src[i], -0x8000, 0x7fff);
- }
- }
- dstRow += dstRowStride;
- src += srcWidth * components;
- }
- }
-
- free((void *) tempImage);
- }
- return GL_TRUE;
-}
-
-
-/* non-normalized, signed int32 */
-static GLboolean
-_mesa_texstore_rgba_int32(TEXSTORE_PARAMS)
-{
- GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
- GLint components = _mesa_components_in_format(baseFormat);
-
- /* this forces alpha to 1 in make_temp_uint_image */
- if (dstFormat == MESA_FORMAT_RGBX_SINT32) {
- baseFormat = GL_RGBA;
- components = 4;
- }
-
- ASSERT(dstFormat == MESA_FORMAT_R_SINT32 ||
- dstFormat == MESA_FORMAT_RG_SINT32 ||
- dstFormat == MESA_FORMAT_RGB_SINT32 ||
- dstFormat == MESA_FORMAT_RGBA_SINT32 ||
- dstFormat == MESA_FORMAT_A_SINT32 ||
- dstFormat == MESA_FORMAT_I_SINT32 ||
- dstFormat == MESA_FORMAT_L_SINT32 ||
- dstFormat == MESA_FORMAT_LA_SINT32 ||
- dstFormat == MESA_FORMAT_RGBX_SINT32);
- ASSERT(baseInternalFormat == GL_RGBA ||
- baseInternalFormat == GL_RGB ||
- baseInternalFormat == GL_RG ||
- baseInternalFormat == GL_RED ||
- baseInternalFormat == GL_ALPHA ||
- baseInternalFormat == GL_LUMINANCE ||
- baseInternalFormat == GL_LUMINANCE_ALPHA ||
- baseInternalFormat == GL_INTENSITY);
- ASSERT(_mesa_get_format_bytes(dstFormat) == components * sizeof(GLint));
-
- {
- /* general path */
- const GLuint *tempImage = make_temp_uint_image(ctx, dims,
- baseInternalFormat,
- baseFormat,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType,
- srcAddr,
- srcPacking);
- const GLuint *src = tempImage;
- GLint img, row;
- GLboolean is_unsigned = _mesa_is_type_unsigned(srcType);
- if (!tempImage)
- return GL_FALSE;
- for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstSlices[img];
- for (row = 0; row < srcHeight; row++) {
- GLint *dstTexel = (GLint *) dstRow;
- GLint i;
- if (is_unsigned) {
- for (i = 0; i < srcWidth * components; i++) {
- dstTexel[i] = (GLint) MIN2(src[i], 0x7fffffff);
- }
- } else {
- for (i = 0; i < srcWidth * components; i++) {
- dstTexel[i] = (GLint) src[i];
- }
- }
- dstRow += dstRowStride;
- src += srcWidth * components;
- }
- }
-
- free((void *) tempImage);
- }
- return GL_TRUE;
-}
-
-
-/* non-normalized, unsigned int8 */
-static GLboolean
-_mesa_texstore_rgba_uint8(TEXSTORE_PARAMS)
-{
- GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
- GLint components = _mesa_components_in_format(baseFormat);
-
- /* this forces alpha to 1 in make_temp_uint_image */
- if (dstFormat == MESA_FORMAT_RGBX_UINT8) {
- baseFormat = GL_RGBA;
- components = 4;
- }
-
- ASSERT(dstFormat == MESA_FORMAT_R_UINT8 ||
- dstFormat == MESA_FORMAT_RG_UINT8 ||
- dstFormat == MESA_FORMAT_RGB_UINT8 ||
- dstFormat == MESA_FORMAT_RGBA_UINT8 ||
- dstFormat == MESA_FORMAT_A_UINT8 ||
- dstFormat == MESA_FORMAT_I_UINT8 ||
- dstFormat == MESA_FORMAT_L_UINT8 ||
- dstFormat == MESA_FORMAT_LA_UINT8 ||
- dstFormat == MESA_FORMAT_RGBX_UINT8);
- ASSERT(baseInternalFormat == GL_RGBA ||
- baseInternalFormat == GL_RGB ||
- baseInternalFormat == GL_RG ||
- baseInternalFormat == GL_RED ||
- baseInternalFormat == GL_ALPHA ||
- baseInternalFormat == GL_LUMINANCE ||
- baseInternalFormat == GL_LUMINANCE_ALPHA ||
- baseInternalFormat == GL_INTENSITY);
- ASSERT(_mesa_get_format_bytes(dstFormat) == components * sizeof(GLubyte));
-
- {
- /* general path */
- const GLuint *tempImage =
- make_temp_uint_image(ctx, dims, baseInternalFormat, baseFormat,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr, srcPacking);
- const GLuint *src = tempImage;
- GLint img, row;
- GLboolean is_unsigned = _mesa_is_type_unsigned(srcType);
- if (!tempImage)
- return GL_FALSE;
- for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstSlices[img];
- for (row = 0; row < srcHeight; row++) {
- GLubyte *dstTexel = (GLubyte *) dstRow;
- GLint i;
- if (is_unsigned) {
- for (i = 0; i < srcWidth * components; i++) {
- dstTexel[i] = (GLubyte) MIN2(src[i], 0xff);
- }
- } else {
- for (i = 0; i < srcWidth * components; i++) {
- dstTexel[i] = (GLubyte) CLAMP((GLint) src[i], 0, 0xff);
- }
- }
- dstRow += dstRowStride;
- src += srcWidth * components;
- }
- }
-
- free((void *) tempImage);
- }
- return GL_TRUE;
-}
-
-
-/* non-normalized, unsigned int16 */
-static GLboolean
-_mesa_texstore_rgba_uint16(TEXSTORE_PARAMS)
-{
- GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
- GLint components = _mesa_components_in_format(baseFormat);
-
- /* this forces alpha to 1 in make_temp_uint_image */
- if (dstFormat == MESA_FORMAT_RGBX_UINT16) {
- baseFormat = GL_RGBA;
- components = 4;
- }
-
- ASSERT(dstFormat == MESA_FORMAT_R_UINT16 ||
- dstFormat == MESA_FORMAT_RG_UINT16 ||
- dstFormat == MESA_FORMAT_RGB_UINT16 ||
- dstFormat == MESA_FORMAT_RGBA_UINT16 ||
- dstFormat == MESA_FORMAT_A_UINT16 ||
- dstFormat == MESA_FORMAT_I_UINT16 ||
- dstFormat == MESA_FORMAT_L_UINT16 ||
- dstFormat == MESA_FORMAT_LA_UINT16 ||
- dstFormat == MESA_FORMAT_RGBX_UINT16);
- ASSERT(baseInternalFormat == GL_RGBA ||
- baseInternalFormat == GL_RGB ||
- baseInternalFormat == GL_RG ||
- baseInternalFormat == GL_RED ||
- baseInternalFormat == GL_ALPHA ||
- baseInternalFormat == GL_LUMINANCE ||
- baseInternalFormat == GL_LUMINANCE_ALPHA ||
- baseInternalFormat == GL_INTENSITY);
- ASSERT(_mesa_get_format_bytes(dstFormat) == components * sizeof(GLushort));
-
- {
- /* general path */
- const GLuint *tempImage =
- make_temp_uint_image(ctx, dims, baseInternalFormat, baseFormat,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr, srcPacking);
- const GLuint *src = tempImage;
- GLint img, row;
- GLboolean is_unsigned = _mesa_is_type_unsigned(srcType);
- if (!tempImage)
- return GL_FALSE;
- for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstSlices[img];
- for (row = 0; row < srcHeight; row++) {
- GLushort *dstTexel = (GLushort *) dstRow;
- GLint i;
- if (is_unsigned) {
- for (i = 0; i < srcWidth * components; i++) {
- dstTexel[i] = (GLushort) MIN2(src[i], 0xffff);
- }
- } else {
- for (i = 0; i < srcWidth * components; i++) {
- dstTexel[i] = (GLushort) CLAMP((GLint) src[i], 0, 0xffff);
- }
- }
- dstRow += dstRowStride;
- src += srcWidth * components;
- }
- }
-
- free((void *) tempImage);
- }
- return GL_TRUE;
-}
-
-
-/* non-normalized, unsigned int32 */
-static GLboolean
-_mesa_texstore_rgba_uint32(TEXSTORE_PARAMS)
-{
- GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
- GLint components = _mesa_components_in_format(baseFormat);
-
- /* this forces alpha to 1 in make_temp_uint_image */
- if (dstFormat == MESA_FORMAT_RGBX_UINT32) {
- baseFormat = GL_RGBA;
- components = 4;
- }
-
- ASSERT(dstFormat == MESA_FORMAT_R_UINT32 ||
- dstFormat == MESA_FORMAT_RG_UINT32 ||
- dstFormat == MESA_FORMAT_RGB_UINT32 ||
- dstFormat == MESA_FORMAT_RGBA_UINT32 ||
- dstFormat == MESA_FORMAT_A_UINT32 ||
- dstFormat == MESA_FORMAT_I_UINT32 ||
- dstFormat == MESA_FORMAT_L_UINT32 ||
- dstFormat == MESA_FORMAT_LA_UINT32 ||
- dstFormat == MESA_FORMAT_RGBX_UINT32);
- ASSERT(baseInternalFormat == GL_RGBA ||
- baseInternalFormat == GL_RGB ||
- baseInternalFormat == GL_RG ||
- baseInternalFormat == GL_RED ||
- baseInternalFormat == GL_ALPHA ||
- baseInternalFormat == GL_LUMINANCE ||
- baseInternalFormat == GL_LUMINANCE_ALPHA ||
- baseInternalFormat == GL_INTENSITY);
- ASSERT(_mesa_get_format_bytes(dstFormat) == components * sizeof(GLuint));
-
- {
- /* general path */
- const GLuint *tempImage =
- make_temp_uint_image(ctx, dims, baseInternalFormat, baseFormat,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr, srcPacking);
- const GLuint *src = tempImage;
- GLboolean is_unsigned = _mesa_is_type_unsigned(srcType);
- GLint img, row;
- if (!tempImage)
- return GL_FALSE;
- for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstSlices[img];
- for (row = 0; row < srcHeight; row++) {
- GLuint *dstTexel = (GLuint *) dstRow;
- GLint i;
- if (is_unsigned) {
- for (i = 0; i < srcWidth * components; i++) {
- dstTexel[i] = src[i];
- }
- } else {
- for (i = 0; i < srcWidth * components; i++) {
- dstTexel[i] = MAX2((GLint) src[i], 0);
- }
- }
- dstRow += dstRowStride;
- src += srcWidth * components;
- }
- }
-
- free((void *) tempImage);
- }
- return GL_TRUE;
-}
-
-
-static GLboolean
-_mesa_texstore_srgb8(TEXSTORE_PARAMS)
-{
- mesa_format newDstFormat;
- GLboolean k;
-
- ASSERT(dstFormat == MESA_FORMAT_BGR_SRGB8);
-
- /* reuse normal rgb texstore code */
- newDstFormat = MESA_FORMAT_BGR_UNORM8;
-
- k = _mesa_texstore_rgb888(ctx, dims, baseInternalFormat,
- newDstFormat,
- dstRowStride, dstSlices,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType,
- srcAddr, srcPacking);
- return k;
-}
-
-
-static GLboolean
-_mesa_texstore_srgba8(TEXSTORE_PARAMS)
-{
- mesa_format newDstFormat;
- GLboolean k;
-
- ASSERT(dstFormat == MESA_FORMAT_A8B8G8R8_SRGB ||
- dstFormat == MESA_FORMAT_R8G8B8X8_SRGB ||
- dstFormat == MESA_FORMAT_R8G8B8A8_SRGB);
-
- newDstFormat = _mesa_get_srgb_format_linear(dstFormat);
-
- k = _mesa_texstore_rgba8888(ctx, dims, baseInternalFormat,
- newDstFormat,
- dstRowStride, dstSlices,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType,
- srcAddr, srcPacking);
- return k;
-}
-
-
-static GLboolean
-_mesa_texstore_sargb8(TEXSTORE_PARAMS)
-{
- mesa_format newDstFormat;
- GLboolean k;
-
- assert(dstFormat == MESA_FORMAT_B8G8R8A8_SRGB ||
- dstFormat == MESA_FORMAT_B8G8R8X8_SRGB);
-
- newDstFormat = _mesa_get_srgb_format_linear(dstFormat);
-
- k = _mesa_texstore_argb8888(ctx, dims, baseInternalFormat,
- newDstFormat,
- dstRowStride, dstSlices,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType,
- srcAddr, srcPacking);
- return k;
-}
-
-
-static GLboolean
-_mesa_texstore_sl8(TEXSTORE_PARAMS)
-{
- mesa_format newDstFormat;
- GLboolean k;
-
- ASSERT(dstFormat == MESA_FORMAT_L_SRGB8);
-
- newDstFormat = MESA_FORMAT_L_UNORM8;
-
- /* _mesa_textore_a8 handles luminance8 too */
- k = _mesa_texstore_unorm8(ctx, dims, baseInternalFormat,
- newDstFormat,
- dstRowStride, dstSlices,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType,
- srcAddr, srcPacking);
- return k;
-}
-
-
-static GLboolean
-_mesa_texstore_sla8(TEXSTORE_PARAMS)
-{
- mesa_format newDstFormat;
- GLboolean k;
-
- ASSERT(dstFormat == MESA_FORMAT_L8A8_SRGB);
-
- /* reuse normal luminance/alpha texstore code */
- newDstFormat = MESA_FORMAT_L8A8_UNORM;
-
- k = _mesa_texstore_unorm88(ctx, dims, baseInternalFormat,
- newDstFormat,
- dstRowStride, dstSlices,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType,
- srcAddr, srcPacking);
- return k;
-}
-
-static GLboolean
-_mesa_texstore_rgb9_e5(TEXSTORE_PARAMS)
-{
- const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
-
- ASSERT(dstFormat == MESA_FORMAT_R9G9B9E5_FLOAT);
- ASSERT(baseInternalFormat == GL_RGB);
-
- {
- /* general path */
- const GLfloat *tempImage = _mesa_make_temp_float_image(ctx, dims,
- baseInternalFormat,
- baseFormat,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr,
- srcPacking,
- ctx->_ImageTransferState);
- const GLfloat *srcRow = tempImage;
- GLint img, row, col;
- if (!tempImage)
- return GL_FALSE;
- for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstSlices[img];
- for (row = 0; row < srcHeight; row++) {
- GLuint *dstUI = (GLuint*)dstRow;
- for (col = 0; col < srcWidth; col++) {
- dstUI[col] = float3_to_rgb9e5(&srcRow[col * 3]);
- }
- dstRow += dstRowStride;
- srcRow += srcWidth * 3;
- }
- }
-
- free((void *) tempImage);
- }
- return GL_TRUE;
-}
-
-static GLboolean
-_mesa_texstore_r11_g11_b10f(TEXSTORE_PARAMS)
-{
- const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
-
- ASSERT(dstFormat == MESA_FORMAT_R11G11B10_FLOAT);
- ASSERT(baseInternalFormat == GL_RGB);
-
- {
- /* general path */
- const GLfloat *tempImage = _mesa_make_temp_float_image(ctx, dims,
- baseInternalFormat,
- baseFormat,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr,
- srcPacking,
- ctx->_ImageTransferState);
- const GLfloat *srcRow = tempImage;
- GLint img, row, col;
- if (!tempImage)
- return GL_FALSE;
- for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstSlices[img];
- for (row = 0; row < srcHeight; row++) {
- GLuint *dstUI = (GLuint*)dstRow;
- for (col = 0; col < srcWidth; col++) {
- dstUI[col] = float3_to_r11g11b10f(&srcRow[col * 3]);
- }
- dstRow += dstRowStride;
- srcRow += srcWidth * 3;
- }
- }
-
- free((void *) tempImage);
- }
- return GL_TRUE;
-}
-
-
static GLboolean
_mesa_texstore_z32f_x24s8(TEXSTORE_PARAMS)
{
@@ -3496,118 +1355,16 @@ _mesa_texstore_abgr2101010_uint(TEXSTORE_PARAMS)
return GL_TRUE;
}
-static GLboolean
-_mesa_texstore_abgr2101010(TEXSTORE_PARAMS)
-{
- const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
-
- ASSERT(dstFormat == MESA_FORMAT_R10G10B10A2_UNORM);
- ASSERT(_mesa_get_format_bytes(dstFormat) == 4);
-
- {
- /* general path */
- const GLfloat *tempImage = _mesa_make_temp_float_image(ctx, dims,
- baseInternalFormat,
- baseFormat,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr,
- srcPacking,
- ctx->_ImageTransferState);
- const GLfloat *src = tempImage;
- GLint img, row, col;
- if (!tempImage)
- return GL_FALSE;
- for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstSlices[img];
-
- for (row = 0; row < srcHeight; row++) {
- GLuint *dstUI = (GLuint *) dstRow;
- for (col = 0; col < srcWidth; col++) {
- GLushort a,r,g,b;
-
- UNCLAMPED_FLOAT_TO_USHORT(a, src[ACOMP]);
- UNCLAMPED_FLOAT_TO_USHORT(r, src[RCOMP]);
- UNCLAMPED_FLOAT_TO_USHORT(g, src[GCOMP]);
- UNCLAMPED_FLOAT_TO_USHORT(b, src[BCOMP]);
- dstUI[col] = PACK_COLOR_2101010_US(a, b, g, r);
- src += 4;
- }
- dstRow += dstRowStride;
- }
- }
- free((void *) tempImage);
- }
- return GL_TRUE;
-}
static GLboolean
-_mesa_texstore_null(TEXSTORE_PARAMS)
-{
- (void) ctx; (void) dims;
- (void) baseInternalFormat;
- (void) dstFormat;
- (void) dstRowStride; (void) dstSlices,
- (void) srcWidth; (void) srcHeight; (void) srcDepth;
- (void) srcFormat; (void) srcType;
- (void) srcAddr;
- (void) srcPacking;
-
- /* should never happen */
- _mesa_problem(NULL, "_mesa_texstore_null() is called");
- return GL_FALSE;
-}
-
-
-/**
- * Return the StoreTexImageFunc pointer to store an image in the given format.
- */
-static StoreTexImageFunc
-_mesa_get_texstore_func(mesa_format format)
+texstore_depth_stencil(TEXSTORE_PARAMS)
{
static StoreTexImageFunc table[MESA_FORMAT_COUNT];
static GLboolean initialized = GL_FALSE;
if (!initialized) {
- table[MESA_FORMAT_NONE] = _mesa_texstore_null;
-
- table[MESA_FORMAT_A8B8G8R8_UNORM] = _mesa_texstore_rgba8888;
- table[MESA_FORMAT_R8G8B8A8_UNORM] = _mesa_texstore_rgba8888;
- table[MESA_FORMAT_B8G8R8A8_UNORM] = _mesa_texstore_argb8888;
- table[MESA_FORMAT_A8R8G8B8_UNORM] = _mesa_texstore_argb8888;
- table[MESA_FORMAT_X8B8G8R8_UNORM] = _mesa_texstore_rgba8888;
- table[MESA_FORMAT_R8G8B8X8_UNORM] = _mesa_texstore_rgba8888;
- table[MESA_FORMAT_B8G8R8X8_UNORM] = _mesa_texstore_argb8888;
- table[MESA_FORMAT_X8R8G8B8_UNORM] = _mesa_texstore_argb8888;
- table[MESA_FORMAT_BGR_UNORM8] = _mesa_texstore_rgb888;
- table[MESA_FORMAT_RGB_UNORM8] = _mesa_texstore_bgr888;
- table[MESA_FORMAT_B5G6R5_UNORM] = _mesa_texstore_rgb565;
- table[MESA_FORMAT_R5G6B5_UNORM] = _mesa_texstore_rgb565;
- table[MESA_FORMAT_B4G4R4A4_UNORM] = store_ubyte_texture;
- table[MESA_FORMAT_A4R4G4B4_UNORM] = store_ubyte_texture;
- table[MESA_FORMAT_A1B5G5R5_UNORM] = store_ubyte_texture;
- table[MESA_FORMAT_B5G5R5A1_UNORM] = store_ubyte_texture;
- table[MESA_FORMAT_A1R5G5B5_UNORM] = store_ubyte_texture;
- table[MESA_FORMAT_L4A4_UNORM] = _mesa_texstore_unorm44;
- table[MESA_FORMAT_L8A8_UNORM] = _mesa_texstore_unorm88;
- table[MESA_FORMAT_A8L8_UNORM] = _mesa_texstore_unorm88;
- table[MESA_FORMAT_L16A16_UNORM] = _mesa_texstore_unorm1616;
- table[MESA_FORMAT_A16L16_UNORM] = _mesa_texstore_unorm1616;
- table[MESA_FORMAT_B2G3R3_UNORM] = store_ubyte_texture;
- table[MESA_FORMAT_A_UNORM8] = _mesa_texstore_unorm8;
- table[MESA_FORMAT_A_UNORM16] = _mesa_texstore_unorm16;
- table[MESA_FORMAT_L_UNORM8] = _mesa_texstore_unorm8;
- table[MESA_FORMAT_L_UNORM16] = _mesa_texstore_unorm16;
- table[MESA_FORMAT_I_UNORM8] = _mesa_texstore_unorm8;
- table[MESA_FORMAT_I_UNORM16] = _mesa_texstore_unorm16;
- table[MESA_FORMAT_YCBCR] = _mesa_texstore_ycbcr;
- table[MESA_FORMAT_YCBCR_REV] = _mesa_texstore_ycbcr;
- table[MESA_FORMAT_R_UNORM8] = _mesa_texstore_unorm8;
- table[MESA_FORMAT_R8G8_UNORM] = _mesa_texstore_unorm88;
- table[MESA_FORMAT_G8R8_UNORM] = _mesa_texstore_unorm88;
- table[MESA_FORMAT_R_UNORM16] = _mesa_texstore_unorm16;
- table[MESA_FORMAT_R16G16_UNORM] = _mesa_texstore_unorm1616;
- table[MESA_FORMAT_G16R16_UNORM] = _mesa_texstore_unorm1616;
- table[MESA_FORMAT_B10G10R10A2_UNORM] = _mesa_texstore_argb2101010;
+ memset(table, 0, sizeof table);
+
table[MESA_FORMAT_S8_UINT_Z24_UNORM] = _mesa_texstore_z24_s8;
table[MESA_FORMAT_Z24_UNORM_S8_UINT] = _mesa_texstore_s8_z24;
table[MESA_FORMAT_Z_UNORM16] = _mesa_texstore_z16;
@@ -3615,11 +1372,28 @@ _mesa_get_texstore_func(mesa_format format)
table[MESA_FORMAT_X8_UINT_Z24_UNORM] = _mesa_texstore_z24_x8;
table[MESA_FORMAT_Z_UNORM32] = _mesa_texstore_z32;
table[MESA_FORMAT_S_UINT8] = _mesa_texstore_s8;
- table[MESA_FORMAT_BGR_SRGB8] = _mesa_texstore_srgb8;
- table[MESA_FORMAT_A8B8G8R8_SRGB] = _mesa_texstore_srgba8;
- table[MESA_FORMAT_B8G8R8A8_SRGB] = _mesa_texstore_sargb8;
- table[MESA_FORMAT_L_SRGB8] = _mesa_texstore_sl8;
- table[MESA_FORMAT_L8A8_SRGB] = _mesa_texstore_sla8;
+ table[MESA_FORMAT_Z_FLOAT32] = _mesa_texstore_z32;
+ table[MESA_FORMAT_Z32_FLOAT_S8X24_UINT] = _mesa_texstore_z32f_x24s8;
+
+ initialized = GL_TRUE;
+ }
+
+ ASSERT(table[dstFormat]);
+ return table[dstFormat](ctx, dims, baseInternalFormat,
+ dstFormat, dstRowStride, dstSlices,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr, srcPacking);
+}
+
+static GLboolean
+texstore_compressed(TEXSTORE_PARAMS)
+{
+ static StoreTexImageFunc table[MESA_FORMAT_COUNT];
+ static GLboolean initialized = GL_FALSE;
+
+ if (!initialized) {
+ memset(table, 0, sizeof table);
+
table[MESA_FORMAT_SRGB_DXT1] = _mesa_texstore_rgb_dxt1;
table[MESA_FORMAT_SRGBA_DXT1] = _mesa_texstore_rgba_dxt1;
table[MESA_FORMAT_SRGBA_DXT3] = _mesa_texstore_rgba_dxt3;
@@ -3630,32 +1404,6 @@ _mesa_get_texstore_func(mesa_format format)
table[MESA_FORMAT_RGBA_DXT1] = _mesa_texstore_rgba_dxt1;
table[MESA_FORMAT_RGBA_DXT3] = _mesa_texstore_rgba_dxt3;
table[MESA_FORMAT_RGBA_DXT5] = _mesa_texstore_rgba_dxt5;
- table[MESA_FORMAT_RGBA_FLOAT32] = _mesa_texstore_rgba_float32;
- table[MESA_FORMAT_RGBA_FLOAT16] = _mesa_texstore_rgba_float16;
- table[MESA_FORMAT_RGB_FLOAT32] = _mesa_texstore_rgba_float32;
- table[MESA_FORMAT_RGB_FLOAT16] = _mesa_texstore_rgba_float16;
- table[MESA_FORMAT_A_FLOAT32] = _mesa_texstore_rgba_float32;
- table[MESA_FORMAT_A_FLOAT16] = _mesa_texstore_rgba_float16;
- table[MESA_FORMAT_L_FLOAT32] = _mesa_texstore_rgba_float32;
- table[MESA_FORMAT_L_FLOAT16] = _mesa_texstore_rgba_float16;
- table[MESA_FORMAT_LA_FLOAT32] = _mesa_texstore_rgba_float32;
- table[MESA_FORMAT_LA_FLOAT16] = _mesa_texstore_rgba_float16;
- table[MESA_FORMAT_I_FLOAT32] = _mesa_texstore_rgba_float32;
- table[MESA_FORMAT_I_FLOAT16] = _mesa_texstore_rgba_float16;
- table[MESA_FORMAT_R_FLOAT32] = _mesa_texstore_rgba_float32;
- table[MESA_FORMAT_R_FLOAT16] = _mesa_texstore_rgba_float16;
- table[MESA_FORMAT_RG_FLOAT32] = _mesa_texstore_rgba_float32;
- table[MESA_FORMAT_RG_FLOAT16] = _mesa_texstore_rgba_float16;
- table[MESA_FORMAT_R_SNORM8] = _mesa_texstore_snorm8;
- table[MESA_FORMAT_R8G8_SNORM] = _mesa_texstore_snorm88;
- table[MESA_FORMAT_X8B8G8R8_SNORM] = _mesa_texstore_signed_rgbx8888;
- table[MESA_FORMAT_A8B8G8R8_SNORM] = _mesa_texstore_signed_rgba8888;
- table[MESA_FORMAT_R8G8B8A8_SNORM] = _mesa_texstore_signed_rgba8888;
- table[MESA_FORMAT_R_SNORM16] = _mesa_texstore_snorm16;
- table[MESA_FORMAT_R16G16_SNORM] = _mesa_texstore_snorm1616;
- table[MESA_FORMAT_RGB_SNORM16] = _mesa_texstore_signed_rgba_16;
- table[MESA_FORMAT_RGBA_SNORM16] = _mesa_texstore_signed_rgba_16;
- table[MESA_FORMAT_RGBA_UNORM16] = _mesa_texstore_rgba_16;
table[MESA_FORMAT_R_RGTC1_UNORM] = _mesa_texstore_red_rgtc1;
table[MESA_FORMAT_R_RGTC1_SNORM] = _mesa_texstore_signed_red_rgtc1;
table[MESA_FORMAT_RG_RGTC2_UNORM] = _mesa_texstore_rg_rgtc2;
@@ -3677,107 +1425,327 @@ _mesa_get_texstore_func(mesa_format format)
_mesa_texstore_etc2_rgb8_punchthrough_alpha1;
table[MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1] =
_mesa_texstore_etc2_srgb8_punchthrough_alpha1;
- table[MESA_FORMAT_A_SNORM8] = _mesa_texstore_snorm8;
- table[MESA_FORMAT_L_SNORM8] = _mesa_texstore_snorm8;
- table[MESA_FORMAT_L8A8_SNORM] = _mesa_texstore_snorm88;
- table[MESA_FORMAT_I_SNORM8] = _mesa_texstore_snorm8;
- table[MESA_FORMAT_A_SNORM16] = _mesa_texstore_snorm16;
- table[MESA_FORMAT_L_SNORM16] = _mesa_texstore_snorm16;
- table[MESA_FORMAT_LA_SNORM16] = _mesa_texstore_snorm1616;
- table[MESA_FORMAT_I_SNORM16] = _mesa_texstore_snorm16;
- table[MESA_FORMAT_R9G9B9E5_FLOAT] = _mesa_texstore_rgb9_e5;
- table[MESA_FORMAT_R11G11B10_FLOAT] = _mesa_texstore_r11_g11_b10f;
- table[MESA_FORMAT_Z_FLOAT32] = _mesa_texstore_z32;
- table[MESA_FORMAT_Z32_FLOAT_S8X24_UINT] = _mesa_texstore_z32f_x24s8;
- table[MESA_FORMAT_A_UINT8] = _mesa_texstore_rgba_uint8;
- table[MESA_FORMAT_A_UINT16] = _mesa_texstore_rgba_uint16;
- table[MESA_FORMAT_A_UINT32] = _mesa_texstore_rgba_uint32;
- table[MESA_FORMAT_A_SINT8] = _mesa_texstore_rgba_int8;
- table[MESA_FORMAT_A_SINT16] = _mesa_texstore_rgba_int16;
- table[MESA_FORMAT_A_SINT32] = _mesa_texstore_rgba_int32;
-
- table[MESA_FORMAT_I_UINT8] = _mesa_texstore_rgba_uint8;
- table[MESA_FORMAT_I_UINT16] = _mesa_texstore_rgba_uint16;
- table[MESA_FORMAT_I_UINT32] = _mesa_texstore_rgba_uint32;
- table[MESA_FORMAT_I_SINT8] = _mesa_texstore_rgba_int8;
- table[MESA_FORMAT_I_SINT16] = _mesa_texstore_rgba_int16;
- table[MESA_FORMAT_I_SINT32] = _mesa_texstore_rgba_int32;
-
- table[MESA_FORMAT_L_UINT8] = _mesa_texstore_rgba_uint8;
- table[MESA_FORMAT_L_UINT16] = _mesa_texstore_rgba_uint16;
- table[MESA_FORMAT_L_UINT32] = _mesa_texstore_rgba_uint32;
- table[MESA_FORMAT_L_SINT8] = _mesa_texstore_rgba_int8;
- table[MESA_FORMAT_L_SINT16] = _mesa_texstore_rgba_int16;
- table[MESA_FORMAT_L_SINT32] = _mesa_texstore_rgba_int32;
-
- table[MESA_FORMAT_LA_UINT8] = _mesa_texstore_rgba_uint8;
- table[MESA_FORMAT_LA_UINT16] = _mesa_texstore_rgba_uint16;
- table[MESA_FORMAT_LA_UINT32] = _mesa_texstore_rgba_uint32;
- table[MESA_FORMAT_LA_SINT8] = _mesa_texstore_rgba_int8;
- table[MESA_FORMAT_LA_SINT16] = _mesa_texstore_rgba_int16;
- table[MESA_FORMAT_LA_SINT32] = _mesa_texstore_rgba_int32;
-
- table[MESA_FORMAT_R_SINT8] = _mesa_texstore_rgba_int8;
- table[MESA_FORMAT_RG_SINT8] = _mesa_texstore_rgba_int8;
- table[MESA_FORMAT_RGB_SINT8] = _mesa_texstore_rgba_int8;
- table[MESA_FORMAT_RGBA_SINT8] = _mesa_texstore_rgba_int8;
- table[MESA_FORMAT_R_SINT16] = _mesa_texstore_rgba_int16;
- table[MESA_FORMAT_RG_SINT16] = _mesa_texstore_rgba_int16;
- table[MESA_FORMAT_RGB_SINT16] = _mesa_texstore_rgba_int16;
- table[MESA_FORMAT_RGBA_SINT16] = _mesa_texstore_rgba_int16;
- table[MESA_FORMAT_R_SINT32] = _mesa_texstore_rgba_int32;
- table[MESA_FORMAT_RG_SINT32] = _mesa_texstore_rgba_int32;
- table[MESA_FORMAT_RGB_SINT32] = _mesa_texstore_rgba_int32;
- table[MESA_FORMAT_RGBA_SINT32] = _mesa_texstore_rgba_int32;
-
- table[MESA_FORMAT_R_UINT8] = _mesa_texstore_rgba_uint8;
- table[MESA_FORMAT_RG_UINT8] = _mesa_texstore_rgba_uint8;
- table[MESA_FORMAT_RGB_UINT8] = _mesa_texstore_rgba_uint8;
- table[MESA_FORMAT_RGBA_UINT8] = _mesa_texstore_rgba_uint8;
- table[MESA_FORMAT_R_UINT16] = _mesa_texstore_rgba_uint16;
- table[MESA_FORMAT_RG_UINT16] = _mesa_texstore_rgba_uint16;
- table[MESA_FORMAT_RGB_UINT16] = _mesa_texstore_rgba_uint16;
- table[MESA_FORMAT_RGBA_UINT16] = _mesa_texstore_rgba_uint16;
- table[MESA_FORMAT_R_UINT32] = _mesa_texstore_rgba_uint32;
- table[MESA_FORMAT_RG_UINT32] = _mesa_texstore_rgba_uint32;
- table[MESA_FORMAT_RGB_UINT32] = _mesa_texstore_rgba_uint32;
- table[MESA_FORMAT_RGBA_UINT32] = _mesa_texstore_rgba_uint32;
+ initialized = GL_TRUE;
+ }
+
+ ASSERT(table[dstFormat]);
+ return table[dstFormat](ctx, dims, baseInternalFormat,
+ dstFormat, dstRowStride, dstSlices,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr, srcPacking);
+}
+
+static void
+invert_swizzle(uint8_t dst[4], const uint8_t src[4])
+{
+ int i, j;
+
+ dst[0] = MESA_FORMAT_SWIZZLE_NONE;
+ dst[1] = MESA_FORMAT_SWIZZLE_NONE;
+ dst[2] = MESA_FORMAT_SWIZZLE_NONE;
+ dst[3] = MESA_FORMAT_SWIZZLE_NONE;
+
+ for (i = 0; i < 4; ++i)
+ for (j = 0; j < 4; ++j)
+ if (src[j] == i && dst[i] == MESA_FORMAT_SWIZZLE_NONE)
+ dst[i] = j;
+}
+
+/** Store a texture by per-channel conversions and swizzling.
+ *
+ * This function attempts to perform a texstore operation by doing simple
+ * per-channel conversions and swizzling. This covers a huge chunk of the
+ * texture storage operations that anyone cares about. If this function is
+ * incapable of performing the operation, it bails and returns GL_FALSE.
+ */
+static GLboolean
+texstore_swizzle(TEXSTORE_PARAMS)
+{
+ const GLint srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth,
+ srcFormat, srcType);
+ const GLint srcImageStride = _mesa_image_image_stride(srcPacking,
+ srcWidth, srcHeight, srcFormat, srcType);
+ const GLubyte *srcImage = (const GLubyte *) _mesa_image_address(dims,
+ srcPacking, srcAddr, srcWidth, srcHeight, srcFormat, srcType, 0, 0, 0);
+ const int src_components = _mesa_components_in_format(srcFormat);
+
+ GLubyte swizzle[4], rgba2base[6], base2src[6], rgba2dst[4], dst2rgba[4];
+ const GLubyte *swap;
+ GLenum dst_type;
+ int dst_components;
+ bool is_array, normalized, need_swap;
+ GLint i, img, row;
+ const GLubyte *src_row;
+ GLubyte *dst_row;
+
+ is_array = _mesa_format_to_array(dstFormat, &dst_type, &dst_components,
+ rgba2dst, &normalized);
+
+ if (!is_array)
+ return GL_FALSE;
+
+ switch (srcType) {
+ case GL_FLOAT:
+ case GL_UNSIGNED_BYTE:
+ case GL_BYTE:
+ case GL_UNSIGNED_SHORT:
+ case GL_SHORT:
+ case GL_UNSIGNED_INT:
+ case GL_INT:
+ /* If wa have to swap bytes in a multi-byte datatype, that means
+ * we're not doing an array conversion anymore */
+ if (srcPacking->SwapBytes)
+ return GL_FALSE;
+ need_swap = false;
+ break;
+ case GL_UNSIGNED_INT_8_8_8_8:
+ need_swap = srcPacking->SwapBytes;
+ if (_mesa_little_endian())
+ need_swap = !need_swap;
+ srcType = GL_UNSIGNED_BYTE;
+ break;
+ case GL_UNSIGNED_INT_8_8_8_8_REV:
+ need_swap = srcPacking->SwapBytes;
+ if (!_mesa_little_endian())
+ need_swap = !need_swap;
+ srcType = GL_UNSIGNED_BYTE;
+ break;
+ default:
+ return GL_FALSE;
+ }
+ swap = need_swap ? map_3210 : map_identity;
+
+ compute_component_mapping(srcFormat, baseInternalFormat, base2src);
+ compute_component_mapping(baseInternalFormat, GL_RGBA, rgba2base);
+ invert_swizzle(dst2rgba, rgba2dst);
+
+ for (i = 0; i < 4; i++) {
+ if (dst2rgba[i] == MESA_FORMAT_SWIZZLE_NONE)
+ swizzle[i] = MESA_FORMAT_SWIZZLE_NONE;
+ else
+ swizzle[i] = swap[base2src[rgba2base[dst2rgba[i]]]];
+ }
+
+ /* Is it normalized? */
+ normalized |= !_mesa_is_enum_format_integer(srcFormat);
+
+ for (img = 0; img < srcDepth; img++) {
+ if (dstRowStride == srcWidth * dst_components &&
+ srcRowStride == srcWidth * src_components) {
+ _mesa_swizzle_and_convert(dstSlices[img], dst_type, dst_components,
+ srcImage, srcType, src_components,
+ swizzle, normalized, srcWidth * srcHeight);
+ } else {
+ src_row = srcImage;
+ dst_row = dstSlices[img];
+ for (row = 0; row < srcHeight; row++) {
+ _mesa_swizzle_and_convert(dst_row, dst_type, dst_components,
+ src_row, srcType, src_components,
+ swizzle, normalized, srcWidth);
+ dst_row += dstRowStride;
+ src_row += srcRowStride;
+ }
+ }
+ srcImage += srcImageStride;
+ }
+
+ return GL_TRUE;
+}
+
+
+/** Stores a texture by converting float and then to the texture format
+ *
+ * This function performs a texstore operation by converting to float,
+ * applying pixel transfer ops, and then converting to the texture's
+ * internal format using pixel store functions. This function will work
+ * for any rgb or srgb textore format.
+ */
+static GLboolean
+texstore_via_float(TEXSTORE_PARAMS)
+{
+ GLuint i, img, row;
+ const GLint src_stride =
+ _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType);
+ float *tmp_row;
+ bool need_convert;
+ uint8_t *src_row, *dst_row, map[4], rgba2base[6], base2rgba[6];
+
+ tmp_row = malloc(srcWidth * 4 * sizeof(*tmp_row));
+ if (!tmp_row)
+ return GL_FALSE;
+
+ /* The GL spec (4.0, compatibility profile) only specifies srgb
+ * conversion as something that is done in the sampler during the
+ * filtering process before the colors are handed to the shader.
+ * Furthermore, the flowchart (Figure 3.7 in the 4.0 compatibility spec)
+ * does not list RGB <-> sRGB conversions anywhere. Therefore, we just
+ * treat sRGB formats the same as RGB formats for the purposes of
+ * texture upload and transfer ops.
+ */
+ dstFormat = _mesa_get_srgb_format_linear(dstFormat);
+
+ need_convert = false;
+ if (baseInternalFormat != _mesa_get_format_base_format(dstFormat)) {
+ compute_component_mapping(GL_RGBA, baseInternalFormat, base2rgba);
+ compute_component_mapping(baseInternalFormat, GL_RGBA, rgba2base);
+ for (i = 0; i < 4; ++i) {
+ map[i] = base2rgba[rgba2base[i]];
+ if (map[i] != i)
+ need_convert = true;
+ }
+ }
+
+ for (img = 0; img < srcDepth; img++) {
+ dst_row = dstSlices[img];
+ src_row = _mesa_image_address(dims, srcPacking, srcAddr,
+ srcWidth, srcHeight,
+ srcFormat, srcType,
+ img, 0, 0);
+ for (row = 0; row < srcHeight; row++) {
+ _mesa_unpack_color_span_float(ctx, srcWidth, GL_RGBA, tmp_row,
+ srcFormat, srcType, src_row,
+ srcPacking, ctx->_ImageTransferState);
+ if (need_convert)
+ _mesa_swizzle_and_convert(tmp_row, GL_FLOAT, 4,
+ tmp_row, GL_FLOAT, 4,
+ map, false, srcWidth);
+ _mesa_pack_float_rgba_row(dstFormat, srcWidth,
+ (const GLfloat (*)[4])tmp_row,
+ dst_row);
+ dst_row += dstRowStride;
+ src_row += src_stride;
+ }
+ }
+
+ return GL_TRUE;
+}
+
+/** Stores an integer rgba texture
+ *
+ * This function performs an integer texture storage operation by unpacking
+ * the texture to 32-bit integers, and repacking it into the internal
+ * format of the texture. This will work for any integer rgb texture
+ * storage operation.
+ */
+static GLboolean
+texstore_rgba_integer(TEXSTORE_PARAMS)
+{
+ GLuint i, img, row, *tmp_row;
+ GLenum dst_type, tmp_type;
+ const GLint src_stride =
+ _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType);
+ int num_dst_components;
+ bool is_array, normalized;
+ uint8_t *src_row, *dst_row;
+ uint8_t swizzle[4], rgba2base[6], base2rgba[6], rgba2dst[4], dst2rgba[4];
+
+ tmp_row = malloc(srcWidth * 4 * sizeof(*tmp_row));
+ if (!tmp_row)
+ return GL_FALSE;
+
+ is_array = _mesa_format_to_array(dstFormat, &dst_type, &num_dst_components,
+ rgba2dst, &normalized);
+
+ assert(is_array && !normalized);
+
+ if (!is_array)
+ return GL_FALSE;
+
+ invert_swizzle(dst2rgba, rgba2dst);
+ compute_component_mapping(GL_RGBA, baseInternalFormat, base2rgba);
+ compute_component_mapping(baseInternalFormat, GL_RGBA, rgba2base);
+
+ for (i = 0; i < 4; ++i) {
+ if (dst2rgba[i] == MESA_FORMAT_SWIZZLE_NONE)
+ swizzle[i] = MESA_FORMAT_SWIZZLE_NONE;
+ else
+ swizzle[i] = base2rgba[rgba2base[dst2rgba[i]]];
+ }
+
+ if (_mesa_is_type_unsigned(srcType)) {
+ tmp_type = GL_UNSIGNED_INT;
+ } else {
+ tmp_type = GL_INT;
+ }
+
+ for (img = 0; img < srcDepth; img++) {
+ dst_row = dstSlices[img];
+ src_row = _mesa_image_address(dims, srcPacking, srcAddr,
+ srcWidth, srcHeight,
+ srcFormat, srcType,
+ img, 0, 0);
+ for (row = 0; row < srcHeight; row++) {
+ _mesa_unpack_color_span_uint(ctx, srcWidth, GL_RGBA, tmp_row,
+ srcFormat, srcType, src_row, srcPacking);
+ _mesa_swizzle_and_convert(dst_row, dst_type, num_dst_components,
+ tmp_row, tmp_type, 4,
+ swizzle, false, srcWidth);
+ dst_row += dstRowStride;
+ src_row += src_stride;
+ }
+ }
+
+ return GL_TRUE;
+}
+
+static GLboolean
+texstore_rgba(TEXSTORE_PARAMS)
+{
+ static StoreTexImageFunc table[MESA_FORMAT_COUNT];
+ static GLboolean initialized = GL_FALSE;
+
+ if (!initialized) {
+ memset(table, 0, sizeof table);
+
+ table[MESA_FORMAT_B5G6R5_UNORM] = _mesa_texstore_rgb565;
+ table[MESA_FORMAT_R5G6B5_UNORM] = _mesa_texstore_rgb565;
+ table[MESA_FORMAT_YCBCR] = _mesa_texstore_ycbcr;
+ table[MESA_FORMAT_YCBCR_REV] = _mesa_texstore_ycbcr;
table[MESA_FORMAT_B10G10R10A2_UINT] = _mesa_texstore_argb2101010_uint;
table[MESA_FORMAT_R10G10B10A2_UINT] = _mesa_texstore_abgr2101010_uint;
- table[MESA_FORMAT_B4G4R4X4_UNORM] = store_ubyte_texture;
- table[MESA_FORMAT_B5G5R5X1_UNORM] = store_ubyte_texture;
- table[MESA_FORMAT_R8G8B8X8_SNORM] = _mesa_texstore_signed_rgbx8888;
- table[MESA_FORMAT_R8G8B8X8_SRGB] = _mesa_texstore_srgba8;
- table[MESA_FORMAT_R8G8B8A8_SRGB] = _mesa_texstore_srgba8;
- table[MESA_FORMAT_RGBX_UINT8] = _mesa_texstore_rgba_uint8;
- table[MESA_FORMAT_RGBX_SINT8] = _mesa_texstore_rgba_int8;
- table[MESA_FORMAT_B10G10R10X2_UNORM] = _mesa_texstore_argb2101010;
- table[MESA_FORMAT_RGBX_UNORM16] = _mesa_texstore_rgba_16;
- table[MESA_FORMAT_RGBX_SNORM16] = _mesa_texstore_signed_rgba_16;
- table[MESA_FORMAT_RGBX_FLOAT16] = _mesa_texstore_rgba_float16;
- table[MESA_FORMAT_RGBX_UINT16] = _mesa_texstore_rgba_uint16;
- table[MESA_FORMAT_RGBX_SINT16] = _mesa_texstore_rgba_int16;
- table[MESA_FORMAT_RGBX_FLOAT32] = _mesa_texstore_rgba_float32;
- table[MESA_FORMAT_RGBX_UINT32] = _mesa_texstore_rgba_uint32;
- table[MESA_FORMAT_RGBX_SINT32] = _mesa_texstore_rgba_int32;
-
- table[MESA_FORMAT_R10G10B10A2_UNORM] = _mesa_texstore_abgr2101010;
-
- table[MESA_FORMAT_G8R8_SNORM] = _mesa_texstore_snorm88;
- table[MESA_FORMAT_G16R16_SNORM] = _mesa_texstore_snorm1616;
-
- table[MESA_FORMAT_B8G8R8X8_SRGB] = _mesa_texstore_sargb8;
-
initialized = GL_TRUE;
}
- ASSERT(table[format]);
- return table[format];
-}
+ if (table[dstFormat] && table[dstFormat](ctx, dims, baseInternalFormat,
+ dstFormat, dstRowStride, dstSlices,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr,
+ srcPacking)) {
+ return GL_TRUE;
+ }
+
+ if (texstore_swizzle(ctx, dims, baseInternalFormat,
+ dstFormat,
+ dstRowStride, dstSlices,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr, srcPacking)) {
+ return GL_TRUE;
+ }
+ if (_mesa_is_format_integer(dstFormat)) {
+ return texstore_rgba_integer(ctx, dims, baseInternalFormat,
+ dstFormat, dstRowStride, dstSlices,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr,
+ srcPacking);
+ } else if (_mesa_get_format_max_bits(dstFormat) <= 8 &&
+ !_mesa_is_format_signed(dstFormat)) {
+ return store_ubyte_texture(ctx, dims, baseInternalFormat,
+ dstFormat,
+ dstRowStride, dstSlices,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr, srcPacking);
+ } else {
+ return texstore_via_float(ctx, dims, baseInternalFormat,
+ dstFormat, dstRowStride, dstSlices,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr,
+ srcPacking);
+ }
+}
GLboolean
_mesa_texstore_needs_transfer_ops(struct gl_context *ctx,
@@ -3863,8 +1831,6 @@ _mesa_texstore_memcpy(TEXSTORE_PARAMS)
srcAddr, srcPacking);
return GL_TRUE;
}
-
-
/**
* Store user data into texture memory.
* Called via glTex[Sub]Image1/2/3D()
@@ -3873,9 +1839,6 @@ _mesa_texstore_memcpy(TEXSTORE_PARAMS)
GLboolean
_mesa_texstore(TEXSTORE_PARAMS)
{
- StoreTexImageFunc storeImage;
- GLboolean success;
-
if (_mesa_texstore_memcpy(ctx, dims, baseInternalFormat,
dstFormat,
dstRowStride, dstSlices,
@@ -3884,14 +1847,22 @@ _mesa_texstore(TEXSTORE_PARAMS)
return GL_TRUE;
}
- storeImage = _mesa_get_texstore_func(dstFormat);
-
- success = storeImage(ctx, dims, baseInternalFormat,
- dstFormat,
- dstRowStride, dstSlices,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr, srcPacking);
- return success;
+ if (_mesa_is_depth_or_stencil_format(baseInternalFormat)) {
+ return texstore_depth_stencil(ctx, dims, baseInternalFormat,
+ dstFormat, dstRowStride, dstSlices,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr, srcPacking);
+ } else if (_mesa_is_format_compressed(dstFormat)) {
+ return texstore_compressed(ctx, dims, baseInternalFormat,
+ dstFormat, dstRowStride, dstSlices,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr, srcPacking);
+ } else {
+ return texstore_rgba(ctx, dims, baseInternalFormat,
+ dstFormat, dstRowStride, dstSlices,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr, srcPacking);
+ }
}
diff --git a/mesalib/src/mesa/main/textureview.c b/mesalib/src/mesa/main/textureview.c
index 77a3b782b..b3521e219 100644
--- a/mesalib/src/mesa/main/textureview.c
+++ b/mesalib/src/mesa/main/textureview.c
@@ -320,15 +320,11 @@ target_valid(struct gl_context *ctx, GLenum origTarget, GLenum newTarget)
* If an error is found, record it with _mesa_error()
* \return false if any error, true otherwise.
*/
-static bool
-compatible_format(struct gl_context *ctx, const struct gl_texture_object *origTexObj,
- GLenum internalformat)
+GLboolean
+_mesa_texture_view_compatible_format(struct gl_context *ctx,
+ GLenum origInternalFormat,
+ GLenum newInternalFormat)
{
- /* Level 0 of a texture created by glTextureStorage or glTextureView
- * is always defined.
- */
- struct gl_texture_image *texImage = origTexObj->Image[0][0];
- GLint origInternalFormat = texImage->InternalFormat;
unsigned int origViewClass, newViewClass;
/* The two textures' internal formats must be compatible according to
@@ -337,19 +333,15 @@ compatible_format(struct gl_context *ctx, const struct gl_texture_object *origTe
* The internal formats must be identical if not in that table,
* or an INVALID_OPERATION error is generated.
*/
- if (origInternalFormat == internalformat)
- return true;
+ if (origInternalFormat == newInternalFormat)
+ return GL_TRUE;
origViewClass = lookup_view_class(ctx, origInternalFormat);
- newViewClass = lookup_view_class(ctx, internalformat);
+ newViewClass = lookup_view_class(ctx, newInternalFormat);
if ((origViewClass == newViewClass) && origViewClass != false)
- return true;
+ return GL_TRUE;
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glTextureView(internalformat %s not compatible with origtexture %s)",
- _mesa_lookup_enum_by_nr(internalformat),
- _mesa_lookup_enum_by_nr(origInternalFormat));
- return false;
+ return GL_FALSE;
}
/**
* Helper function for TexStorage and teximagemultisample to set immutable
@@ -512,8 +504,14 @@ _mesa_TextureView(GLuint texture, GLenum target, GLuint origtexture,
return;
}
- if (!compatible_format(ctx, origTexObj, internalformat)) {
- return; /* Error logged */
+ if (!_mesa_texture_view_compatible_format(ctx,
+ origTexObj->Image[0][0]->InternalFormat,
+ internalformat)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glTextureView(internalformat %s not compatible with origtexture %s)",
+ _mesa_lookup_enum_by_nr(internalformat),
+ _mesa_lookup_enum_by_nr(origTexObj->Image[0][0]->InternalFormat));
+ return;
}
texFormat = _mesa_choose_texture_format(ctx, texObj, target, 0,
diff --git a/mesalib/src/mesa/main/textureview.h b/mesalib/src/mesa/main/textureview.h
index 3088ac193..549a13cd8 100644
--- a/mesalib/src/mesa/main/textureview.h
+++ b/mesalib/src/mesa/main/textureview.h
@@ -29,6 +29,10 @@
#ifndef TEXTUREVIEW_H
#define TEXTUREVIEW_H
+GLboolean
+_mesa_texture_view_compatible_format(struct gl_context *ctx,
+ GLenum origInternalFormat,
+ GLenum newInternalFormat);
extern void GLAPIENTRY
_mesa_TextureView(GLuint texture, GLenum target, GLuint origtexture,
diff --git a/mesalib/src/mesa/main/uniform_query.cpp b/mesalib/src/mesa/main/uniform_query.cpp
index 609d94bd7..7e630e65b 100644
--- a/mesalib/src/mesa/main/uniform_query.cpp
+++ b/mesalib/src/mesa/main/uniform_query.cpp
@@ -171,18 +171,17 @@ _mesa_GetActiveUniformsiv(GLuint program,
_mesa_error(ctx, GL_INVALID_ENUM, "glGetActiveUniformsiv(pname)");
}
-static bool
+static struct gl_uniform_storage *
validate_uniform_parameters(struct gl_context *ctx,
struct gl_shader_program *shProg,
GLint location, GLsizei count,
- unsigned *loc,
unsigned *array_index,
const char *caller,
bool negative_one_is_not_valid)
{
if (!shProg || !shProg->LinkStatus) {
_mesa_error(ctx, GL_INVALID_OPERATION, "%s(program not linked)", caller);
- return false;
+ return NULL;
}
if (location == -1) {
@@ -214,7 +213,7 @@ validate_uniform_parameters(struct gl_context *ctx,
caller, location);
}
- return false;
+ return NULL;
}
/* From page 12 (page 26 of the PDF) of the OpenGL 2.1 spec:
@@ -224,7 +223,7 @@ validate_uniform_parameters(struct gl_context *ctx,
*/
if (count < 0) {
_mesa_error(ctx, GL_INVALID_VALUE, "%s(count < 0)", caller);
- return false;
+ return NULL;
}
/* Page 82 (page 96 of the PDF) of the OpenGL 2.1 spec says:
@@ -243,14 +242,14 @@ validate_uniform_parameters(struct gl_context *ctx,
if (location < -1) {
_mesa_error(ctx, GL_INVALID_OPERATION, "%s(location=%d)",
caller, location);
- return false;
+ 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 false;
+ return NULL;
}
/* If the driver storage pointer in remap table is -1, we ignore silently.
@@ -266,30 +265,33 @@ validate_uniform_parameters(struct gl_context *ctx,
*/
if (shProg->UniformRemapTable[location] ==
INACTIVE_UNIFORM_EXPLICIT_LOCATION)
- return false;
+ return NULL;
- _mesa_uniform_split_location_offset(shProg, location, loc, array_index);
+ struct gl_uniform_storage *const uni = shProg->UniformRemapTable[location];
- if (shProg->UniformStorage[*loc].array_elements == 0 && count > 1) {
+ if (uni->array_elements == 0 && count > 1) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"%s(count > 1 for non-array, location=%d)",
caller, location);
- return false;
+ return NULL;
}
+ /* The array index specified by the uniform location is just the uniform
+ * location minus the base location of of the uniform.
+ */
+ *array_index = location - uni->remap_location;
+
/* If the uniform is an array, check that array_index is in bounds.
* If not an array, check that array_index is zero.
* array_index is unsigned so no need to check for less than zero.
*/
- unsigned limit = shProg->UniformStorage[*loc].array_elements;
- if (limit == 0)
- limit = 1;
+ const unsigned limit = MAX2(uni->array_elements, 1);
if (*array_index >= limit) {
_mesa_error(ctx, GL_INVALID_OPERATION, "%s(location=%d)",
caller, location);
- return false;
+ return NULL;
}
- return true;
+ return uni;
}
/**
@@ -302,15 +304,14 @@ _mesa_get_uniform(struct gl_context *ctx, GLuint program, GLint location,
{
struct gl_shader_program *shProg =
_mesa_lookup_shader_program_err(ctx, program, "glGetUniformfv");
- struct gl_uniform_storage *uni;
- unsigned loc, offset;
+ unsigned offset;
- if (!validate_uniform_parameters(ctx, shProg, location, 1,
- &loc, &offset, "glGetUniform", true))
+ struct gl_uniform_storage *const uni =
+ validate_uniform_parameters(ctx, shProg, location, 1,
+ &offset, "glGetUniform", true);
+ if (uni == NULL)
return;
- uni = &shProg->UniformStorage[loc];
-
{
unsigned elements = (uni->type->is_sampler())
? 1 : uni->type->components();
@@ -607,18 +608,17 @@ _mesa_uniform(struct gl_context *ctx, struct gl_shader_program *shProg,
GLint location, GLsizei count,
const GLvoid *values, GLenum type)
{
- unsigned loc, offset;
+ unsigned offset;
unsigned components;
unsigned src_components;
enum glsl_base_type basicType;
- struct gl_uniform_storage *uni;
- if (!validate_uniform_parameters(ctx, shProg, location, count,
- &loc, &offset, "glUniform", false))
+ struct gl_uniform_storage *const uni =
+ validate_uniform_parameters(ctx, shProg, location, count,
+ &offset, "glUniform", false);
+ if (uni == NULL)
return;
- uni = &shProg->UniformStorage[loc];
-
/* Verify that the types are compatible.
*/
switch (type) {
@@ -894,17 +894,17 @@ _mesa_uniform_matrix(struct gl_context *ctx, struct gl_shader_program *shProg,
GLint location, GLsizei count,
GLboolean transpose, const GLfloat *values)
{
- unsigned loc, offset;
+ unsigned offset;
unsigned vectors;
unsigned components;
unsigned elements;
- struct gl_uniform_storage *uni;
- if (!validate_uniform_parameters(ctx, shProg, location, count,
- &loc, &offset, "glUniformMatrix", false))
+ struct gl_uniform_storage *const uni =
+ validate_uniform_parameters(ctx, shProg, location, count,
+ &offset, "glUniformMatrix", false);
+ if (uni == NULL)
return;
- uni = &shProg->UniformStorage[loc];
if (!uni->type->is_matrix()) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glUniformMatrix(non-matrix uniform)");
@@ -993,9 +993,7 @@ _mesa_uniform_matrix(struct gl_context *ctx, struct gl_shader_program *shProg,
*
* Returns the uniform index into UniformStorage (also the
* glGetActiveUniformsiv uniform index), and stores the referenced
- * array offset in *offset, or GL_INVALID_INDEX (-1). Those two
- * return values can be encoded into a uniform location for
- * glUniform* using _mesa_uniform_merge_location_offset(index, offset).
+ * array offset in *offset, or GL_INVALID_INDEX (-1).
*/
extern "C" unsigned
_mesa_get_uniform_location(struct gl_context *ctx,
diff --git a/mesalib/src/mesa/main/uniforms.c b/mesalib/src/mesa/main/uniforms.c
index f450173af..0d0cbf57e 100644
--- a/mesalib/src/mesa/main/uniforms.c
+++ b/mesalib/src/mesa/main/uniforms.c
@@ -932,7 +932,8 @@ _mesa_GetUniformLocation(GLuint programObj, const GLcharARB *name)
shProg->UniformStorage[index].atomic_buffer_index != -1)
return -1;
- return _mesa_uniform_merge_location_offset(shProg, index, offset);
+ /* location in remap table + array element offset */
+ return shProg->UniformStorage[index].remap_location + offset;
}
GLuint GLAPIENTRY
@@ -1089,18 +1090,38 @@ _mesa_GetActiveUniformBlockiv(GLuint program,
params[0] = strlen(block->Name) + 1;
return;
- case GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS:
- params[0] = block->NumUniforms;
+ case GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS: {
+ unsigned count = 0;
+
+ for (i = 0; i < block->NumUniforms; i++) {
+ unsigned offset;
+ const int idx =
+ _mesa_get_uniform_location(ctx, shProg,
+ block->Uniforms[i].IndexName,
+ &offset);
+ if (idx != -1)
+ count++;
+ }
+
+ params[0] = count;
return;
+ }
+
+ case GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES: {
+ unsigned count = 0;
- case GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES:
for (i = 0; i < block->NumUniforms; i++) {
unsigned offset;
- params[i] = _mesa_get_uniform_location(ctx, shProg,
- block->Uniforms[i].IndexName,
- &offset);
+ const int idx =
+ _mesa_get_uniform_location(ctx, shProg,
+ block->Uniforms[i].IndexName,
+ &offset);
+
+ if (idx != -1)
+ params[count++] = idx;
}
return;
+ }
case GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER:
params[0] = shProg->UniformBlockStageIndex[MESA_SHADER_VERTEX][uniformBlockIndex] != -1;
diff --git a/mesalib/src/mesa/main/uniforms.h b/mesalib/src/mesa/main/uniforms.h
index 10518dcbb..e7a370e84 100644
--- a/mesalib/src/mesa/main/uniforms.h
+++ b/mesalib/src/mesa/main/uniforms.h
@@ -323,69 +323,6 @@ struct gl_builtin_uniform_desc {
unsigned int num_elements;
};
-/**
- * \name GLSL uniform arrays and structs require special handling.
- *
- * The GL_ARB_shader_objects spec says that if you use
- * glGetUniformLocation to get the location of an array, you CANNOT
- * access other elements of the array by adding an offset to the
- * returned location. For example, you must call
- * glGetUniformLocation("foo[16]") if you want to set the 16th element
- * of the array with glUniform().
- *
- * HOWEVER, some other OpenGL drivers allow accessing array elements
- * by adding an offset to the returned array location. And some apps
- * seem to depend on that behaviour.
- *
- * Mesa's gl_uniform_list doesn't directly support this since each
- * entry in the list describes one uniform variable, not one uniform
- * element. We could insert dummy entries in the list for each array
- * element after [0] but that causes complications elsewhere.
- *
- * We solve this problem by creating multiple entries for uniform arrays
- * in the UniformRemapTable so that their elements get sequential locations.
- *
- * Utility functions below offer functionality to split UniformRemapTable
- * location in to location of the uniform in UniformStorage + offset to the
- * array element (0 if not an array) and also merge it back again as the
- * UniformRemapTable location.
- *
- */
-/*@{*/
-/**
- * Combine the uniform's storage index and the array index
- */
-static inline GLint
-_mesa_uniform_merge_location_offset(const struct gl_shader_program *prog,
- unsigned storage_index,
- unsigned uniform_array_index)
-{
- /* location in remap table + array element offset */
- return prog->UniformStorage[storage_index].remap_location +
- uniform_array_index;
-}
-
-/**
- * Separate the uniform storage index and array index
- */
-static inline void
-_mesa_uniform_split_location_offset(const struct gl_shader_program *prog,
- GLint location, unsigned *storage_index,
- unsigned *uniform_array_index)
-{
- *storage_index = prog->UniformRemapTable[location] - prog->UniformStorage;
- *uniform_array_index = location -
- prog->UniformRemapTable[location]->remap_location;
-
- /*gl_uniform_storage in UniformStorage with the calculated base_location
- * must match with the entry in remap table
- */
- assert(&prog->UniformStorage[*storage_index] ==
- prog->UniformRemapTable[location]);
-}
-/*@}*/
-
-
#ifdef __cplusplus
}
#endif
diff --git a/mesalib/src/mesa/main/varray.c b/mesalib/src/mesa/main/varray.c
index 46956efb5..230fb30cb 100644
--- a/mesalib/src/mesa/main/varray.c
+++ b/mesalib/src/mesa/main/varray.c
@@ -24,6 +24,8 @@
*/
+#include <inttypes.h> /* for PRId64 macro */
+
#include "glheader.h"
#include "imports.h"
#include "bufferobj.h"
@@ -46,21 +48,22 @@
/** Used to indicate which GL datatypes are accepted by each of the
* glVertex/Color/Attrib/EtcPointer() functions.
*/
-#define BOOL_BIT 0x1
-#define BYTE_BIT 0x2
-#define UNSIGNED_BYTE_BIT 0x4
-#define SHORT_BIT 0x8
-#define UNSIGNED_SHORT_BIT 0x10
-#define INT_BIT 0x20
-#define UNSIGNED_INT_BIT 0x40
-#define HALF_BIT 0x80
-#define FLOAT_BIT 0x100
-#define DOUBLE_BIT 0x200
-#define FIXED_ES_BIT 0x400
-#define FIXED_GL_BIT 0x800
-#define UNSIGNED_INT_2_10_10_10_REV_BIT 0x1000
-#define INT_2_10_10_10_REV_BIT 0x2000
-#define UNSIGNED_INT_10F_11F_11F_REV_BIT 0x4000
+#define BOOL_BIT (1 << 0)
+#define BYTE_BIT (1 << 1)
+#define UNSIGNED_BYTE_BIT (1 << 2)
+#define SHORT_BIT (1 << 3)
+#define UNSIGNED_SHORT_BIT (1 << 4)
+#define INT_BIT (1 << 5)
+#define UNSIGNED_INT_BIT (1 << 6)
+#define HALF_BIT (1 << 7)
+#define FLOAT_BIT (1 << 8)
+#define DOUBLE_BIT (1 << 9)
+#define FIXED_ES_BIT (1 << 10)
+#define FIXED_GL_BIT (1 << 11)
+#define UNSIGNED_INT_2_10_10_10_REV_BIT (1 << 12)
+#define INT_2_10_10_10_REV_BIT (1 << 13)
+#define UNSIGNED_INT_10F_11F_11F_REV_BIT (1 << 14)
+#define ALL_TYPE_BITS ((1 << 15) - 1)
/** Convert GL datatype enum into a <type>_BIT value seen above */
@@ -179,6 +182,53 @@ vertex_binding_divisor(struct gl_context *ctx, GLuint bindingIndex,
/**
+ * Examine the API profile and extensions to determine which types are legal
+ * for vertex arrays. This is called once from update_array_format().
+ */
+static GLbitfield
+get_legal_types_mask(const struct gl_context *ctx)
+{
+ GLbitfield legalTypesMask = ALL_TYPE_BITS;
+
+ if (_mesa_is_gles(ctx)) {
+ legalTypesMask &= ~(FIXED_GL_BIT |
+ DOUBLE_BIT |
+ UNSIGNED_INT_10F_11F_11F_REV_BIT);
+
+ /* GL_INT and GL_UNSIGNED_INT data is not allowed in OpenGL ES until
+ * 3.0. The 2_10_10_10 types are added in OpenGL ES 3.0 or
+ * GL_OES_vertex_type_10_10_10_2. GL_HALF_FLOAT data is not allowed
+ * until 3.0 or with the GL_OES_vertex_half float extension, which isn't
+ * quite as trivial as we'd like because it uses a different enum value
+ * for GL_HALF_FLOAT_OES.
+ */
+ if (ctx->Version < 30) {
+ legalTypesMask &= ~(UNSIGNED_INT_BIT |
+ INT_BIT |
+ UNSIGNED_INT_2_10_10_10_REV_BIT |
+ INT_2_10_10_10_REV_BIT |
+ HALF_BIT);
+ }
+ }
+ else {
+ legalTypesMask &= ~FIXED_ES_BIT;
+
+ if (!ctx->Extensions.ARB_ES2_compatibility)
+ legalTypesMask &= ~FIXED_GL_BIT;
+
+ if (!ctx->Extensions.ARB_vertex_type_2_10_10_10_rev)
+ legalTypesMask &= ~(UNSIGNED_INT_2_10_10_10_REV_BIT |
+ INT_2_10_10_10_REV_BIT);
+
+ if (!ctx->Extensions.ARB_vertex_type_10f_11f_11f_rev)
+ legalTypesMask &= ~UNSIGNED_INT_10F_11F_11F_REV_BIT;
+ }
+
+ return legalTypesMask;
+}
+
+
+/**
* Does error checking and updates the format in an attrib array.
*
* Called by update_array() and VertexAttrib*Format().
@@ -208,40 +258,19 @@ update_array_format(struct gl_context *ctx,
GLuint elementSize;
GLenum format = GL_RGBA;
- if (_mesa_is_gles(ctx)) {
- legalTypesMask &= ~(FIXED_GL_BIT | DOUBLE_BIT | UNSIGNED_INT_10F_11F_11F_REV_BIT);
-
- /* GL_INT and GL_UNSIGNED_INT data is not allowed in OpenGL ES until
- * 3.0. The 2_10_10_10 types are added in OpenGL ES 3.0 or
- * GL_OES_vertex_type_10_10_10_2. GL_HALF_FLOAT data is not allowed
- * until 3.0 or with the GL_OES_vertex_half float extension, which isn't
- * quite as trivial as we'd like because it uses a different enum value
- * for GL_HALF_FLOAT_OES.
+ if (ctx->Array.LegalTypesMask == 0) {
+ /* One-time initialization. We can't do this in _mesa_init_varrays()
+ * below because extensions are not yet enabled at that point.
*/
- if (ctx->Version < 30) {
- legalTypesMask &= ~(UNSIGNED_INT_BIT
- | INT_BIT
- | UNSIGNED_INT_2_10_10_10_REV_BIT
- | INT_2_10_10_10_REV_BIT
- | HALF_BIT);
- }
+ ctx->Array.LegalTypesMask = get_legal_types_mask(ctx);
+ }
+
+ legalTypesMask &= ctx->Array.LegalTypesMask;
+ if (_mesa_is_gles(ctx) && sizeMax == BGRA_OR_4) {
/* BGRA ordering is not supported in ES contexts.
*/
- if (sizeMax == BGRA_OR_4)
- sizeMax = 4;
- } else {
- legalTypesMask &= ~FIXED_ES_BIT;
-
- if (!ctx->Extensions.ARB_ES2_compatibility)
- legalTypesMask &= ~FIXED_GL_BIT;
-
- if (!ctx->Extensions.ARB_vertex_type_2_10_10_10_rev)
- legalTypesMask &= ~(UNSIGNED_INT_2_10_10_10_REV_BIT |
- INT_2_10_10_10_REV_BIT);
-
- if (!ctx->Extensions.ARB_vertex_type_10f_11f_11f_rev)
- legalTypesMask &= ~UNSIGNED_INT_10F_11F_11F_REV_BIT;
+ sizeMax = 4;
}
typeBit = type_to_bit(ctx, type);
@@ -1397,7 +1426,8 @@ _mesa_BindVertexBuffer(GLuint bindingIndex, GLuint buffer, GLintptr offset,
*/
if (offset < 0) {
_mesa_error(ctx, GL_INVALID_VALUE,
- "glBindVertexBuffer(offset=%lld < 0)", (long long)offset);
+ "glBindVertexBuffer(offset=%" PRId64 " < 0)",
+ (int64_t) offset);
return;
}
@@ -1523,15 +1553,15 @@ _mesa_BindVertexBuffers(GLuint first, GLsizei count, const GLuint *buffers,
*/
if (offsets[i] < 0) {
_mesa_error(ctx, GL_INVALID_VALUE,
- "glBindVertexBuffer(offsets[%u]=%lldd < 0)",
- i, (long long int) offsets[i]);
+ "glBindVertexBuffer(offsets[%u]=%" PRId64 " < 0)",
+ i, (int64_t) offsets[i]);
continue;
}
if (strides[i] < 0) {
_mesa_error(ctx, GL_INVALID_VALUE,
- "glBindVertexBuffer(strides[%u]=%lld < 0)",
- i, (long long int) strides[i]);
+ "glBindVertexBuffer(strides[%u]=%d < 0)",
+ i, strides[i]);
continue;
}
diff --git a/mesalib/src/mesa/main/vdpau.c b/mesalib/src/mesa/main/vdpau.c
index 975b812cd..e1c3e00ba 100644
--- a/mesalib/src/mesa/main/vdpau.c
+++ b/mesalib/src/mesa/main/vdpau.c
@@ -32,9 +32,9 @@
*/
#include <stdbool.h>
+#include "util/hash_table.h"
#include "context.h"
#include "glformats.h"
-#include "hash_table.h"
#include "set.h"
#include "texobj.h"
#include "teximage.h"
diff --git a/mesalib/src/mesa/program/arbprogparse.c b/mesalib/src/mesa/program/arbprogparse.c
index 5b9665091..7dec399a5 100644
--- a/mesalib/src/mesa/program/arbprogparse.c
+++ b/mesalib/src/mesa/program/arbprogparse.c
@@ -60,6 +60,7 @@ having three separate program parameter arrays.
#include "prog_parameter.h"
#include "prog_statevars.h"
#include "prog_instruction.h"
+#include "prog_optimize.h"
#include "program_parser.h"
@@ -84,6 +85,9 @@ _mesa_parse_arb_fragment_program(struct gl_context* ctx, GLenum target,
return;
}
+ if ((ctx->_Shader->Flags & GLSL_NO_OPT) == 0)
+ _mesa_optimize_program(ctx, &prog);
+
free(program->Base.String);
/* Copy the relevant contents of the arb_program struct into the
@@ -177,6 +181,9 @@ _mesa_parse_arb_vertex_program(struct gl_context *ctx, GLenum target,
return;
}
+ if ((ctx->_Shader->Flags & GLSL_NO_OPT) == 0)
+ _mesa_optimize_program(ctx, &prog);
+
free(program->Base.String);
/* Copy the relevant contents of the arb_program struct into the
diff --git a/mesalib/src/mesa/program/ir_to_mesa.cpp b/mesalib/src/mesa/program/ir_to_mesa.cpp
index 2a82e9d9d..b088160d3 100644
--- a/mesalib/src/mesa/program/ir_to_mesa.cpp
+++ b/mesalib/src/mesa/program/ir_to_mesa.cpp
@@ -793,7 +793,7 @@ ir_to_mesa_visitor::visit(ir_function *ir)
const ir_function_signature *sig;
exec_list empty;
- sig = ir->matching_signature(NULL, &empty);
+ sig = ir->matching_signature(NULL, &empty, false);
assert(sig);
diff --git a/mesalib/src/mesa/program/prog_execute.c b/mesalib/src/mesa/program/prog_execute.c
index 115525eba..fcc9ed518 100644
--- a/mesalib/src/mesa/program/prog_execute.c
+++ b/mesalib/src/mesa/program/prog_execute.c
@@ -52,7 +52,6 @@
/**
* Set x to positive or negative infinity.
*/
-#if defined(USE_IEEE) || defined(_WIN32)
#define SET_POS_INFINITY(x) \
do { \
fi_type fi; \
@@ -65,10 +64,6 @@
fi.i = 0xFF800000; \
x = fi.f; \
} while (0)
-#else
-#define SET_POS_INFINITY(x) x = (GLfloat) HUGE_VAL
-#define SET_NEG_INFINITY(x) x = (GLfloat) -HUGE_VAL
-#endif
#define SET_FLOAT_BITS(x, bits) ((fi_type *) (void *) &(x))->i = bits
diff --git a/mesalib/src/mesa/program/program.c b/mesalib/src/mesa/program/program.c
index aedce3e3c..ef5bf6b11 100644
--- a/mesalib/src/mesa/program/program.c
+++ b/mesalib/src/mesa/program/program.c
@@ -226,27 +226,24 @@ _mesa_find_line_column(const GLubyte *string, const GLubyte *pos,
/**
- * Initialize a new vertex/fragment program object.
+ * Initialize a new gl_program object.
*/
-static struct gl_program *
-_mesa_init_program_struct( struct gl_context *ctx, struct gl_program *prog,
- GLenum target, GLuint id)
+static void
+init_program_struct(struct gl_program *prog, GLenum target, GLuint id)
{
- (void) ctx;
- if (prog) {
- GLuint i;
- memset(prog, 0, sizeof(*prog));
- prog->Id = id;
- prog->Target = target;
- prog->RefCount = 1;
- prog->Format = GL_PROGRAM_FORMAT_ASCII_ARB;
-
- /* default mapping from samplers to texture units */
- for (i = 0; i < MAX_SAMPLERS; i++)
- prog->SamplerUnits[i] = i;
- }
+ GLuint i;
- return prog;
+ assert(prog);
+
+ memset(prog, 0, sizeof(*prog));
+ prog->Id = id;
+ prog->Target = target;
+ prog->RefCount = 1;
+ prog->Format = GL_PROGRAM_FORMAT_ASCII_ARB;
+
+ /* default mapping from samplers to texture units */
+ for (i = 0; i < MAX_SAMPLERS; i++)
+ prog->SamplerUnits[i] = i;
}
@@ -254,13 +251,15 @@ _mesa_init_program_struct( struct gl_context *ctx, struct gl_program *prog,
* Initialize a new fragment program object.
*/
struct gl_program *
-_mesa_init_fragment_program( struct gl_context *ctx, struct gl_fragment_program *prog,
- GLenum target, GLuint id)
+_mesa_init_fragment_program(struct gl_context *ctx,
+ struct gl_fragment_program *prog,
+ GLenum target, GLuint id)
{
- if (prog)
- return _mesa_init_program_struct( ctx, &prog->Base, target, id );
- else
- return NULL;
+ if (prog) {
+ init_program_struct(&prog->Base, target, id);
+ return &prog->Base;
+ }
+ return NULL;
}
@@ -268,13 +267,15 @@ _mesa_init_fragment_program( struct gl_context *ctx, struct gl_fragment_program
* Initialize a new vertex program object.
*/
struct gl_program *
-_mesa_init_vertex_program( struct gl_context *ctx, struct gl_vertex_program *prog,
- GLenum target, GLuint id)
+_mesa_init_vertex_program(struct gl_context *ctx,
+ struct gl_vertex_program *prog,
+ GLenum target, GLuint id)
{
- if (prog)
- return _mesa_init_program_struct( ctx, &prog->Base, target, id );
- else
- return NULL;
+ if (prog) {
+ init_program_struct(&prog->Base, target, id);
+ return &prog->Base;
+ }
+ return NULL;
}
@@ -283,13 +284,14 @@ _mesa_init_vertex_program( struct gl_context *ctx, struct gl_vertex_program *pro
*/
struct gl_program *
_mesa_init_compute_program(struct gl_context *ctx,
- struct gl_compute_program *prog, GLenum target,
- GLuint id)
+ struct gl_compute_program *prog,
+ GLenum target, GLuint id)
{
- if (prog)
- return _mesa_init_program_struct( ctx, &prog->Base, target, id );
- else
- return NULL;
+ if (prog) {
+ init_program_struct(&prog->Base, target, id);
+ return &prog->Base;
+ }
+ return NULL;
}
@@ -297,13 +299,15 @@ _mesa_init_compute_program(struct gl_context *ctx,
* Initialize a new geometry program object.
*/
struct gl_program *
-_mesa_init_geometry_program( struct gl_context *ctx, struct gl_geometry_program *prog,
- GLenum target, GLuint id)
+_mesa_init_geometry_program(struct gl_context *ctx,
+ struct gl_geometry_program *prog,
+ GLenum target, GLuint id)
{
- if (prog)
- return _mesa_init_program_struct( ctx, &prog->Base, target, id );
- else
- return NULL;
+ if (prog) {
+ init_program_struct(&prog->Base, target, id);
+ return &prog->Base;
+ }
+ return NULL;
}
diff --git a/mesalib/src/mesa/program/register_allocate.c b/mesalib/src/mesa/program/register_allocate.c
index 6fac69033..549154e8a 100644
--- a/mesalib/src/mesa/program/register_allocate.c
+++ b/mesalib/src/mesa/program/register_allocate.c
@@ -71,8 +71,8 @@
*/
#include <stdbool.h>
-#include <ralloc.h>
+#include "util/ralloc.h"
#include "main/imports.h"
#include "main/macros.h"
#include "main/mtypes.h"
diff --git a/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c b/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c
index 3b4d28d47..e0cb979f2 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c
@@ -31,6 +31,8 @@
*/
+#include <inttypes.h> /* for PRId64 macro */
+
#include "main/imports.h"
#include "main/mtypes.h"
#include "main/arrayobj.h"
@@ -271,7 +273,8 @@ st_bufferobj_data(struct gl_context *ctx,
pipe_resource_reference( &st_obj->buffer, NULL );
if (ST_DEBUG & DEBUG_BUFFER) {
- debug_printf("Create buffer size %td bind 0x%x\n", size, bind);
+ debug_printf("Create buffer size %" PRId64 " bind 0x%x\n",
+ (int64_t) size, bind);
}
if (size != 0) {
diff --git a/mesalib/src/mesa/state_tracker/st_cb_clear.c b/mesalib/src/mesa/state_tracker/st_cb_clear.c
index 4bfa8d75a..2c1414e48 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_clear.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_clear.c
@@ -173,6 +173,9 @@ draw_quad(struct st_context *st,
return;
}
+ /* Convert Z from [0,1] to [-1,1] range */
+ z = z * 2.0f - 1.0f;
+
/* positions */
vertices[0][0][0] = x0;
vertices[0][0][1] = y0;
@@ -319,11 +322,11 @@ clear_with_quad(struct gl_context *ctx, unsigned clear_buffers)
struct pipe_viewport_state vp;
vp.scale[0] = 0.5f * fb_width;
vp.scale[1] = fb_height * (invert ? -0.5f : 0.5f);
- vp.scale[2] = 1.0f;
+ vp.scale[2] = 0.5f;
vp.scale[3] = 1.0f;
vp.translate[0] = 0.5f * fb_width;
vp.translate[1] = 0.5f * fb_height;
- vp.translate[2] = 0.0f;
+ vp.translate[2] = 0.5f;
vp.translate[3] = 0.0f;
cso_set_viewport(st->cso_context, &vp);
}
diff --git a/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c b/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c
index 6119cc275..d13a17f50 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -494,22 +494,19 @@ make_texture(struct st_context *st,
pipeFormat = st_choose_matching_format(pipe->screen, PIPE_BIND_SAMPLER_VIEW,
format, type, unpack->SwapBytes);
- if (pipeFormat != PIPE_FORMAT_NONE) {
- mformat = st_pipe_format_to_mesa_format(pipeFormat);
- baseInternalFormat = _mesa_get_format_base_format(mformat);
- }
- else {
+ if (pipeFormat == PIPE_FORMAT_NONE) {
/* Use the generic approach. */
GLenum intFormat = internal_format(ctx, format, type);
- baseInternalFormat = _mesa_base_tex_format(ctx, intFormat);
pipeFormat = st_choose_format(st, intFormat, format, type,
PIPE_TEXTURE_2D, 0, PIPE_BIND_SAMPLER_VIEW,
FALSE);
assert(pipeFormat != PIPE_FORMAT_NONE);
- mformat = st_pipe_format_to_mesa_format(pipeFormat);
}
+ mformat = st_pipe_format_to_mesa_format(pipeFormat);
+ baseInternalFormat = _mesa_get_format_base_format(mformat);
+
pixels = _mesa_map_pbo_source(ctx, unpack, pixels);
if (!pixels)
return NULL;
diff --git a/mesalib/src/mesa/state_tracker/st_cb_texture.c b/mesalib/src/mesa/state_tracker/st_cb_texture.c
index aa6b05f0b..c4b2107ba 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_texture.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_texture.c
@@ -719,6 +719,8 @@ st_TexSubImage(struct gl_context *ctx, GLuint dims,
/* From now on, we need the gallium representation of dimensions. */
if (gl_target == GL_TEXTURE_1D_ARRAY) {
+ zoffset = yoffset;
+ yoffset = 0;
depth = height;
height = 1;
}
diff --git a/mesalib/src/mesa/state_tracker/st_extensions.c b/mesalib/src/mesa/state_tracker/st_extensions.c
index aa59fbfa9..7ac484056 100644
--- a/mesalib/src/mesa/state_tracker/st_extensions.c
+++ b/mesalib/src/mesa/state_tracker/st_extensions.c
@@ -146,7 +146,7 @@ void st_init_limits(struct st_context *st)
c->MaxUniformBlockSize =
screen->get_shader_param(screen, PIPE_SHADER_FRAGMENT,
- PIPE_SHADER_CAP_MAX_CONSTS) * 16;
+ PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE);
if (c->MaxUniformBlockSize < 16384) {
can_ubo = FALSE;
}
@@ -194,7 +194,8 @@ void st_init_limits(struct st_context *st)
_min(screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_ADDRS),
MAX_PROGRAM_ADDRESS_REGS);
pc->MaxParameters = pc->MaxNativeParameters =
- screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_CONSTS);
+ screen->get_shader_param(screen, sh,
+ PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE) / sizeof(float[4]);
pc->MaxUniformComponents = 4 * MIN2(pc->MaxNativeParameters, MAX_UNIFORMS);
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 5ea146547..0290553c6 100644
--- a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -1192,7 +1192,7 @@ glsl_to_tgsi_visitor::visit(ir_function *ir)
const ir_function_signature *sig;
exec_list empty;
- sig = ir->matching_signature(NULL, &empty);
+ sig = ir->matching_signature(NULL, &empty, false);
assert(sig);
@@ -1354,7 +1354,7 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir)
/* Quick peephole: Emit OPCODE_MAD(-a, -b, a) instead of AND(a, NOT(b))
*/
- if (ir->operation == ir_binop_logic_and) {
+ if (!native_integers && ir->operation == ir_binop_logic_and) {
if (try_emit_mad_for_and_not(ir, 1))
return;
if (try_emit_mad_for_and_not(ir, 0))
@@ -1947,16 +1947,16 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir)
break;
case ir_binop_ubo_load: {
- ir_constant *uniform_block = ir->operands[0]->as_constant();
+ ir_constant *const_uniform_block = ir->operands[0]->as_constant();
ir_constant *const_offset_ir = ir->operands[1]->as_constant();
unsigned const_offset = const_offset_ir ? const_offset_ir->value.u[0] : 0;
+ unsigned const_block = const_uniform_block ? const_uniform_block->value.u[0] + 1 : 0;
st_src_reg index_reg = get_temp(glsl_type::uint_type);
st_src_reg cbuf;
cbuf.type = glsl_type::vec4_type->base_type;
cbuf.file = PROGRAM_CONSTANT;
cbuf.index = 0;
- cbuf.index2D = uniform_block->value.u[0] + 1;
cbuf.reladdr = NULL;
cbuf.negate = 0;
@@ -1966,7 +1966,6 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir)
/* Constant index into constant buffer */
cbuf.reladdr = NULL;
cbuf.index = const_offset / 16;
- cbuf.has_index2 = true;
}
else {
/* Relative/variable index into constant buffer */
@@ -1976,6 +1975,20 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir)
memcpy(cbuf.reladdr, &index_reg, sizeof(index_reg));
}
+ if (const_uniform_block) {
+ /* Constant constant buffer */
+ cbuf.reladdr2 = NULL;
+ cbuf.index2D = const_block;
+ cbuf.has_index2 = true;
+ }
+ else {
+ /* Relative/variable constant buffer */
+ cbuf.reladdr2 = ralloc(mem_ctx, st_src_reg);
+ cbuf.index2D = 1;
+ memcpy(cbuf.reladdr2, &op[0], sizeof(st_src_reg));
+ cbuf.has_index2 = true;
+ }
+
cbuf.swizzle = swizzle_for_size(ir->type->vector_elements);
cbuf.swizzle += MAKE_SWIZZLE4(const_offset % 16 / 4,
const_offset % 16 / 4,
@@ -3216,78 +3229,6 @@ count_resources(glsl_to_tgsi_visitor *v, gl_program *prog)
_mesa_update_shader_textures_used(v->shader_program, prog);
}
-static void
-set_uniform_initializer(struct gl_context *ctx, void *mem_ctx,
- struct gl_shader_program *shader_program,
- const char *name, const glsl_type *type,
- ir_constant *val)
-{
- if (type->is_record()) {
- ir_constant *field_constant;
-
- field_constant = (ir_constant *)val->components.get_head();
-
- for (unsigned int i = 0; i < type->length; i++) {
- const glsl_type *field_type = type->fields.structure[i].type;
- const char *field_name = ralloc_asprintf(mem_ctx, "%s.%s", name,
- type->fields.structure[i].name);
- set_uniform_initializer(ctx, mem_ctx, shader_program, field_name,
- field_type, field_constant);
- field_constant = (ir_constant *)field_constant->next;
- }
- return;
- }
-
- unsigned offset;
- unsigned index = _mesa_get_uniform_location(ctx, shader_program, name,
- &offset);
- if (offset == GL_INVALID_INDEX) {
- fail_link(shader_program,
- "Couldn't find uniform for initializer %s\n", name);
- return;
- }
- int loc = _mesa_uniform_merge_location_offset(shader_program, index, offset);
-
- for (unsigned int i = 0; i < (type->is_array() ? type->length : 1); i++) {
- ir_constant *element;
- const glsl_type *element_type;
- if (type->is_array()) {
- element = val->array_elements[i];
- element_type = type->fields.array;
- } else {
- element = val;
- element_type = type;
- }
-
- void *values;
-
- if (element_type->base_type == GLSL_TYPE_BOOL) {
- int *conv = ralloc_array(mem_ctx, int, element_type->components());
- for (unsigned int j = 0; j < element_type->components(); j++) {
- conv[j] = element->value.b[j];
- }
- values = (void *)conv;
- element_type = glsl_type::get_instance(GLSL_TYPE_INT,
- element_type->vector_elements,
- 1);
- } else {
- values = &element->value;
- }
-
- if (element_type->is_matrix()) {
- _mesa_uniform_matrix(ctx, shader_program,
- element_type->matrix_columns,
- element_type->vector_elements,
- loc, 1, GL_FALSE, (GLfloat *)values);
- } else {
- _mesa_uniform(ctx, shader_program, loc, element_type->matrix_columns,
- values, element_type->gl_type);
- }
-
- loc++;
- }
-}
-
/**
* Returns the mask of channels (bitmask of WRITEMASK_X,Y,Z,W) which
* are read from the given src in this instruction
@@ -4225,14 +4166,22 @@ struct st_translate {
};
/** Map Mesa's SYSTEM_VALUE_x to TGSI_SEMANTIC_x */
-static unsigned mesa_sysval_to_semantic[SYSTEM_VALUE_MAX] = {
- TGSI_SEMANTIC_FACE,
+const unsigned _mesa_sysval_to_semantic[SYSTEM_VALUE_MAX] = {
+ /* Vertex shader
+ */
TGSI_SEMANTIC_VERTEXID,
TGSI_SEMANTIC_INSTANCEID,
+
+ /* Geometry shader
+ */
+ TGSI_SEMANTIC_INVOCATIONID,
+
+ /* Fragment shader
+ */
+ TGSI_SEMANTIC_FACE,
TGSI_SEMANTIC_SAMPLEID,
TGSI_SEMANTIC_SAMPLEPOS,
TGSI_SEMANTIC_SAMPLEMASK,
- TGSI_SEMANTIC_INVOCATIONID,
};
/**
@@ -4321,9 +4270,8 @@ dst_register(struct st_translate *t,
return ureg_dst_undef();
case PROGRAM_TEMPORARY:
- assert(index >= 0);
- assert(index < (int) Elements(t->temps));
-
+ assert(index < Elements(t->temps));
+
if (ureg_dst_is_undef(t->temps[index]))
t->temps[index] = ureg_DECL_local_temporary(t->ureg);
@@ -4332,8 +4280,7 @@ dst_register(struct st_translate *t,
case PROGRAM_ARRAY:
array = index >> 16;
- assert(array >= 0);
- assert(array < (int) Elements(t->arrays));
+ assert(array < Elements(t->arrays));
if (ureg_dst_is_undef(t->arrays[array]))
t->arrays[array] = ureg_DECL_array_temporary(
@@ -4367,51 +4314,45 @@ dst_register(struct st_translate *t,
* Map a glsl_to_tgsi src register to a TGSI ureg_src register.
*/
static struct ureg_src
-src_register(struct st_translate *t,
- gl_register_file file,
- GLint index, GLint index2D)
+src_register(struct st_translate *t, const struct st_src_reg *reg)
{
- switch(file) {
+ switch(reg->file) {
case PROGRAM_UNDEFINED:
return ureg_src_undef();
case PROGRAM_TEMPORARY:
case PROGRAM_ARRAY:
- return ureg_src(dst_register(t, file, index));
+ return ureg_src(dst_register(t, reg->file, reg->index));
case PROGRAM_UNIFORM:
- assert(index >= 0);
- return t->constants[index];
+ assert(reg->index >= 0);
+ return t->constants[reg->index];
case PROGRAM_STATE_VAR:
case PROGRAM_CONSTANT: /* ie, immediate */
- if (index2D) {
- struct ureg_src src;
- src = ureg_src_register(TGSI_FILE_CONSTANT, index);
- src.Dimension = 1;
- src.DimensionIndex = index2D;
- return src;
- } else if (index < 0)
+ if (reg->has_index2)
+ return ureg_src_register(TGSI_FILE_CONSTANT, reg->index);
+ else if (reg->index < 0)
return ureg_DECL_constant(t->ureg, 0);
else
- return t->constants[index];
+ return t->constants[reg->index];
case PROGRAM_IMMEDIATE:
- return t->immediates[index];
+ return t->immediates[reg->index];
case PROGRAM_INPUT:
- assert(t->inputMapping[index] < Elements(t->inputs));
- return t->inputs[t->inputMapping[index]];
+ assert(t->inputMapping[reg->index] < Elements(t->inputs));
+ return t->inputs[t->inputMapping[reg->index]];
case PROGRAM_OUTPUT:
- assert(t->outputMapping[index] < Elements(t->outputs));
- return ureg_src(t->outputs[t->outputMapping[index]]); /* not needed? */
+ assert(t->outputMapping[reg->index] < Elements(t->outputs));
+ return ureg_src(t->outputs[t->outputMapping[reg->index]]); /* not needed? */
case PROGRAM_ADDRESS:
- return ureg_src(t->address[index]);
+ return ureg_src(t->address[reg->index]);
case PROGRAM_SYSTEM_VALUE:
- assert(index < (int) Elements(t->systemValues));
- return t->systemValues[index];
+ assert(reg->index < (int) Elements(t->systemValues));
+ return t->systemValues[reg->index];
default:
assert(!"unknown src register file");
@@ -4472,13 +4413,12 @@ translate_dst(struct st_translate *t,
static struct ureg_src
translate_src(struct st_translate *t, const st_src_reg *src_reg)
{
- struct ureg_src src = src_register(t, src_reg->file, src_reg->index, src_reg->index2D);
+ struct ureg_src src = src_register(t, src_reg);
if (src_reg->has_index2) {
/* 2D indexes occur with geometry shader inputs (attrib, vertex)
* and UBO constant buffers (buffer, position).
*/
- src = src_register(t, src_reg->file, src_reg->index, src_reg->index2D);
if (src_reg->reladdr2)
src = ureg_src_dimension_indirect(src, ureg_src(t->address[1]),
src_reg->index2D);
@@ -4900,6 +4840,21 @@ st_translate_program(
assert(numInputs <= Elements(t->inputs));
assert(numOutputs <= Elements(t->outputs));
+ assert(_mesa_sysval_to_semantic[SYSTEM_VALUE_FRONT_FACE] ==
+ TGSI_SEMANTIC_FACE);
+ assert(_mesa_sysval_to_semantic[SYSTEM_VALUE_VERTEX_ID] ==
+ TGSI_SEMANTIC_VERTEXID);
+ assert(_mesa_sysval_to_semantic[SYSTEM_VALUE_INSTANCE_ID] ==
+ TGSI_SEMANTIC_INSTANCEID);
+ assert(_mesa_sysval_to_semantic[SYSTEM_VALUE_SAMPLE_ID] ==
+ TGSI_SEMANTIC_SAMPLEID);
+ assert(_mesa_sysval_to_semantic[SYSTEM_VALUE_SAMPLE_POS] ==
+ TGSI_SEMANTIC_SAMPLEPOS);
+ assert(_mesa_sysval_to_semantic[SYSTEM_VALUE_SAMPLE_MASK_IN] ==
+ TGSI_SEMANTIC_SAMPLEMASK);
+ assert(_mesa_sysval_to_semantic[SYSTEM_VALUE_INVOCATION_ID] ==
+ TGSI_SEMANTIC_INVOCATIONID);
+
t = CALLOC_STRUCT(st_translate);
if (!t) {
ret = PIPE_ERROR_OUT_OF_MEMORY;
@@ -5035,7 +4990,7 @@ st_translate_program(
unsigned numSys = 0;
for (i = 0; sysInputs; i++) {
if (sysInputs & (1 << i)) {
- unsigned semName = mesa_sysval_to_semantic[i];
+ unsigned semName = _mesa_sysval_to_semantic[i];
t->systemValues[i] = ureg_DECL_system_value(ureg, numSys, semName, 0);
if (semName == TGSI_SEMANTIC_INSTANCEID ||
semName == TGSI_SEMANTIC_VERTEXID) {
@@ -5109,8 +5064,7 @@ st_translate_program(
unsigned num_ubos = program->shader->NumUniformBlocks;
for (i = 0; i < num_ubos; i++) {
- unsigned size =
- program->shader_program->UniformBlocks[i].UniformBufferSize;
+ unsigned size = program->shader->UniformBlocks[i].UniformBufferSize;
unsigned num_const_vecs = (size + 15) / 16;
unsigned first, last;
assert(num_const_vecs > 0);
diff --git a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.h b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.h
index 2e7cb78d5..18f666f5b 100644
--- a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.h
+++ b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.h
@@ -73,6 +73,7 @@ st_translate_stream_output_info(struct glsl_to_tgsi_visitor *glsl_to_tgsi,
const GLuint outputMapping[],
struct pipe_stream_output_info *so);
+extern const unsigned _mesa_sysval_to_semantic[SYSTEM_VALUE_MAX];
#ifdef __cplusplus
}
diff --git a/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c b/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c
index 683cd1cac..26a5f51c7 100644
--- a/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c
+++ b/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c
@@ -44,6 +44,7 @@
#include "util/u_debug.h"
#include "util/u_math.h"
#include "util/u_memory.h"
+#include "st_glsl_to_tgsi.h" /* for _mesa_sysval_to_semantic */
#define PROGRAM_ANY_CONST ((1 << PROGRAM_STATE_VAR) | \
@@ -96,14 +97,6 @@ struct st_translate {
};
-/** Map Mesa's SYSTEM_VALUE_x to TGSI_SEMANTIC_x */
-static unsigned mesa_sysval_to_semantic[SYSTEM_VALUE_MAX] = {
- TGSI_SEMANTIC_FACE,
- TGSI_SEMANTIC_VERTEXID,
- TGSI_SEMANTIC_INSTANCEID
-};
-
-
/**
* Make note of a branch to a label in the TGSI code.
* After we've emitted all instructions, we'll go over the list
@@ -1147,7 +1140,7 @@ st_translate_mesa_program(
unsigned numSys = 0;
for (i = 0; sysInputs; i++) {
if (sysInputs & (1 << i)) {
- unsigned semName = mesa_sysval_to_semantic[i];
+ unsigned semName = _mesa_sysval_to_semantic[i];
t->systemValues[i] = ureg_DECL_system_value(ureg, numSys, semName, 0);
if (semName == TGSI_SEMANTIC_INSTANCEID ||
semName == TGSI_SEMANTIC_VERTEXID) {
diff --git a/mesalib/src/mesa/state_tracker/st_program.c b/mesalib/src/mesa/state_tracker/st_program.c
index 9d7b7c475..fbf8930cb 100644
--- a/mesalib/src/mesa/state_tracker/st_program.c
+++ b/mesalib/src/mesa/state_tracker/st_program.c
@@ -393,13 +393,12 @@ st_translate_vertex_program(struct st_context *st,
&vpv->tgsi.stream_output);
}
- vpv->driver_shader = pipe->create_vs_state(pipe, &vpv->tgsi);
-
if (ST_DEBUG & DEBUG_TGSI) {
- tgsi_dump( vpv->tgsi.tokens, 0 );
+ tgsi_dump(vpv->tgsi.tokens, 0);
debug_printf("\n");
}
+ vpv->driver_shader = pipe->create_vs_state(pipe, &vpv->tgsi);
return vpv;
fail:
@@ -804,15 +803,15 @@ st_translate_fragment_program(struct st_context *st,
variant->tgsi.tokens = ureg_get_tokens( ureg, NULL );
ureg_destroy( ureg );
- /* fill in variant */
- variant->driver_shader = pipe->create_fs_state(pipe, &variant->tgsi);
- variant->key = *key;
-
if (ST_DEBUG & DEBUG_TGSI) {
- tgsi_dump( variant->tgsi.tokens, 0/*TGSI_DUMP_VERBOSE*/ );
+ tgsi_dump(variant->tgsi.tokens, 0/*TGSI_DUMP_VERBOSE*/);
debug_printf("\n");
}
+ /* fill in variant */
+ variant->driver_shader = pipe->create_fs_state(pipe, &variant->tgsi);
+ variant->key = *key;
+
if (deleteFP) {
/* Free the temporary program made above */
struct gl_fragment_program *fp = &stfp->Base;
@@ -1173,10 +1172,6 @@ st_translate_geometry_program(struct st_context *st,
&stgp->tgsi.stream_output);
}
- /* fill in new variant */
- gpv->driver_shader = pipe->create_gs_state(pipe, &stgp->tgsi);
- gpv->key = *key;
-
if ((ST_DEBUG & DEBUG_TGSI) && (ST_DEBUG & DEBUG_MESA)) {
_mesa_print_program(&stgp->Base.Base);
debug_printf("\n");
@@ -1187,6 +1182,9 @@ st_translate_geometry_program(struct st_context *st,
debug_printf("\n");
}
+ /* fill in new variant */
+ gpv->driver_shader = pipe->create_gs_state(pipe, &stgp->tgsi);
+ gpv->key = *key;
return gpv;
}
diff --git a/mesalib/src/mesa/swrast/s_texfetch.c b/mesalib/src/mesa/swrast/s_texfetch.c
index e508368c8..aef023217 100644
--- a/mesalib/src/mesa/swrast/s_texfetch.c
+++ b/mesalib/src/mesa/swrast/s_texfetch.c
@@ -46,35 +46,7 @@
#include "s_texfetch.h"
#include "../../gallium/auxiliary/util/u_format_rgb9e5.h"
#include "../../gallium/auxiliary/util/u_format_r11g11b10f.h"
-
-
-/**
- * Convert an 8-bit sRGB value from non-linear space to a
- * linear RGB value in [0, 1].
- * Implemented with a 256-entry lookup table.
- */
-static inline GLfloat
-nonlinear_to_linear(GLubyte cs8)
-{
- static GLfloat table[256];
- static GLboolean tableReady = GL_FALSE;
- if (!tableReady) {
- /* compute lookup table now */
- GLuint i;
- for (i = 0; i < 256; i++) {
- const GLfloat cs = UBYTE_TO_FLOAT(i);
- if (cs <= 0.04045) {
- table[i] = cs / 12.92f;
- }
- else {
- table[i] = (GLfloat) pow((cs + 0.055) / 1.055, 2.4);
- }
- }
- tableReady = GL_TRUE;
- }
- return table[cs8];
-}
-
+#include "util/format_srgb.h"
/* Texel fetch routines for all supported formats
diff --git a/mesalib/src/mesa/swrast/s_texfetch_tmp.h b/mesalib/src/mesa/swrast/s_texfetch_tmp.h
index deda59246..72037ec00 100644
--- a/mesalib/src/mesa/swrast/s_texfetch_tmp.h
+++ b/mesalib/src/mesa/swrast/s_texfetch_tmp.h
@@ -737,9 +737,9 @@ FETCH(BGR_SRGB8)(const struct swrast_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel)
{
const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 3);
- texel[RCOMP] = nonlinear_to_linear(src[2]);
- texel[GCOMP] = nonlinear_to_linear(src[1]);
- texel[BCOMP] = nonlinear_to_linear(src[0]);
+ texel[RCOMP] = util_format_srgb_8unorm_to_linear_float(src[2]);
+ texel[GCOMP] = util_format_srgb_8unorm_to_linear_float(src[1]);
+ texel[BCOMP] = util_format_srgb_8unorm_to_linear_float(src[0]);
texel[ACOMP] = 1.0F;
}
@@ -749,9 +749,9 @@ FETCH(A8B8G8R8_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] = nonlinear_to_linear( (s >> 24) );
- texel[GCOMP] = nonlinear_to_linear( (s >> 16) & 0xff );
- texel[BCOMP] = nonlinear_to_linear( (s >> 8) & 0xff );
+ 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] = UBYTE_TO_FLOAT( (s ) & 0xff ); /* linear! */
}
@@ -761,9 +761,9 @@ FETCH(B8G8R8A8_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] = nonlinear_to_linear( (s >> 16) & 0xff );
- texel[GCOMP] = nonlinear_to_linear( (s >> 8) & 0xff );
- texel[BCOMP] = nonlinear_to_linear( (s ) & 0xff );
+ texel[RCOMP] = util_format_srgb_8unorm_to_linear_float( (s >> 16) & 0xff );
+ texel[GCOMP] = util_format_srgb_8unorm_to_linear_float( (s >> 8) & 0xff );
+ texel[BCOMP] = util_format_srgb_8unorm_to_linear_float( (s ) & 0xff );
texel[ACOMP] = UBYTE_TO_FLOAT( (s >> 24) ); /* linear! */
}
@@ -773,9 +773,9 @@ FETCH(R8G8B8A8_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] = nonlinear_to_linear( (s ) & 0xff );
- texel[GCOMP] = nonlinear_to_linear( (s >> 8) & 0xff );
- texel[BCOMP] = nonlinear_to_linear( (s >> 16) & 0xff );
+ texel[RCOMP] = util_format_srgb_8unorm_to_linear_float( (s ) & 0xff );
+ texel[GCOMP] = util_format_srgb_8unorm_to_linear_float( (s >> 8) & 0xff );
+ texel[BCOMP] = util_format_srgb_8unorm_to_linear_float( (s >> 16) & 0xff );
texel[ACOMP] = UBYTE_TO_FLOAT( (s >> 24) ); /* linear! */
}
@@ -785,9 +785,9 @@ FETCH(R8G8B8X8_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] = nonlinear_to_linear( (s ) & 0xff );
- texel[GCOMP] = nonlinear_to_linear( (s >> 8) & 0xff );
- texel[BCOMP] = nonlinear_to_linear( (s >> 16) & 0xff );
+ texel[RCOMP] = util_format_srgb_8unorm_to_linear_float( (s ) & 0xff );
+ texel[GCOMP] = util_format_srgb_8unorm_to_linear_float( (s >> 8) & 0xff );
+ texel[BCOMP] = util_format_srgb_8unorm_to_linear_float( (s >> 16) & 0xff );
texel[ACOMP] = 1.0f;
}
@@ -799,7 +799,7 @@ FETCH(L_SRGB8)(const struct swrast_texture_image *texImage,
const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
texel[RCOMP] =
texel[GCOMP] =
- texel[BCOMP] = nonlinear_to_linear(src[0]);
+ texel[BCOMP] = util_format_srgb_8unorm_to_linear_float(src[0]);
texel[ACOMP] = 1.0F;
}
@@ -811,7 +811,7 @@ FETCH(L8A8_SRGB)(const struct swrast_texture_image *texImage,
const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 2);
texel[RCOMP] =
texel[GCOMP] =
- texel[BCOMP] = nonlinear_to_linear(src[0]);
+ texel[BCOMP] = util_format_srgb_8unorm_to_linear_float(src[0]);
texel[ACOMP] = UBYTE_TO_FLOAT(src[1]); /* linear */
}
diff --git a/mesalib/src/mesa/x86/common_x86.c b/mesalib/src/mesa/x86/common_x86.c
index b401c354a..2a936a473 100644
--- a/mesalib/src/mesa/x86/common_x86.c
+++ b/mesalib/src/mesa/x86/common_x86.c
@@ -343,16 +343,18 @@ _mesa_get_x86_features(void)
#endif
#elif defined(USE_X86_64_ASM)
- unsigned int uninitialized_var(eax), uninitialized_var(ebx),
- uninitialized_var(ecx), uninitialized_var(edx);
+ {
+ unsigned int uninitialized_var(eax), uninitialized_var(ebx),
+ uninitialized_var(ecx), uninitialized_var(edx);
- /* Always available on x86-64. */
- _mesa_x86_cpu_features |= X86_FEATURE_XMM | X86_FEATURE_XMM2;
+ /* Always available on x86-64. */
+ _mesa_x86_cpu_features |= X86_FEATURE_XMM | X86_FEATURE_XMM2;
- __get_cpuid(1, &eax, &ebx, &ecx, &edx);
+ __get_cpuid(1, &eax, &ebx, &ecx, &edx);
- if (ecx & bit_SSE4_1)
- _mesa_x86_cpu_features |= X86_FEATURE_SSE4_1;
+ if (ecx & bit_SSE4_1)
+ _mesa_x86_cpu_features |= X86_FEATURE_SSE4_1;
+ }
#endif /* USE_X86_64_ASM */
(void) detection_debug;
diff --git a/mesalib/src/util/.gitignore b/mesalib/src/util/.gitignore
new file mode 100644
index 000000000..e945ecbb5
--- /dev/null
+++ b/mesalib/src/util/.gitignore
@@ -0,0 +1 @@
+format_srgb.c
diff --git a/mesalib/src/util/Makefile.am b/mesalib/src/util/Makefile.am
new file mode 100644
index 000000000..4733a1a74
--- /dev/null
+++ b/mesalib/src/util/Makefile.am
@@ -0,0 +1,41 @@
+# 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.
+
+SUBDIRS = . tests/hash_table
+
+include Makefile.sources
+
+noinst_LTLIBRARIES = libmesautil.la
+
+libmesautil_la_CPPFLAGS = \
+ $(DEFINES) \
+ -I$(top_srcdir)/include \
+ $(VISIBILITY_CFLAGS)
+
+libmesautil_la_SOURCES = \
+ $(MESA_UTIL_FILES) \
+ $(MESA_UTIL_GENERATED_FILES)
+
+BUILT_SOURCES = $(MESA_UTIL_GENERATED_FILES)
+CLEANFILES = $(BUILT_SOURCES)
+
+format_srgb.c: $(srcdir)/format_srgb.py
+ $(AM_V_GEN) $(PYTHON2) $< > $@
diff --git a/mesalib/src/util/Makefile.sources b/mesalib/src/util/Makefile.sources
new file mode 100644
index 000000000..b99aa25e8
--- /dev/null
+++ b/mesalib/src/util/Makefile.sources
@@ -0,0 +1,6 @@
+MESA_UTIL_FILES := \
+ hash_table.c \
+ ralloc.c
+
+MESA_UTIL_GENERATED_FILES = \
+ format_srgb.c
diff --git a/mesalib/src/util/SConscript b/mesalib/src/util/SConscript
new file mode 100644
index 000000000..84803c016
--- /dev/null
+++ b/mesalib/src/util/SConscript
@@ -0,0 +1,35 @@
+import common
+
+Import('*')
+
+from sys import executable as python_cmd
+
+env = env.Clone()
+
+env.Prepend(CPPPATH = [
+ '#include',
+ '#src/util',
+])
+
+env.CodeGenerate(
+ target = 'format_srgb.c',
+ script = 'format_srgb.py',
+ source = [],
+ command = python_cmd + ' $SCRIPT > $TARGET'
+)
+
+# parse Makefile.sources
+source_lists = env.ParseSourceList('Makefile.sources')
+
+mesautil_sources = (
+ source_lists['MESA_UTIL_FILES'] +
+ source_lists['MESA_UTIL_GENERATED_FILES']
+)
+
+mesautil = env.ConvenienceLibrary(
+ target = 'mesautil',
+ source = mesautil_sources,
+)
+
+env.Alias('mesautil', mesautil)
+Export('mesautil')
diff --git a/mesalib/src/gallium/auxiliary/util/u_format_srgb.h b/mesalib/src/util/format_srgb.h
index 740a91974..4a8d73f12 100644
--- a/mesalib/src/gallium/auxiliary/util/u_format_srgb.h
+++ b/mesalib/src/util/format_srgb.h
@@ -37,11 +37,9 @@
#ifndef U_FORMAT_SRGB_H_
#define U_FORMAT_SRGB_H_
-
-#include "pipe/p_compiler.h"
-#include "u_pack_color.h"
-#include "u_math.h"
-
+#include <stdint.h>
+#include <math.h>
+#include "c99_compat.h"
extern const float
util_format_srgb_8unorm_to_linear_float_table[256];
@@ -56,54 +54,58 @@ extern const unsigned
util_format_linear_to_srgb_helper_table[104];
+static inline float
+util_format_linear_to_srgb_float(float cl)
+{
+ if (cl < 0.0f)
+ return 0.0f;
+ else if (cl < 0.0031308f)
+ return 12.92f * cl;
+ else if (cl < 1.0f)
+ return 1.055f * powf(cl, 0.41666f) - 0.055f;
+ else
+ return 1.0f;
+}
+
+
/**
* Convert a unclamped linear float to srgb value in the [0,255].
*/
-static INLINE uint8_t
+static inline uint8_t
util_format_linear_float_to_srgb_8unorm(float x)
{
- /* this would be exact but (probably much) slower */
- if (0) {
- if (x >= 1.0f)
- return 255;
- else if (x >= 0.0031308f)
- return float_to_ubyte(1.055f * powf(x, 0.41666666f) - 0.055f);
- else if (x > 0.0f)
- return float_to_ubyte(12.92f * x);
- else
- return 0;
- }
- else {
- /*
- * This is taken from https://gist.github.com/rygorous/2203834
- * Use LUT and do linear interpolation.
- */
- union fi almostone, minval, f;
- unsigned tab, bias, scale, t;
-
- almostone.ui = 0x3f7fffff;
- minval.ui = (127-13) << 23;
-
- /*
- * Clamp to [2^(-13), 1-eps]; these two values map to 0 and 1, respectively.
- * The tests are carefully written so that NaNs map to 0, same as in the
- * reference implementation.
- */
- if (!(x > minval.f))
- x = minval.f;
- if (x > almostone.f)
- x = almostone.f;
-
- /* Do the table lookup and unpack bias, scale */
- f.f = x;
- tab = util_format_linear_to_srgb_helper_table[(f.ui - minval.ui) >> 20];
- bias = (tab >> 16) << 9;
- scale = tab & 0xffff;
-
- /* Grab next-highest mantissa bits and perform linear interpolation */
- t = (f.ui >> 12) & 0xff;
- return (uint8_t) ((bias + scale*t) >> 16);
- }
+ /*
+ * This is taken from https://gist.github.com/rygorous/2203834
+ * Use LUT and do linear interpolation.
+ */
+ union {
+ uint32_t ui;
+ float f;
+ } almostone, minval, f;
+ unsigned tab, bias, scale, t;
+
+ almostone.ui = 0x3f7fffff;
+ minval.ui = (127-13) << 23;
+
+ /*
+ * Clamp to [2^(-13), 1-eps]; these two values map to 0 and 1, respectively.
+ * The tests are carefully written so that NaNs map to 0, same as in the
+ * reference implementation.
+ */
+ if (!(x > minval.f))
+ x = minval.f;
+ if (x > almostone.f)
+ x = almostone.f;
+
+ /* Do the table lookup and unpack bias, scale */
+ f.f = x;
+ tab = util_format_linear_to_srgb_helper_table[(f.ui - minval.ui) >> 20];
+ bias = (tab >> 16) << 9;
+ scale = tab & 0xffff;
+
+ /* Grab next-highest mantissa bits and perform linear interpolation */
+ t = (f.ui >> 12) & 0xff;
+ return (uint8_t) ((bias + scale*t) >> 16);
}
@@ -112,7 +114,7 @@ util_format_linear_float_to_srgb_8unorm(float x)
* linear RGB value in [0, 1].
* Implemented with a 256-entry lookup table.
*/
-static INLINE float
+static inline float
util_format_srgb_8unorm_to_linear_float(uint8_t x)
{
return util_format_srgb_8unorm_to_linear_float_table[x];
@@ -127,7 +129,7 @@ util_format_srgb_8unorm_to_linear_float(uint8_t x)
/**
* Convert a 8bit normalized value from linear to srgb.
*/
-static INLINE uint8_t
+static inline uint8_t
util_format_linear_to_srgb_8unorm(uint8_t x)
{
return util_format_linear_to_srgb_8unorm_table[x];
@@ -137,7 +139,7 @@ util_format_linear_to_srgb_8unorm(uint8_t x)
/**
* Convert a 8bit normalized value from srgb to linear.
*/
-static INLINE uint8_t
+static inline uint8_t
util_format_srgb_to_linear_8unorm(uint8_t x)
{
return util_format_srgb_to_linear_8unorm_table[x];
diff --git a/mesalib/src/gallium/auxiliary/util/u_format_srgb.py b/mesalib/src/util/format_srgb.py
index c6c02f053..d5cbcf764 100644
--- a/mesalib/src/gallium/auxiliary/util/u_format_srgb.py
+++ b/mesalib/src/util/format_srgb.py
@@ -109,7 +109,7 @@ def generate_srgb_tables():
start = ((127 - numexp) << 23) + bucket*(bucketsize << stepshift)
sum_a = 0.0
sum_b = 0.0
-
+
for i in range(0, bucketsize):
j = (i << stepshift) >> mantshift
fint = start + (i << stepshift)
@@ -123,7 +123,7 @@ def generate_srgb_tables():
scaled_a = solved_a * 65536.0 / 512.0
scaled_b = solved_b * 65536.0
-
+
int_a = int(scaled_a + 0.5)
int_b = int(scaled_b + 0.5)
@@ -146,9 +146,9 @@ def main():
# This will print the copyright message on the top of this file
print CopyRight.strip()
print
- print '#include "u_format_srgb.h"'
+ print '#include "format_srgb.h"'
print
- generate_srgb_tables()
+ generate_srgb_tables()
if __name__ == '__main__':
diff --git a/mesalib/src/mesa/main/hash_table.c b/mesalib/src/util/hash_table.c
index ad8f89852..1b6726c79 100644
--- a/mesalib/src/mesa/main/hash_table.c
+++ b/mesalib/src/util/hash_table.c
@@ -43,9 +43,9 @@
#include <stdlib.h>
#include <string.h>
-#include "main/hash_table.h"
-#include "main/macros.h"
+#include "hash_table.h"
#include "ralloc.h"
+#include "macros.h"
static const uint32_t deleted_key_value;
diff --git a/mesalib/src/mesa/main/hash_table.h b/mesalib/src/util/hash_table.h
index f51131aee..d6b6ebf40 100644
--- a/mesalib/src/mesa/main/hash_table.h
+++ b/mesalib/src/util/hash_table.h
@@ -28,10 +28,11 @@
#ifndef _HASH_TABLE_H
#define _HASH_TABLE_H
+#include <stdlib.h>
#include <inttypes.h>
#include <stdbool.h>
-
-#include "compiler.h"
+#include "c99_compat.h"
+#include "macros.h"
#ifdef __cplusplus
extern "C" {
diff --git a/mesalib/src/util/macros.h b/mesalib/src/util/macros.h
new file mode 100644
index 000000000..ee05e05a4
--- /dev/null
+++ b/mesalib/src/util/macros.h
@@ -0,0 +1,128 @@
+/*
+ * 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.
+ */
+
+#ifndef UTIL_MACROS_H
+#define UTIL_MACROS_H
+
+/* Compute the size of an array */
+#ifndef ARRAY_SIZE
+# define ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x)))
+#endif
+
+
+/**
+ * __builtin_expect macros
+ */
+#if !defined(__GNUC__)
+# define __builtin_expect(x, y) (x)
+#endif
+
+#ifndef likely
+# ifdef __GNUC__
+# define likely(x) __builtin_expect(!!(x), 1)
+# define unlikely(x) __builtin_expect(!!(x), 0)
+# else
+# define likely(x) (x)
+# define unlikely(x) (x)
+# endif
+#endif
+
+
+/**
+ * Static (compile-time) assertion.
+ * Basically, use COND to dimension an array. If COND is false/zero the
+ * array size will be -1 and we'll get a compilation error.
+ */
+#define STATIC_ASSERT(COND) \
+ do { \
+ (void) sizeof(char [1 - 2*!(COND)]); \
+ } while (0)
+
+
+/**
+ * Unreachable macro. Useful for suppressing "control reaches end of non-void
+ * function" warnings.
+ */
+#if __GNUC__ >= 4 && __GNUC_MINOR__ >= 5
+#define unreachable(str) \
+do { \
+ assert(!str); \
+ __builtin_unreachable(); \
+} while (0)
+#elif (defined(__clang__) && defined(__has_builtin))
+# if __has_builtin(__builtin_unreachable)
+# define unreachable(str) \
+do { \
+ assert(!str); \
+ __builtin_unreachable(); \
+} while (0)
+# endif
+#endif
+
+#ifndef unreachable
+#define unreachable(str)
+#endif
+
+
+#if (__GNUC__ >= 3)
+#define PRINTFLIKE(f, a) __attribute__ ((format(__printf__, f, a)))
+#else
+#define PRINTFLIKE(f, a)
+#endif
+
+
+/* Used to optionally mark structures with misaligned elements or size as
+ * packed, to trade off performance for space.
+ */
+#if (__GNUC__ >= 3)
+#define PACKED __attribute__((__packed__))
+#else
+#define PACKED
+#endif
+
+
+#ifdef __cplusplus
+/**
+ * Macro function that evaluates to true if T is a trivially
+ * destructible type -- that is, if its (non-virtual) destructor
+ * performs no action and all member variables and base classes are
+ * trivially destructible themselves.
+ */
+# if defined(__GNUC__)
+# if ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3)))
+# define HAS_TRIVIAL_DESTRUCTOR(T) __has_trivial_destructor(T)
+# endif
+# elif (defined(__clang__) && defined(__has_feature))
+# if __has_feature(has_trivial_destructor)
+# define HAS_TRIVIAL_DESTRUCTOR(T) __has_trivial_destructor(T)
+# endif
+# endif
+# ifndef HAS_TRIVIAL_DESTRUCTOR
+ /* It's always safe (if inefficient) to assume that a
+ * destructor is non-trivial.
+ */
+# define HAS_TRIVIAL_DESTRUCTOR(T) (false)
+# endif
+#endif
+
+#endif /* UTIL_MACROS_H */
diff --git a/mesalib/src/glsl/ralloc.c b/mesalib/src/util/ralloc.c
index 36bc61fd0..36bc61fd0 100644
--- a/mesalib/src/glsl/ralloc.c
+++ b/mesalib/src/util/ralloc.c
diff --git a/mesalib/src/glsl/ralloc.h b/mesalib/src/util/ralloc.h
index 1fe53573f..4b88f3286 100644
--- a/mesalib/src/glsl/ralloc.h
+++ b/mesalib/src/util/ralloc.h
@@ -53,7 +53,8 @@ extern "C" {
#include <stddef.h>
#include <stdarg.h>
#include <stdbool.h>
-#include "main/compiler.h"
+
+#include "macros.h"
/**
* \def ralloc(ctx, type)
diff --git a/xorg-server/Xext/saver.c b/xorg-server/Xext/saver.c
index 6afd79c34..43c110dac 100644
--- a/xorg-server/Xext/saver.c
+++ b/xorg-server/Xext/saver.c
@@ -472,9 +472,6 @@ CreateSaverWindow(ScreenPtr pScreen)
WindowPtr pWin;
int result;
unsigned long mask;
- Colormap *installedMaps;
- int numInstalled;
- int i;
Colormap wantMap;
ColormapPtr pCmap;
@@ -550,18 +547,7 @@ CreateSaverWindow(ScreenPtr pScreen)
/* check and install our own colormap if it isn't installed now */
wantMap = wColormap(pWin);
- if (wantMap == None)
- return TRUE;
- installedMaps = malloc(pScreen->maxInstalledCmaps * sizeof(Colormap));
- numInstalled = (*pWin->drawable.pScreen->ListInstalledColormaps)
- (pScreen, installedMaps);
- for (i = 0; i < numInstalled; i++)
- if (installedMaps[i] == wantMap)
- break;
-
- free((char *) installedMaps);
-
- if (i < numInstalled)
+ if (wantMap == None || IsMapInstalled(wantMap, pWin))
return TRUE;
result = dixLookupResourceByType((void **) &pCmap, wantMap, RT_COLORMAP,
diff --git a/xorg-server/Xext/xvdisp.c b/xorg-server/Xext/xvdisp.c
index f2d49a2b8..0bdfed370 100644
--- a/xorg-server/Xext/xvdisp.c
+++ b/xorg-server/Xext/xvdisp.c
@@ -297,9 +297,6 @@ SWriteListImageFormatsReply(ClientPtr client, xvListImageFormatsReply * rep)
if ((_c)->swapped) SWriteImageFormatInfo(_c, _d); \
else WriteToClient(_c, sz_xvImageFormatInfo, _d)
-#define _AllocatePort(_i,_p) \
- ((_p)->id != _i) ? (* (_p)->pAdaptor->ddAllocatePort)(_i,_p,&_p) : Success
-
static int
ProcXvQueryExtension(ClientPtr client)
{
@@ -356,8 +353,6 @@ ProcXvQueryAdaptors(ClientPtr client)
return Success;
}
- (*pxvs->ddQueryAdaptors) (pScreen, &pxvs->pAdaptors, &pxvs->nAdaptors);
-
rep = (xvQueryAdaptorsReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
@@ -422,18 +417,12 @@ ProcXvQueryEncodings(ClientPtr client)
XvPortPtr pPort;
int ne;
XvEncodingPtr pe;
- int status;
REQUEST(xvQueryEncodingsReq);
REQUEST_SIZE_MATCH(xvQueryEncodingsReq);
VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
- if ((status = _AllocatePort(stuff->port, pPort)) != Success) {
- client->errorValue = stuff->port;
- return status;
- }
-
rep = (xvQueryEncodingsReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
@@ -485,11 +474,6 @@ ProcXvPutVideo(ClientPtr client)
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
- if ((status = _AllocatePort(stuff->port, pPort)) != Success) {
- client->errorValue = stuff->port;
- return status;
- }
-
if (!(pPort->pAdaptor->type & XvInputMask) ||
!(pPort->pAdaptor->type & XvVideoMask)) {
client->errorValue = stuff->port;
@@ -520,11 +504,6 @@ ProcXvPutStill(ClientPtr client)
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
- if ((status = _AllocatePort(stuff->port, pPort)) != Success) {
- client->errorValue = stuff->port;
- return status;
- }
-
if (!(pPort->pAdaptor->type & XvInputMask) ||
!(pPort->pAdaptor->type & XvStillMask)) {
client->errorValue = stuff->port;
@@ -555,11 +534,6 @@ ProcXvGetVideo(ClientPtr client)
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixReadAccess);
VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
- if ((status = _AllocatePort(stuff->port, pPort)) != Success) {
- client->errorValue = stuff->port;
- return status;
- }
-
if (!(pPort->pAdaptor->type & XvOutputMask) ||
!(pPort->pAdaptor->type & XvVideoMask)) {
client->errorValue = stuff->port;
@@ -590,11 +564,6 @@ ProcXvGetStill(ClientPtr client)
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixReadAccess);
VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
- if ((status = _AllocatePort(stuff->port, pPort)) != Success) {
- client->errorValue = stuff->port;
- return status;
- }
-
if (!(pPort->pAdaptor->type & XvOutputMask) ||
!(pPort->pAdaptor->type & XvStillMask)) {
client->errorValue = stuff->port;
@@ -631,7 +600,6 @@ ProcXvSelectVideoNotify(ClientPtr client)
static int
ProcXvSelectPortNotify(ClientPtr client)
{
- int status;
XvPortPtr pPort;
REQUEST(xvSelectPortNotifyReq);
@@ -639,11 +607,6 @@ ProcXvSelectPortNotify(ClientPtr client)
VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
- if ((status = _AllocatePort(stuff->port, pPort)) != Success) {
- client->errorValue = stuff->port;
- return status;
- }
-
return XvdiSelectPortNotify(client, pPort, stuff->onoff);
}
@@ -659,11 +622,6 @@ ProcXvGrabPort(ClientPtr client)
VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
- if ((status = _AllocatePort(stuff->port, pPort)) != Success) {
- client->errorValue = stuff->port;
- return status;
- }
-
status = XvdiGrabPort(client, pPort, stuff->time, &result);
if (status != Success) {
@@ -684,7 +642,6 @@ ProcXvGrabPort(ClientPtr client)
static int
ProcXvUngrabPort(ClientPtr client)
{
- int status;
XvPortPtr pPort;
REQUEST(xvGrabPortReq);
@@ -692,18 +649,13 @@ ProcXvUngrabPort(ClientPtr client)
VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
- if ((status = _AllocatePort(stuff->port, pPort)) != Success) {
- client->errorValue = stuff->port;
- return status;
- }
-
return XvdiUngrabPort(client, pPort, stuff->time);
}
static int
ProcXvStopVideo(ClientPtr client)
{
- int status, ret;
+ int ret;
DrawablePtr pDraw;
XvPortPtr pPort;
@@ -712,11 +664,6 @@ ProcXvStopVideo(ClientPtr client)
VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
- if ((status = _AllocatePort(stuff->port, pPort)) != Success) {
- client->errorValue = stuff->port;
- return status;
- }
-
ret = dixLookupDrawable(&pDraw, stuff->drawable, client, 0, DixWriteAccess);
if (ret != Success)
return ret;
@@ -735,11 +682,6 @@ ProcXvSetPortAttribute(ClientPtr client)
VALIDATE_XV_PORT(stuff->port, pPort, DixSetAttrAccess);
- if ((status = _AllocatePort(stuff->port, pPort)) != Success) {
- client->errorValue = stuff->port;
- return status;
- }
-
if (!ValidAtom(stuff->attribute)) {
client->errorValue = stuff->attribute;
return BadAtom;
@@ -769,11 +711,6 @@ ProcXvGetPortAttribute(ClientPtr client)
VALIDATE_XV_PORT(stuff->port, pPort, DixGetAttrAccess);
- if ((status = _AllocatePort(stuff->port, pPort)) != Success) {
- client->errorValue = stuff->port;
- return status;
- }
-
if (!ValidAtom(stuff->attribute)) {
client->errorValue = stuff->attribute;
return BadAtom;
@@ -800,7 +737,6 @@ ProcXvGetPortAttribute(ClientPtr client)
static int
ProcXvQueryBestSize(ClientPtr client)
{
- int status;
unsigned int actual_width, actual_height;
XvPortPtr pPort;
xvQueryBestSizeReply rep;
@@ -810,12 +746,7 @@ ProcXvQueryBestSize(ClientPtr client)
VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
- if ((status = _AllocatePort(stuff->port, pPort)) != Success) {
- client->errorValue = stuff->port;
- return status;
- }
-
- (*pPort->pAdaptor->ddQueryBestSize) (client, pPort, stuff->motion,
+ (*pPort->pAdaptor->ddQueryBestSize) (pPort, stuff->motion,
stuff->vid_w, stuff->vid_h,
stuff->drw_w, stuff->drw_h,
&actual_width, &actual_height);
@@ -836,7 +767,7 @@ ProcXvQueryBestSize(ClientPtr client)
static int
ProcXvQueryPortAttributes(ClientPtr client)
{
- int status, size, i;
+ int size, i;
XvPortPtr pPort;
XvAttributePtr pAtt;
xvQueryPortAttributesReply rep;
@@ -847,11 +778,6 @@ ProcXvQueryPortAttributes(ClientPtr client)
VALIDATE_XV_PORT(stuff->port, pPort, DixGetAttrAccess);
- if ((status = _AllocatePort(stuff->port, pPort)) != Success) {
- client->errorValue = stuff->port;
- return status;
- }
-
rep = (xvQueryPortAttributesReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
@@ -902,11 +828,6 @@ ProcXvPutImage(ClientPtr client)
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
- if ((status = _AllocatePort(stuff->port, pPort)) != Success) {
- client->errorValue = stuff->port;
- return status;
- }
-
if (!(pPort->pAdaptor->type & XvImageMask) ||
!(pPort->pAdaptor->type & XvInputMask)) {
client->errorValue = stuff->port;
@@ -930,8 +851,7 @@ ProcXvPutImage(ClientPtr client)
width = stuff->width;
height = stuff->height;
- size = (*pPort->pAdaptor->ddQueryImageAttributes) (client,
- pPort, pImage, &width,
+ size = (*pPort->pAdaptor->ddQueryImageAttributes) (pPort, pImage, &width,
&height, NULL, NULL);
size += sizeof(xvPutImageReq);
size = bytes_to_int32(size);
@@ -968,11 +888,6 @@ ProcXvShmPutImage(ClientPtr client)
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
- if ((status = _AllocatePort(stuff->port, pPort)) != Success) {
- client->errorValue = stuff->port;
- return status;
- }
-
if (!(pPort->pAdaptor->type & XvImageMask) ||
!(pPort->pAdaptor->type & XvInputMask)) {
client->errorValue = stuff->port;
@@ -1001,8 +916,7 @@ ProcXvShmPutImage(ClientPtr client)
width = stuff->width;
height = stuff->height;
- size_needed = (*pPort->pAdaptor->ddQueryImageAttributes) (client,
- pPort, pImage,
+ size_needed = (*pPort->pAdaptor->ddQueryImageAttributes) (pPort, pImage,
&width, &height,
NULL, NULL);
if ((size_needed + stuff->offset) > shmdesc->size)
@@ -1086,7 +1000,7 @@ ProcXvQueryImageAttributes(ClientPtr client)
width = stuff->width;
height = stuff->height;
- size = (*pPort->pAdaptor->ddQueryImageAttributes) (client, pPort, pImage,
+ size = (*pPort->pAdaptor->ddQueryImageAttributes) (pPort, pImage,
&width, &height, offsets,
pitches);
diff --git a/xorg-server/Xext/xvdix.h b/xorg-server/Xext/xvdix.h
index bb08cf4c7..e67a3c766 100644
--- a/xorg-server/Xext/xvdix.h
+++ b/xorg-server/Xext/xvdix.h
@@ -157,32 +157,29 @@ typedef struct {
int nPorts;
struct _XvPortRec *pPorts;
ScreenPtr pScreen;
- int (*ddAllocatePort) (unsigned long, struct _XvPortRec *,
- struct _XvPortRec **);
- int (*ddFreePort) (struct _XvPortRec *);
- int (*ddPutVideo) (ClientPtr, DrawablePtr, struct _XvPortRec *, GCPtr,
+ int (*ddPutVideo) (DrawablePtr, struct _XvPortRec *, GCPtr,
INT16, INT16, CARD16, CARD16,
INT16, INT16, CARD16, CARD16);
- int (*ddPutStill) (ClientPtr, DrawablePtr, struct _XvPortRec *, GCPtr,
+ int (*ddPutStill) (DrawablePtr, struct _XvPortRec *, GCPtr,
INT16, INT16, CARD16, CARD16,
INT16, INT16, CARD16, CARD16);
- int (*ddGetVideo) (ClientPtr, DrawablePtr, struct _XvPortRec *, GCPtr,
+ int (*ddGetVideo) (DrawablePtr, struct _XvPortRec *, GCPtr,
INT16, INT16, CARD16, CARD16,
INT16, INT16, CARD16, CARD16);
- int (*ddGetStill) (ClientPtr, DrawablePtr, struct _XvPortRec *, GCPtr,
+ int (*ddGetStill) (DrawablePtr, struct _XvPortRec *, GCPtr,
INT16, INT16, CARD16, CARD16,
INT16, INT16, CARD16, CARD16);
- int (*ddStopVideo) (ClientPtr, struct _XvPortRec *, DrawablePtr);
- int (*ddSetPortAttribute) (ClientPtr, struct _XvPortRec *, Atom, INT32);
- int (*ddGetPortAttribute) (ClientPtr, struct _XvPortRec *, Atom, INT32 *);
- int (*ddQueryBestSize) (ClientPtr, struct _XvPortRec *, CARD8,
+ int (*ddStopVideo) (struct _XvPortRec *, DrawablePtr);
+ int (*ddSetPortAttribute) (struct _XvPortRec *, Atom, INT32);
+ int (*ddGetPortAttribute) (struct _XvPortRec *, Atom, INT32 *);
+ int (*ddQueryBestSize) (struct _XvPortRec *, CARD8,
CARD16, CARD16, CARD16, CARD16,
unsigned int *, unsigned int *);
- int (*ddPutImage) (ClientPtr, DrawablePtr, struct _XvPortRec *, GCPtr,
+ int (*ddPutImage) (DrawablePtr, struct _XvPortRec *, GCPtr,
INT16, INT16, CARD16, CARD16,
INT16, INT16, CARD16, CARD16,
XvImagePtr, unsigned char *, Bool, CARD16, CARD16);
- int (*ddQueryImageAttributes) (ClientPtr, struct _XvPortRec *, XvImagePtr,
+ int (*ddQueryImageAttributes) (struct _XvPortRec *, XvImagePtr,
CARD16 *, CARD16 *, int *, int *);
DevUnion devPriv;
} XvAdaptorRec, *XvAdaptorPtr;
@@ -213,9 +210,6 @@ typedef struct {
DestroyWindowProcPtr DestroyWindow;
DestroyPixmapProcPtr DestroyPixmap;
CloseScreenProcPtr CloseScreen;
- Bool (*ddCloseScreen) (ScreenPtr);
- int (*ddQueryAdaptors) (ScreenPtr, XvAdaptorPtr *, int *);
- DevUnion devPriv;
} XvScreenRec, *XvScreenPtr;
#define SCREEN_PROLOGUE(pScreen, field) ((pScreen)->field = ((XvScreenPtr) \
@@ -235,8 +229,10 @@ extern _X_EXPORT int SProcXvDispatch(ClientPtr);
extern _X_EXPORT int XvScreenInit(ScreenPtr);
extern _X_EXPORT DevPrivateKey XvGetScreenKey(void);
extern _X_EXPORT unsigned long XvGetRTPort(void);
+extern _X_EXPORT void XvFreeAdaptor(XvAdaptorPtr pAdaptor);
+extern void _X_EXPORT XvFillColorKey(DrawablePtr pDraw, CARD32 key,
+ RegionPtr region);
extern _X_EXPORT int XvdiSendPortNotify(XvPortPtr, Atom, INT32);
-extern _X_EXPORT int XvdiVideoStopped(XvPortPtr, int);
extern _X_EXPORT int XvdiPutVideo(ClientPtr, DrawablePtr, XvPortPtr, GCPtr,
INT16, INT16, CARD16, CARD16,
@@ -260,7 +256,6 @@ extern _X_EXPORT int XvdiSelectPortNotify(ClientPtr, XvPortPtr, BOOL);
extern _X_EXPORT int XvdiSetPortAttribute(ClientPtr, XvPortPtr, Atom, INT32);
extern _X_EXPORT int XvdiGetPortAttribute(ClientPtr, XvPortPtr, Atom, INT32 *);
extern _X_EXPORT int XvdiStopVideo(ClientPtr, XvPortPtr, DrawablePtr);
-extern _X_EXPORT int XvdiPreemptVideo(ClientPtr, XvPortPtr, DrawablePtr);
extern _X_EXPORT int XvdiMatchPort(XvPortPtr, DrawablePtr);
extern _X_EXPORT int XvdiGrabPort(ClientPtr, XvPortPtr, Time, int *);
extern _X_EXPORT int XvdiUngrabPort(ClientPtr, XvPortPtr, Time);
diff --git a/xorg-server/Xext/xvmain.c b/xorg-server/Xext/xvmain.c
index 9020b2497..607560efa 100644..100755
--- a/xorg-server/Xext/xvmain.c
+++ b/xorg-server/Xext/xvmain.c
@@ -302,8 +302,6 @@ XvCloseScreen(ScreenPtr pScreen)
pScreen->DestroyWindow = pxvs->DestroyWindow;
pScreen->CloseScreen = pxvs->CloseScreen;
- if (pxvs->ddCloseScreen) (*pxvs->ddCloseScreen) (pScreen);
-
free(pxvs);
dixSetPrivate(&pScreen->devPrivates, XvScreenKey, NULL);
@@ -358,7 +356,7 @@ XvDestroyPixmap(PixmapPtr pPix)
if (pp->pDraw == (DrawablePtr) pPix) {
XvdiSendVideoNotify(pp, pp->pDraw, XvPreempted);
- (void) (*pp->pAdaptor->ddStopVideo) (NULL, pp, pp->pDraw);
+ (void) (*pp->pAdaptor->ddStopVideo) (pp, pp->pDraw);
pp->pDraw = NULL;
pp->client = NULL;
@@ -406,7 +404,7 @@ XvDestroyWindow(WindowPtr pWin)
if (pp->pDraw == (DrawablePtr) pWin) {
XvdiSendVideoNotify(pp, pp->pDraw, XvPreempted);
- (void) (*pp->pAdaptor->ddStopVideo) (NULL, pp, pp->pDraw);
+ (void) (*pp->pAdaptor->ddStopVideo) (pp, pp->pDraw);
pp->pDraw = NULL;
pp->client = NULL;
@@ -425,34 +423,10 @@ XvDestroyWindow(WindowPtr pWin)
}
-/* The XvdiVideoStopped procedure is a hook for the device dependent layer.
- It provides a way for the dd layer to inform the di layer that video has
- stopped in a port for reasons that the di layer had no control over; note
- that it doesn't call back into the dd layer */
-
-int
-XvdiVideoStopped(XvPortPtr pPort, int reason)
-{
-
- /* IF PORT ISN'T ACTIVE THEN WE'RE DONE */
-
- if (!pPort->pDraw)
- return Success;
-
- XvdiSendVideoNotify(pPort, pPort->pDraw, reason);
-
- pPort->pDraw = NULL;
- pPort->client = NULL;
- pPort->time = currentTime;
-
- return Success;
-
-}
-
static int
XvdiDestroyPort(void *pPort, XID id)
{
- return (*((XvPortPtr) pPort)->pAdaptor->ddFreePort) (pPort);
+ return Success;
}
static int
@@ -592,7 +566,7 @@ XvdiPutVideo(ClientPtr client,
XvdiSendVideoNotify(pPort, pPort->pDraw, XvPreempted);
}
- (void) (*pPort->pAdaptor->ddPutVideo) (client, pDraw, pPort, pGC,
+ (void) (*pPort->pAdaptor->ddPutVideo) (pDraw, pPort, pGC,
vid_x, vid_y, vid_w, vid_h,
drw_x, drw_y, drw_w, drw_h);
@@ -634,7 +608,7 @@ XvdiPutStill(ClientPtr client,
pPort->time = currentTime;
- status = (*pPort->pAdaptor->ddPutStill) (client, pDraw, pPort, pGC,
+ status = (*pPort->pAdaptor->ddPutStill) (pDraw, pPort, pGC,
vid_x, vid_y, vid_w, vid_h,
drw_x, drw_y, drw_w, drw_h);
@@ -670,7 +644,7 @@ XvdiPutImage(ClientPtr client,
pPort->time = currentTime;
- return (*pPort->pAdaptor->ddPutImage) (client, pDraw, pPort, pGC,
+ return (*pPort->pAdaptor->ddPutImage) (pDraw, pPort, pGC,
src_x, src_y, src_w, src_h,
drw_x, drw_y, drw_w, drw_h,
image, data, sync, width, height);
@@ -709,7 +683,7 @@ XvdiGetVideo(ClientPtr client,
XvdiSendVideoNotify(pPort, pPort->pDraw, XvPreempted);
}
- (void) (*pPort->pAdaptor->ddGetVideo) (client, pDraw, pPort, pGC,
+ (void) (*pPort->pAdaptor->ddGetVideo) (pDraw, pPort, pGC,
vid_x, vid_y, vid_w, vid_h,
drw_x, drw_y, drw_w, drw_h);
@@ -749,7 +723,7 @@ XvdiGetStill(ClientPtr client,
return Success;
}
- status = (*pPort->pAdaptor->ddGetStill) (client, pDraw, pPort, pGC,
+ status = (*pPort->pAdaptor->ddGetStill) (pDraw, pPort, pGC,
vid_x, vid_y, vid_w, vid_h,
drw_x, drw_y, drw_w, drw_h);
@@ -981,29 +955,7 @@ XvdiStopVideo(ClientPtr client, XvPortPtr pPort, DrawablePtr pDraw)
XvdiSendVideoNotify(pPort, pDraw, XvStopped);
- status = (*pPort->pAdaptor->ddStopVideo) (client, pPort, pDraw);
-
- pPort->pDraw = NULL;
- pPort->client = (ClientPtr) client;
- pPort->time = currentTime;
-
- return status;
-
-}
-
-int
-XvdiPreemptVideo(ClientPtr client, XvPortPtr pPort, DrawablePtr pDraw)
-{
- int status;
-
- /* IF PORT ISN'T ACTIVE THEN WE'RE DONE */
-
- if (!pPort->pDraw || (pPort->pDraw != pDraw))
- return Success;
-
- XvdiSendVideoNotify(pPort, pPort->pDraw, XvPreempted);
-
- status = (*pPort->pAdaptor->ddStopVideo) (client, pPort, pPort->pDraw);
+ status = (*pPort->pAdaptor->ddStopVideo) (pPort, pDraw);
pPort->pDraw = NULL;
pPort->client = (ClientPtr) client;
@@ -1046,7 +998,7 @@ XvdiSetPortAttribute(ClientPtr client,
int status;
status =
- (*pPort->pAdaptor->ddSetPortAttribute) (client, pPort, attribute,
+ (*pPort->pAdaptor->ddSetPortAttribute) (pPort, attribute,
value);
if (status == Success)
XvdiSendPortNotify(pPort, attribute, value);
@@ -1060,7 +1012,7 @@ XvdiGetPortAttribute(ClientPtr client,
{
return
- (*pPort->pAdaptor->ddGetPortAttribute) (client, pPort, attribute,
+ (*pPort->pAdaptor->ddGetPortAttribute) (pPort, attribute,
p_value);
}
@@ -1091,3 +1043,77 @@ WriteSwappedPortNotifyEvent(xvEvent * from, xvEvent * to)
cpswapl(from->u.portNotify.value, to->u.portNotify.value);
}
+
+void
+XvFreeAdaptor(XvAdaptorPtr pAdaptor)
+{
+ int i;
+
+ free(pAdaptor->name);
+ pAdaptor->name = NULL;
+
+ if (pAdaptor->pEncodings) {
+ XvEncodingPtr pEncode = pAdaptor->pEncodings;
+
+ for (i = 0; i < pAdaptor->nEncodings; i++, pEncode++)
+ free(pEncode->name);
+ free(pAdaptor->pEncodings);
+ pAdaptor->pEncodings = NULL;
+ }
+
+ free(pAdaptor->pFormats);
+ pAdaptor->pFormats = NULL;
+
+ free(pAdaptor->pPorts);
+ pAdaptor->pPorts = NULL;
+
+ if (pAdaptor->pAttributes) {
+ XvAttributePtr pAttribute = pAdaptor->pAttributes;
+
+ for (i = 0; i < pAdaptor->nAttributes; i++, pAttribute++)
+ free(pAttribute->name);
+ free(pAdaptor->pAttributes);
+ pAdaptor->pAttributes = NULL;
+ }
+
+ free(pAdaptor->pImages);
+ pAdaptor->pImages = NULL;
+
+ free(pAdaptor->devPriv.ptr);
+ pAdaptor->devPriv.ptr = NULL;
+}
+
+void
+XvFillColorKey(DrawablePtr pDraw, CARD32 key, RegionPtr region)
+{
+ ScreenPtr pScreen = pDraw->pScreen;
+ ChangeGCVal pval[2];
+ BoxPtr pbox = RegionRects(region);
+ int i, nbox = RegionNumRects(region);
+ xRectangle *rects;
+ GCPtr gc;
+
+ gc = GetScratchGC(pDraw->depth, pScreen);
+ if (!gc)
+ return;
+
+ pval[0].val = key;
+ pval[1].val = IncludeInferiors;
+ (void) ChangeGC(NullClient, gc, GCForeground | GCSubwindowMode, pval);
+ ValidateGC(pDraw, gc);
+
+ rects = malloc(nbox * sizeof(xRectangle));
+ if (rects) {
+ for (i = 0; i < nbox; i++, pbox++) {
+ rects[i].x = pbox->x1 - pDraw->x;
+ rects[i].y = pbox->y1 - pDraw->y;
+ rects[i].width = pbox->x2 - pbox->x1;
+ rects[i].height = pbox->y2 - pbox->y1;
+ }
+
+ (*gc->ops->PolyFillRect) (pDraw, gc, nbox, rects);
+
+ free(rects);
+ }
+ FreeScratchGC(gc);
+}
diff --git a/xorg-server/dix/devices.c b/xorg-server/dix/devices.c
index 468b5a199..01983d75e 100644
--- a/xorg-server/dix/devices.c
+++ b/xorg-server/dix/devices.c
@@ -2260,7 +2260,7 @@ ProcBell(ClientPtr client)
for (dev = inputInfo.devices; dev; dev = dev->next) {
if ((dev == keybd ||
(!IsMaster(dev) && GetMaster(dev, MASTER_KEYBOARD) == keybd)) &&
- dev->kbdfeed && dev->kbdfeed->BellProc) {
+ ((dev->kbdfeed && dev->kbdfeed->BellProc) || dev->xkb_interest)) {
rc = XaceHook(XACE_DEVICE_ACCESS, client, dev, DixBellAccess);
if (rc != Success)
diff --git a/xorg-server/dix/dispatch.c b/xorg-server/dix/dispatch.c
index 28a54de76..f6ed81302 100644..100755
--- a/xorg-server/dix/dispatch.c
+++ b/xorg-server/dix/dispatch.c
@@ -3232,13 +3232,11 @@ ProcKillClient(ClientPtr client)
rc = dixLookupClient(&killclient, stuff->id, client, DixDestroyAccess);
if (rc == Success) {
CloseDownClient(killclient);
- /* if an LBX proxy gets killed, isItTimeToYield will be set */
- if (isItTimeToYield || (client == killclient)) {
+ if (client == killclient) {
/* force yield and return Success, so that Dispatch()
* doesn't try to touch client
*/
isItTimeToYield = TRUE;
- return Success;
}
return Success;
}
diff --git a/xorg-server/doc/Xserver-spec.xml b/xorg-server/doc/Xserver-spec.xml
index cd1a9d07a..4c344194d 100644
--- a/xorg-server/doc/Xserver-spec.xml
+++ b/xorg-server/doc/Xserver-spec.xml
@@ -1217,11 +1217,9 @@ library is contained in dix/dixfonts.c
<section>
<title>Memory Management</title>
<para>
-Memory management is based on functions in the C runtime library.
-Xalloc(), Xrealloc(), and Xfree() are deprecated aliases for malloc(),
+Memory management is based on functions in the C runtime library, malloc(),
realloc(), and free(), and you should simply call the C library functions
-directly. Consult a C runtime library reference
-manual for more details.
+directly. Consult a C runtime library reference manual for more details.
</para>
<para>
Treat memory allocation carefully in your implementation. Memory
diff --git a/xorg-server/dri3/dri3.h b/xorg-server/dri3/dri3.h
index edc7fa267..7562352ff 100644
--- a/xorg-server/dri3/dri3.h
+++ b/xorg-server/dri3/dri3.h
@@ -23,8 +23,6 @@
#ifndef _DRI3_H_
#define _DRI3_H_
-#include <xorg-server.h>
-
#ifdef DRI3
#include <X11/extensions/dri3proto.h>
diff --git a/xorg-server/glamor/glamor_egl.c b/xorg-server/glamor/glamor_egl.c
index 54af2753e..182e2e8c9 100644
--- a/xorg-server/glamor/glamor_egl.c
+++ b/xorg-server/glamor/glamor_egl.c
@@ -30,7 +30,6 @@
#include "dix-config.h"
#define GLAMOR_FOR_XORG
-#include <xorg-server.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
diff --git a/xorg-server/glamor/glamor_eglmodule.c b/xorg-server/glamor/glamor_eglmodule.c
index d7e183649..dd4664b22 100644
--- a/xorg-server/glamor/glamor_eglmodule.c
+++ b/xorg-server/glamor/glamor_eglmodule.c
@@ -29,7 +29,6 @@
#include "dix-config.h"
-#include <xorg-server.h>
#include <xf86.h>
#define GLAMOR_FOR_XORG
#include <xf86Module.h>
diff --git a/xorg-server/glamor/glamor_priv.h b/xorg-server/glamor/glamor_priv.h
index 57a46873c..385c0279d 100644
--- a/xorg-server/glamor/glamor_priv.h
+++ b/xorg-server/glamor/glamor_priv.h
@@ -29,7 +29,6 @@
#include "dix-config.h"
-#include <xorg-server.h>
#include "glamor.h"
#include "xvdix.h"
diff --git a/xorg-server/glamor/glamor_xv.c b/xorg-server/glamor/glamor_xv.c
index 68a06a413..3f3e064d5 100644
--- a/xorg-server/glamor/glamor_xv.c
+++ b/xorg-server/glamor/glamor_xv.c
@@ -336,6 +336,7 @@ glamor_xv_render(glamor_port_private *port_priv)
GL_FALSE, 2 * sizeof(float), vertices);
glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
+ glEnable(GL_SCISSOR_TEST);
for (i = 0; i < nBox; i++) {
float off_x = box[i].x1 - port_priv->drw_x;
float off_y = box[i].y1 - port_priv->drw_y;
@@ -356,23 +357,25 @@ glamor_xv_render(glamor_port_private *port_priv)
glamor_set_normalize_vcoords(pixmap_priv,
dst_xscale, dst_yscale,
- dstx,
+ dstx - dstw,
dsty,
dstx + dstw,
- dsty + dsth,
+ dsty + dsth * 2,
vertices);
glamor_set_normalize_tcoords(src_pixmap_priv[0],
src_xscale[0],
src_yscale[0],
- srcx,
+ srcx - srcw,
srcy,
srcx + srcw,
- srcy + srch,
+ srcy + srch * 2,
texcoords);
- glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
+ glScissor(dstx, dsty, dstw, dsth);
+ glDrawArrays(GL_TRIANGLE_FAN, 0, 3);
}
+ glDisable(GL_SCISSOR_TEST);
glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
diff --git a/xorg-server/hw/kdrive/Xkdrive.man b/xorg-server/hw/kdrive/Xkdrive.man
index b37f9f10a..c3e2089bc 100644
--- a/xorg-server/hw/kdrive/Xkdrive.man
+++ b/xorg-server/hw/kdrive/Xkdrive.man
@@ -4,10 +4,6 @@
.SH NAME
Xkdrive \- tiny X server
.SH SYNOPSIS
-.B Xvesa
-.RI [ :display ]
-.RI [ option ...]
-
.B Xfbdev
.RI [ :display ]
.RI [ option ...]
@@ -24,9 +20,6 @@ Xserver(1)), all the
.B Xkdrive
servers accept the following options:
.TP 8
-.B -card \fIpcmcia\fP
-use pcmcia card as additional screen.
-.TP 8
.B -dumb
disable hardware acceleration.
.TP 8
diff --git a/xorg-server/hw/kdrive/src/kxv.c b/xorg-server/hw/kdrive/src/kxv.c
index 60a83458c..f979e1fbd 100644
--- a/xorg-server/hw/kdrive/src/kxv.c
+++ b/xorg-server/hw/kdrive/src/kxv.c
@@ -56,46 +56,39 @@ of the copyright holder.
#include "kxv.h"
#include "fourcc.h"
-/* XvScreenRec fields */
-
-static Bool KdXVCloseScreen(ScreenPtr);
-static int KdXVQueryAdaptors(ScreenPtr, XvAdaptorPtr *, int *);
-
/* XvAdaptorRec fields */
-static int KdXVAllocatePort(unsigned long, XvPortPtr, XvPortPtr *);
-static int KdXVFreePort(XvPortPtr);
-static int KdXVPutVideo(ClientPtr, DrawablePtr, XvPortPtr, GCPtr,
+static int KdXVPutVideo(DrawablePtr, XvPortPtr, GCPtr,
INT16, INT16, CARD16, CARD16,
INT16, INT16, CARD16, CARD16);
-static int KdXVPutStill(ClientPtr, DrawablePtr, XvPortPtr, GCPtr,
+static int KdXVPutStill(DrawablePtr, XvPortPtr, GCPtr,
INT16, INT16, CARD16, CARD16,
INT16, INT16, CARD16, CARD16);
-static int KdXVGetVideo(ClientPtr, DrawablePtr, XvPortPtr, GCPtr,
+static int KdXVGetVideo(DrawablePtr, XvPortPtr, GCPtr,
INT16, INT16, CARD16, CARD16,
INT16, INT16, CARD16, CARD16);
-static int KdXVGetStill(ClientPtr, DrawablePtr, XvPortPtr, GCPtr,
+static int KdXVGetStill(DrawablePtr, XvPortPtr, GCPtr,
INT16, INT16, CARD16, CARD16,
INT16, INT16, CARD16, CARD16);
-static int KdXVStopVideo(ClientPtr, XvPortPtr, DrawablePtr);
-static int KdXVSetPortAttribute(ClientPtr, XvPortPtr, Atom, INT32);
-static int KdXVGetPortAttribute(ClientPtr, XvPortPtr, Atom, INT32 *);
-static int KdXVQueryBestSize(ClientPtr, XvPortPtr, CARD8,
+static int KdXVStopVideo(XvPortPtr, DrawablePtr);
+static int KdXVSetPortAttribute(XvPortPtr, Atom, INT32);
+static int KdXVGetPortAttribute(XvPortPtr, Atom, INT32 *);
+static int KdXVQueryBestSize(XvPortPtr, CARD8,
CARD16, CARD16, CARD16, CARD16,
unsigned int *, unsigned int *);
-static int KdXVPutImage(ClientPtr, DrawablePtr, XvPortPtr, GCPtr,
+static int KdXVPutImage(DrawablePtr, XvPortPtr, GCPtr,
INT16, INT16, CARD16, CARD16,
INT16, INT16, CARD16, CARD16,
XvImagePtr, unsigned char *, Bool, CARD16, CARD16);
-static int KdXVQueryImageAttributes(ClientPtr, XvPortPtr, XvImagePtr,
+static int KdXVQueryImageAttributes(XvPortPtr, XvImagePtr,
CARD16 *, CARD16 *, int *, int *);
/* ScreenRec fields */
-static Bool KdXVCreateWindow(WindowPtr pWin);
static Bool KdXVDestroyWindow(WindowPtr pWin);
static void KdXVWindowExposures(WindowPtr pWin, RegionPtr r1, RegionPtr r2);
static void KdXVClipNotify(WindowPtr pWin, int dx, int dy);
+static Bool KdXVCloseScreen(ScreenPtr);
/* misc */
static Bool KdXVInitAdaptors(ScreenPtr, KdVideoAdaptorPtr, int);
@@ -104,6 +97,7 @@ static DevPrivateKeyRec KdXVWindowKeyRec;
#define KdXVWindowKey (&KdXVWindowKeyRec)
static DevPrivateKey KdXvScreenKey;
+static DevPrivateKeyRec KdXVScreenPrivateKey;
static unsigned long KdXVGeneration = 0;
static unsigned long PortResource = 0;
@@ -111,7 +105,7 @@ static unsigned long PortResource = 0;
dixLookupPrivate(&(pScreen)->devPrivates, KdXvScreenKey))
#define GET_KDXV_SCREEN(pScreen) \
- ((KdXVScreenPtr)(GET_XV_SCREEN(pScreen)->devPriv.ptr))
+ ((KdXVScreenPtr)(dixGetPrivate(&pScreen->devPrivates, &KdXVScreenPrivateKey)))
#define GET_KDXV_WINDOW(pWin) ((KdXVWindowPtr) \
dixLookupPrivate(&(pWin)->devPrivates, KdXVWindowKey))
@@ -132,7 +126,6 @@ Bool
KdXVScreenInit(ScreenPtr pScreen, KdVideoAdaptorPtr adaptors, int num)
{
KdXVScreenPtr ScreenPriv;
- XvScreenPtr pxvs;
/* fprintf(stderr,"KdXVScreenInit initializing %d adaptors\n",num); */
@@ -144,6 +137,8 @@ KdXVScreenInit(ScreenPtr pScreen, KdVideoAdaptorPtr adaptors, int num)
if (!dixRegisterPrivateKey(&KdXVWindowKeyRec, PRIVATE_WINDOW, 0))
return FALSE;
+ if (!dixRegisterPrivateKey(&KdXVScreenPrivateKey, PRIVATE_SCREEN, 0))
+ return FALSE;
if (Success != XvScreenInit(pScreen))
return FALSE;
@@ -151,36 +146,23 @@ KdXVScreenInit(ScreenPtr pScreen, KdVideoAdaptorPtr adaptors, int num)
KdXvScreenKey = XvGetScreenKey();
PortResource = XvGetRTPort();
- pxvs = GET_XV_SCREEN(pScreen);
-
- /* Anyone initializing the Xv layer must provide these two.
- The Xv di layer calls them without even checking if they exist! */
-
- pxvs->ddCloseScreen = KdXVCloseScreen;
- pxvs->ddQueryAdaptors = KdXVQueryAdaptors;
-
- /* The Xv di layer provides us with a private hook so that we don't
- have to allocate our own screen private. They also provide
- a CloseScreen hook so that we don't have to wrap it. I'm not
- sure that I appreciate that. */
-
ScreenPriv = malloc(sizeof(KdXVScreenRec));
- pxvs->devPriv.ptr = (void *) ScreenPriv;
+ dixSetPrivate(&pScreen->devPrivates, &KdXVScreenPrivateKey, ScreenPriv);
if (!ScreenPriv)
return FALSE;
- ScreenPriv->CreateWindow = pScreen->CreateWindow;
ScreenPriv->DestroyWindow = pScreen->DestroyWindow;
ScreenPriv->WindowExposures = pScreen->WindowExposures;
ScreenPriv->ClipNotify = pScreen->ClipNotify;
+ ScreenPriv->CloseScreen = pScreen->CloseScreen;
/* fprintf(stderr,"XV: Wrapping screen funcs\n"); */
- pScreen->CreateWindow = KdXVCreateWindow;
pScreen->DestroyWindow = KdXVDestroyWindow;
pScreen->WindowExposures = KdXVWindowExposures;
pScreen->ClipNotify = KdXVClipNotify;
+ pScreen->CloseScreen = KdXVCloseScreen;
if (!KdXVInitAdaptors(pScreen, adaptors, num))
return FALSE;
@@ -193,19 +175,6 @@ KdXVFreeAdaptor(XvAdaptorPtr pAdaptor)
{
int i;
- free(pAdaptor->name);
-
- if (pAdaptor->pEncodings) {
- XvEncodingPtr pEncode = pAdaptor->pEncodings;
-
- for (i = 0; i < pAdaptor->nEncodings; i++, pEncode++) {
- free(pEncode->name);
- }
- free(pAdaptor->pEncodings);
- }
-
- free(pAdaptor->pFormats);
-
if (pAdaptor->pPorts) {
XvPortPtr pPort = pAdaptor->pPorts;
XvPortRecPrivatePtr pPriv;
@@ -220,22 +189,9 @@ KdXVFreeAdaptor(XvAdaptorPtr pAdaptor)
free(pPriv);
}
}
- free(pAdaptor->pPorts);
}
- if (pAdaptor->nAttributes) {
- XvAttributePtr pAttribute = pAdaptor->pAttributes;
-
- for (i = 0; i < pAdaptor->nAttributes; i++, pAttribute++) {
- free(pAttribute->name);
- }
-
- free(pAdaptor->pAttributes);
- }
-
- free(pAdaptor->pImages);
-
- free(pAdaptor->devPriv.ptr);
+ XvFreeAdaptor(pAdaptor);
}
static Bool
@@ -302,8 +258,6 @@ KdXVInitAdaptors(ScreenPtr pScreen, KdVideoAdaptorPtr infoPtr, int number)
continue;
pa->pScreen = pScreen;
- pa->ddAllocatePort = KdXVAllocatePort;
- pa->ddFreePort = KdXVFreePort;
pa->ddPutVideo = KdXVPutVideo;
pa->ddPutStill = KdXVPutStill;
pa->ddGetVideo = KdXVGetVideo;
@@ -588,10 +542,6 @@ KdXVRegetVideo(XvPortRecPrivatePtr portPriv)
goto CLIP_VIDEO_BAILOUT;
}
- if (portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
- RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
- }
-
ret = (*portPriv->AdaptorRec->GetVideo) (portPriv->screen, portPriv->pDraw,
portPriv->vid_x, portPriv->vid_y,
WinBox.x1, WinBox.y1,
@@ -668,22 +618,6 @@ KdXVReputVideo(XvPortRecPrivatePtr portPriv)
goto CLIP_VIDEO_BAILOUT;
}
- /* bailout if we have to clip but the hardware doesn't support it */
- if (portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) {
- BoxPtr clipBox = RegionRects(&ClipRegion);
-
- if ((RegionNumRects(&ClipRegion) != 1) ||
- (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
- (clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2)) {
- clippedAway = TRUE;
- goto CLIP_VIDEO_BAILOUT;
- }
- }
-
- if (portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
- RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
- }
-
ret = (*portPriv->AdaptorRec->PutVideo) (portPriv->screen, portPriv->pDraw,
portPriv->vid_x, portPriv->vid_y,
WinBox.x1, WinBox.y1,
@@ -760,22 +694,6 @@ KdXVReputImage(XvPortRecPrivatePtr portPriv)
goto CLIP_VIDEO_BAILOUT;
}
- /* bailout if we have to clip but the hardware doesn't support it */
- if (portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) {
- BoxPtr clipBox = RegionRects(&ClipRegion);
-
- if ((RegionNumRects(&ClipRegion) != 1) ||
- (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
- (clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2)) {
- clippedAway = TRUE;
- goto CLIP_VIDEO_BAILOUT;
- }
- }
-
- if (portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
- RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
- }
-
ret =
(*portPriv->AdaptorRec->ReputImage) (portPriv->screen, portPriv->pDraw,
WinBox.x1, WinBox.y1, &ClipRegion,
@@ -872,23 +790,6 @@ KdXVRemovePortFromWindow(WindowPtr pWin, XvPortRecPrivatePtr portPriv)
/**** ScreenRec fields ****/
static Bool
-KdXVCreateWindow(WindowPtr pWin)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- KdXVScreenPtr ScreenPriv = GET_KDXV_SCREEN(pScreen);
- int ret;
-
- pScreen->CreateWindow = ScreenPriv->CreateWindow;
- ret = (*pScreen->CreateWindow) (pWin);
- pScreen->CreateWindow = KdXVCreateWindow;
-
- if (ret)
- dixSetPrivate(&pWin->devPrivates, KdXVWindowKey, NULL);
-
- return ret;
-}
-
-static Bool
KdXVDestroyWindow(WindowPtr pWin)
{
ScreenPtr pScreen = pWin->drawable.pScreen;
@@ -1052,10 +953,10 @@ KdXVCloseScreen(ScreenPtr pScreen)
if (!ScreenPriv)
return TRUE;
- pScreen->CreateWindow = ScreenPriv->CreateWindow;
pScreen->DestroyWindow = ScreenPriv->DestroyWindow;
pScreen->WindowExposures = ScreenPriv->WindowExposures;
pScreen->ClipNotify = ScreenPriv->ClipNotify;
+ pScreen->CloseScreen = ScreenPriv->CloseScreen;
/* fprintf(stderr,"XV: Unwrapping screen funcs\n"); */
@@ -1066,19 +967,7 @@ KdXVCloseScreen(ScreenPtr pScreen)
free(pxvs->pAdaptors);
free(ScreenPriv);
- return TRUE;
-}
-
-static int
-KdXVQueryAdaptors(ScreenPtr pScreen,
- XvAdaptorPtr * p_pAdaptors, int *p_nAdaptors)
-{
- XvScreenPtr pxvs = GET_XV_SCREEN(pScreen);
-
- *p_nAdaptors = pxvs->nAdaptors;
- *p_pAdaptors = pxvs->pAdaptors;
-
- return Success;
+ return pScreen->CloseScreen(pScreen);
}
static Bool
@@ -1139,21 +1028,7 @@ KdXVDisable(ScreenPtr pScreen)
/**** XvAdaptorRec fields ****/
static int
-KdXVAllocatePort(unsigned long port, XvPortPtr pPort, XvPortPtr * ppPort)
-{
- *ppPort = pPort;
- return Success;
-}
-
-static int
-KdXVFreePort(XvPortPtr pPort)
-{
- return Success;
-}
-
-static int
-KdXVPutVideo(ClientPtr client,
- DrawablePtr pDraw,
+KdXVPutVideo(DrawablePtr pDraw,
XvPortPtr pPort,
GCPtr pGC,
INT16 vid_x, INT16 vid_y,
@@ -1206,8 +1081,7 @@ KdXVPutVideo(ClientPtr client,
}
static int
-KdXVPutStill(ClientPtr client,
- DrawablePtr pDraw,
+KdXVPutStill(DrawablePtr pDraw,
XvPortPtr pPort,
GCPtr pGC,
INT16 vid_x, INT16 vid_y,
@@ -1263,21 +1137,6 @@ KdXVPutStill(ClientPtr client,
goto PUT_STILL_BAILOUT;
}
- if (portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) {
- BoxPtr clipBox = RegionRects(&ClipRegion);
-
- if ((RegionNumRects(&ClipRegion) != 1) ||
- (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
- (clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2)) {
- clippedAway = TRUE;
- goto PUT_STILL_BAILOUT;
- }
- }
-
- if (portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
- RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
- }
-
ret = (*portPriv->AdaptorRec->PutStill) (portPriv->screen, pDraw,
vid_x, vid_y, WinBox.x1, WinBox.y1,
vid_w, vid_h, drw_w, drw_h,
@@ -1314,8 +1173,7 @@ KdXVPutStill(ClientPtr client,
}
static int
-KdXVGetVideo(ClientPtr client,
- DrawablePtr pDraw,
+KdXVGetVideo(DrawablePtr pDraw,
XvPortPtr pPort,
GCPtr pGC,
INT16 vid_x, INT16 vid_y,
@@ -1368,8 +1226,7 @@ KdXVGetVideo(ClientPtr client,
}
static int
-KdXVGetStill(ClientPtr client,
- DrawablePtr pDraw,
+KdXVGetStill(DrawablePtr pDraw,
XvPortPtr pPort,
GCPtr pGC,
INT16 vid_x, INT16 vid_y,
@@ -1410,10 +1267,6 @@ KdXVGetStill(ClientPtr client,
goto GET_STILL_BAILOUT;
}
- if (portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
- RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
- }
-
ret = (*portPriv->AdaptorRec->GetStill) (portPriv->screen, pDraw,
vid_x, vid_y, WinBox.x1, WinBox.y1,
vid_w, vid_h, drw_w, drw_h,
@@ -1435,7 +1288,7 @@ KdXVGetStill(ClientPtr client,
}
static int
-KdXVStopVideo(ClientPtr client, XvPortPtr pPort, DrawablePtr pDraw)
+KdXVStopVideo(XvPortPtr pPort, DrawablePtr pDraw)
{
XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr) (pPort->devPriv.ptr);
@@ -1461,8 +1314,7 @@ KdXVStopVideo(ClientPtr client, XvPortPtr pPort, DrawablePtr pDraw)
}
static int
-KdXVSetPortAttribute(ClientPtr client,
- XvPortPtr pPort, Atom attribute, INT32 value)
+KdXVSetPortAttribute(XvPortPtr pPort, Atom attribute, INT32 value)
{
XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr) (pPort->devPriv.ptr);
@@ -1472,8 +1324,7 @@ KdXVSetPortAttribute(ClientPtr client,
}
static int
-KdXVGetPortAttribute(ClientPtr client,
- XvPortPtr pPort, Atom attribute, INT32 *p_value)
+KdXVGetPortAttribute(XvPortPtr pPort, Atom attribute, INT32 *p_value)
{
XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr) (pPort->devPriv.ptr);
@@ -1484,8 +1335,7 @@ KdXVGetPortAttribute(ClientPtr client,
}
static int
-KdXVQueryBestSize(ClientPtr client,
- XvPortPtr pPort,
+KdXVQueryBestSize(XvPortPtr pPort,
CARD8 motion,
CARD16 vid_w, CARD16 vid_h,
CARD16 drw_w, CARD16 drw_h,
@@ -1502,8 +1352,7 @@ KdXVQueryBestSize(ClientPtr client,
}
static int
-KdXVPutImage(ClientPtr client,
- DrawablePtr pDraw,
+KdXVPutImage(DrawablePtr pDraw,
XvPortPtr pPort,
GCPtr pGC,
INT16 src_x, INT16 src_y,
@@ -1561,21 +1410,6 @@ KdXVPutImage(ClientPtr client,
goto PUT_IMAGE_BAILOUT;
}
- if (portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) {
- BoxPtr clipBox = RegionRects(&ClipRegion);
-
- if ((RegionNumRects(&ClipRegion) != 1) ||
- (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
- (clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2)) {
- clippedAway = TRUE;
- goto PUT_IMAGE_BAILOUT;
- }
- }
-
- if (portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
- RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
- }
-
ret = (*portPriv->AdaptorRec->PutImage) (portPriv->screen, pDraw,
src_x, src_y, WinBox.x1, WinBox.y1,
src_w, src_h, drw_w, drw_h,
@@ -1613,8 +1447,7 @@ KdXVPutImage(ClientPtr client,
}
static int
-KdXVQueryImageAttributes(ClientPtr client,
- XvPortPtr pPort,
+KdXVQueryImageAttributes(XvPortPtr pPort,
XvImagePtr format,
CARD16 *width,
CARD16 *height, int *pitches, int *offsets)
@@ -1770,44 +1603,3 @@ KdXVCopyPlanarData(KdScreenInfo * screen, CARD8 *src, CARD8 *dst, int randr,
}
}
}
-
-void
-KXVPaintRegion(DrawablePtr pDraw, RegionPtr pRgn, Pixel fg)
-{
- GCPtr pGC;
- ChangeGCVal val[2];
- xRectangle *rects, *r;
- BoxPtr pBox = RegionRects(pRgn);
- int nBox = RegionNumRects(pRgn);
-
- rects = malloc(nBox * sizeof(xRectangle));
- if (!rects)
- goto bail0;
- r = rects;
- while (nBox--) {
- r->x = pBox->x1 - pDraw->x;
- r->y = pBox->y1 - pDraw->y;
- r->width = pBox->x2 - pBox->x1;
- r->height = pBox->y2 - pBox->y1;
- r++;
- pBox++;
- }
-
- pGC = GetScratchGC(pDraw->depth, pDraw->pScreen);
- if (!pGC)
- goto bail1;
-
- val[0].val = fg;
- val[1].val = IncludeInferiors;
- ChangeGC(NullClient, pGC, GCForeground | GCSubwindowMode, val);
-
- ValidateGC(pDraw, pGC);
-
- (*pGC->ops->PolyFillRect) (pDraw, pGC, RegionNumRects(pRgn), rects);
-
- FreeScratchGC(pGC);
- bail1:
- free(rects);
- bail0:
- ;
-}
diff --git a/xorg-server/hw/kdrive/src/kxv.h b/xorg-server/hw/kdrive/src/kxv.h
index 3a49a659f..b99729922 100644
--- a/xorg-server/hw/kdrive/src/kxv.h
+++ b/xorg-server/hw/kdrive/src/kxv.h
@@ -50,21 +50,10 @@ of the copyright holder.
#include "../../Xext/xvdix.h"
-#define VIDEO_NO_CLIPPING 0x00000001
-#define VIDEO_INVERT_CLIPLIST 0x00000002
#define VIDEO_OVERLAID_IMAGES 0x00000004
#define VIDEO_OVERLAID_STILLS 0x00000008
#define VIDEO_CLIP_TO_VIEWPORT 0x00000010
-typedef struct {
- KdScreenInfo *screen;
- int id;
- unsigned short width, height;
- int *pitches; /* bytes */
- int *offsets; /* in bytes from start of framebuffer */
- DevUnion devPrivate;
-} KdSurfaceRec, *KdSurfacePtr;
-
typedef int (*PutVideoFuncPtr) (KdScreenInfo * screen, DrawablePtr pDraw,
short vid_x, short vid_y, short drw_x,
short drw_y, short vid_w, short vid_h,
@@ -172,9 +161,6 @@ KdXVCopyPlanarData(KdScreenInfo * screen, CARD8 *src, CARD8 *dst, int randr,
int srcH, int height, int top, int left, int h, int w,
int id);
-void
- KXVPaintRegion(DrawablePtr pDraw, RegionPtr pRgn, Pixel fg);
-
KdVideoAdaptorPtr KdXVAllocateVideoAdaptorRec(KdScreenInfo * screen);
void KdXVFreeVideoAdaptorRec(KdVideoAdaptorPtr ptr);
@@ -186,10 +172,10 @@ void KdXVDisable(ScreenPtr);
/*** These are DDX layer privates ***/
typedef struct {
- CreateWindowProcPtr CreateWindow;
DestroyWindowProcPtr DestroyWindow;
ClipNotifyProcPtr ClipNotify;
WindowExposuresProcPtr WindowExposures;
+ CloseScreenProcPtr CloseScreen;
} KdXVScreenRec, *KdXVScreenPtr;
typedef struct {
diff --git a/xorg-server/hw/xfree86/common/compiler.h b/xorg-server/hw/xfree86/common/compiler.h
index a44afacde..4cb127745 100644..100755
--- a/xorg-server/hw/xfree86/common/compiler.h
+++ b/xorg-server/hw/xfree86/common/compiler.h
@@ -79,8 +79,6 @@
#ifndef __inline__
#if defined(__GNUC__)
/* gcc has __inline__ */
-#elif defined(__HIGHC__)
-#define __inline__ _Inline
#else
#define __inline__ /**/
#endif
@@ -88,8 +86,6 @@
#ifndef __inline
#if defined(__GNUC__) || defined(_MSC_VER)
/* gcc has __inline */
-#elif defined(__HIGHC__)
-#define __inline _Inline
#else
#define __inline /**/
#endif
@@ -98,9 +94,10 @@
#if !defined(__GNUC__) && !defined(__FUNCTION__)
#define __FUNCTION__ __func__ /* C99 */
#endif
-#if defined(NO_INLINE) || defined(DO_PROTOTYPES)
+
+#if defined(DO_PROTOTYPES)
#if !defined(__arm__)
-#if !defined(__sparc__) && !defined(__sparc) && !defined(__arm32__) && !defined(__nds32__) \
+#if !defined(__sparc__) && !defined(__arm32__) && !defined(__nds32__) \
&& !(defined(__alpha__) && defined(linux)) \
&& !(defined(__ia64__) && defined(linux)) \
&& !(defined(__mips64) && defined(linux)) \
@@ -131,33 +128,12 @@ extern _X_EXPORT void xf86WriteMmio16Be (void *, unsigned long, unsigned int);
extern _X_EXPORT void xf86WriteMmio16Le (void *, unsigned long, unsigned int);
extern _X_EXPORT void xf86WriteMmio32Be (void *, unsigned long, unsigned int);
extern _X_EXPORT void xf86WriteMmio32Le (void *, unsigned long, unsigned int);
-extern _X_EXPORT void xf86WriteMmio8NB (void *, unsigned long, unsigned int);
-extern _X_EXPORT void xf86WriteMmio16BeNB (void *, unsigned long, unsigned int);
-extern _X_EXPORT void xf86WriteMmio16LeNB (void *, unsigned long, unsigned int);
-extern _X_EXPORT void xf86WriteMmio32BeNB (void *, unsigned long, unsigned int);
-extern _X_EXPORT void xf86WriteMmio32LeNB (void *, unsigned long, unsigned int);
#endif /* _SUNPRO_C */
#endif /* __sparc__, __arm32__, __alpha__, __nds32__ */
#endif /* __arm__ */
-#if defined(__powerpc__) && !defined(__OpenBSD__)
-extern unsigned long ldq_u(unsigned long *);
-extern unsigned long ldl_u(unsigned int *);
-extern unsigned long ldw_u(unsigned short *);
-extern void stq_u(unsigned long, unsigned long *);
-extern void stl_u(unsigned long, unsigned int *);
-extern void stw_u(unsigned long, unsigned short *);
-extern void mem_barrier(void);
-extern void write_mem_barrier(void);
-extern void stl_brx(unsigned long, volatile unsigned char *, int);
-extern void stw_brx(unsigned short, volatile unsigned char *, int);
-extern unsigned long ldl_brx(volatile unsigned char *, int);
-extern unsigned short ldw_brx(volatile unsigned char *, int);
-#endif /* __powerpc__ && !__OpenBSD */
-
#endif /* NO_INLINE || DO_PROTOTYPES */
-#ifndef NO_INLINE
#ifdef __GNUC__
#ifdef __i386__
@@ -210,14 +186,7 @@ extern unsigned short ldw_brx(volatile unsigned char *, int);
#elif defined __powerpc__
-#if defined(linux) && defined(__powerpc64__)
-#include <linux/version.h>
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)
-#include <asm/memory.h>
-#endif
-#endif /* defined(linux) && defined(__powerpc64__) */
-
-#ifndef eieio /* We deal with arch-specific eieio() routines above... */
+#ifndef eieio
#define eieio() __asm__ __volatile__ ("eieio" ::: "memory")
#endif /* eieio */
#define mem_barrier() eieio()
@@ -230,7 +199,10 @@ extern unsigned short ldw_brx(volatile unsigned char *, int);
#define write_mem_barrier() /* XXX: nop for now */
#endif
#endif /* __GNUC__ */
-#endif /* NO_INLINE */
+
+#ifndef barrier
+#define barrier()
+#endif
#ifndef mem_barrier
#define mem_barrier() /* NOP */
@@ -240,133 +212,8 @@ extern unsigned short ldw_brx(volatile unsigned char *, int);
#define write_mem_barrier() /* NOP */
#endif
-#ifndef NO_INLINE
-#ifdef __GNUC__
-
-/* Define some packed structures to use with unaligned accesses */
-
-struct __una_u64 {
- uint64_t x __attribute__ ((packed));
-};
-struct __una_u32 {
- uint32_t x __attribute__ ((packed));
-};
-struct __una_u16 {
- uint16_t x __attribute__ ((packed));
-};
-
-/* Elemental unaligned loads */
-
-static __inline__ uint64_t
-ldq_u(uint64_t * p)
-{
- const struct __una_u64 *ptr = (const struct __una_u64 *) p;
-
- return ptr->x;
-}
-
-static __inline__ uint32_t
-ldl_u(uint32_t * p)
-{
- const struct __una_u32 *ptr = (const struct __una_u32 *) p;
-
- return ptr->x;
-}
-
-static __inline__ uint16_t
-ldw_u(uint16_t * p)
-{
- const struct __una_u16 *ptr = (const struct __una_u16 *) p;
-
- return ptr->x;
-}
-
-/* Elemental unaligned stores */
-
-static __inline__ void
-stq_u(uint64_t val, uint64_t * p)
-{
- struct __una_u64 *ptr = (struct __una_u64 *) p;
-
- ptr->x = val;
-}
-
-static __inline__ void
-stl_u(uint32_t val, uint32_t * p)
-{
- struct __una_u32 *ptr = (struct __una_u32 *) p;
-
- ptr->x = val;
-}
-
-static __inline__ void
-stw_u(uint16_t val, uint16_t * p)
-{
- struct __una_u16 *ptr = (struct __una_u16 *) p;
-
- ptr->x = val;
-}
-#else /* !__GNUC__ */
-
-#include <string.h> /* needed for memmove */
-
-static __inline__ uint64_t
-ldq_u(uint64_t * p)
-{
- uint64_t ret;
-
- memmove(&ret, p, sizeof(*p));
- return ret;
-}
-
-static __inline__ uint32_t
-ldl_u(uint32_t * p)
-{
- uint32_t ret;
-
- memmove(&ret, p, sizeof(*p));
- return ret;
-}
-
-static __inline__ uint16_t
-ldw_u(uint16_t * p)
-{
- uint16_t ret;
-
- memmove(&ret, p, sizeof(*p));
- return ret;
-}
-
-static __inline__ void
-stq_u(uint64_t val, uint64_t * p)
-{
- uint64_t tmp = val;
-
- memmove(p, &tmp, sizeof(*p));
-}
-
-static __inline__ void
-stl_u(uint32_t val, uint32_t * p)
-{
- uint32_t tmp = val;
-
- memmove(p, &tmp, sizeof(*p));
-}
-
-static __inline__ void
-stw_u(uint16_t val, uint16_t * p)
-{
- uint16_t tmp = val;
-
- memmove(p, &tmp, sizeof(*p));
-}
-
-#endif /* __GNUC__ */
-#endif /* NO_INLINE */
-
-#ifndef NO_INLINE
#ifdef __GNUC__
-#if (defined(linux) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)) && (defined(__alpha__))
+#if defined(__alpha__)
#ifdef linux
/* for Linux on Alpha, we use the LIBC _inx/_outx routines */
@@ -439,7 +286,7 @@ extern _X_EXPORT unsigned int inl(unsigned int port);
#include <machine/pio.h>
#endif /* __NetBSD__ */
-#elif (defined(linux) || defined(__FreeBSD__)) && defined(__amd64__)
+#elif defined(__amd64__)
#include <inttypes.h>
@@ -488,7 +335,7 @@ inl(unsigned short port)
return ret;
}
-#elif (defined(linux) || defined(sun) || defined(__OpenBSD__) || defined(__FreeBSD__)) && defined(__sparc__)
+#elif defined(__sparc__)
#ifndef ASI_PL
#define ASI_PL 0x88
@@ -671,56 +518,6 @@ xf86WriteMmio32Le(__volatile__ void *base, const unsigned long offset,
barrier();
}
-static __inline__ void
-xf86WriteMmio8NB(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- unsigned long addr = ((unsigned long) base) + offset;
-
- __asm__ __volatile__("stba %0, [%1] %2": /* No outputs */
- :"r"(val), "r"(addr), "i"(ASI_PL));
-}
-
-static __inline__ void
-xf86WriteMmio16BeNB(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- unsigned long addr = ((unsigned long) base) + offset;
-
- __asm__ __volatile__("sth %0, [%1]": /* No outputs */
- :"r"(val), "r"(addr));
-}
-
-static __inline__ void
-xf86WriteMmio16LeNB(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- unsigned long addr = ((unsigned long) base) + offset;
-
- __asm__ __volatile__("stha %0, [%1] %2": /* No outputs */
- :"r"(val), "r"(addr), "i"(ASI_PL));
-}
-
-static __inline__ void
-xf86WriteMmio32BeNB(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- unsigned long addr = ((unsigned long) base) + offset;
-
- __asm__ __volatile__("st %0, [%1]": /* No outputs */
- :"r"(val), "r"(addr));
-}
-
-static __inline__ void
-xf86WriteMmio32LeNB(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- unsigned long addr = ((unsigned long) base) + offset;
-
- __asm__ __volatile__("sta %0, [%1] %2": /* No outputs */
- :"r"(val), "r"(addr), "i"(ASI_PL));
-}
-
#elif defined(__mips__) || (defined(__arm32__) && !defined(__linux__))
#if defined(__arm32__) || defined(__mips64)
#define PORT_SIZE long
@@ -800,7 +597,7 @@ xf86WriteMmio32Be(__volatile__ void *base, const unsigned long offset,
#endif /* !linux */
#endif /* __mips__ */
-#elif (defined(linux) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__)) && defined(__powerpc__)
+#elif defined(__powerpc__)
#ifndef MAP_FAILED
#define MAP_FAILED ((void *)-1)
@@ -859,92 +656,57 @@ xf86ReadMmio32Le(__volatile__ void *base, const unsigned long offset)
}
static __inline__ void
-xf86WriteMmioNB8(__volatile__ void *base, const unsigned long offset,
- const unsigned char val)
+xf86WriteMmio8(__volatile__ void *base, const unsigned long offset,
+ const unsigned char val)
{
__asm__
__volatile__("stbx %1,%2,%3\n\t":"=m"
(*((volatile unsigned char *) base + offset))
:"r"(val), "b"(base), "r"(offset));
+ eieio();
}
static __inline__ void
-xf86WriteMmioNB16Le(__volatile__ void *base, const unsigned long offset,
- const unsigned short val)
+xf86WriteMmio16Le(__volatile__ void *base, const unsigned long offset,
+ const unsigned short val)
{
__asm__
__volatile__("sthbrx %1,%2,%3\n\t":"=m"
(*((volatile unsigned char *) base + offset))
:"r"(val), "b"(base), "r"(offset));
+ eieio();
}
static __inline__ void
-xf86WriteMmioNB16Be(__volatile__ void *base, const unsigned long offset,
- const unsigned short val)
+xf86WriteMmio16Be(__volatile__ void *base, const unsigned long offset,
+ const unsigned short val)
{
__asm__
__volatile__("sthx %1,%2,%3\n\t":"=m"
(*((volatile unsigned char *) base + offset))
:"r"(val), "b"(base), "r"(offset));
+ eieio();
}
static __inline__ void
-xf86WriteMmioNB32Le(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
+xf86WriteMmio32Le(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
{
__asm__
__volatile__("stwbrx %1,%2,%3\n\t":"=m"
(*((volatile unsigned char *) base + offset))
:"r"(val), "b"(base), "r"(offset));
+ eieio();
}
static __inline__ void
-xf86WriteMmioNB32Be(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
+xf86WriteMmio32Be(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
{
__asm__
__volatile__("stwx %1,%2,%3\n\t":"=m"
(*((volatile unsigned char *) base + offset))
:"r"(val), "b"(base), "r"(offset));
-}
-
-static __inline__ void
-xf86WriteMmio8(__volatile__ void *base, const unsigned long offset,
- const unsigned char val)
-{
- xf86WriteMmioNB8(base, offset, val);
- eieio();
-}
-
-static __inline__ void
-xf86WriteMmio16Le(__volatile__ void *base, const unsigned long offset,
- const unsigned short val)
-{
- xf86WriteMmioNB16Le(base, offset, val);
- eieio();
-}
-
-static __inline__ void
-xf86WriteMmio16Be(__volatile__ void *base, const unsigned long offset,
- const unsigned short val)
-{
- xf86WriteMmioNB16Be(base, offset, val);
- eieio();
-}
-
-static __inline__ void
-xf86WriteMmio32Le(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- xf86WriteMmioNB32Le(base, offset, val);
- eieio();
-}
-
-static __inline__ void
-xf86WriteMmio32Be(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- xf86WriteMmioNB32Be(base, offset, val);
eieio();
}
@@ -1030,12 +792,9 @@ xf_outl(unsigned short port, unsigned int val)
/*
* Assume all port access are aligned. We need to revise this implementation
- * if there is unaligned port access. For ldq_u, ldl_u, ldw_u, stq_u, stl_u and
- * stw_u, they are assumed unaligned.
+ * if there is unaligned port access.
*/
-#define barrier() /* no barrier */
-
#define PORT_SIZE long
static __inline__ unsigned char
@@ -1052,13 +811,6 @@ xf86WriteMmio8(__volatile__ void *base, const unsigned long offset,
barrier();
}
-static __inline__ void
-xf86WriteMmio8NB(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- *(volatile unsigned char *) ((unsigned char *) base + offset) = val;
-}
-
static __inline__ unsigned short
xf86ReadMmio16Swap(__volatile__ void *base, const unsigned long offset)
{
@@ -1097,23 +849,6 @@ xf86WriteMmio16(__volatile__ void *base, const unsigned long offset,
barrier();
}
-static __inline__ void
-xf86WriteMmio16SwapNB(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- unsigned long addr = ((unsigned long) base) + offset;
-
- __asm__ __volatile__("wsbh %0, %0;\n\t" "shi %0, [%1];\n\t": /* No outputs */
- :"r"(val), "r"(addr));
-}
-
-static __inline__ void
-xf86WriteMmio16NB(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- *(volatile unsigned short *) ((unsigned char *) base + offset) = val;
-}
-
static __inline__ unsigned int
xf86ReadMmio32Swap(__volatile__ void *base, const unsigned long offset)
{
@@ -1153,23 +888,6 @@ xf86WriteMmio32(__volatile__ void *base, const unsigned long offset,
barrier();
}
-static __inline__ void
-xf86WriteMmio32SwapNB(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- unsigned long addr = ((unsigned long) base) + offset;
-
- __asm__ __volatile__("wsbh %0, %0;\n\t" "rotri %0, %0, 16;\n\t" "swi %0, [%1];\n\t": /* No outputs */
- :"r"(val), "r"(addr));
-}
-
-static __inline__ void
-xf86WriteMmio32NB(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- *(volatile unsigned int *) ((unsigned char *) base + offset) = val;
-}
-
#if defined(NDS32_MMIO_SWAP)
static __inline__ void
outb(unsigned PORT_SIZE port, unsigned char val)
@@ -1207,50 +925,6 @@ inl(unsigned PORT_SIZE port)
return xf86ReadMmio32Swap(IOPortBase, port);
}
-static __inline__ unsigned long
-ldq_u(unsigned long *p)
-{
- unsigned long addr = (unsigned long) p;
- unsigned int ret;
-
- __asm__ __volatile__("lmw.bi %0, [%1], %0, 0;\n\t"
- "wsbh %0, %0;\n\t" "rotri %0, %0, 16;\n\t":"=r"(ret)
- :"r"(addr));
-
- return ret;
-}
-
-static __inline__ unsigned long
-ldl_u(unsigned int *p)
-{
- unsigned long addr = (unsigned long) p;
- unsigned int ret;
-
- __asm__ __volatile__("lmw.bi %0, [%1], %0, 0;\n\t"
- "wsbh %0, %0;\n\t" "rotri %0, %0, 16;\n\t":"=r"(ret)
- :"r"(addr));
-
- return ret;
-}
-
-static __inline__ void
-stq_u(unsigned long val, unsigned long *p)
-{
- unsigned long addr = (unsigned long) p;
-
- __asm__ __volatile__("wsbh %0, %0;\n\t" "rotri %0, %0, 16;\n\t" "smw.bi %0, [%1], %0, 0;\n\t": /* No outputs */
- :"r"(val), "r"(addr));
-}
-
-static __inline__ void
-stl_u(unsigned long val, unsigned int *p)
-{
- unsigned long addr = (unsigned long) p;
-
- __asm__ __volatile__("wsbh %0, %0;\n\t" "rotri %0, %0, 16;\n\t" "smw.bi %0, [%1], %0, 0;\n\t": /* No outputs */
- :"r"(val), "r"(addr));
-}
-
#else /* !NDS32_MMIO_SWAP */
static __inline__ void
outb(unsigned PORT_SIZE port, unsigned char val)
@@ -1291,124 +965,9 @@ inl(unsigned PORT_SIZE port)
return *(volatile unsigned int *) (((unsigned PORT_SIZE) (port)));
}
-static __inline__ unsigned long
-ldq_u(unsigned long *p)
-{
- unsigned long addr = (unsigned long) p;
- unsigned int ret;
-
- __asm__ __volatile__("lmw.bi %0, [%1], %0, 0;\n\t":"=r"(ret)
- :"r"(addr));
-
- return ret;
-}
-
-static __inline__ unsigned long
-ldl_u(unsigned int *p)
-{
- unsigned long addr = (unsigned long) p;
- unsigned int ret;
-
- __asm__ __volatile__("lmw.bi %0, [%1], %0, 0;\n\t":"=r"(ret)
- :"r"(addr));
-
- return ret;
-}
-
-static __inline__ void
-stq_u(unsigned long val, unsigned long *p)
-{
- unsigned long addr = (unsigned long) p;
-
- __asm__ __volatile__("smw.bi %0, [%1], %0, 0;\n\t": /* No outputs */
- :"r"(val), "r"(addr));
-}
-
-static __inline__ void
-stl_u(unsigned long val, unsigned int *p)
-{
- unsigned long addr = (unsigned long) p;
-
- __asm__ __volatile__("smw.bi %0, [%1], %0, 0;\n\t": /* No outputs */
- :"r"(val), "r"(addr));
-}
#endif /* NDS32_MMIO_SWAP */
-#if (((X_BYTE_ORDER == X_BIG_ENDIAN) && !defined(NDS32_MMIO_SWAP)) || ((X_BYTE_ORDER != X_BIG_ENDIAN) && defined(NDS32_MMIO_SWAP)))
-#define ldw_u(p) ((*(unsigned char *)(p)) << 8 | \
- (*((unsigned char *)(p)+1)))
-#define stw_u(v,p) (*(unsigned char *)(p)) = ((v) >> 8); \
- (*((unsigned char *)(p)+1)) = (v)
-#else
-#define ldw_u(p) ((*(unsigned char *)(p)) | \
- (*((unsigned char *)(p)+1)<<8))
-#define stw_u(v,p) (*(unsigned char *)(p)) = (v); \
- (*((unsigned char *)(p)+1)) = ((v) >> 8)
-#endif
-
-#define mem_barrier() /* XXX: nop for now */
-#define write_mem_barrier() /* XXX: nop for now */
-
-#else /* ix86 */
-
-#if !defined(__SUNPRO_C)
-#if !defined(FAKEIT) && !defined(__mc68000__) && !defined(__arm__) && \
- !defined(__sh__) && !defined(__hppa__) && !defined(__s390__) && \
- !defined(__m32r__) && !defined(__aarch64__) && !defined(__arc__) && \
- !defined(__xtensa__)
-#ifdef GCCUSESGAS
-
-/*
- * If gcc uses gas rather than the native assembler, the syntax of these
- * inlines has to be different. DHD
- */
-
-static __inline__ void
-outb(unsigned short port, unsigned char val)
-{
- __asm__ __volatile__("outb %0,%1"::"a"(val), "d"(port));
-}
-
-static __inline__ void
-outw(unsigned short port, unsigned short val)
-{
- __asm__ __volatile__("outw %0,%1"::"a"(val), "d"(port));
-}
-
-static __inline__ void
-outl(unsigned short port, unsigned int val)
-{
- __asm__ __volatile__("outl %0,%1"::"a"(val), "d"(port));
-}
-
-static __inline__ unsigned int
-inb(unsigned short port)
-{
- unsigned char ret;
- __asm__ __volatile__("inb %1,%0":"=a"(ret):"d"(port));
-
- return ret;
-}
-
-static __inline__ unsigned int
-inw(unsigned short port)
-{
- unsigned short ret;
- __asm__ __volatile__("inw %1,%0":"=a"(ret):"d"(port));
-
- return ret;
-}
-
-static __inline__ unsigned int
-inl(unsigned short port)
-{
- unsigned int ret;
- __asm__ __volatile__("inl %1,%0":"=a"(ret):"d"(port));
-
- return ret;
-}
-
-#else /* GCCUSESGAS */
+#elif defined(__i386__) || defined(__ia64__)
static __inline__ void
outb(unsigned short port, unsigned char val)
@@ -1455,47 +1014,7 @@ inl(unsigned short port)
return ret;
}
-#endif /* GCCUSESGAS */
-
-#else /* !defined(FAKEIT) && !defined(__mc68000__) && !defined(__arm__) && !defined(__sh__) && !defined(__hppa__) && !defined(__m32r__) && !defined(__arc__) */
-
-static __inline__ void
-outb(unsigned short port, unsigned char val)
-{
-}
-
-static __inline__ void
-outw(unsigned short port, unsigned short val)
-{
-}
-
-static __inline__ void
-outl(unsigned short port, unsigned int val)
-{
-}
-
-static __inline__ unsigned int
-inb(unsigned short port)
-{
- return 0;
-}
-
-static __inline__ unsigned int
-inw(unsigned short port)
-{
- return 0;
-}
-
-static __inline__ unsigned int
-inl(unsigned short port)
-{
- return 0;
-}
-
-#endif /* FAKEIT */
-#endif /* __SUNPRO_C */
-
-#endif /* ix86 */
+#endif /* arch madness */
#else /* !GNUC */
#if defined(__STDC__) && (__STDC__ == 1)
@@ -1506,18 +1025,12 @@ inl(unsigned short port)
#if !defined(__SUNPRO_C) && !defined(_MSC_VER)
#include <sys/inline.h>
#endif
-#if (!defined(__HIGHC__) && !defined(__SUNPRO_C) && !defined(_MSC_VER)) || \
- defined(__USLC__)
-#pragma asm partial_optimization outl
-#pragma asm partial_optimization outw
-#pragma asm partial_optimization outb
-#pragma asm partial_optimization inl
-#pragma asm partial_optimization inw
-#pragma asm partial_optimization inb
-#endif
#endif /* __GNUC__ */
-#endif /* NO_INLINE */
+#if !defined(MMIO_IS_BE) && \
+ (defined(SPARC_MMIO_IS_BE) || defined(PPC_MMIO_IS_BE))
+#define MMIO_IS_BE
+#endif
#ifdef __alpha__
/* entry points for Mmio memory access routines */
@@ -1538,9 +1051,6 @@ xf86ReadMmio32(void *Base, unsigned long Offset)
extern _X_EXPORT void (*xf86WriteMmio8) (int, void *, unsigned long);
extern _X_EXPORT void (*xf86WriteMmio16) (int, void *, unsigned long);
extern _X_EXPORT void (*xf86WriteMmio32) (int, void *, unsigned long);
-extern _X_EXPORT void (*xf86WriteMmioNB8) (int, void *, unsigned long);
-extern _X_EXPORT void (*xf86WriteMmioNB16) (int, void *, unsigned long);
-extern _X_EXPORT void (*xf86WriteMmioNB32) (int, void *, unsigned long);
extern _X_EXPORT void xf86SlowBCopyFromBus(unsigned char *, unsigned char *,
int);
extern _X_EXPORT void xf86SlowBCopyToBus(unsigned char *, unsigned char *, int);
@@ -1560,43 +1070,29 @@ extern _X_EXPORT void xf86SlowBCopyToBus(unsigned char *, unsigned char *, int);
write_mem_barrier(); \
*(volatile CARD32 *)(void *)(((CARD8*)(base)) + (offset)) = (val); \
} while (0)
-#define MMIO_ONB32(base, offset, val) \
- *(volatile CARD32 *)(void *)(((CARD8*)(base)) + (offset)) = (val)
#define MMIO_OUT8(base, offset, val) \
(*xf86WriteMmio8)((CARD8)(val), base, offset)
#define MMIO_OUT16(base, offset, val) \
(*xf86WriteMmio16)((CARD16)(val), base, offset)
-#define MMIO_ONB8(base, offset, val) \
- (*xf86WriteMmioNB8)((CARD8)(val), base, offset)
-#define MMIO_ONB16(base, offset, val) \
- (*xf86WriteMmioNB16)((CARD16)(val), base, offset)
-#define MMIO_MOVE32(base, offset, val) \
- MMIO_OUT32(base, offset, val)
-#elif defined(__powerpc__)
+#elif defined(__powerpc__) || defined(__sparc__)
/*
* we provide byteswapping and no byteswapping functions here
* with byteswapping as default,
- * drivers that don't need byteswapping should define PPC_MMIO_IS_BE
+ * drivers that don't need byteswapping should define MMIO_IS_BE
*/
#define MMIO_IN8(base, offset) xf86ReadMmio8(base, offset)
#define MMIO_OUT8(base, offset, val) \
xf86WriteMmio8(base, offset, (CARD8)(val))
-#define MMIO_ONB8(base, offset, val) \
- xf86WriteMmioNB8(base, offset, (CARD8)(val))
-#if defined(PPC_MMIO_IS_BE) /* No byteswapping */
+#if defined(MMIO_IS_BE) /* No byteswapping */
#define MMIO_IN16(base, offset) xf86ReadMmio16Be(base, offset)
#define MMIO_IN32(base, offset) xf86ReadMmio32Be(base, offset)
#define MMIO_OUT16(base, offset, val) \
xf86WriteMmio16Be(base, offset, (CARD16)(val))
#define MMIO_OUT32(base, offset, val) \
xf86WriteMmio32Be(base, offset, (CARD32)(val))
-#define MMIO_ONB16(base, offset, val) \
- xf86WriteMmioNB16Be(base, offset, (CARD16)(val))
-#define MMIO_ONB32(base, offset, val) \
- xf86WriteMmioNB32Be(base, offset, (CARD32)(val))
#else /* byteswapping is the default */
#define MMIO_IN16(base, offset) xf86ReadMmio16Le(base, offset)
#define MMIO_IN32(base, offset) xf86ReadMmio32Le(base, offset)
@@ -1604,56 +1100,8 @@ extern _X_EXPORT void xf86SlowBCopyToBus(unsigned char *, unsigned char *, int);
xf86WriteMmio16Le(base, offset, (CARD16)(val))
#define MMIO_OUT32(base, offset, val) \
xf86WriteMmio32Le(base, offset, (CARD32)(val))
-#define MMIO_ONB16(base, offset, val) \
- xf86WriteMmioNB16Le(base, offset, (CARD16)(val))
-#define MMIO_ONB32(base, offset, val) \
- xf86WriteMmioNB32Le(base, offset, (CARD32)(val))
#endif
-#define MMIO_MOVE32(base, offset, val) \
- xf86WriteMmio32Be(base, offset, (CARD32)(val))
-
-#elif defined(__sparc__) || defined(sparc) || defined(__sparc)
- /*
- * Like powerpc, we provide byteswapping and no byteswapping functions
- * here with byteswapping as default, drivers that don't need byteswapping
- * should define SPARC_MMIO_IS_BE (perhaps create a generic macro so that we
- * do not need to use PPC_MMIO_IS_BE and the sparc one in all the same places
- * of drivers?).
- */
-#define MMIO_IN8(base, offset) xf86ReadMmio8(base, offset)
-#define MMIO_OUT8(base, offset, val) \
- xf86WriteMmio8(base, offset, (CARD8)(val))
-#define MMIO_ONB8(base, offset, val) \
- xf86WriteMmio8NB(base, offset, (CARD8)(val))
-
-#if defined(SPARC_MMIO_IS_BE) /* No byteswapping */
-#define MMIO_IN16(base, offset) xf86ReadMmio16Be(base, offset)
-#define MMIO_IN32(base, offset) xf86ReadMmio32Be(base, offset)
-#define MMIO_OUT16(base, offset, val) \
- xf86WriteMmio16Be(base, offset, (CARD16)(val))
-#define MMIO_OUT32(base, offset, val) \
- xf86WriteMmio32Be(base, offset, (CARD32)(val))
-#define MMIO_ONB16(base, offset, val) \
- xf86WriteMmio16BeNB(base, offset, (CARD16)(val))
-#define MMIO_ONB32(base, offset, val) \
- xf86WriteMmio32BeNB(base, offset, (CARD32)(val))
-#else /* byteswapping is the default */
-#define MMIO_IN16(base, offset) xf86ReadMmio16Le(base, offset)
-#define MMIO_IN32(base, offset) xf86ReadMmio32Le(base, offset)
-#define MMIO_OUT16(base, offset, val) \
- xf86WriteMmio16Le(base, offset, (CARD16)(val))
-#define MMIO_OUT32(base, offset, val) \
- xf86WriteMmio32Le(base, offset, (CARD32)(val))
-#define MMIO_ONB16(base, offset, val) \
- xf86WriteMmio16LeNB(base, offset, (CARD16)(val))
-#define MMIO_ONB32(base, offset, val) \
- xf86WriteMmio32LeNB(base, offset, (CARD32)(val))
-#endif
-
-#define MMIO_MOVE32(base, offset, val) \
- xf86WriteMmio32Be(base, offset, (CARD32)(val))
-
#elif defined(__nds32__)
/*
* we provide byteswapping and no byteswapping functions here
@@ -1664,8 +1112,6 @@ extern _X_EXPORT void xf86SlowBCopyToBus(unsigned char *, unsigned char *, int);
#define MMIO_IN8(base, offset) xf86ReadMmio8(base, offset)
#define MMIO_OUT8(base, offset, val) \
xf86WriteMmio8(base, offset, (CARD8)(val))
-#define MMIO_ONB8(base, offset, val) \
- xf86WriteMmioNB8(base, offset, (CARD8)(val))
#if defined(NDS32_MMIO_SWAP) /* byteswapping */
#define MMIO_IN16(base, offset) xf86ReadMmio16Swap(base, offset)
@@ -1674,10 +1120,6 @@ extern _X_EXPORT void xf86SlowBCopyToBus(unsigned char *, unsigned char *, int);
xf86WriteMmio16Swap(base, offset, (CARD16)(val))
#define MMIO_OUT32(base, offset, val) \
xf86WriteMmio32Swap(base, offset, (CARD32)(val))
-#define MMIO_ONB16(base, offset, val) \
- xf86WriteMmioNB16Swap(base, offset, (CARD16)(val))
-#define MMIO_ONB32(base, offset, val) \
- xf86WriteMmioNB32Swap(base, offset, (CARD32)(val))
#else /* no byteswapping is the default */
#define MMIO_IN16(base, offset) xf86ReadMmio16(base, offset)
#define MMIO_IN32(base, offset) xf86ReadMmio32(base, offset)
@@ -1685,30 +1127,6 @@ extern _X_EXPORT void xf86SlowBCopyToBus(unsigned char *, unsigned char *, int);
xf86WriteMmio16(base, offset, (CARD16)(val))
#define MMIO_OUT32(base, offset, val) \
xf86WriteMmio32(base, offset, (CARD32)(val))
-#define MMIO_ONB16(base, offset, val) \
- xf86WriteMmioNB16(base, offset, (CARD16)(val))
-#define MMIO_ONB32(base, offset, val) \
- xf86WriteMmioNB32(base, offset, (CARD32)(val))
-#endif
-
-#define MMIO_MOVE32(base, offset, val) \
- xf86WriteMmio32(base, offset, (CARD32)(val))
-
-#ifdef N1213_HC /* for NDS32 N1213 hardcore */
-static __inline__ void
-nds32_flush_icache(char *addr)
-{
- __asm__ volatile ("isync %0;"
- "msync;"
- "isb;"
- "cctl %0,L1I_VA_INVAL;" "isb;"::"r" (addr):"memory");
-}
-#else
-static __inline__ void
-nds32_flush_icache(char *addr)
-{
- __asm__ volatile ("isync %0;" "isb;"::"r" (addr):"memory");
-}
#endif
#else /* !__alpha__ && !__powerpc__ && !__sparc__ */
@@ -1725,11 +1143,6 @@ nds32_flush_icache(char *addr)
*(volatile CARD16 *)(void *)(((CARD8*)(base)) + (offset)) = (val)
#define MMIO_OUT32(base, offset, val) \
*(volatile CARD32 *)(void *)(((CARD8*)(base)) + (offset)) = (val)
-#define MMIO_ONB8(base, offset, val) MMIO_OUT8(base, offset, val)
-#define MMIO_ONB16(base, offset, val) MMIO_OUT16(base, offset, val)
-#define MMIO_ONB32(base, offset, val) MMIO_OUT32(base, offset, val)
-
-#define MMIO_MOVE32(base, offset, val) MMIO_OUT32(base, offset, val)
#endif /* __alpha__ */
diff --git a/xorg-server/hw/xfree86/common/xf86.h b/xorg-server/hw/xfree86/common/xf86.h
index cec31354e..49ff35b86 100644
--- a/xorg-server/hw/xfree86/common/xf86.h
+++ b/xorg-server/hw/xfree86/common/xf86.h
@@ -129,14 +129,6 @@ extern _X_EXPORT ScrnInfoPtr xf86ConfigPciEntity(ScrnInfoPtr pScrn,
EntityProc enter,
EntityProc leave,
void *private);
-/* Obsolete! don't use */
-extern _X_EXPORT Bool xf86ConfigActivePciEntity(ScrnInfoPtr pScrn,
- int entityIndex,
- PciChipsets * p_chip,
- void *dummy, EntityProc init,
- EntityProc enter,
- EntityProc leave,
- void *private);
#else
#define xf86VGAarbiterInit() do {} while (0)
#define xf86VGAarbiterFini() do {} while (0)
diff --git a/xorg-server/hw/xfree86/common/xf86Cursor.c b/xorg-server/hw/xfree86/common/xf86Cursor.c
index 7d0776eaa..92c08af9e 100644
--- a/xorg-server/hw/xfree86/common/xf86Cursor.c
+++ b/xorg-server/hw/xfree86/common/xf86Cursor.c
@@ -37,8 +37,6 @@
#include "scrnintstr.h"
#include "globals.h"
-#include "compiler.h"
-
#include "xf86.h"
#include "xf86Priv.h"
#include "xf86_OSproc.h"
@@ -76,8 +74,6 @@ static miPointerScreenFuncRec xf86PointerScreenFuncs = {
static xf86ScreenLayoutRec xf86ScreenLayout[MAXSCREENS];
-static Bool HardEdges;
-
/*
* xf86InitViewport --
* Initialize paning & zooming parameters, so that a driver must only
@@ -431,16 +427,6 @@ xf86CursorOffScreen(ScreenPtr *pScreen, int *x, int *y)
}
}
-#if 0
- /* This presents problems for overlapping screens when
- HardEdges is used. Have to think about the logic more */
- if ((*x < 0) || (*x >= (*pScreen)->width) ||
- (*y < 0) || (*y >= (*pScreen)->height)) {
- /* We may have crossed more than one screen */
- xf86CursorOffScreen(pScreen, x, y);
- }
-#endif
-
return TRUE;
}
@@ -584,9 +570,6 @@ xf86InitOrigins(void)
xf86ScreenLayoutPtr pLayout;
Bool OldStyleConfig = FALSE;
- /* need to have this set up with a config file option */
- HardEdges = FALSE;
-
memset(xf86ScreenLayout, 0, MAXSCREENS * sizeof(xf86ScreenLayoutRec));
screensLeft = prevScreensLeft = (1 << xf86NumScreens) - 1;
@@ -838,7 +821,7 @@ xf86InitOrigins(void)
}
}
- if (!HardEdges && !OldStyleConfig) {
+ if (!OldStyleConfig) {
for (i = 0; i < xf86NumScreens; i++) {
pLayout = &xf86ScreenLayout[i];
pScreen = xf86Screens[i]->pScreen;
diff --git a/xorg-server/hw/xfree86/common/xf86Events.c b/xorg-server/hw/xfree86/common/xf86Events.c
index 35a673d15..16b3e2821 100644
--- a/xorg-server/hw/xfree86/common/xf86Events.c
+++ b/xorg-server/hw/xfree86/common/xf86Events.c
@@ -58,7 +58,6 @@
#include <X11/Xproto.h>
#include <X11/Xatom.h>
#include "misc.h"
-#include "compiler.h"
#include "xf86.h"
#include "xf86Priv.h"
#define XF86_OS_PRIVS
diff --git a/xorg-server/hw/xfree86/common/xf86Init.c b/xorg-server/hw/xfree86/common/xf86Init.c
index 5a45004f5..b197c1c38 100644
--- a/xorg-server/hw/xfree86/common/xf86Init.c
+++ b/xorg-server/hw/xfree86/common/xf86Init.c
@@ -56,8 +56,6 @@
#include "dbus-core.h"
#include "systemd-logind.h"
-#include "compiler.h"
-
#include "loaderProcs.h"
#ifdef XFreeXDGA
#include "dgaproc.h"
diff --git a/xorg-server/hw/xfree86/common/xf86RandR.c b/xorg-server/hw/xfree86/common/xf86RandR.c
index 2418731dc..08f656b30 100644
--- a/xorg-server/hw/xfree86/common/xf86RandR.c
+++ b/xorg-server/hw/xfree86/common/xf86RandR.c
@@ -37,7 +37,6 @@
#include "inputstr.h"
typedef struct _xf86RandRInfo {
- CreateScreenResourcesProcPtr CreateScreenResources;
CloseScreenProcPtr CloseScreen;
int virtualX;
int virtualY;
@@ -336,34 +335,6 @@ xf86RandRSetConfig(ScreenPtr pScreen,
}
/*
- * Wait until the screen is initialized before whacking the
- * sizes around; otherwise the screen pixmap will be allocated
- * at the current mode size rather than the maximum size
- */
-static Bool
-xf86RandRCreateScreenResources(ScreenPtr pScreen)
-{
- XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
-
-#if 0
- ScrnInfoPtr scrp = xf86ScreenToScrn(pScreen);
- DisplayModePtr mode;
-#endif
-
- pScreen->CreateScreenResources = randrp->CreateScreenResources;
- if (!(*pScreen->CreateScreenResources) (pScreen))
- return FALSE;
-
-#if 0
- mode = scrp->currentMode;
- if (mode)
- xf86RandRSetMode(pScreen, mode, TRUE);
-#endif
-
- return TRUE;
-}
-
-/*
* Reset size back to original
*/
static Bool
@@ -463,9 +434,6 @@ xf86RandRInit(ScreenPtr pScreen)
randrp->mmWidth = pScreen->mmWidth;
randrp->mmHeight = pScreen->mmHeight;
- randrp->CreateScreenResources = pScreen->CreateScreenResources;
- pScreen->CreateScreenResources = xf86RandRCreateScreenResources;
-
randrp->CloseScreen = pScreen->CloseScreen;
pScreen->CloseScreen = xf86RandRCloseScreen;
diff --git a/xorg-server/hw/xfree86/common/xf86pciBus.c b/xorg-server/hw/xfree86/common/xf86pciBus.c
index c06b04033..e86ecb9d4 100644
--- a/xorg-server/hw/xfree86/common/xf86pciBus.c
+++ b/xorg-server/hw/xfree86/common/xf86pciBus.c
@@ -1061,33 +1061,6 @@ xf86ConfigPciEntity(ScrnInfoPtr pScrn, int scrnFlag, int entityIndex,
return pScrn;
}
-/*
- * OBSOLETE ! xf86ConfigActivePciEntity() is an obsolete function.
- * It is likely to be removed. Don't use!
- */
-Bool
-xf86ConfigActivePciEntity(ScrnInfoPtr pScrn, int entityIndex,
- PciChipsets * p_chip, void *dummy, EntityProc init,
- EntityProc enter, EntityProc leave, void *private)
-{
- EntityInfoPtr pEnt = xf86GetEntityInfo(entityIndex);
-
- if (!pEnt)
- return FALSE;
-
- if (!pEnt->active || !(pEnt->location.type == BUS_PCI)) {
- free(pEnt);
- return FALSE;
- }
- xf86AddEntityToScreen(pScrn, entityIndex);
-
- free(pEnt);
- if (!xf86SetEntityFuncs(entityIndex, init, enter, leave, private))
- return FALSE;
-
- return TRUE;
-}
-
int
xf86VideoPtrToDriverList(struct pci_device *dev,
char *returnList[], int returnListMax)
@@ -1500,15 +1473,3 @@ xf86PciConfigureNewDev(void *busData, struct pci_device *pVideo,
if (*chipset < 0)
*chipset = (pVideo->vendor_id << 16) | pVideo->device_id;
}
-
-struct pci_io_handle *
-xf86MapLegacyIO(struct pci_device *dev)
-{
- return pci_legacy_open_io(dev, 0, 64 * 1024);
-}
-
-void
-xf86UnmapLegacyIO(struct pci_device *dev, struct pci_io_handle *handle)
-{
- pci_device_close_io(dev, handle);
-}
diff --git a/xorg-server/hw/xfree86/common/xf86platformBus.c b/xorg-server/hw/xfree86/common/xf86platformBus.c
index 22e4603e6..946039940 100644
--- a/xorg-server/hw/xfree86/common/xf86platformBus.c
+++ b/xorg-server/hw/xfree86/common/xf86platformBus.c
@@ -348,7 +348,7 @@ static Bool doPlatformProbe(struct xf86_platform_device *dev, DriverPtr drvp,
GDevPtr gdev, int flags, intptr_t match_data)
{
Bool foundScreen = FALSE;
- int entity, fd, major, minor;
+ int entity;
if (gdev && gdev->screen == 0 && !xf86_check_platform_slot(dev))
return FALSE;
@@ -374,10 +374,7 @@ static Bool doPlatformProbe(struct xf86_platform_device *dev, DriverPtr drvp,
if (entity != -1) {
if ((dev->flags & XF86_PDEV_SERVER_FD) && (!drvp->driverFunc ||
!drvp->driverFunc(NULL, SUPPORTS_SERVER_FDS, NULL))) {
- fd = dev->attribs->fd;
- major = dev->attribs->major;
- minor = dev->attribs->minor;
- systemd_logind_release_fd(major, minor, fd);
+ systemd_logind_release_fd(dev->attribs->major, dev->attribs->minor, dev->attribs->fd);
dev->attribs->fd = -1;
dev->flags &= ~XF86_PDEV_SERVER_FD;
}
diff --git a/xorg-server/hw/xfree86/common/xf86xv.c b/xorg-server/hw/xfree86/common/xf86xv.c
index e212a7387..d342bdecc 100644
--- a/xorg-server/hw/xfree86/common/xf86xv.c
+++ b/xorg-server/hw/xfree86/common/xf86xv.c
@@ -54,38 +54,31 @@
#include "xf86xvpriv.h"
-/* XvScreenRec fields */
-
-static Bool xf86XVCloseScreen(ScreenPtr);
-static int xf86XVQueryAdaptors(ScreenPtr, XvAdaptorPtr *, int *);
-
/* XvAdaptorRec fields */
-static int xf86XVAllocatePort(unsigned long, XvPortPtr, XvPortPtr *);
-static int xf86XVFreePort(XvPortPtr);
-static int xf86XVPutVideo(ClientPtr, DrawablePtr, XvPortPtr, GCPtr,
+static int xf86XVPutVideo(DrawablePtr, XvPortPtr, GCPtr,
INT16, INT16, CARD16, CARD16,
INT16, INT16, CARD16, CARD16);
-static int xf86XVPutStill(ClientPtr, DrawablePtr, XvPortPtr, GCPtr,
+static int xf86XVPutStill(DrawablePtr, XvPortPtr, GCPtr,
INT16, INT16, CARD16, CARD16,
INT16, INT16, CARD16, CARD16);
-static int xf86XVGetVideo(ClientPtr, DrawablePtr, XvPortPtr, GCPtr,
+static int xf86XVGetVideo(DrawablePtr, XvPortPtr, GCPtr,
INT16, INT16, CARD16, CARD16,
INT16, INT16, CARD16, CARD16);
-static int xf86XVGetStill(ClientPtr, DrawablePtr, XvPortPtr, GCPtr,
+static int xf86XVGetStill(DrawablePtr, XvPortPtr, GCPtr,
INT16, INT16, CARD16, CARD16,
INT16, INT16, CARD16, CARD16);
-static int xf86XVStopVideo(ClientPtr, XvPortPtr, DrawablePtr);
-static int xf86XVSetPortAttribute(ClientPtr, XvPortPtr, Atom, INT32);
-static int xf86XVGetPortAttribute(ClientPtr, XvPortPtr, Atom, INT32 *);
-static int xf86XVQueryBestSize(ClientPtr, XvPortPtr, CARD8,
+static int xf86XVStopVideo(XvPortPtr, DrawablePtr);
+static int xf86XVSetPortAttribute(XvPortPtr, Atom, INT32);
+static int xf86XVGetPortAttribute(XvPortPtr, Atom, INT32 *);
+static int xf86XVQueryBestSize(XvPortPtr, CARD8,
CARD16, CARD16, CARD16, CARD16,
unsigned int *, unsigned int *);
-static int xf86XVPutImage(ClientPtr, DrawablePtr, XvPortPtr, GCPtr,
+static int xf86XVPutImage(DrawablePtr, XvPortPtr, GCPtr,
INT16, INT16, CARD16, CARD16,
INT16, INT16, CARD16, CARD16,
XvImagePtr, unsigned char *, Bool, CARD16, CARD16);
-static int xf86XVQueryImageAttributes(ClientPtr, XvPortPtr, XvImagePtr,
+static int xf86XVQueryImageAttributes(XvPortPtr, XvImagePtr,
CARD16 *, CARD16 *, int *, int *);
/* ScreenRec fields */
@@ -95,6 +88,7 @@ static void xf86XVWindowExposures(WindowPtr pWin, RegionPtr r1, RegionPtr r2);
static void xf86XVPostValidateTree(WindowPtr pWin, WindowPtr pLayerWin,
VTKind kind);
static void xf86XVClipNotify(WindowPtr pWin, int dx, int dy);
+static Bool xf86XVCloseScreen(ScreenPtr);
#define PostValidateTreeUndefined ((PostValidateTreeProcPtr)-1)
@@ -113,7 +107,10 @@ static DevPrivateKeyRec XF86XVWindowKeyRec;
#define XF86XVWindowKey (&XF86XVWindowKeyRec)
+/* dixmain.c XvScreenPtr screen private */
DevPrivateKey XF86XvScreenKey;
+/** xf86xv.c XF86XVScreenPtr screen private */
+static DevPrivateKeyRec XF86XVScreenPrivateKey;
static unsigned long PortResource = 0;
@@ -121,7 +118,7 @@ static unsigned long PortResource = 0;
((XvScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, XF86XvScreenKey))
#define GET_XF86XV_SCREEN(pScreen) \
- ((XF86XVScreenPtr)(GET_XV_SCREEN(pScreen)->devPriv.ptr))
+ ((XF86XVScreenPtr)(dixGetPrivate(&pScreen->devPrivates, &XF86XVScreenPrivateKey)))
#define GET_XF86XV_WINDOW(pWin) \
((XF86XVWindowPtr)dixLookupPrivate(&(pWin)->devPrivates, XF86XVWindowKey))
@@ -232,7 +229,6 @@ xf86XVScreenInit(ScreenPtr pScreen, XF86VideoAdaptorPtr * adaptors, int num)
{
ScrnInfoPtr pScrn;
XF86XVScreenPtr ScreenPriv;
- XvScreenPtr pxvs;
if (num <= 0 || noXvExtension)
return FALSE;
@@ -242,26 +238,15 @@ xf86XVScreenInit(ScreenPtr pScreen, XF86VideoAdaptorPtr * adaptors, int num)
if (!dixRegisterPrivateKey(&XF86XVWindowKeyRec, PRIVATE_WINDOW, 0))
return FALSE;
+ if (!dixRegisterPrivateKey(&XF86XVScreenPrivateKey, PRIVATE_SCREEN, 0))
+ return FALSE;
XF86XvScreenKey = XvGetScreenKey();
PortResource = XvGetRTPort();
- pxvs = GET_XV_SCREEN(pScreen);
-
- /* Anyone initializing the Xv layer must provide these two.
- The Xv di layer calls them without even checking if they exist! */
-
- pxvs->ddCloseScreen = xf86XVCloseScreen;
- pxvs->ddQueryAdaptors = xf86XVQueryAdaptors;
-
- /* The Xv di layer provides us with a private hook so that we don't
- have to allocate our own screen private. They also provide
- a CloseScreen hook so that we don't have to wrap it. I'm not
- sure that I appreciate that. */
-
ScreenPriv = malloc(sizeof(XF86XVScreenRec));
- pxvs->devPriv.ptr = (void *) ScreenPriv;
+ dixSetPrivate(&pScreen->devPrivates, &XF86XVScreenPrivateKey, ScreenPriv);
if (!ScreenPriv)
return FALSE;
@@ -272,6 +257,7 @@ xf86XVScreenInit(ScreenPtr pScreen, XF86VideoAdaptorPtr * adaptors, int num)
ScreenPriv->WindowExposures = pScreen->WindowExposures;
ScreenPriv->PostValidateTree = PostValidateTreeUndefined;
ScreenPriv->ClipNotify = pScreen->ClipNotify;
+ ScreenPriv->CloseScreen = pScreen->CloseScreen;
ScreenPriv->EnterVT = pScrn->EnterVT;
ScreenPriv->LeaveVT = pScrn->LeaveVT;
ScreenPriv->AdjustFrame = pScrn->AdjustFrame;
@@ -280,6 +266,7 @@ xf86XVScreenInit(ScreenPtr pScreen, XF86VideoAdaptorPtr * adaptors, int num)
pScreen->DestroyWindow = xf86XVDestroyWindow;
pScreen->WindowExposures = xf86XVWindowExposures;
pScreen->ClipNotify = xf86XVClipNotify;
+ pScreen->CloseScreen = xf86XVCloseScreen;
pScrn->EnterVT = xf86XVEnterVT;
pScrn->LeaveVT = xf86XVLeaveVT;
if (pScrn->AdjustFrame)
@@ -297,21 +284,6 @@ xf86XVFreeAdaptor(XvAdaptorPtr pAdaptor)
{
int i;
- free(pAdaptor->name);
- pAdaptor->name = NULL;
-
- if (pAdaptor->pEncodings) {
- XvEncodingPtr pEncode = pAdaptor->pEncodings;
-
- for (i = 0; i < pAdaptor->nEncodings; i++, pEncode++)
- free(pEncode->name);
- free(pAdaptor->pEncodings);
- pAdaptor->pEncodings = NULL;
- }
-
- free(pAdaptor->pFormats);
- pAdaptor->pFormats = NULL;
-
if (pAdaptor->pPorts) {
XvPortPtr pPort = pAdaptor->pPorts;
XvPortRecPrivatePtr pPriv;
@@ -328,23 +300,9 @@ xf86XVFreeAdaptor(XvAdaptorPtr pAdaptor)
free(pPriv);
}
}
- free(pAdaptor->pPorts);
- pAdaptor->pPorts = NULL;
- }
-
- if (pAdaptor->pAttributes) {
- XvAttributePtr pAttribute = pAdaptor->pAttributes;
-
- for (i = 0; i < pAdaptor->nAttributes; i++, pAttribute++)
- free(pAttribute->name);
- free(pAdaptor->pAttributes);
- pAdaptor->pAttributes = NULL;
}
- free(pAdaptor->pImages);
- free(pAdaptor->devPriv.ptr);
- pAdaptor->pImages = NULL;
- pAdaptor->devPriv.ptr = NULL;
+ XvFreeAdaptor(pAdaptor);
}
static Bool
@@ -409,8 +367,6 @@ xf86XVInitAdaptors(ScreenPtr pScreen, XF86VideoAdaptorPtr * infoPtr, int number)
continue;
pa->pScreen = pScreen;
- pa->ddAllocatePort = xf86XVAllocatePort;
- pa->ddFreePort = xf86XVFreePort;
pa->ddPutVideo = xf86XVPutVideo;
pa->ddPutStill = xf86XVPutStill;
pa->ddGetVideo = xf86XVGetVideo;
@@ -712,10 +668,6 @@ xf86XVRegetVideo(XvPortRecPrivatePtr portPriv)
goto CLIP_VIDEO_BAILOUT;
}
- if (portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
- RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
- }
-
ret = (*portPriv->AdaptorRec->GetVideo) (portPriv->pScrn,
portPriv->vid_x, portPriv->vid_y,
WinBox.x1, WinBox.y1,
@@ -788,22 +740,6 @@ xf86XVReputVideo(XvPortRecPrivatePtr portPriv)
goto CLIP_VIDEO_BAILOUT;
}
- /* bailout if we have to clip but the hardware doesn't support it */
- if (portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) {
- BoxPtr clipBox = RegionRects(&ClipRegion);
-
- if ((RegionNumRects(&ClipRegion) != 1) ||
- (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
- (clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2)) {
- clippedAway = TRUE;
- goto CLIP_VIDEO_BAILOUT;
- }
- }
-
- if (portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
- RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
- }
-
ret = (*portPriv->AdaptorRec->PutVideo) (portPriv->pScrn,
portPriv->vid_x, portPriv->vid_y,
WinBox.x1, WinBox.y1,
@@ -882,22 +818,6 @@ xf86XVReputImage(XvPortRecPrivatePtr portPriv)
goto CLIP_VIDEO_BAILOUT;
}
- /* bailout if we have to clip but the hardware doesn't support it */
- if (portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) {
- BoxPtr clipBox = RegionRects(&ClipRegion);
-
- if ((RegionNumRects(&ClipRegion) != 1) ||
- (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
- (clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2)) {
- clippedAway = TRUE;
- goto CLIP_VIDEO_BAILOUT;
- }
- }
-
- if (portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
- RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
- }
-
ret = (*portPriv->AdaptorRec->ReputImage) (portPriv->pScrn,
portPriv->vid_x, portPriv->vid_y,
WinBox.x1, WinBox.y1,
@@ -1235,6 +1155,7 @@ xf86XVCloseScreen(ScreenPtr pScreen)
pScreen->DestroyWindow = ScreenPriv->DestroyWindow;
pScreen->WindowExposures = ScreenPriv->WindowExposures;
pScreen->ClipNotify = ScreenPriv->ClipNotify;
+ pScreen->CloseScreen = ScreenPriv->CloseScreen;
pScrn->EnterVT = ScreenPriv->EnterVT;
pScrn->LeaveVT = ScreenPriv->LeaveVT;
@@ -1247,19 +1168,8 @@ xf86XVCloseScreen(ScreenPtr pScreen)
free(pxvs->pAdaptors);
free(ScreenPriv);
- return TRUE;
-}
-
-static int
-xf86XVQueryAdaptors(ScreenPtr pScreen,
- XvAdaptorPtr * p_pAdaptors, int *p_nAdaptors)
-{
- XvScreenPtr pxvs = GET_XV_SCREEN(pScreen);
- *p_nAdaptors = pxvs->nAdaptors;
- *p_pAdaptors = pxvs->pAdaptors;
-
- return Success;
+ return pScreen->CloseScreen(pScreen);
}
/**** ScrnInfoRec fields ****/
@@ -1361,21 +1271,7 @@ xf86XVModeSet(ScrnInfoPtr pScrn)
/**** XvAdaptorRec fields ****/
static int
-xf86XVAllocatePort(unsigned long port, XvPortPtr pPort, XvPortPtr * ppPort)
-{
- *ppPort = pPort;
- return Success;
-}
-
-static int
-xf86XVFreePort(XvPortPtr pPort)
-{
- return Success;
-}
-
-static int
-xf86XVPutVideo(ClientPtr client,
- DrawablePtr pDraw,
+xf86XVPutVideo(DrawablePtr pDraw,
XvPortPtr pPort,
GCPtr pGC,
INT16 vid_x, INT16 vid_y,
@@ -1425,8 +1321,7 @@ xf86XVPutVideo(ClientPtr client,
}
static int
-xf86XVPutStill(ClientPtr client,
- DrawablePtr pDraw,
+xf86XVPutStill(DrawablePtr pDraw,
XvPortPtr pPort,
GCPtr pGC,
INT16 vid_x, INT16 vid_y,
@@ -1480,21 +1375,6 @@ xf86XVPutStill(ClientPtr client,
goto PUT_STILL_BAILOUT;
}
- if (portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) {
- BoxPtr clipBox = RegionRects(&ClipRegion);
-
- if ((RegionNumRects(&ClipRegion) != 1) ||
- (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
- (clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2)) {
- clippedAway = TRUE;
- goto PUT_STILL_BAILOUT;
- }
- }
-
- if (portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
- RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
- }
-
ret = (*portPriv->AdaptorRec->PutStill) (portPriv->pScrn,
vid_x, vid_y, WinBox.x1, WinBox.y1,
vid_w, vid_h, drw_w, drw_h,
@@ -1538,8 +1418,7 @@ xf86XVPutStill(ClientPtr client,
}
static int
-xf86XVGetVideo(ClientPtr client,
- DrawablePtr pDraw,
+xf86XVGetVideo(DrawablePtr pDraw,
XvPortPtr pPort,
GCPtr pGC,
INT16 vid_x, INT16 vid_y,
@@ -1589,8 +1468,7 @@ xf86XVGetVideo(ClientPtr client,
}
static int
-xf86XVGetStill(ClientPtr client,
- DrawablePtr pDraw,
+xf86XVGetStill(DrawablePtr pDraw,
XvPortPtr pPort,
GCPtr pGC,
INT16 vid_x, INT16 vid_y,
@@ -1628,10 +1506,6 @@ xf86XVGetStill(ClientPtr client,
goto GET_STILL_BAILOUT;
}
- if (portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
- RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
- }
-
ret = (*portPriv->AdaptorRec->GetStill) (portPriv->pScrn,
vid_x, vid_y, WinBox.x1, WinBox.y1,
vid_w, vid_h, drw_w, drw_h,
@@ -1653,7 +1527,7 @@ xf86XVGetStill(ClientPtr client,
}
static int
-xf86XVStopVideo(ClientPtr client, XvPortPtr pPort, DrawablePtr pDraw)
+xf86XVStopVideo(XvPortPtr pPort, DrawablePtr pDraw)
{
XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr) (pPort->devPriv.ptr);
@@ -1677,8 +1551,7 @@ xf86XVStopVideo(ClientPtr client, XvPortPtr pPort, DrawablePtr pDraw)
}
static int
-xf86XVSetPortAttribute(ClientPtr client,
- XvPortPtr pPort, Atom attribute, INT32 value)
+xf86XVSetPortAttribute(XvPortPtr pPort, Atom attribute, INT32 value)
{
XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr) (pPort->devPriv.ptr);
@@ -1688,8 +1561,7 @@ xf86XVSetPortAttribute(ClientPtr client,
}
static int
-xf86XVGetPortAttribute(ClientPtr client,
- XvPortPtr pPort, Atom attribute, INT32 *p_value)
+xf86XVGetPortAttribute(XvPortPtr pPort, Atom attribute, INT32 *p_value)
{
XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr) (pPort->devPriv.ptr);
@@ -1699,8 +1571,7 @@ xf86XVGetPortAttribute(ClientPtr client,
}
static int
-xf86XVQueryBestSize(ClientPtr client,
- XvPortPtr pPort,
+xf86XVQueryBestSize(XvPortPtr pPort,
CARD8 motion,
CARD16 vid_w, CARD16 vid_h,
CARD16 drw_w, CARD16 drw_h,
@@ -1717,8 +1588,7 @@ xf86XVQueryBestSize(ClientPtr client,
}
static int
-xf86XVPutImage(ClientPtr client,
- DrawablePtr pDraw,
+xf86XVPutImage(DrawablePtr pDraw,
XvPortPtr pPort,
GCPtr pGC,
INT16 src_x, INT16 src_y,
@@ -1780,21 +1650,6 @@ xf86XVPutImage(ClientPtr client,
goto PUT_IMAGE_BAILOUT;
}
- if (portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) {
- BoxPtr clipBox = RegionRects(&ClipRegion);
-
- if ((RegionNumRects(&ClipRegion) != 1) ||
- (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
- (clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2)) {
- clippedAway = TRUE;
- goto PUT_IMAGE_BAILOUT;
- }
- }
-
- if (portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
- RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
- }
-
ret = (*portPriv->AdaptorRec->PutImage) (portPriv->pScrn,
src_x, src_y, WinBox.x1, WinBox.y1,
src_w, src_h, drw_w, drw_h,
@@ -1838,8 +1693,7 @@ xf86XVPutImage(ClientPtr client,
}
static int
-xf86XVQueryImageAttributes(ClientPtr client,
- XvPortPtr pPort,
+xf86XVQueryImageAttributes(XvPortPtr pPort,
XvImagePtr format,
CARD16 *width,
CARD16 *height, int *pitches, int *offsets)
@@ -1856,34 +1710,11 @@ void
xf86XVFillKeyHelperDrawable(DrawablePtr pDraw, CARD32 key, RegionPtr fillboxes)
{
ScreenPtr pScreen = pDraw->pScreen;
- ChangeGCVal pval[2];
- BoxPtr pbox = RegionRects(fillboxes);
- int i, nbox = RegionNumRects(fillboxes);
- xRectangle *rects;
- GCPtr gc;
if (!xf86ScreenToScrn(pScreen)->vtSema)
return;
- gc = GetScratchGC(pDraw->depth, pScreen);
- pval[0].val = key;
- pval[1].val = IncludeInferiors;
- (void) ChangeGC(NullClient, gc, GCForeground | GCSubwindowMode, pval);
- ValidateGC(pDraw, gc);
-
- rects = malloc(nbox * sizeof(xRectangle));
-
- for (i = 0; i < nbox; i++, pbox++) {
- rects[i].x = pbox->x1 - pDraw->x;
- rects[i].y = pbox->y1 - pDraw->y;
- rects[i].width = pbox->x2 - pbox->x1;
- rects[i].height = pbox->y2 - pbox->y1;
- }
-
- (*gc->ops->PolyFillRect) (pDraw, gc, nbox, rects);
-
- free(rects);
- FreeScratchGC(gc);
+ XvFillColorKey(pDraw, key, fillboxes);
}
void
diff --git a/xorg-server/hw/xfree86/common/xf86xv.h b/xorg-server/hw/xfree86/common/xf86xv.h
index de17eb133..c6455d703 100644
--- a/xorg-server/hw/xfree86/common/xf86xv.h
+++ b/xorg-server/hw/xfree86/common/xf86xv.h
@@ -32,8 +32,6 @@
#include "xvdix.h"
#include "xf86str.h"
-#define VIDEO_NO_CLIPPING 0x00000001
-#define VIDEO_INVERT_CLIPLIST 0x00000002
#define VIDEO_OVERLAID_IMAGES 0x00000004
#define VIDEO_OVERLAID_STILLS 0x00000008
/*
diff --git a/xorg-server/hw/xfree86/common/xf86xvpriv.h b/xorg-server/hw/xfree86/common/xf86xvpriv.h
index e95f959a8..c0dff16d5 100644
--- a/xorg-server/hw/xfree86/common/xf86xvpriv.h
+++ b/xorg-server/hw/xfree86/common/xf86xvpriv.h
@@ -45,6 +45,7 @@ typedef struct {
Bool (*EnterVT) (ScrnInfoPtr);
void (*LeaveVT) (ScrnInfoPtr);
xf86ModeSetProc *ModeSet;
+ CloseScreenProcPtr CloseScreen;
} XF86XVScreenRec, *XF86XVScreenPtr;
typedef struct {
diff --git a/xorg-server/hw/xfree86/doc/ddxDesign.xml b/xorg-server/hw/xfree86/doc/ddxDesign.xml
index d1fd9af7b..6a9de9e7f 100644
--- a/xorg-server/hw/xfree86/doc/ddxDesign.xml
+++ b/xorg-server/hw/xfree86/doc/ddxDesign.xml
@@ -4543,31 +4543,6 @@ as follows:
<variablelist>
<varlistentry>
- <term><constant>VIDEO_NO_CLIPPING</constant></term>
- <listitem><para>
- This indicates that the video adaptor does not support
- clipping. The driver will never receive <quote>Put</quote> requests
- where less than the entire area determined by
- <parameter>drw_x</parameter>, <parameter>drw_y</parameter>,
- <parameter>drw_w</parameter> and <parameter>drw_h</parameter> is visible.
- This flag does not apply to <quote>Get</quote> requests. Hardware
- that is incapable of clipping <quote>Gets</quote> may punt or get
- the extents of the clipping region passed to it.
- </para></listitem>
-
- </varlistentry>
-
- <varlistentry>
- <term><constant>VIDEO_INVERT_CLIPLIST</constant></term>
- <listitem><para>
- This indicates that the video driver requires the clip
- list to contain the regions which are obscured rather
- than the regions which are are visible.
- </para></listitem>
-
- </varlistentry>
-
- <varlistentry>
<term><constant>VIDEO_OVERLAID_STILLS</constant></term>
<listitem><para>
Implementing PutStill for hardware that does video as an
@@ -4724,18 +4699,13 @@ as follows:
</para>
<para>
- If the <constant>VIDEO_NO_CLIPPING</constant>
- flag is set, the <literal remap="tt">clipBoxes</literal> may be ignored by
- the driver. <literal remap="tt">ClipBoxes</literal> is an <literal remap="tt">X-Y</literal>
+ <literal remap="tt">ClipBoxes</literal> is an <literal remap="tt">X-Y</literal>
banded region identical to those used throughout the server.
The clipBoxes represent the visible portions of the area determined
by <literal remap="tt">drw_x</literal>, <literal remap="tt">drw_y</literal>,
<literal remap="tt">drw_w</literal> and <literal remap="tt">drw_h</literal> in the Get/Put
function. The boxes are in screen coordinates, are guaranteed
not to overlap and an empty region will never be passed.
- If the driver has specified <constant>VIDEO_INVERT_CLIPLIST</constant>,
- <literal remap="tt">clipBoxes</literal> will indicate the areas of the primitive
- which are obscured rather than the areas visible.
</para></listitem></varlistentry>
</variablelist>
@@ -9094,8 +9064,7 @@ ZZZScreenInit(ScreenPtr pScreen, int argc, char **argv)
xf86SetBlackWhitePixels(pScreen);
/*
- * Install colourmap functions. If using the vgahw module,
- * vgaHandleColormaps would usually be called here.
+ * Install colourmap functions.
*/
...
diff --git a/xorg-server/hw/xfree86/dri/dri.c b/xorg-server/hw/xfree86/dri/dri.c
index 95828bbac..3f2f6a9b3 100644
--- a/xorg-server/hw/xfree86/dri/dri.c
+++ b/xorg-server/hw/xfree86/dri/dri.c
@@ -595,14 +595,6 @@ DRIFinishScreenInit(ScreenPtr pScreen)
DRIInfoPtr pDRIInfo = pDRIPriv->pDriverInfo;
/* Wrap DRI support */
- if (pDRIInfo->wrap.ValidateTree) {
- pDRIPriv->wrap.ValidateTree = pScreen->ValidateTree;
- pScreen->ValidateTree = pDRIInfo->wrap.ValidateTree;
- }
- if (pDRIInfo->wrap.PostValidateTree) {
- pDRIPriv->wrap.PostValidateTree = pScreen->PostValidateTree;
- pScreen->PostValidateTree = pDRIInfo->wrap.PostValidateTree;
- }
if (pDRIInfo->wrap.WindowExposures) {
pDRIPriv->wrap.WindowExposures = pScreen->WindowExposures;
pScreen->WindowExposures = pDRIInfo->wrap.WindowExposures;
@@ -652,14 +644,6 @@ DRICloseScreen(ScreenPtr pScreen)
if (pDRIPriv->wrapped) {
/* Unwrap DRI Functions */
- if (pDRIInfo->wrap.ValidateTree) {
- pScreen->ValidateTree = pDRIPriv->wrap.ValidateTree;
- pDRIPriv->wrap.ValidateTree = NULL;
- }
- if (pDRIInfo->wrap.PostValidateTree) {
- pScreen->PostValidateTree = pDRIPriv->wrap.PostValidateTree;
- pDRIPriv->wrap.PostValidateTree = NULL;
- }
if (pDRIInfo->wrap.WindowExposures) {
pScreen->WindowExposures = pDRIPriv->wrap.WindowExposures;
pDRIPriv->wrap.WindowExposures = NULL;
@@ -1601,8 +1585,6 @@ DRICreateInfoRec(void)
inforec->wrap.BlockHandler = DRIDoBlockHandler;
inforec->wrap.WindowExposures = DRIWindowExposures;
inforec->wrap.CopyWindow = DRICopyWindow;
- inforec->wrap.ValidateTree = DRIValidateTree;
- inforec->wrap.PostValidateTree = DRIPostValidateTree;
inforec->wrap.ClipNotify = DRIClipNotify;
inforec->wrap.AdjustFrame = DRIAdjustFrame;
@@ -2064,61 +2046,6 @@ DRILockTree(ScreenPtr pScreen)
}
}
-int
-DRIValidateTree(WindowPtr pParent, WindowPtr pChild, VTKind kind)
-{
- ScreenPtr pScreen = pParent->drawable.pScreen;
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-
- int returnValue = 1; /* always return 1, not checked by dix/window.c */
-
- if (!pDRIPriv)
- return returnValue;
-
- /* call lower wrapped functions */
- if (pDRIPriv->wrap.ValidateTree) {
- /* unwrap */
- pScreen->ValidateTree = pDRIPriv->wrap.ValidateTree;
-
- /* call lower layers */
- returnValue = (*pScreen->ValidateTree) (pParent, pChild, kind);
-
- /* rewrap */
- pDRIPriv->wrap.ValidateTree = pScreen->ValidateTree;
- pScreen->ValidateTree = DRIValidateTree;
- }
-
- return returnValue;
-}
-
-void
-DRIPostValidateTree(WindowPtr pParent, WindowPtr pChild, VTKind kind)
-{
- ScreenPtr pScreen;
- DRIScreenPrivPtr pDRIPriv;
-
- if (pParent) {
- pScreen = pParent->drawable.pScreen;
- }
- else {
- pScreen = pChild->drawable.pScreen;
- }
- if (!(pDRIPriv = DRI_SCREEN_PRIV(pScreen)))
- return;
-
- if (pDRIPriv->wrap.PostValidateTree) {
- /* unwrap */
- pScreen->PostValidateTree = pDRIPriv->wrap.PostValidateTree;
-
- /* call lower layers */
- (*pScreen->PostValidateTree) (pParent, pChild, kind);
-
- /* rewrap */
- pDRIPriv->wrap.PostValidateTree = pScreen->PostValidateTree;
- pScreen->PostValidateTree = DRIPostValidateTree;
- }
-}
-
void
DRIClipNotify(WindowPtr pWin, int dx, int dy)
{
diff --git a/xorg-server/hw/xfree86/dri/dri.h b/xorg-server/hw/xfree86/dri/dri.h
index 64cd7c9d4..dec688582 100644
--- a/xorg-server/hw/xfree86/dri/dri.h
+++ b/xorg-server/hw/xfree86/dri/dri.h
@@ -85,8 +85,6 @@ typedef struct {
ScreenBlockHandlerProcPtr BlockHandler;
WindowExposuresProcPtr WindowExposures;
CopyWindowProcPtr CopyWindow;
- ValidateTreeProcPtr ValidateTree;
- PostValidateTreeProcPtr PostValidateTree;
ClipNotifyProcPtr ClipNotify;
AdjustFramePtr AdjustFrame;
} DRIWrappedFuncsRec, *DRIWrappedFuncsPtr;
@@ -290,12 +288,6 @@ extern _X_EXPORT Bool DRIDestroyWindow(WindowPtr pWin);
extern _X_EXPORT void DRICopyWindow(WindowPtr pWin,
DDXPointRec ptOldOrg, RegionPtr prgnSrc);
-extern _X_EXPORT int DRIValidateTree(WindowPtr pParent,
- WindowPtr pChild, VTKind kind);
-
-extern _X_EXPORT void DRIPostValidateTree(WindowPtr pParent,
- WindowPtr pChild, VTKind kind);
-
extern _X_EXPORT void DRIClipNotify(WindowPtr pWin, int dx, int dy);
extern _X_EXPORT CARD32 DRIGetDrawableIndex(WindowPtr pWin);
diff --git a/xorg-server/hw/xfree86/int10/generic.c b/xorg-server/hw/xfree86/int10/generic.c
index abbd36f3c..73a1e5e49 100644
--- a/xorg-server/hw/xfree86/int10/generic.c
+++ b/xorg-server/hw/xfree86/int10/generic.c
@@ -20,6 +20,42 @@
#define ALLOC_ENTRIES(x) ((V_RAM / x) - 1)
+#include <string.h> /* needed for memmove */
+
+static __inline__ uint32_t
+ldl_u(uint32_t * p)
+{
+ uint32_t ret;
+
+ memmove(&ret, p, sizeof(*p));
+ return ret;
+}
+
+static __inline__ uint16_t
+ldw_u(uint16_t * p)
+{
+ uint16_t ret;
+
+ memmove(&ret, p, sizeof(*p));
+ return ret;
+}
+
+static __inline__ void
+stl_u(uint32_t val, uint32_t * p)
+{
+ uint32_t tmp = val;
+
+ memmove(p, &tmp, sizeof(*p));
+}
+
+static __inline__ void
+stw_u(uint16_t val, uint16_t * p)
+{
+ uint16_t tmp = val;
+
+ memmove(p, &tmp, sizeof(*p));
+}
+
static uint8_t read_b(xf86Int10InfoPtr pInt, int addr);
static uint16_t read_w(xf86Int10InfoPtr pInt, int addr);
static uint32_t read_l(xf86Int10InfoPtr pInt, int addr);
diff --git a/xorg-server/hw/xfree86/loader/loader.c b/xorg-server/hw/xfree86/loader/loader.c
index 64c69bb8a..cc41dcb4c 100644
--- a/xorg-server/hw/xfree86/loader/loader.c
+++ b/xorg-server/hw/xfree86/loader/loader.c
@@ -65,7 +65,6 @@
#include "loaderProcs.h"
#include "xf86.h"
#include "xf86Priv.h"
-#include "compiler.h"
#ifdef HAVE_DLFCN_H
diff --git a/xorg-server/hw/xfree86/modes/xf86Rotate.c b/xorg-server/hw/xfree86/modes/xf86Rotate.c
index 1627e61dd..9c00a443f 100644
--- a/xorg-server/hw/xfree86/modes/xf86Rotate.c
+++ b/xorg-server/hw/xfree86/modes/xf86Rotate.c
@@ -35,7 +35,6 @@
#include "xf86.h"
#include "xf86DDC.h"
-#include "fb.h"
#include "windowstr.h"
#include "xf86Crtc.h"
#include "xf86Modes.h"
@@ -310,6 +309,8 @@ xf86RotateCloseScreen(ScreenPtr screen)
xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
int c;
+ /* This has already been destroyed when the root window was destroyed */
+ xf86_config->rotation_damage = NULL;
for (c = 0; c < xf86_config->num_crtc; c++)
xf86RotateDestroy(xf86_config->crtc[c]);
}
diff --git a/xorg-server/hw/xfree86/os-support/bsd/alpha_video.c b/xorg-server/hw/xfree86/os-support/bsd/alpha_video.c
index 95bd0591a..f656f5595 100644
--- a/xorg-server/hw/xfree86/os-support/bsd/alpha_video.c
+++ b/xorg-server/hw/xfree86/os-support/bsd/alpha_video.c
@@ -431,12 +431,6 @@ extern int readDense8(void *Base, register unsigned long Offset);
extern int readDense16(void *Base, register unsigned long Offset);
extern int readDense32(void *Base, register unsigned long Offset);
extern void
- writeDenseNB8(int Value, void *Base, register unsigned long Offset);
-extern void
- writeDenseNB16(int Value, void *Base, register unsigned long Offset);
-extern void
- writeDenseNB32(int Value, void *Base, register unsigned long Offset);
-extern void
writeDense8(int Value, void *Base, register unsigned long Offset);
extern void
writeDense16(int Value, void *Base, register unsigned long Offset);
@@ -666,12 +660,6 @@ void (*xf86WriteMmio16) (int Value, void *Base, unsigned long Offset)
= writeDense16;
void (*xf86WriteMmio32) (int Value, void *Base, unsigned long Offset)
= writeDense32;
-void (*xf86WriteMmioNB8) (int Value, void *Base, unsigned long Offset)
- = writeDenseNB8;
-void (*xf86WriteMmioNB16) (int Value, void *Base, unsigned long Offset)
- = writeDenseNB16;
-void (*xf86WriteMmioNB32) (int Value, void *Base, unsigned long Offset)
- = writeDenseNB32;
int (*xf86ReadMmio8) (void *Base, unsigned long Offset)
= readDense8;
int (*xf86ReadMmio16) (void *Base, unsigned long Offset)
diff --git a/xorg-server/hw/xfree86/os-support/bsd/arm_video.c b/xorg-server/hw/xfree86/os-support/bsd/arm_video.c
index 6a977c2db..e295c9244 100644
--- a/xorg-server/hw/xfree86/os-support/bsd/arm_video.c
+++ b/xorg-server/hw/xfree86/os-support/bsd/arm_video.c
@@ -487,142 +487,3 @@ xf86DisableIO()
}
#endif /* USE_ARC_MMAP */
-
-#if 0
-/*
- * XXX This is here for reference. It needs to be handled differently for the
- * ND.
- */
-#if defined(USE_ARC_MMAP) || defined(__arm32__)
-
-#ifdef USE_ARM32_MMAP
-#define DEV_MEM_IOBASE 0x43000000
-#endif
-
-static Bool ScreenEnabled[MAXSCREENS];
-static Bool ExtendedEnabled = FALSE;
-static Bool InitDone = FALSE;
-
-Bool
-xf86EnableIOPorts(ScreenNum)
-int ScreenNum;
-{
- int i;
- int fd;
- void *base;
-
-#ifdef __arm32__
- struct memAccess *memInfoP;
- int *Size;
-#endif
-
- ScreenEnabled[ScreenNum] = TRUE;
-
- if (ExtendedEnabled)
- return TRUE;
-
-#ifdef USE_ARC_MMAP
- if ((fd = open("/dev/ttyC0", O_RDWR)) >= 0) {
- /* Try to map a page at the pccons I/O space */
- base = (void *) mmap((caddr_t) 0, 65536, PROT_READ | PROT_WRITE,
- MAP_FLAGS, fd, (off_t) 0x0000);
-
- if (base != (void *) -1) {
- IOPortBase = base;
- }
- else {
- xf86Msg(X_ERROR,
- "EnableIOPorts: failed to mmap %s (%s)\n",
- "/dev/ttyC0", strerror(errno));
- }
- }
- else {
- xf86Msg(X_ERROR, "EnableIOPorts: failed to open %s (%s)\n",
- "/dev/ttyC0", strerror(errno));
- }
-#endif
-
-#ifdef __arm32__
- IOPortBase = (unsigned int) -1;
-
- if ((memInfoP = checkMapInfo(TRUE, MMIO_REGION)) != NULL) {
- /*
- * xf86MapInfoMap maps an offset from the start of video IO
- * space (e.g. 0x3B0), but IOPortBase is expected to map to
- * physical address 0x000, so subtract the start of video I/O
- * space from the result. This is safe for now becase we
- * actually mmap the start of the page, then the start of video
- * I/O space is added as an internal offset.
- */
- IOPortBase = (unsigned int) xf86MapInfoMap(memInfoP, (caddr_t) 0x0, 0L)
- - memInfoP->memInfo.u.map_info_mmap.internal_offset;
- ExtendedEnabled = TRUE;
- return TRUE;
- }
-#ifdef USE_ARM32_MMAP
- checkDevMem(TRUE);
-
- if (devMemFd >= 0 && useDevMem) {
- base = (void *) mmap((caddr_t) 0, 0x400, PROT_READ | PROT_WRITE,
- MAP_FLAGS, devMemFd, (off_t) DEV_MEM_IOBASE);
-
- if (base != (void *) -1)
- IOPortBase = (unsigned int) base;
- }
-
- if (IOPortBase == (unsigned int) -1) {
- xf86Msg(X_WARNING,
- "xf86EnableIOPorts: failed to open mem device or map IO base. \n\
-Make sure you have the Aperture Driver installed, or a kernel built with the INSECURE option\n");
- return FALSE;
- }
-#else
- /* We don't have the IOBASE, so we can't map the address */
- xf86Msg(X_WARNING,
- "xf86EnableIOPorts: failed to open mem device or map IO base. \n\
-Try building the server with USE_ARM32_MMAP defined\n");
- return FALSE;
-#endif
-#endif
-
- ExtendedEnabled = TRUE;
-
- return TRUE;
-}
-
-void
-xf86DisableIOPorts(ScreenNum)
-int ScreenNum;
-{
- int i;
-
-#ifdef __arm32__
- struct memAccess *memInfoP;
-#endif
-
- ScreenEnabled[ScreenNum] = FALSE;
-
-#ifdef __arm32__
- if ((memInfoP = checkMapInfo(FALSE, MMIO_REGION)) != NULL) {
- xf86MapInfoUnmap(memInfoP, 0);
- }
-#endif
-
-#ifdef USE_ARM32_MMAP
- if (!ExtendedEnabled)
- return;
-
- for (i = 0; i < MAXSCREENS; i++)
- if (ScreenEnabled[i])
- return;
-
- munmap((caddr_t) IOPortBase, 0x400);
- IOPortBase = (unsigned int) -1;
- ExtendedEnabled = FALSE;
-#endif
-
- return;
-}
-
-#endif /* USE_ARC_MMAP || USE_ARM32_MMAP */
-#endif
diff --git a/xorg-server/hw/xfree86/os-support/bsd/bsd_ev56.c b/xorg-server/hw/xfree86/os-support/bsd/bsd_ev56.c
index 320bb23b6..95883491b 100644
--- a/xorg-server/hw/xfree86/os-support/bsd/bsd_ev56.c
+++ b/xorg-server/hw/xfree86/os-support/bsd/bsd_ev56.c
@@ -26,12 +26,6 @@ int readDense8(void *Base, register unsigned long Offset);
int readDense16(void *Base, register unsigned long Offset);
int readDense32(void *Base, register unsigned long Offset);
void
- writeDenseNB8(int Value, void *Base, register unsigned long Offset);
-void
- writeDenseNB16(int Value, void *Base, register unsigned long Offset);
-void
- writeDenseNB32(int Value, void *Base, register unsigned long Offset);
-void
writeDense8(int Value, void *Base, register unsigned long Offset);
void
writeDense16(int Value, void *Base, register unsigned long Offset);
@@ -60,24 +54,6 @@ readDense32(void *Base, register unsigned long Offset)
}
void
-writeDenseNB8(int Value, void *Base, register unsigned long Offset)
-{
- alpha_stb((void *) ((unsigned long) Base + (Offset)), Value);
-}
-
-void
-writeDenseNB16(int Value, void *Base, register unsigned long Offset)
-{
- alpha_stw((void *) ((unsigned long) Base + (Offset)), Value);
-}
-
-void
-writeDenseNB32(int Value, void *Base, register unsigned long Offset)
-{
- *(volatile CARD32 *) ((unsigned long) Base + (Offset)) = Value;
-}
-
-void
writeDense8(int Value, void *Base, register unsigned long Offset)
{
write_mem_barrier();
diff --git a/xorg-server/hw/xfree86/os-support/bus/xf86Pci.h b/xorg-server/hw/xfree86/os-support/bus/xf86Pci.h
index f69e55b39..210ab3d89 100644
--- a/xorg-server/hw/xfree86/os-support/bus/xf86Pci.h
+++ b/xorg-server/hw/xfree86/os-support/bus/xf86Pci.h
@@ -232,28 +232,7 @@
* Typedefs, etc...
*/
-/* Primitive Types */
-typedef unsigned long ADDRESS; /* Memory/PCI address */
-typedef unsigned long IOADDRESS _X_DEPRECATED; /* Must be large enough for a pointer */
-typedef CARD32 PCITAG _X_DEPRECATED;
-
-typedef enum {
- PCI_MEM,
- PCI_MEM_SIZE,
- PCI_MEM_SPARSE_BASE,
- PCI_MEM_SPARSE_MASK,
- PCI_IO,
- PCI_IO_SIZE,
- PCI_IO_SPARSE_BASE,
- PCI_IO_SPARSE_MASK
-} PciAddrType;
-
/* Public PCI access functions */
extern _X_EXPORT Bool xf86scanpci(void);
-/* Domain access functions. Some of these probably shouldn't be public */
-extern _X_EXPORT struct pci_io_handle *xf86MapLegacyIO(struct pci_device *dev);
-extern _X_EXPORT void xf86UnmapLegacyIO(struct pci_device *,
- struct pci_io_handle *);
-
#endif /* _XF86PCI_H */
diff --git a/xorg-server/hw/xfree86/os-support/linux/lnx_ev56.c b/xorg-server/hw/xfree86/os-support/linux/lnx_ev56.c
index b6950009c..4e886b6ce 100644
--- a/xorg-server/hw/xfree86/os-support/linux/lnx_ev56.c
+++ b/xorg-server/hw/xfree86/os-support/linux/lnx_ev56.c
@@ -10,12 +10,6 @@ int readDense8(void *Base, register unsigned long Offset);
int readDense16(void *Base, register unsigned long Offset);
int readDense32(void *Base, register unsigned long Offset);
void
- writeDenseNB8(int Value, void *Base, register unsigned long Offset);
-void
- writeDenseNB16(int Value, void *Base, register unsigned long Offset);
-void
- writeDenseNB32(int Value, void *Base, register unsigned long Offset);
-void
writeDense8(int Value, void *Base, register unsigned long Offset);
void
writeDense16(int Value, void *Base, register unsigned long Offset);
@@ -44,24 +38,6 @@ readDense32(void *Base, register unsigned long Offset)
}
void
-writeDenseNB8(int Value, void *Base, register unsigned long Offset)
-{
- *(volatile CARD8 *) ((unsigned long) Base + (Offset)) = Value;
-}
-
-void
-writeDenseNB16(int Value, void *Base, register unsigned long Offset)
-{
- *(volatile CARD16 *) ((unsigned long) Base + (Offset)) = Value;
-}
-
-void
-writeDenseNB32(int Value, void *Base, register unsigned long Offset)
-{
- *(volatile CARD32 *) ((unsigned long) Base + (Offset)) = Value;
-}
-
-void
writeDense8(int Value, void *Base, register unsigned long Offset)
{
write_mem_barrier();
diff --git a/xorg-server/hw/xfree86/os-support/linux/lnx_video.c b/xorg-server/hw/xfree86/os-support/linux/lnx_video.c
index 652f963a2..ffffc81c5 100644
--- a/xorg-server/hw/xfree86/os-support/linux/lnx_video.c
+++ b/xorg-server/hw/xfree86/os-support/linux/lnx_video.c
@@ -571,12 +571,6 @@ extern int readDense8(void *Base, register unsigned long Offset);
extern int readDense16(void *Base, register unsigned long Offset);
extern int readDense32(void *Base, register unsigned long Offset);
extern void
- writeDenseNB8(int Value, void *Base, register unsigned long Offset);
-extern void
- writeDenseNB16(int Value, void *Base, register unsigned long Offset);
-extern void
- writeDenseNB32(int Value, void *Base, register unsigned long Offset);
-extern void
writeDense8(int Value, void *Base, register unsigned long Offset);
extern void
writeDense16(int Value, void *Base, register unsigned long Offset);
@@ -867,12 +861,6 @@ void (*xf86WriteMmio16) (int Value, void *Base, unsigned long Offset)
= writeDense16;
void (*xf86WriteMmio32) (int Value, void *Base, unsigned long Offset)
= writeDense32;
-void (*xf86WriteMmioNB8) (int Value, void *Base, unsigned long Offset)
- = writeDenseNB8;
-void (*xf86WriteMmioNB16) (int Value, void *Base, unsigned long Offset)
- = writeDenseNB16;
-void (*xf86WriteMmioNB32) (int Value, void *Base, unsigned long Offset)
- = writeDenseNB32;
int (*xf86ReadMmio8) (void *Base, unsigned long Offset)
= readDense8;
int (*xf86ReadMmio16) (void *Base, unsigned long Offset)
diff --git a/xorg-server/hw/xfree86/os-support/xf86OSpriv.h b/xorg-server/hw/xfree86/os-support/xf86OSpriv.h
index 7f003e8ce..b56f45a3e 100644
--- a/xorg-server/hw/xfree86/os-support/xf86OSpriv.h
+++ b/xorg-server/hw/xfree86/os-support/xf86OSpriv.h
@@ -36,14 +36,12 @@ typedef void *(*MapMemProcPtr) (int, unsigned long, unsigned long, int);
typedef void (*UnmapMemProcPtr) (int, void *, unsigned long);
typedef void *(*SetWCProcPtr) (int, unsigned long, unsigned long, Bool,
MessageType);
-typedef void (*ProtectMemProcPtr) (int, void *, unsigned long, Bool);
typedef void (*UndoWCProcPtr) (int, void *);
typedef struct {
Bool initialised;
MapMemProcPtr mapMem;
UnmapMemProcPtr unmapMem;
- ProtectMemProcPtr protectMem;
SetWCProcPtr setWC;
UndoWCProcPtr undoWC;
Bool linearSupported;
diff --git a/xorg-server/hw/xfree86/os-support/xf86_OSlib.h b/xorg-server/hw/xfree86/os-support/xf86_OSlib.h
index eb0a338c9..9120bd7dc 100644
--- a/xorg-server/hw/xfree86/os-support/xf86_OSlib.h
+++ b/xorg-server/hw/xfree86/os-support/xf86_OSlib.h
@@ -364,8 +364,4 @@ struct pcvtid {
#define XF86_OS_PRIVS
#include "xf86_OSproc.h"
-#ifndef NO_COMPILER_H
-#include "compiler.h"
-#endif
-
#endif /* _XF86_OSLIB_H */
diff --git a/xorg-server/hw/xfree86/ramdac/xf86RamDacCmap.c b/xorg-server/hw/xfree86/ramdac/xf86RamDacCmap.c
index fa7a86663..2a0f75569 100644
--- a/xorg-server/hw/xfree86/ramdac/xf86RamDacCmap.c
+++ b/xorg-server/hw/xfree86/ramdac/xf86RamDacCmap.c
@@ -35,7 +35,6 @@
#include "micmap.h"
#include "xf86.h"
-#include "compiler.h"
#include "colormapst.h"
#include "xf86RamDacPriv.h"
diff --git a/xorg-server/hw/xfree86/vgahw/Makefile.am b/xorg-server/hw/xfree86/vgahw/Makefile.am
index 4b718b489..b8196a695 100644
--- a/xorg-server/hw/xfree86/vgahw/Makefile.am
+++ b/xorg-server/hw/xfree86/vgahw/Makefile.am
@@ -6,5 +6,3 @@ AM_CPPFLAGS = $(XORG_INCS) -I$(srcdir)/../ddc -I$(srcdir)/../i2c
AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS)
sdk_HEADERS = vgaHW.h
-
-EXTRA_DIST = vgaCmap.c
diff --git a/xorg-server/hw/xfree86/vgahw/vgaCmap.c b/xorg-server/hw/xfree86/vgahw/vgaCmap.c
deleted file mode 100644
index 6e028a7f5..000000000
--- a/xorg-server/hw/xfree86/vgahw/vgaCmap.c
+++ /dev/null
@@ -1,276 +0,0 @@
-/*
- * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Thomas Roell not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Thomas Roell makes no representations
- * about the suitability of this software for any purpose. It is provided
- * "as is" without express or implied warranty.
- *
- * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL THOMAS ROELL BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- *
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <X11/X.h>
-#include <X11/Xproto.h>
-#include "windowstr.h"
-#include "compiler.h"
-#include "mipointer.h"
-#include "micmap.h"
-
-#include "xf86.h"
-#include "vgaHW.h"
-
-#include <X11/extensions/xf86dgaproto.h>
-#include "dgaproc.h"
-
-#define NOMAPYET (ColormapPtr) 0
-
-int
-vgaListInstalledColormaps(pScreen, pmaps)
-ScreenPtr pScreen;
-Colormap *pmaps;
-{
- /* By the time we are processing requests, we can guarantee that there
- * is always a colormap installed */
-
- *pmaps = GetInstalledmiColormap(pScreen)->mid;
- return 1;
-}
-
-int
-vgaGetInstalledColormaps(pScreen, pmaps)
-ScreenPtr pScreen;
-ColormapPtr *pmaps;
-{
- /* By the time we are processing requests, we can guarantee that there
- * is always a colormap installed */
-
- *pmaps = GetInstalledmiColormap(pScreen);
- return 1;
-}
-
-int
-vgaCheckColorMap(ColormapPtr pmap)
-{
- return (pmap != GetInstalledmiColormap(pmap->pScreen));
-}
-
-void
-vgaStoreColors(pmap, ndef, pdefs)
-ColormapPtr pmap;
-int ndef;
-xColorItem *pdefs;
-{
- int i;
- unsigned char *cmap, *tmp = NULL;
- xColorItem directDefs[256];
- Bool new_overscan = FALSE;
- Bool writeColormap;
- int scrnIndex = pmap->pScreen->myNum;
- ScrnInfoPtr scrninfp = xf86ScreenToScrn(pmap->pScreen);
- vgaHWPtr hwp = VGAHWPTR(scrninfp);
-
- unsigned char overscan = hwp->ModeReg.Attribute[OVERSCAN];
- unsigned char tmp_overscan = 0;
-
- if (vgaCheckColorMap(pmap))
- return;
-
- if ((pmap->pVisual->class | DynamicClass) == DirectColor) {
- ndef = miExpandDirectColors(pmap, ndef, pdefs, directDefs);
- pdefs = directDefs;
- }
-
- writeColormap = scrninfp->vtSema;
- if (DGAScreenAvailable(pmap->pScreen)) {
- writeColormap = writeColormap ||
- (DGAGetDirectMode(scrnIndex) &&
- !(DGAGetFlags(scrnIndex) & XF86DGADirectColormap)) ||
- (DGAGetFlags(scrnIndex) & XF86DGAHasColormap);
- }
-
- if (writeColormap)
- hwp->enablePalette(hwp);
-
- for (i = 0; i < ndef; i++) {
- if (pdefs[i].pixel == overscan) {
- new_overscan = TRUE;
- }
- cmap = &(hwp->ModeReg.DAC[pdefs[i].pixel * 3]);
- if (scrninfp->rgbBits == 8) {
- cmap[0] = pdefs[i].red >> 8;
- cmap[1] = pdefs[i].green >> 8;
- cmap[2] = pdefs[i].blue >> 8;
- }
- else {
- cmap[0] = pdefs[i].red >> 10;
- cmap[1] = pdefs[i].green >> 10;
- cmap[2] = pdefs[i].blue >> 10;
- }
-#if 0
- if (clgd6225Lcd) {
- /* The LCD doesn't like white */
- if (cmap[0] == 63)
- cmap[0] = 62;
- if (cmap[1] == 63)
- cmap[1] = 62;
- if (cmap[2] == 63)
- cmap[2] = 62;
- }
-#endif
-
- if (writeColormap) {
- if (hwp->ShowOverscan && i == 255)
- continue;
- hwp->writeDacWriteAddr(hwp, pdefs[i].pixel);
- DACDelay(hwp);
- hwp->writeDacData(hwp, cmap[0]);
- DACDelay(hwp);
- hwp->writeDacData(hwp, cmap[1]);
- DACDelay(hwp);
- hwp->writeDacData(hwp, cmap[2]);
- DACDelay(hwp);
- }
- }
- if (new_overscan && !hwp->ShowOverscan) {
- new_overscan = FALSE;
- for (i = 0; i < ndef; i++) {
- if (pdefs[i].pixel == overscan) {
- if ((pdefs[i].red != 0) ||
- (pdefs[i].green != 0) || (pdefs[i].blue != 0)) {
- new_overscan = TRUE;
- tmp_overscan = overscan;
- tmp = &(hwp->ModeReg.DAC[pdefs[i].pixel * 3]);
- }
- break;
- }
- }
- if (new_overscan) {
- /*
- * Find a black pixel, or the nearest match.
- */
- for (i = 255; i >= 0; i--) {
- cmap = &(hwp->ModeReg.DAC[i * 3]);
- if ((cmap[0] == 0) && (cmap[1] == 0) && (cmap[2] == 0)) {
- overscan = i;
- break;
- }
- else {
- if ((cmap[0] < tmp[0]) &&
- (cmap[1] < tmp[1]) && (cmap[2] < tmp[2])) {
- tmp = cmap;
- tmp_overscan = i;
- }
- }
- }
- if (i < 0) {
- overscan = tmp_overscan;
- }
- hwp->ModeReg.Attribute[OVERSCAN] = overscan;
- if (writeColormap) {
- hwp->writeAttr(hwp, OVERSCAN, overscan);
- }
- }
- }
-
- if (writeColormap)
- hwp->disablePalette(hwp);
-}
-
-void
-vgaInstallColormap(pmap)
-ColormapPtr pmap;
-{
- ColormapPtr oldmap = GetInstalledmiColormap(pmap->pScreen);
- int entries;
- Pixel *ppix;
- xrgb *prgb;
- xColorItem *defs;
- int i;
-
- if (pmap == oldmap)
- return;
-
- if ((pmap->pVisual->class | DynamicClass) == DirectColor)
- entries = (pmap->pVisual->redMask |
- pmap->pVisual->greenMask | pmap->pVisual->blueMask) + 1;
- else
- entries = pmap->pVisual->ColormapEntries;
-
- ppix = (Pixel *) malloc(entries * sizeof(Pixel));
- prgb = (xrgb *) malloc(entries * sizeof(xrgb));
- defs = (xColorItem *) malloc(entries * sizeof(xColorItem));
-
- if (oldmap != NOMAPYET)
- WalkTree(pmap->pScreen, TellLostMap, &oldmap->mid);
-
- SetInstalledmiColormap(pmap->pScreen, pmap);
-
- for (i = 0; i < entries; i++)
- ppix[i] = i;
-
- QueryColors(pmap, entries, ppix, prgb, serverClient);
-
- for (i = 0; i < entries; i++) { /* convert xrgbs to xColorItems */
- defs[i].pixel = ppix[i];
- defs[i].red = prgb[i].red;
- defs[i].green = prgb[i].green;
- defs[i].blue = prgb[i].blue;
- defs[i].flags = DoRed | DoGreen | DoBlue;
- }
- pmap->pScreen->StoreColors(pmap, entries, defs);
-
- WalkTree(pmap->pScreen, TellGainedMap, &pmap->mid);
-
- free(ppix);
- free(prgb);
- free(defs);
-}
-
-void
-vgaUninstallColormap(pmap)
-ColormapPtr pmap;
-{
-
- ColormapPtr defColormap;
-
- if (pmap != GetInstalledmiColormap(pmap->pScreen))
- return;
-
- dixLookupResourceByType((void **) &defColormap,
- pmap->pScreen->defColormap, RT_COLORMAP,
- serverClient, DixInstallAccess);
-
- if (defColormap == GetInstalledmiColormap(pmap->pScreen))
- return;
-
- (*pmap->pScreen->InstallColormap) (defColormap);
-}
-
-void
-vgaHandleColormaps(ScreenPtr pScreen, ScrnInfoPtr scrnp)
-{
- if (scrnp->bitsPerPixel > 1) {
- if (scrnp->bitsPerPixel <= 8) { /* For 8bpp SVGA and VGA16 */
- pScreen->InstallColormap = vgaInstallColormap;
- pScreen->UninstallColormap = vgaUninstallColormap;
- pScreen->ListInstalledColormaps = vgaListInstalledColormaps;
- pScreen->StoreColors = vgaStoreColors;
- }
- }
-}
diff --git a/xorg-server/hw/xquartz/xpr/dri.c b/xorg-server/hw/xquartz/xpr/dri.c
index 014709b04..0f1904738 100644
--- a/xorg-server/hw/xquartz/xpr/dri.c
+++ b/xorg-server/hw/xquartz/xpr/dri.c
@@ -138,12 +138,6 @@ DRIFinishScreenInit(ScreenPtr pScreen)
DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
/* Wrap DRI support */
- pDRIPriv->wrap.ValidateTree = pScreen->ValidateTree;
- pScreen->ValidateTree = DRIValidateTree;
-
- pDRIPriv->wrap.PostValidateTree = pScreen->PostValidateTree;
- pScreen->PostValidateTree = DRIPostValidateTree;
-
pDRIPriv->wrap.WindowExposures = pScreen->WindowExposures;
pScreen->WindowExposures = DRIWindowExposures;
@@ -624,51 +618,6 @@ DRICopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
pScreen->CopyWindow = DRICopyWindow;
}
-int
-DRIValidateTree(WindowPtr pParent, WindowPtr pChild, VTKind kind)
-{
- ScreenPtr pScreen = pParent->drawable.pScreen;
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- int returnValue;
-
- /* unwrap */
- pScreen->ValidateTree = pDRIPriv->wrap.ValidateTree;
-
- /* call lower layers */
- returnValue = (*pScreen->ValidateTree)(pParent, pChild, kind);
-
- /* rewrap */
- pScreen->ValidateTree = DRIValidateTree;
-
- return returnValue;
-}
-
-void
-DRIPostValidateTree(WindowPtr pParent, WindowPtr pChild, VTKind kind)
-{
- ScreenPtr pScreen;
- DRIScreenPrivPtr pDRIPriv;
-
- if (pParent) {
- pScreen = pParent->drawable.pScreen;
- }
- else {
- pScreen = pChild->drawable.pScreen;
- }
- pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-
- if (pDRIPriv->wrap.PostValidateTree) {
- /* unwrap */
- pScreen->PostValidateTree = pDRIPriv->wrap.PostValidateTree;
-
- /* call lower layers */
- (*pScreen->PostValidateTree)(pParent, pChild, kind);
-
- /* rewrap */
- pScreen->PostValidateTree = DRIPostValidateTree;
- }
-}
-
void
DRIClipNotify(WindowPtr pWin, int dx, int dy)
{
diff --git a/xorg-server/hw/xquartz/xpr/dri.h b/xorg-server/hw/xquartz/xpr/dri.h
index 70cb8b6d6..4476b06af 100644
--- a/xorg-server/hw/xquartz/xpr/dri.h
+++ b/xorg-server/hw/xquartz/xpr/dri.h
@@ -53,8 +53,6 @@ typedef void (*ClipNotifyPtr)(WindowPtr, int, int);
typedef struct {
WindowExposuresProcPtr WindowExposures;
CopyWindowProcPtr CopyWindow;
- ValidateTreeProcPtr ValidateTree;
- PostValidateTreeProcPtr PostValidateTree;
ClipNotifyProcPtr ClipNotify;
} DRIWrappedFuncsRec, *DRIWrappedFuncsPtr;
@@ -107,12 +105,6 @@ DRIGetWrappedFuncs(ScreenPtr pScreen);
extern void
DRICopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc);
-extern int
-DRIValidateTree(WindowPtr pParent, WindowPtr pChild, VTKind kind);
-
-extern void
-DRIPostValidateTree(WindowPtr pParent, WindowPtr pChild, VTKind kind);
-
extern void
DRIClipNotify(WindowPtr pWin, int dx, int dy);
diff --git a/xorg-server/hw/xwayland/xwayland.h b/xorg-server/hw/xwayland/xwayland.h
index fc6855044..60b0c2964 100644
--- a/xorg-server/hw/xwayland/xwayland.h
+++ b/xorg-server/hw/xwayland/xwayland.h
@@ -27,7 +27,6 @@
#define XWAYLAND_H
#include <dix-config.h>
-#include <xorg-server.h>
#include <stdio.h>
#include <unistd.h>
diff --git a/xorg-server/include/os.h b/xorg-server/include/os.h
index 43718ce2b..2e2dca0c3 100755
--- a/xorg-server/include/os.h
+++ b/xorg-server/include/os.h
@@ -67,15 +67,11 @@ SOFTWARE.
typedef struct _FontPathRec *FontPathPtr;
typedef struct _NewClientRec *NewClientPtr;
-#ifndef xalloc
+#ifndef xnfalloc
#define xnfalloc(size) XNFalloc((unsigned long)(size))
#define xnfcalloc(_num, _size) XNFcalloc((unsigned long)(_num)*(unsigned long)(_size))
#define xnfrealloc(ptr, size) XNFrealloc((void *)(ptr), (unsigned long)(size))
-#define xalloc(size) Xalloc((unsigned long)(size))
-#define xcalloc(_num, _size) Xcalloc((unsigned long)(_num)*(unsigned long)(_size))
-#define xrealloc(ptr, size) Xrealloc((void *)(ptr), (unsigned long)(size))
-#define xfree(ptr) Xfree((void *)(ptr))
#define xstrdup(s) Xstrdup(s)
#define xnfstrdup(s) XNFstrdup(s)
#endif
@@ -216,37 +212,6 @@ extern _X_EXPORT int set_font_authorizations(char **authorizations,
int *authlen,
void *client);
-#ifndef _HAVE_XALLOC_DECLS
-#define _HAVE_XALLOC_DECLS
-
-/*
- * Use malloc(3) instead.
- */
-extern _X_EXPORT void *
-Xalloc(unsigned long /*amount */ ) _X_DEPRECATED;
-
-/*
- * Use calloc(3) instead
- */
-extern _X_EXPORT void *
-Xcalloc(unsigned long /*amount */ ) _X_DEPRECATED;
-
-/*
- * Use realloc(3) instead
- */
-extern _X_EXPORT void *
-Xrealloc(void * /*ptr */ , unsigned long /*amount */ )
- _X_DEPRECATED;
-
-/*
- * Use free(3) instead
- */
-extern _X_EXPORT void
-Xfree(void * /*ptr */ )
- _X_DEPRECATED;
-
-#endif
-
/*
* This function malloc(3)s buffer, terminating the server if there is not
* enough memory.
@@ -417,9 +382,6 @@ typedef struct sockaddr *sockaddrPtr;
extern _X_EXPORT int
InvalidHost(sockaddrPtr /*saddr */ , int /*len */ , ClientPtr client);
-extern _X_EXPORT int
-LocalClientCred(ClientPtr, int *, int *);
-
#define LCC_UID_SET (1 << 0)
#define LCC_GID_SET (1 << 1)
#define LCC_PID_SET (1 << 2)
diff --git a/xorg-server/include/servermd.h b/xorg-server/include/servermd.h
index e75228ebb..3e6bcf45f 100755
--- a/xorg-server/include/servermd.h
+++ b/xorg-server/include/servermd.h
@@ -47,7 +47,10 @@ SOFTWARE.
#ifndef SERVERMD_H
#define SERVERMD_H 1
-#include "dix-config.h"
+#if !defined(_DIX_CONFIG_H_) && !defined(_XORG_SERVER_H_)
+#error Drivers must include xorg-server.h before any other xserver headers
+#error xserver code must include dix-config.h before any other headers
+#endif
#if X_BYTE_ORDER == X_LITTLE_ENDIAN
#define IMAGE_BYTE_ORDER LSBFirst
diff --git a/xorg-server/include/xorg-server.h.in b/xorg-server/include/xorg-server.h.in
index 8bf9d38f2..4cb94875c 100644
--- a/xorg-server/include/xorg-server.h.in
+++ b/xorg-server/include/xorg-server.h.in
@@ -16,6 +16,10 @@
#ifndef _XORG_SERVER_H_
#define _XORG_SERVER_H_
+#ifdef HAVE_XORG_CONFIG_H
+#error Include xorg-config.h when building the X server
+#endif
+
/* Support BigRequests extension */
#undef BIGREQS
@@ -227,4 +231,7 @@
/* Ask fontsproto to make font path element names const */
#define FONT_PATH_ELEMENT_NAME_CONST 1
+/* byte order */
+#undef X_BYTE_ORDER
+
#endif /* _XORG_SERVER_H_ */
diff --git a/xorg-server/mi/mi.h b/xorg-server/mi/mi.h
index feba5cb0c..d5a5ba374 100755
--- a/xorg-server/mi/mi.h
+++ b/xorg-server/mi/mi.h
@@ -515,9 +515,6 @@ extern _X_EXPORT void miMarkUnrealizedWindow(WindowPtr /*pChild */ ,
Bool /*fromConfigure */
);
-extern _X_EXPORT void miSegregateChildren(WindowPtr pWin, RegionPtr pReg,
- int depth);
-
extern _X_EXPORT WindowPtr miSpriteTrace(SpritePtr pSprite, int x, int y);
extern _X_EXPORT WindowPtr miXYToWindow(ScreenPtr pScreen, SpritePtr pSprite, int x, int y);
diff --git a/xorg-server/mi/micoord.h b/xorg-server/mi/micoord.h
index c6fa41d53..71587c033 100644
--- a/xorg-server/mi/micoord.h
+++ b/xorg-server/mi/micoord.h
@@ -32,27 +32,7 @@
/* Macros which handle a coordinate in a single register */
-/*
- * Most compilers will convert divisions by 65536 into shifts, if signed
- * shifts exist. If your machine does arithmetic shifts and your compiler
- * can't get it right, add to this line.
- */
-
-/*
- * mips compiler - what a joke - it CSEs the 65536 constant into a reg
- * forcing as to use div instead of shift. Let's be explicit.
- */
-
-#if defined(mips) || \
- defined(sparc) || defined(__sparc64__) || \
- defined(__alpha) || defined(__alpha__) || \
- defined(__i386__) || defined(__i386) || defined(__ia64__) || \
- defined(__s390x__) || defined(__s390__) || \
- defined(__amd64__) || defined(amd64) || defined(__amd64)
#define GetHighWord(x) (((int) (x)) >> 16)
-#else
-#define GetHighWord(x) (((int) (x)) / 65536)
-#endif
#if IMAGE_BYTE_ORDER == MSBFirst
#define intToCoord(i,x,y) (((x) = GetHighWord(i)), ((y) = (int) ((short) ((i)&0xffff))))
diff --git a/xorg-server/mi/miwindow.c b/xorg-server/mi/miwindow.c
index 3ee83d7c0..31b196fe7 100644
--- a/xorg-server/mi/miwindow.c
+++ b/xorg-server/mi/miwindow.c
@@ -746,20 +746,6 @@ miMarkUnrealizedWindow(WindowPtr pChild, WindowPtr pWin, Bool fromConfigure)
}
}
-void
-miSegregateChildren(WindowPtr pWin, RegionPtr pReg, int depth)
-{
- WindowPtr pChild;
-
- for (pChild = pWin->firstChild; pChild; pChild = pChild->nextSib) {
- if (pChild->drawable.depth == depth)
- RegionUnion(pReg, pReg, &pChild->borderClip);
-
- if (pChild->firstChild)
- miSegregateChildren(pChild, pReg, depth);
- }
-}
-
WindowPtr
miSpriteTrace(SpritePtr pSprite, int x, int y)
{
diff --git a/xorg-server/miext/shadow/shadow.c b/xorg-server/miext/shadow/shadow.c
index 522e21bd0..0dd3604a7 100644
--- a/xorg-server/miext/shadow/shadow.c
+++ b/xorg-server/miext/shadow/shadow.c
@@ -93,8 +93,6 @@ shadowGetImage(DrawablePtr pDrawable, int sx, int sy, int w, int h,
wrap(pBuf, pScreen, GetImage);
}
-#define BACKWARDS_COMPATIBILITY
-
static Bool
shadowCloseScreen(ScreenPtr pScreen)
{
@@ -104,35 +102,12 @@ shadowCloseScreen(ScreenPtr pScreen)
unwrap(pBuf, pScreen, CloseScreen);
shadowRemove(pScreen, pBuf->pPixmap);
DamageDestroy(pBuf->pDamage);
-#ifdef BACKWARDS_COMPATIBILITY
- RegionUninit(&pBuf->damage); /* bc */
-#endif
if (pBuf->pPixmap)
pScreen->DestroyPixmap(pBuf->pPixmap);
free(pBuf);
return pScreen->CloseScreen(pScreen);
}
-#ifdef BACKWARDS_COMPATIBILITY
-static void
-shadowReportFunc(DamagePtr pDamage, RegionPtr pRegion, void *closure)
-{
- ScreenPtr pScreen = closure;
- shadowBufPtr pBuf = (shadowBufPtr)
- dixLookupPrivate(&pScreen->devPrivates, shadowScrPrivateKey);
-
- /* Register the damaged region, use DamageReportNone below when we
- * want to break BC below... */
- RegionUnion(&pDamage->damage, &pDamage->damage, pRegion);
-
- /*
- * BC hack. In 7.0 and earlier several drivers would inspect the
- * 'damage' member directly, so we have to keep it existing.
- */
- RegionCopy(&pBuf->damage, pRegion);
-}
-#endif
-
Bool
shadowSetup(ScreenPtr pScreen)
{
@@ -147,15 +122,9 @@ shadowSetup(ScreenPtr pScreen)
pBuf = malloc(sizeof(shadowBufRec));
if (!pBuf)
return FALSE;
-#ifdef BACKWARDS_COMPATIBILITY
- pBuf->pDamage = DamageCreate((DamageReportFunc) shadowReportFunc,
- (DamageDestroyFunc) NULL,
- DamageReportRawRegion, TRUE, pScreen, pScreen);
-#else
pBuf->pDamage = DamageCreate((DamageReportFunc) NULL,
(DamageDestroyFunc) NULL,
DamageReportNone, TRUE, pScreen, pScreen);
-#endif
if (!pBuf->pDamage) {
free(pBuf);
return FALSE;
@@ -168,9 +137,6 @@ shadowSetup(ScreenPtr pScreen)
pBuf->pPixmap = 0;
pBuf->closure = 0;
pBuf->randr = 0;
-#ifdef BACKWARDS_COMPATIBILITY
- RegionNull(&pBuf->damage); /* bc */
-#endif
dixSetPrivate(&pScreen->devPrivates, shadowScrPrivateKey, pBuf);
return TRUE;
@@ -230,23 +196,3 @@ shadowRemove(ScreenPtr pScreen, PixmapPtr pPixmap)
RemoveBlockAndWakeupHandlers(shadowBlockHandler, shadowWakeupHandler,
(void *) pScreen);
}
-
-Bool
-shadowInit(ScreenPtr pScreen, ShadowUpdateProc update, ShadowWindowProc window)
-{
- PixmapPtr pPixmap;
-
- pPixmap = pScreen->CreatePixmap(pScreen, pScreen->width, pScreen->height,
- pScreen->rootDepth, 0);
- if (!pPixmap)
- return FALSE;
-
- if (!shadowSetup(pScreen)) {
- pScreen->DestroyPixmap(pPixmap);
- return FALSE;
- }
-
- shadowAdd(pScreen, pPixmap, update, window, SHADOW_ROTATE_0, 0);
-
- return TRUE;
-}
diff --git a/xorg-server/miext/shadow/shadow.h b/xorg-server/miext/shadow/shadow.h
index 421ae96a6..86fa94479 100644
--- a/xorg-server/miext/shadow/shadow.h
+++ b/xorg-server/miext/shadow/shadow.h
@@ -43,12 +43,10 @@ typedef void *(*ShadowWindowProc) (ScreenPtr pScreen,
CARD32 offset,
int mode, CARD32 *size, void *closure);
-/* BC hack: do not move the damage member. see shadow.c for explanation. */
typedef struct _shadowBuf {
DamagePtr pDamage;
ShadowUpdateProc update;
ShadowWindowProc window;
- RegionRec damage;
PixmapPtr pPixmap;
void *closure;
int randr;
@@ -89,10 +87,6 @@ shadowAdd(ScreenPtr pScreen,
extern _X_EXPORT void
shadowRemove(ScreenPtr pScreen, PixmapPtr pPixmap);
-extern _X_EXPORT Bool
-
-shadowInit(ScreenPtr pScreen, ShadowUpdateProc update, ShadowWindowProc window);
-
extern _X_EXPORT void *shadowAlloc(int width, int height, int bpp);
extern _X_EXPORT void
diff --git a/xorg-server/os/access.c b/xorg-server/os/access.c
index 31b07720d..0dda35bb5 100644
--- a/xorg-server/os/access.c
+++ b/xorg-server/os/access.c
@@ -1183,33 +1183,6 @@ ComputeLocalClient(ClientPtr client)
}
/*
- * Return the uid and gid of a connected local client
- *
- * Used by XShm to test access rights to shared memory segments
- */
-int
-LocalClientCred(ClientPtr client, int *pUid, int *pGid)
-{
- LocalClientCredRec *lcc;
- int ret = GetLocalClientCreds(client, &lcc);
-
- if (ret == 0) {
-#ifdef HAVE_GETZONEID /* only local if in the same zone */
- if ((lcc->fieldsSet & LCC_ZID_SET) && (lcc->zoneid != getzoneid())) {
- FreeLocalClientCreds(lcc);
- return -1;
- }
-#endif
- if ((lcc->fieldsSet & LCC_UID_SET) && (pUid != NULL))
- *pUid = lcc->euid;
- if ((lcc->fieldsSet & LCC_GID_SET) && (pGid != NULL))
- *pGid = lcc->egid;
- FreeLocalClientCreds(lcc);
- }
- return ret;
-}
-
-/*
* Return the uid and all gids of a connected local client
* Allocates a LocalClientCredRec - caller must call FreeLocalClientCreds
*
diff --git a/xorg-server/os/utils.c b/xorg-server/os/utils.c
index 153096aa0..0e231537a 100755
--- a/xorg-server/os/utils.c
+++ b/xorg-server/os/utils.c
@@ -1110,24 +1110,6 @@ set_font_authorizations(char **authorizations, int *authlen, void *client)
}
void *
-Xalloc(unsigned long amount)
-{
- /*
- * Xalloc used to return NULL when large amount of memory is requested. In
- * order to catch the buggy callers this warning has been added, slated to
- * removal by anyone who touches this code (or just looks at it) in 2011.
- *
- * -- Mikhail Gusarov
- */
- if ((long) amount <= 0)
- ErrorF("Warning: Xalloc: "
- "requesting unpleasantly large amount of memory: %lu bytes.\n",
- amount);
-
- return malloc(amount);
-}
-
-void *
XNFalloc(unsigned long amount)
{
void *ptr = malloc(amount);
@@ -1138,12 +1120,6 @@ XNFalloc(unsigned long amount)
}
void *
-Xcalloc(unsigned long amount)
-{
- return calloc(1, amount);
-}
-
-void *
XNFcalloc(unsigned long amount)
{
void *ret = calloc(1, amount);
@@ -1154,24 +1130,6 @@ XNFcalloc(unsigned long amount)
}
void *
-Xrealloc(void *ptr, unsigned long amount)
-{
- /*
- * Xrealloc used to return NULL when large amount of memory is requested. In
- * order to catch the buggy callers this warning has been added, slated to
- * removal by anyone who touches this code (or just looks at it) in 2011.
- *
- * -- Mikhail Gusarov
- */
- if ((long) amount <= 0)
- ErrorF("Warning: Xrealloc: "
- "requesting unpleasantly large amount of memory: %lu bytes.\n",
- amount);
-
- return realloc(ptr, amount);
-}
-
-void *
XNFrealloc(void *ptr, unsigned long amount)
{
void *ret = realloc(ptr, amount);
@@ -1181,12 +1139,6 @@ XNFrealloc(void *ptr, unsigned long amount)
return ret;
}
-void
-Xfree(void *ptr)
-{
- free(ptr);
-}
-
char *
Xstrdup(const char *s)
{
diff --git a/xorg-server/present/present.c b/xorg-server/present/present.c
index 6528bd231..c0b83f705 100644
--- a/xorg-server/present/present.c
+++ b/xorg-server/present/present.c
@@ -291,14 +291,18 @@ present_window_to_crtc_msc(WindowPtr window, RRCrtcPtr crtc, uint64_t window_msc
if (crtc != window_priv->crtc) {
uint64_t old_ust, old_msc;
- /* The old CRTC may have been turned off, in which case
- * we'll just use whatever previous MSC we'd seen from this CRTC
- */
+ if (window_priv->crtc == PresentCrtcNeverSet) {
+ window_priv->msc_offset = 0;
+ } else {
+ /* The old CRTC may have been turned off, in which case
+ * we'll just use whatever previous MSC we'd seen from this CRTC
+ */
- if (present_get_ust_msc(window->drawable.pScreen, window_priv->crtc, &old_ust, &old_msc) != Success)
- old_msc = window_priv->msc;
+ if (present_get_ust_msc(window->drawable.pScreen, window_priv->crtc, &old_ust, &old_msc) != Success)
+ old_msc = window_priv->msc;
- window_priv->msc_offset += new_msc - old_msc;
+ window_priv->msc_offset += new_msc - old_msc;
+ }
window_priv->crtc = crtc;
}
@@ -395,7 +399,8 @@ present_set_abort_flip(ScreenPtr screen)
present_set_tree_pixmap(screen_priv->flip_window,
(*screen->GetScreenPixmap)(screen));
- present_set_tree_pixmap(screen->root, (*screen->GetScreenPixmap)(screen));
+ if (screen->root)
+ present_set_tree_pixmap(screen->root, (*screen->GetScreenPixmap)(screen));
screen_priv->flip_pending->abort_flip = TRUE;
}
@@ -725,7 +730,7 @@ present_pixmap(WindowPtr window,
if (!pixmap)
target_crtc = window_priv->crtc;
- if (!target_crtc)
+ if (!target_crtc || target_crtc == PresentCrtcNeverSet)
target_crtc = present_get_crtc(window);
}
diff --git a/xorg-server/present/present_priv.h b/xorg-server/present/present_priv.h
index d8569a2b6..f5c1652d1 100644
--- a/xorg-server/present/present_priv.h
+++ b/xorg-server/present/present_priv.h
@@ -134,6 +134,8 @@ typedef struct present_window_priv {
struct xorg_list notifies;
} present_window_priv_rec, *present_window_priv_ptr;
+#define PresentCrtcNeverSet ((RRCrtcPtr) 1)
+
extern DevPrivateKeyRec present_window_private_key;
static inline present_window_priv_ptr
diff --git a/xorg-server/present/present_screen.c b/xorg-server/present/present_screen.c
index 1e4f55d37..7bfebf1d2 100644
--- a/xorg-server/present/present_screen.c
+++ b/xorg-server/present/present_screen.c
@@ -45,6 +45,7 @@ present_get_window_priv(WindowPtr window, Bool create)
return NULL;
xorg_list_init(&window_priv->vblank);
xorg_list_init(&window_priv->notifies);
+ window_priv->crtc = PresentCrtcNeverSet;
dixSetPrivate(&window->devPrivates, &present_window_private_key, window_priv);
return window_priv;
}
diff --git a/xorg-server/randr/rrpointer.c b/xorg-server/randr/rrpointer.c
index eb6b6770c..b301d050d 100644
--- a/xorg-server/randr/rrpointer.c
+++ b/xorg-server/randr/rrpointer.c
@@ -77,21 +77,22 @@ RRPointerToNearestCrtc(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y,
if (x < crtc->x)
dx = crtc->x - x;
- else if (x > crtc->x + scan_width)
- dx = x - (crtc->x + scan_width);
+ else if (x > crtc->x + scan_width - 1)
+ dx = crtc->x + (scan_width - 1) - x;
else
dx = 0;
if (y < crtc->y)
dy = crtc->y - y;
- else if (y > crtc->y + scan_height)
- dy = y - (crtc->y + scan_height);
+ else if (y > crtc->y + scan_height - 1)
+ dy = crtc->y + (scan_height - 1) - y;
else
dy = 0;
- dist = dx + dy;
+ dist = dx * dx + dy * dy;
if (!nearest || dist < best) {
nearest = crtc;
best_dx = dx;
best_dy = dy;
+ best = dist;
}
}
if (best_dx || best_dy)
diff --git a/xorg-server/render/picture.c b/xorg-server/render/picture.c
index 7da93102b..58535d475 100644
--- a/xorg-server/render/picture.c
+++ b/xorg-server/render/picture.c
@@ -1332,87 +1332,6 @@ SetPictureTransform(PicturePtr pPicture, PictTransform * transform)
return Success;
}
-void
-CopyPicture(PicturePtr pSrc, Mask mask, PicturePtr pDst)
-{
- PictureScreenPtr ps = GetPictureScreen(pSrc->pDrawable->pScreen);
- Mask origMask = mask;
-
- pDst->serialNumber |= GC_CHANGE_SERIAL_BIT;
- pDst->stateChanges |= mask;
-
- while (mask) {
- Mask bit = lowbit(mask);
-
- switch (bit) {
- case CPRepeat:
- pDst->repeat = pSrc->repeat;
- pDst->repeatType = pSrc->repeatType;
- break;
- case CPAlphaMap:
- if (pSrc->alphaMap &&
- pSrc->alphaMap->pDrawable->type == DRAWABLE_PIXMAP)
- pSrc->alphaMap->refcnt++;
- if (pDst->alphaMap)
- FreePicture((void *) pDst->alphaMap, (XID) 0);
- pDst->alphaMap = pSrc->alphaMap;
- break;
- case CPAlphaXOrigin:
- pDst->alphaOrigin.x = pSrc->alphaOrigin.x;
- break;
- case CPAlphaYOrigin:
- pDst->alphaOrigin.y = pSrc->alphaOrigin.y;
- break;
- case CPClipXOrigin:
- pDst->clipOrigin.x = pSrc->clipOrigin.x;
- break;
- case CPClipYOrigin:
- pDst->clipOrigin.y = pSrc->clipOrigin.y;
- break;
- case CPClipMask:
- switch (pSrc->clientClipType) {
- case CT_NONE:
- (*ps->ChangePictureClip) (pDst, CT_NONE, NULL, 0);
- break;
- case CT_REGION:
- if (!pSrc->clientClip) {
- (*ps->ChangePictureClip) (pDst, CT_NONE, NULL, 0);
- }
- else {
- RegionPtr clientClip;
- RegionPtr srcClientClip = (RegionPtr) pSrc->clientClip;
-
- clientClip = RegionCreate(RegionExtents(srcClientClip),
- RegionNumRects(srcClientClip));
- (*ps->ChangePictureClip) (pDst, CT_REGION, clientClip, 0);
- }
- break;
- default:
- /* XXX: CT_PIXMAP unimplemented */
- break;
- }
- break;
- case CPGraphicsExposure:
- pDst->graphicsExposures = pSrc->graphicsExposures;
- break;
- case CPPolyEdge:
- pDst->polyEdge = pSrc->polyEdge;
- break;
- case CPPolyMode:
- pDst->polyMode = pSrc->polyMode;
- break;
- case CPDither:
- break;
- case CPComponentAlpha:
- pDst->componentAlpha = pSrc->componentAlpha;
- break;
- }
- mask &= ~bit;
- }
-
- (*ps->ChangePicture) (pDst, origMask);
-}
-
static void
ValidateOnePicture(PicturePtr pPicture)
{
diff --git a/xorg-server/render/picturestr.h b/xorg-server/render/picturestr.h
index 8c8100d81..1278f620a 100644
--- a/xorg-server/render/picturestr.h
+++ b/xorg-server/render/picturestr.h
@@ -476,9 +476,6 @@ extern _X_EXPORT int
SetPictureTransform(PicturePtr pPicture, PictTransform * transform);
extern _X_EXPORT void
- CopyPicture(PicturePtr pSrc, Mask mask, PicturePtr pDst);
-
-extern _X_EXPORT void
ValidatePicture(PicturePtr pPicture);
extern _X_EXPORT int
diff --git a/xorg-server/xkb/xkbEvents.c b/xorg-server/xkb/xkbEvents.c
index e2ba38886..ccf64215d 100644
--- a/xorg-server/xkb/xkbEvents.c
+++ b/xorg-server/xkb/xkbEvents.c
@@ -235,7 +235,6 @@ XkbSendStateNotify(DeviceIntPtr kbd, xkbStateNotify * pSN)
while (interest) {
if ((!interest->client->clientGone) &&
- (interest->client->requestVector != InitialVector) &&
(interest->client->xkbClientFlags & _XkbClientInitialized) &&
(interest->stateNotifyMask & changed)) {
pSN->sequenceNumber = interest->client->sequence;
@@ -398,7 +397,6 @@ XkbSendControlsNotify(DeviceIntPtr kbd, xkbControlsNotify * pCN)
pCN->numGroups = xkbi->desc->ctrls->num_groups;
while (interest) {
if ((!interest->client->clientGone) &&
- (interest->client->requestVector != InitialVector) &&
(interest->client->xkbClientFlags & _XkbClientInitialized) &&
(interest->ctrlsNotifyMask & changedControls)) {
if (!initialized) {
@@ -445,7 +443,6 @@ XkbSendIndicatorNotify(DeviceIntPtr kbd, int xkbType, xkbIndicatorNotify * pEv)
changed = pEv->changed;
while (interest) {
if ((!interest->client->clientGone) &&
- (interest->client->requestVector != InitialVector) &&
(interest->client->xkbClientFlags & _XkbClientInitialized) &&
(((xkbType == XkbIndicatorStateNotify) &&
(interest->iStateNotifyMask & changed)) ||
@@ -526,7 +523,6 @@ XkbHandleBell(BOOL force,
initialized = 0;
while (interest) {
if ((!interest->client->clientGone) &&
- (interest->client->requestVector != InitialVector) &&
(interest->client->xkbClientFlags & _XkbClientInitialized) &&
(interest->bellNotifyMask)) {
if (!initialized) {
@@ -579,7 +575,6 @@ XkbSendAccessXNotify(DeviceIntPtr kbd, xkbAccessXNotify * pEv)
db_delay = pEv->debounceDelay;
while (interest) {
if ((!interest->client->clientGone) &&
- (interest->client->requestVector != InitialVector) &&
(interest->client->xkbClientFlags & _XkbClientInitialized) &&
(interest->accessXNotifyMask & (1 << pEv->detail))) {
if (!initialized) {
@@ -625,7 +620,6 @@ XkbSendNamesNotify(DeviceIntPtr kbd, xkbNamesNotify * pEv)
changedVirtualMods = pEv->changedVirtualMods;
while (interest) {
if ((!interest->client->clientGone) &&
- (interest->client->requestVector != InitialVector) &&
(interest->client->xkbClientFlags & _XkbClientInitialized) &&
(interest->namesNotifyMask & pEv->changed)) {
if (!initialized) {
@@ -669,7 +663,6 @@ XkbSendCompatMapNotify(DeviceIntPtr kbd, xkbCompatMapNotify * pEv)
initialized = 0;
while (interest) {
if ((!interest->client->clientGone) &&
- (interest->client->requestVector != InitialVector) &&
(interest->client->xkbClientFlags & _XkbClientInitialized) &&
(interest->compatNotifyMask)) {
if (!initialized) {
@@ -720,7 +713,6 @@ XkbSendActionMessage(DeviceIntPtr kbd, xkbActionMessage * pEv)
pEv->group = xkbi->state.group;
while (interest) {
if ((!interest->client->clientGone) &&
- (interest->client->requestVector != InitialVector) &&
(interest->client->xkbClientFlags & _XkbClientInitialized) &&
(interest->actionMessageMask)) {
if (!initialized) {
@@ -764,7 +756,6 @@ XkbSendExtensionDeviceNotify(DeviceIntPtr dev,
state = pEv->ledState;
while (interest) {
if ((!interest->client->clientGone) &&
- (interest->client->requestVector != InitialVector) &&
(interest->client->xkbClientFlags & _XkbClientInitialized) &&
(interest->extDevNotifyMask & reason)) {
if (!initialized) {
diff --git a/xorg-server/xkeyboard-config/rules/base.extras.xml.in b/xorg-server/xkeyboard-config/rules/base.extras.xml.in
index 9107c03f2..2bda88ba7 100644
--- a/xorg-server/xkeyboard-config/rules/base.extras.xml.in
+++ b/xorg-server/xkeyboard-config/rules/base.extras.xml.in
@@ -815,6 +815,21 @@
</languageList>
</configItem>
</layout>
+ <layout>
+ <configItem>
+ <name>cm</name>
+ <_shortDescription>cm</_shortDescription>
+ <_description>English (Cameroon)</_description>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>mmuock</name>
+ <_description>Mmuock</_description>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
</layoutList>
<optionList/>
</xkbConfigRegistry>
diff --git a/xorg-server/xkeyboard-config/symbols/cm b/xorg-server/xkeyboard-config/symbols/cm
index 6b7a51854..685ef2afa 100644
--- a/xorg-server/xkeyboard-config/symbols/cm
+++ b/xorg-server/xkeyboard-config/symbols/cm
@@ -324,3 +324,128 @@ xkb_symbols "semicolon_switch_dvorak" {
modifier_map Mod5 { ISO_Level3_Latch };
};
+// EXTRAS:
+
+// ------- begin Mmuock keyboard map ------------------------------------------
+// This layout is used for the Mmuock alphabet as described in the book
+// _The Sound of Mmuock: Orthography_ [isbn: 978-9956-645-17-6]. Mmuock
+// is the language of the Mmuock (local: Muòk) people of Western Cameroon.
+//
+// Author: Tano Fotang <fotang at mmuock dot org>
+// Created: 2014-06-24
+// Version: 1.0
+//
+// CHANGES:
+// 2014-07-06 corrected shifted level3 of <AC11> to quotedbl
+//
+// NOTES:
+// 0. This map is based on the Latin layout for the US keyboard.
+//
+// 1. We use combining diacritical marks to create tone markings. There are 13
+// tones that need to be indicated.
+//
+// 2. When composing Mmuock text, about every fourth symbol is for tone. To
+// facilitate easy and fast input, the combining diacritics are placed on
+// the home row (AC). To reduce the number of key strokes required, the
+// unshifted third level is used. Only 5 of the combining diacritics are not
+// on the AC row; they are in the top number row, AE.
+//
+// 3. Symbols that are used infrequently (`r', `h', `ɛ', `ǝ', etc.) are placed
+// in level3. Additionally, the letter eng (`ŋ'), although commonly used,
+// is found in level3 because it can alternatively be represented by <ng>.
+// (Indeed, the keyman keyboard actually replaces <ng> with `ŋ'.)
+//
+// 4. The unshifted AB10 key (normally assigned to the slash `/') is used as
+// level 3 switch since the slash is not used in the ordinary course of
+// typing Mmuock text.
+//
+// 5. The 'Cameroon Multilingual' keyboard that is defined elsewhere, does not
+// fit our needs because: (a) it is based on a different alphabet, (b) the
+// vast majority of its symbols are not used in Mmuock, and (b) for the few
+// symbols that are shared, the placing of the symbols is not egonomic for
+// typing Mmuock as the _PRIMARY_ language. The aim of this keyboard, is to
+// give priority to symbols that are actually used in the Mmuock alphabet.
+//
+// 6. The following fonts have been found to produce the best results with this
+// keyboard:
+// Family Accuracy
+// DejaVu (except Sans Mono) 9/10
+// Linux Libertine 8/10
+// Ubuntu (except light) 8/10
+// Droid (except sans mono) 7/10
+// Gentium, Gentium Alt 6.5/10
+// In the terminal emulator, the following font variants are most suitable:
+// Ubuntu Mono 9/10
+// Unifont (Medium) 9/10
+// DejaVu Sans Mono 7.5/10
+// Droid Sans Mono 6.5/10
+// These fonts are all freely available.
+//
+// ------the layout-----------
+//
+// ┌─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┲━━━━━━━━━┓
+// │ ~ │ ! │ @ │ # │ $ │ % │ ^ │ & | * │ ( │ ) │ _ │ + ┃ ⌫ Back- ┃
+// AE│ ` │ 1 │ 2 │ 3 │ 4 │ 5 │ 6  ̂│ 7  ̑│ 8  ̍│ 9  ̓│ 0  ̊│ - │ = ┃ space ┃
+// ┢━━━━━┷━┱───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┺━┳━━━━━━━┫
+// ┃ ┃ Q │ W │ E Ǝ │ Š R │ T │ Y │ U Ω │ I Ɛ │ O Φ │ P ∏ │ Ø { │ Σ } ┃ Enter ┃
+// AD┃Tab ↹ ┃ q │ w │ e ǝ │ š r │ t │ y │ u ω │ i ɛ │ o φ │ p π │ ø [ │ σ ] ┃ ⏎ ┃
+// ┣━━━━━━━┻┱────┴┬────┴┬────┴┬────┴┬────┴┬────┴┬────┴┬────┴┬────┴┬────┴┬────┴┬────┺┓ ┃
+// ┃ ┃ A │ S │ D │ F │ G │  ̇ H │ J │ K │ L │ Œ : │ " ” │ Æ | ┃ ┃
+// AC┃Caps ⇬ ┃ a │ s  ̃| d  ̀| f  ̌| g  ̈|  ̣ h │ j  ̆│ k  ̏│ l  ̄│ Œ ; │ ' ’ │ æ \ ┃ ┃
+// ┣━━━━━━━━┹────┬┴────┬┴────┬┴────┬┴────┬┴────┬┴────┬┴────┬┴────┬┴────┬┴────┲┷━━━━━┻━━━━━━┫
+// ┃ │ Z │ X │ C │ V │ B │ N ŋ │ M │ < « │ > » │ ? ┃ ┃
+// AB┃Shift ⇧ │ z │ x │ c │ v │ b │ n Ŋ │ m │ , ‹ │ . › │ / ┃Shift ⇧ ┃
+// ┣━━━━━━━┳━━━━━┷━┳━━━┷━━━┱─┴─────┴─────┴─────┴─────┴─────┴───┲━┷━━━━━╈━━━━━┻━┳━━━━━━━┳━━━┛
+// ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃
+// AA┃Ctrl ┃Meta ┃Alt ┃ Space ┃AltGr ⇮┃Menu ┃Ctrl ┃
+// ┗━━━━━━━┻━━━━━━━┻━━━━━━━┹───────────────────────────────────┺━━━━━━━┻━━━━━━━┻━━━━━━━┛
+//
+
+partial alphanumeric_keys
+xkb_symbols "mmuock" {
+
+ include "latin"
+ include "level3(ralt_switch)"
+
+ name[Group1]= "Mmuock";
+ key <AE06> { [ 6, asciicircum, U0302, NoSymbol ] }; // tone 10
+ key <AE07> { [ 7, ampersand, U0311, NoSymbol ] }; // tone 12
+ key <AE08> { [ 8, asterisk, U030D, trademark ] }; // tone 13
+ key <AE09> { [ 9, parenleft, U0313, plusminus ] }; // tone 14
+ key <AE10> { [ 0, parenright, U030A, degree ] }; // tone 6
+ key <AD03> { [ e, E, U01DD, U018E ] }; // U01DD = reversed E
+ key <AD04> { [ scaron, Scaron, r, R ] };
+ key <AD07> { [ u, U, Greek_omega, Greek_OMEGA ] };
+ key <AD08> { [ i, I, U025B, U0190 ] }; // U025B = open E
+ key <AD09> { [ o, O, Greek_phi, Greek_PHI ] };
+ key <AD10> { [ p, P, Greek_pi, Greek_PI ] };
+ key <AD11> { [ oslash, Ooblique, bracketleft, braceleft ] };
+ key <AD12> { [Greek_sigma, Greek_SIGMA, bracketright, braceright ] };
+ key <AC02> { [ s, S, U0303, NoSymbol ] }; // tone 1
+ key <AC03> { [ d, D, U0300, NoSymbol ] }; // tone 4
+ key <AC04> { [ f, F, U030C, NoSymbol ] }; // tone 5
+ key <AC05> { [ g, G, U0308, NoSymbol ] }; // tone 7
+ key <AC06> { [ U0323, U0307, h, H ] }; // COMBINING DOT BELOW, ABOVE
+ key <AC07> { [ j, J, U0306, NoSymbol ] }; // tone 9
+ key <AC08> { [ k, K, U030F, NoSymbol ] }; // tone 11
+ key <AC09> { [ l, L, U0304, NoSymbol ] }; // tone 0
+ key <AC10> { [ oe, OE, semicolon, colon ] };
+ key <AC11> { [ U0301, U030B, apostrophe, quotedbl ] }; // tone 3, 8
+ key <AB06> { [ n, N, eng, ENG ] };
+ key <AB08> { [ comma, less, guillemotleft, U2039 ] };
+ key <AB09> { [ period, greater, guillemotright, U203A ] };
+ key <BKSL> { [ ae, AE, backslash, bar ] };
+
+ include "cm(solidus_switch)"
+};
+
+// use slash as special key for switching to level3
+partial hidden modifier_keys
+xkb_symbols "solidus_switch" {
+ key <AB10> {
+ symbols[Group1] = [ ISO_Level3_Latch, question, slash, NoSymbol ]
+ };
+ modifier_map Mod5 { ISO_Level3_Latch };
+};
+// ------- end Mmuock keyboard map --------------------------------------------
+
diff --git a/xorg-server/xkeyboard-config/symbols/md b/xorg-server/xkeyboard-config/symbols/md
index cd3430beb..f890233b0 100644
--- a/xorg-server/xkeyboard-config/symbols/md
+++ b/xorg-server/xkeyboard-config/symbols/md
@@ -11,11 +11,11 @@ xkb_symbols "basic" {
// │ ~ │ ! │ " │ # │ ; │ % │ : │ ? │ * │ ( ̣ │ ) │ -- │ + ┃ ⌫ Back ┃
// │ ` │ 1 │ 2 @ │ 3 │ 4 $ │ 5 € │ 6 ^ │ 7 & │ 8 │ 9 │ 0 │ - │ = ┃ space ┃
// ┢━━━━━┷━┱───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┺━┳━━━━━━━┫
-// ┃ ┃ Ţ Q │ Ê W │ E │ R │ T │ Y │ U │ I │ O │ P │ Ö { │ Ü } ┃ Enter ┃
+// ┃ ┃ Ţ Q │ Ê W │ E │ R │ T │ Y │ U │ İ │ O │ P │ Ö { │ Ü } ┃ Enter ┃
// ┃Tab ↹ ┃ ţ q │ ê w │ e │ r │ t │ y │ u │ i │ o │ p │ ö [ │ ü ] ┃ ⏎ ┃
// ┣━━━━━━━┻┱────┴┬────┴┬────┴┬────┴┬────┴┬────┴┬────┴┬────┴┬────┴┬────┴┬────┴┬────┺┓ ┃
// ┃ ┃ A │ S │ D │ F │ G │ H │ J │ K │ L │Ş │I │ / ┃ ┃
-// ┃Caps ⇬ ┃ a │ s │ d │ f │ g │ h │ j │ k │ l │ş │ı │ \ ┃ ┃
+// ┃Caps ⇬ ┃ a │ s │ d │ f │ g │ h │ j │ k │ l │ş │ı' │ \ ┃ ┃
// ┣━━━━━━━━┹────┬┴────┬┴────┬┴────┬┴────┬┴────┬┴────┬┴────┬┴────┬┴────┬┴────┲┷━━━━━┻━━━━━━┫
// ┃ │ Z │ Ç X │ C │ V │ B │ N │ M │Ä │< │> ┃ ┃
// ┃Shift ⇧ │ z │ ç x │ c │ v │ b │ n │ m │ä │, │. ┃Shift ⇧ ┃
@@ -75,7 +75,7 @@ xkb_symbols "gag" {
key <AB01> { [ z, Z ] };
key <AB02> { [ ccedilla, Ccedilla, x, X ] };
- key <AB03> { [ c, Ccedilla ] };
+ key <AB03> { [ c, C ] };
key <AB04> { [ v, V ] };
key <AB05> { [ b, B ] };
key <AB06> { [ n, N ] };