diff options
Diffstat (limited to 'recipes-graphics')
91 files changed, 1515 insertions, 11921 deletions
diff --git a/recipes-graphics/cairo/cairo_%.bbappend b/recipes-graphics/cairo/cairo_%.bbappend index 5b1562ab..bf8c38fc 100644 --- a/recipes-graphics/cairo/cairo_%.bbappend +++ b/recipes-graphics/cairo/cairo_%.bbappend @@ -1,2 +1,5 @@ -PACKAGECONFIG_append_imxgpu3d = " egl glesv2" -PACKAGECONFIG_remove_imxgpu3d = "opengl" +# links with imx-gpu libs which are pre-built for glibc +# gcompat will address it during runtime +LDFLAGS:append:imxgpu:libc-musl = " -Wl,--allow-shlib-undefined" + +RDEPENDS:${PN}:append:imxgpu:libc-musl = " gcompat" diff --git a/recipes-graphics/clutter/clutter-1.0_%.bbappend b/recipes-graphics/clutter/clutter-1.0_%.bbappend deleted file mode 100644 index 0b4c4861..00000000 --- a/recipes-graphics/clutter/clutter-1.0_%.bbappend +++ /dev/null @@ -1,5 +0,0 @@ -PACKAGECONFIG_imxgpu3d ??= " \ - ${@bb.utils.contains('DISTRO_FEATURES', 'wayland', 'wayland egl', \ - bb.utils.contains('DISTRO_FEATURES', 'x11', 'glx x11', \ - '', d), d)} \ -" diff --git a/recipes-graphics/cogl/cogl-1.0_%.bbappend b/recipes-graphics/cogl/cogl-1.0_%.bbappend deleted file mode 100644 index afbaee43..00000000 --- a/recipes-graphics/cogl/cogl-1.0_%.bbappend +++ /dev/null @@ -1,5 +0,0 @@ -PACKAGECONFIG_imxgpu3d ??= " \ - cogl-pango gles2 \ - ${@bb.utils.contains('DISTRO_FEATURES', 'wayland', 'egl-wayland', \ - bb.utils.contains('DISTRO_FEATURES', 'x11', 'egl-x11', \ - '', d), d)}" diff --git a/recipes-graphics/drm/libdrm-armada_git.bb b/recipes-graphics/drm/libdrm-armada_git.bb deleted file mode 100644 index a47987a5..00000000 --- a/recipes-graphics/drm/libdrm-armada_git.bb +++ /dev/null @@ -1,17 +0,0 @@ -SUMMARY = "Userspace interface to kernel DRM services" -SECTION = "x11/base" -LICENSE = "GPLv2 & BSD" - -LIC_FILES_CHKSUM = "file://libdrm_lists.h;beginline=1;endline=25;md5=2af1df1026ba1d24c8e7c370e68ed198" - -DEPENDS = "libdrm" - -SRCREV = "6b461c163b0bd02c76b65d94cc2fb3767167bda8" -PV = "0.1+git${SRCPV}" -SRC_URI = "git://git.armlinux.org.uk/~rmk/libdrm-armada.git" - -inherit autotools pkgconfig - -S = "${WORKDIR}/git" - -COMPATIBLE_MACHINE ?= "(imx|use-mainline-bsp)" diff --git a/recipes-graphics/drm/libdrm/0001-meson-add-libdrm-vivante-to-the-meson-meta-data.patch b/recipes-graphics/drm/libdrm/0001-meson-add-libdrm-vivante-to-the-meson-meta-data.patch deleted file mode 100644 index ae6b0ab7..00000000 --- a/recipes-graphics/drm/libdrm/0001-meson-add-libdrm-vivante-to-the-meson-meta-data.patch +++ /dev/null @@ -1,140 +0,0 @@ -From 45f48f8a5de59c04b0510c23853772bc970f411e Mon Sep 17 00:00:00 2001 -From: Max Krummenacher <max.krummenacher@toradex.com> -Date: Thu, 9 Jan 2020 01:01:35 +0000 -Subject: [PATCH] meson: add libdrm-vivante to the meson meta data - -Upstream libdrm added the option to use meason as the buildsystem. -Integrate Vivante into the relevant meson build information. - -Upstream-Status: Pending - -Signed-off-by: Max Krummenacher <max.krummenacher@toradex.com> ---- - meson.build | 14 +++++++++++++ - meson_options.txt | 7 +++++++ - vivante/meson.build | 50 +++++++++++++++++++++++++++++++++++++++++++++ - 3 files changed, 71 insertions(+) - create mode 100644 vivante/meson.build - -diff --git a/meson.build b/meson.build -index e292554a..f4740634 100644 ---- a/meson.build -+++ b/meson.build -@@ -157,6 +157,15 @@ if _vc4 != 'false' - with_vc4 = _vc4 == 'true' or ['arm', 'aarch64'].contains(host_machine.cpu_family()) - endif - -+with_vivante = false -+_vivante = get_option('vivante') -+if _vivante == 'true' -+ if not with_atomics -+ error('libdrm_vivante requires atomics.') -+ endif -+ with_vivante = true -+endif -+ - # XXX: Apparently only freebsd and dragonfly bsd actually need this (and - # gnu/kfreebsd), not openbsd and netbsd - with_libkms = false -@@ -312,6 +321,7 @@ install_headers( - 'include/drm/savage_drm.h', 'include/drm/sis_drm.h', - 'include/drm/tegra_drm.h', 'include/drm/vc4_drm.h', - 'include/drm/via_drm.h', 'include/drm/virtgpu_drm.h', -+ 'include/drm/vivante_drm.h', - subdir : 'libdrm', - ) - if with_vmwgfx -@@ -362,6 +372,9 @@ endif - if with_etnaviv - subdir('etnaviv') - endif -+if with_vivante -+ subdir('vivante') -+endif - if with_man_pages - subdir('man') - endif -@@ -382,5 +395,6 @@ message(' EXYNOS API @0@'.format(with_exynos)) - message(' Freedreno API @0@ (kgsl: @1@)'.format(with_freedreno, with_freedreno_kgsl)) - message(' Tegra API @0@'.format(with_tegra)) - message(' VC4 API @0@'.format(with_vc4)) -+message(' Vivante API @0@'.format(with_etnaviv)) - message(' Etnaviv API @0@'.format(with_etnaviv)) - message('') -diff --git a/meson_options.txt b/meson_options.txt -index 8af33f1c..dc69563d 100644 ---- a/meson_options.txt -+++ b/meson_options.txt -@@ -95,6 +95,13 @@ option( - choices : ['true', 'false', 'auto'], - description : '''Enable support for vc4's KMS API.''', - ) -+option( -+ 'vivante', -+ type : 'combo', -+ value : 'false', -+ choices : ['true', 'false', 'auto'], -+ description : '''Enable support for vivante's propriatary experimental KMS API.''', -+) - option( - 'etnaviv', - type : 'combo', -diff --git a/vivante/meson.build b/vivante/meson.build -new file mode 100644 -index 00000000..f6adb598 ---- /dev/null -+++ b/vivante/meson.build -@@ -0,0 +1,50 @@ -+# Copyright © 2017-2018 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. -+ -+ -+libdrm_vivante = shared_library( -+ 'drm_vivante', -+ [ -+ files( -+ 'vivante_bo.c', -+ ), -+ config_file -+ ], -+ include_directories : [inc_root, inc_drm], -+ link_with : libdrm, -+ c_args : libdrm_c_args, -+ dependencies : [dep_pthread_stubs, dep_rt, dep_atomic_ops], -+ version : '1.0.0', -+ install : true, -+) -+ -+pkg.generate( -+ name : 'libdrm_vivante', -+ libraries : libdrm_vivante, -+ subdirs : ['.', 'libdrm'], -+ version : meson.project_version(), -+ requires_private : 'libdrm', -+ description : 'Userspace interface to Vivante kernel DRM services', -+) -+ -+ext_libdrm_vivante = declare_dependency( -+ link_with : [libdrm, libdrm_vivante], -+ include_directories : [inc_drm, include_directories('.')], -+) --- -2.20.1 - diff --git a/recipes-graphics/drm/libdrm/musl-ioctl.patch b/recipes-graphics/drm/libdrm/musl-ioctl.patch deleted file mode 100644 index e3d6c5b8..00000000 --- a/recipes-graphics/drm/libdrm/musl-ioctl.patch +++ /dev/null @@ -1,35 +0,0 @@ -Upstream-Status: Submitted -Signed-off-by: Ross Burton <ross.burton@intel.com> - -From 46c0fd6c827a8cb4d04e067bf04fab579ac4712e Mon Sep 17 00:00:00 2001 -From: Ross Burton <ross.burton@intel.com> -Date: Mon, 18 Jun 2018 15:07:03 +0100 -Subject: [PATCH] tests/nouveau/threaded: adapt ioctl signature - -POSIX says ioctl() has the signature (int, int, ...) but glibc has decided to -use (int, unsigned long int, ...) instead. - -Use a #ifdef to adapt the replacement function as appropriate. ---- - tests/nouveau/threaded.c | 4 ++++ - 1 file changed, 4 insertions(+) - -diff --git a/tests/nouveau/threaded.c b/tests/nouveau/threaded.c -index 3669bcd3..e1c27c01 100644 ---- a/tests/nouveau/threaded.c -+++ b/tests/nouveau/threaded.c -@@ -36,7 +36,11 @@ static int failed; - - static int import_fd; - -+#ifdef __GLIBC__ - int ioctl(int fd, unsigned long request, ...) -+#else -+int ioctl(int fd, int request, ...) -+#endif - { - va_list va; - int ret; --- -2.11.0 - diff --git a/recipes-graphics/drm/libdrm_2.4.115.imx.bb b/recipes-graphics/drm/libdrm_2.4.115.imx.bb new file mode 100644 index 00000000..ada0b7ae --- /dev/null +++ b/recipes-graphics/drm/libdrm_2.4.115.imx.bb @@ -0,0 +1,74 @@ +SUMMARY = "Userspace interface to the kernel DRM services" +DESCRIPTION = "The runtime library for accessing the kernel DRM services. DRM \ +stands for \"Direct Rendering Manager\", which is the kernel portion of the \ +\"Direct Rendering Infrastructure\" (DRI). DRI is required for many hardware \ +accelerated OpenGL drivers." +HOMEPAGE = "http://dri.freedesktop.org" +SECTION = "x11/base" +LICENSE = "MIT" +LIC_FILES_CHKSUM = "file://LICENSE;md5=9eb1f4831351ab42d762c40b3ebb7add \ + file://xf86drm.c;beginline=9;endline=32;md5=c8a3b961af7667c530816761e949dc71" +PROVIDES = "drm" +DEPENDS = "libpthread-stubs" + +SRC_URI = "${IMX_LIBDRM_SRC};branch=${SRCBRANCH}" +IMX_LIBDRM_SRC ?= "git://github.com/nxp-imx/libdrm-imx.git;protocol=https" +SRCBRANCH ?= "libdrm-imx-2.4.115" +SRCREV = "0f889a1f9640f6210132dd565141eb19005245fb" + +S = "${WORKDIR}/git" + +DEFAULT_PREFERENCE = "-1" +COMPATIBLE_MACHINE = "(imx-nxp-bsp)" + +inherit meson pkgconfig manpages + +PACKAGECONFIG ??= "intel radeon amdgpu nouveau vmwgfx omap freedreno vc4 etnaviv tests install-test-programs" +PACKAGECONFIG[intel] = "-Dintel=enabled,-Dintel=disabled,libpciaccess" +PACKAGECONFIG[radeon] = "-Dradeon=enabled,-Dradeon=disabled" +PACKAGECONFIG[amdgpu] = "-Damdgpu=enabled,-Damdgpu=disabled" +PACKAGECONFIG[nouveau] = "-Dnouveau=enabled,-Dnouveau=disabled" +PACKAGECONFIG[vmwgfx] = "-Dvmwgfx=enabled,-Dvmwgfx=disabled" +PACKAGECONFIG[omap] = "-Domap=enabled,-Domap=disabled" +PACKAGECONFIG[exynos] = "-Dexynos=enabled,-Dexynos=disabled" +PACKAGECONFIG[freedreno] = "-Dfreedreno=enabled,-Dfreedreno=disabled" +PACKAGECONFIG[tegra] = "-Dtegra=enabled,-Dtegra=disabled" +PACKAGECONFIG[vc4] = "-Dvc4=enabled,-Dvc4=disabled" +PACKAGECONFIG[etnaviv] = "-Detnaviv=enabled,-Detnaviv=disabled" +PACKAGECONFIG[freedreno-kgsl] = "-Dfreedreno-kgsl=true,-Dfreedreno-kgsl=false" +PACKAGECONFIG[valgrind] = "-Dvalgrind=enabled,-Dvalgrind=disabled,valgrind" +PACKAGECONFIG[install-test-programs] = "-Dinstall-test-programs=true,-Dinstall-test-programs=false" +PACKAGECONFIG[cairo-tests] = "-Dcairo-tests=enabled,-Dcairo-tests=disabled" +PACKAGECONFIG[tests] = "-Dtests=true,-Dtests=false" +PACKAGECONFIG[udev] = "-Dudev=true,-Dudev=false,udev" +PACKAGECONFIG[manpages] = "-Dman-pages=enabled,-Dman-pages=disabled,libxslt-native xmlto-native python3-docutils-native" + +ALLOW_EMPTY:${PN}-drivers = "1" +PACKAGES =+ "${PN}-tests ${PN}-drivers ${PN}-radeon ${PN}-nouveau ${PN}-omap \ + ${PN}-intel ${PN}-exynos ${PN}-kms ${PN}-freedreno ${PN}-amdgpu \ + ${PN}-etnaviv" + +RRECOMMENDS:${PN}-drivers = "${PN}-radeon ${PN}-nouveau ${PN}-omap ${PN}-intel \ + ${PN}-exynos ${PN}-freedreno ${PN}-amdgpu \ + ${PN}-etnaviv" + +FILES:${PN}-tests = "${bindir}/*" +FILES:${PN}-radeon = "${libdir}/libdrm_radeon.so.*" +FILES:${PN}-nouveau = "${libdir}/libdrm_nouveau.so.*" +FILES:${PN}-omap = "${libdir}/libdrm_omap.so.*" +FILES:${PN}-intel = "${libdir}/libdrm_intel.so.*" +FILES:${PN}-exynos = "${libdir}/libdrm_exynos.so.*" +FILES:${PN}-kms = "${libdir}/libkms*.so.*" +FILES:${PN}-freedreno = "${libdir}/libdrm_freedreno.so.*" +FILES:${PN}-amdgpu = "${libdir}/libdrm_amdgpu.so.* ${datadir}/${PN}/amdgpu.ids" +FILES:${PN}-etnaviv = "${libdir}/libdrm_etnaviv.so.*" + +BBCLASSEXTEND = "native nativesdk" + +PACKAGES:prepend:imxgpu = "${PN}-vivante " +RRECOMMENDS:${PN}-drivers:append:imxgpu = " ${PN}-vivante" +FILES:${PN}-vivante = "${libdir}/libdrm_vivante.so.*" +PACKAGECONFIG:append:imxgpu = " vivante" +PACKAGECONFIG[vivante] = "-Dvivante=true,-Dvivante=false" + +PACKAGE_ARCH = "${MACHINE_SOCARCH}" diff --git a/recipes-graphics/drm/libdrm_2.4.99.imx.bb b/recipes-graphics/drm/libdrm_2.4.99.imx.bb deleted file mode 100644 index dc2aa8a9..00000000 --- a/recipes-graphics/drm/libdrm_2.4.99.imx.bb +++ /dev/null @@ -1,73 +0,0 @@ -SUMMARY = "Userspace interface to the kernel DRM services" -DESCRIPTION = "The runtime library for accessing the kernel DRM services. DRM \ -stands for \"Direct Rendering Manager\", which is the kernel portion of the \ -\"Direct Rendering Infrastructure\" (DRI). DRI is required for many hardware \ -accelerated OpenGL drivers." -HOMEPAGE = "http://dri.freedesktop.org" -SECTION = "x11/base" -LICENSE = "MIT" -LIC_FILES_CHKSUM = "file://xf86drm.c;beginline=9;endline=32;md5=c8a3b961af7667c530816761e949dc71" -PROVIDES = "drm" -DEPENDS = "libpthread-stubs" - -IMX_LIBDRM_SRC ?= "git://source.codeaurora.org/external/imx/libdrm-imx.git;protocol=https;nobranch=1" -IMX_LIBDRM_BRANCH ?= "libdrm-imx-2.4.99" -SRC_URI = "${IMX_LIBDRM_SRC};branch=${IMX_LIBDRM_BRANCH} \ - file://musl-ioctl.patch \ - file://0001-meson-add-libdrm-vivante-to-the-meson-meta-data.patch " -SRCREV = "f421c9c8c4b8fe48d9e6ef43910e98569c94a4b2" -S = "${WORKDIR}/git" - -DEFAULT_PREFERENCE = "-1" - -inherit meson pkgconfig manpages - -PACKAGECONFIG ??= "libkms intel radeon amdgpu nouveau vmwgfx omap freedreno vc4 etnaviv install-test-programs" -PACKAGECONFIG[libkms] = "-Dlibkms=true,-Dlibkms=false" -PACKAGECONFIG[intel] = "-Dintel=true,-Dintel=false,libpciaccess" -PACKAGECONFIG[radeon] = "-Dradeon=true,-Dradeon=false" -PACKAGECONFIG[amdgpu] = "-Damdgpu=true,-Damdgpu=false" -PACKAGECONFIG[nouveau] = "-Dnouveau=true,-Dnouveau=false" -PACKAGECONFIG[vmwgfx] = "-Dvmwgfx=true,-Dvmwgfx=false" -PACKAGECONFIG[omap] = "-Domap=true,-Domap=false" -PACKAGECONFIG[exynos] = "-Dexynos=true,-Dexynos=false" -PACKAGECONFIG[freedreno] = "-Dfreedreno=true,-Dfreedreno=false" -PACKAGECONFIG[tegra] = "-Dtegra=true,-Dtegra=false" -PACKAGECONFIG[vc4] = "-Dvc4=true,-Dvc4=false" -PACKAGECONFIG[etnaviv] = "-Detnaviv=true,-Detnaviv=false" -PACKAGECONFIG[freedreno-kgsl] = "-Dfreedreno-kgsl=true,-Dfreedreno-kgsl=false" -PACKAGECONFIG[valgrind] = "-Dvalgrind=true,-Dvalgrind=false,valgrind" -PACKAGECONFIG[install-test-programs] = "-Dinstall-test-programs=true,-Dinstall-test-programs=false" -PACKAGECONFIG[cairo-tests] = "-Dcairo-tests=true,-Dcairo-tests=false" -PACKAGECONFIG[udev] = "-Dudev=true,-Dudev=false,udev" -PACKAGECONFIG[manpages] = "-Dman-pages=true,-Dman-pages=false,libxslt-native xmlto-native" - -ALLOW_EMPTY_${PN}-drivers = "1" -PACKAGES =+ "${PN}-tests ${PN}-drivers ${PN}-radeon ${PN}-nouveau ${PN}-omap \ - ${PN}-intel ${PN}-exynos ${PN}-kms ${PN}-freedreno ${PN}-amdgpu \ - ${PN}-etnaviv" - -RRECOMMENDS_${PN}-drivers = "${PN}-radeon ${PN}-nouveau ${PN}-omap ${PN}-intel \ - ${PN}-exynos ${PN}-freedreno ${PN}-amdgpu \ - ${PN}-etnaviv" - -FILES_${PN}-tests = "${bindir}/*" -FILES_${PN}-radeon = "${libdir}/libdrm_radeon.so.*" -FILES_${PN}-nouveau = "${libdir}/libdrm_nouveau.so.*" -FILES_${PN}-omap = "${libdir}/libdrm_omap.so.*" -FILES_${PN}-intel = "${libdir}/libdrm_intel.so.*" -FILES_${PN}-exynos = "${libdir}/libdrm_exynos.so.*" -FILES_${PN}-kms = "${libdir}/libkms*.so.*" -FILES_${PN}-freedreno = "${libdir}/libdrm_freedreno.so.*" -FILES_${PN}-amdgpu = "${libdir}/libdrm_amdgpu.so.* ${datadir}/${PN}/amdgpu.ids" -FILES_${PN}-etnaviv = "${libdir}/libdrm_etnaviv.so.*" - -BBCLASSEXTEND = "native nativesdk" - -PACKAGES_prepend_imxgpu = "${PN}-vivante " -RRECOMMENDS_${PN}-drivers_append_imxgpu = " ${PN}-vivante" -FILES_${PN}-vivante = "${libdir}/libdrm_vivante.so.*" -PACKAGECONFIG_append_imxgpu = " vivante" -PACKAGECONFIG[vivante] = "-Dvivante=true,-Dvivante=false" - -PACKAGE_ARCH = "${MACHINE_SOCARCH}" diff --git a/recipes-graphics/glew/glew_%.bbappend b/recipes-graphics/glew/glew_%.bbappend new file mode 100644 index 00000000..95da4790 --- /dev/null +++ b/recipes-graphics/glew/glew_%.bbappend @@ -0,0 +1 @@ +PACKAGECONFIG:imxgpu = "egl-gles2" diff --git a/recipes-graphics/gtk+/gtk+3_%.bbappend b/recipes-graphics/gtk+/gtk+3_%.bbappend index be2bac75..6bc01807 100644 --- a/recipes-graphics/gtk+/gtk+3_%.bbappend +++ b/recipes-graphics/gtk+/gtk+3_%.bbappend @@ -1,5 +1 @@ -DEPENDS_append_imxgpu2d = " virtual/egl" - -PACKAGECONFIG_remove_imxgpu2d = " \ - ${@bb.utils.contains("DISTRO_FEATURES", "wayland", "x11", "", d)} \ -" +DEPENDS:append:imxgpu2d = " virtual/egl" diff --git a/recipes-graphics/harfbuzz/harfbuzz_%.bbappend b/recipes-graphics/harfbuzz/harfbuzz_%.bbappend new file mode 100644 index 00000000..bf8c38fc --- /dev/null +++ b/recipes-graphics/harfbuzz/harfbuzz_%.bbappend @@ -0,0 +1,5 @@ +# links with imx-gpu libs which are pre-built for glibc +# gcompat will address it during runtime +LDFLAGS:append:imxgpu:libc-musl = " -Wl,--allow-shlib-undefined" + +RDEPENDS:${PN}:append:imxgpu:libc-musl = " gcompat" diff --git a/recipes-graphics/images/core-image-weston.bbappend b/recipes-graphics/images/core-image-weston.bbappend index 2a3cde69..0d4a0c6f 100644 --- a/recipes-graphics/images/core-image-weston.bbappend +++ b/recipes-graphics/images/core-image-weston.bbappend @@ -1,3 +1,3 @@ # FIXME: i.MX6SL cannot use mesa for Graphics and it lacks GL support, # so for now we skip it. -CORE_IMAGE_BASE_INSTALL_remove_mx6sl = "clutter-1.0-examples" +CORE_IMAGE_BASE_INSTALL:remove:mx6sl-nxp-bsp = "clutter-1.0-examples" diff --git a/recipes-graphics/imx-dpu-g2d/imx-dpu-g2d_1.8.3.bb b/recipes-graphics/imx-dpu-g2d/imx-dpu-g2d_1.8.3.bb deleted file mode 100644 index 4465ee7e..00000000 --- a/recipes-graphics/imx-dpu-g2d/imx-dpu-g2d_1.8.3.bb +++ /dev/null @@ -1,30 +0,0 @@ -# Copyright (C) 2016 Freescale Semiconductor -# Copyright 2017-2019 NXP -# Released under the MIT license (see COPYING.MIT for the terms) - -DESCRIPTION = "GPU G2D library and apps for i.MX with 2D GPU and DPU" -LICENSE = "Proprietary" -LIC_FILES_CHKSUM = "file://COPYING;md5=fd4b227530cd88a82af6a5982cfb724d" -PROVIDES += "virtual/libg2d" - -SRC_URI = "${FSL_MIRROR}/${BPN}-${PV}.bin;fsl-eula=true" -SRC_URI[md5sum] = "57a0a0a7d20e4ea1a0d2dcd162abfa79" -SRC_URI[sha256sum] = "f8bc83e23263e179bd66492dafaeb104a3967337d76325d0ec97993ae846fb13" - -inherit fsl-eula-unpack - -do_install () { - install -d ${D}${libdir} - install -d ${D}${includedir} - cp -r ${S}/g2d/usr/lib/*.so* ${D}${libdir} - cp -Pr ${S}/g2d/usr/include/* ${D}${includedir} - cp -r ${S}/gpu-demos/opt ${D} -} - -FILES_${PN} = "${libdir}/libg2d* /opt" -FILES_${PN}-dev = "${libdir}/libg2d${SOLIBSDEV} ${includedir}" -INSANE_SKIP_${PN} += "ldflags" - -RDEPENDS_${PN} = "libgal-imx libdrm" - -COMPATIBLE_MACHINE = "(imxdpu)" diff --git a/recipes-graphics/imx-g2d/imx-dpu-g2d_2.1.10.bb b/recipes-graphics/imx-g2d/imx-dpu-g2d_2.1.10.bb new file mode 100644 index 00000000..16011bd4 --- /dev/null +++ b/recipes-graphics/imx-g2d/imx-dpu-g2d_2.1.10.bb @@ -0,0 +1,38 @@ +# Copyright (C) 2016 Freescale Semiconductor +# Copyright 2017-2022 NXP +# Released under the MIT license (see COPYING.MIT for the terms) + +DESCRIPTION = "G2D library using i.MX DPU" +LICENSE = "Proprietary" +LIC_FILES_CHKSUM = "file://COPYING;md5=db4762b09b6bda63da103963e6e081de" + +DEPENDS = "libgal-imx libdrm" +PROVIDES += "virtual/libg2d" + +SRC_URI = "${FSL_MIRROR}/${IMX_BIN_NAME}.bin;fsl-eula=true" +IMX_BIN_NAME = "${BP}-${IMX_SRCREV_ABBREV}" +IMX_SRCREV_ABBREV = "7ed5396" +SRC_URI[md5sum] = "eed4f724973192564474efbda83f67bc" +SRC_URI[sha256sum] = "bca725e442c1438990cf1b41a59194e6efbd080c63d9b683a0d572e27f900e25" + +S = "${WORKDIR}/${IMX_BIN_NAME}" + +inherit fsl-eula-unpack + +do_install () { + install -d ${D}${libdir} + install -d ${D}${includedir} + cp -d ${S}/g2d/usr/lib/*.so* ${D}${libdir} + cp -Pr ${S}/g2d/usr/include/* ${D}${includedir} +} + +INSANE_SKIP:append:libc-musl = " file-rdeps" +RDEPENDS:${PN}:append:libc-musl = " gcompat" + +# The packaged binaries have been stripped of debug info, so disable +# operations accordingly. +INHIBIT_PACKAGE_DEBUG_SPLIT = "1" +INHIBIT_PACKAGE_STRIP = "1" +INHIBIT_SYSROOT_STRIP = "1" + +COMPATIBLE_MACHINE = "(imxdpu)" diff --git a/recipes-graphics/imx-g2d/imx-g2d-samples_git.bb b/recipes-graphics/imx-g2d/imx-g2d-samples_git.bb new file mode 100644 index 00000000..649a16d2 --- /dev/null +++ b/recipes-graphics/imx-g2d/imx-g2d-samples_git.bb @@ -0,0 +1,68 @@ +SUMMARY = "i.MX G2D Samples" +DESCRIPTION = "Set of sample applications for i.MX G2D" +LICENSE = "BSD-3-Clause" +LIC_FILES_CHKSUM = "file://LICENSE;md5=0858ec9c7a80c4a2cf16e4f825a2cc91" + +DEPENDS = "cairo" + +PV = "2.1+git${SRCPV}" + +SRC_URI = "${GPU_G2D_SAMPLES_SRC};branch=${SRCBRANCH}" +GPU_G2D_SAMPLES_SRC ?= "git://github.com/nxp-imx/g2d-samples.git;protocol=https" +SRCBRANCH ?= "imx_2.1" +SRCREV = "4391dcda499870418bb38fe395c3cba0664c5bab" + +S = "${WORKDIR}/git" + +inherit pkgconfig + +PACKAGECONFIG ??= "${PACKAGECONFIG_IMPLEMENTATION}" +PACKAGECONFIG_IMPLEMENTATION = "" +PACKAGECONFIG_IMPLEMENTATION:imxgpu2d:imxdpu = "dpu" +PACKAGECONFIG_IMPLEMENTATION:imxgpu2d = "gpu-drm" +PACKAGECONFIG_IMPLEMENTATION:imxgpu2d:imxfbdev = "gpu-fbdev" +PACKAGECONFIG_IMPLEMENTATION:mx93-nxp-bsp = "pxp" + +PACKAGECONFIG[dpu] = " \ + BUILD_IMPLEMENTATION=dpu, \ + , \ + imx-dpu-g2d wayland-native wayland wayland-protocols, \ + , \ + , \ + gpu-drm gpu-fbdev pxp" +PACKAGECONFIG[gpu-drm] = " \ + BUILD_IMPLEMENTATION=gpu-drm, \ + , \ + imx-gpu-g2d wayland-native wayland wayland-protocols, \ + , \ + , \ + dpu gpu-fbdev pxp" +PACKAGECONFIG[gpu-fbdev] = " \ + BUILD_IMPLEMENTATION=gpu-fbdev, \ + , \ + imx-gpu-g2d, \ + , \ + , \ + dpu gpu-drm pxp" +PACKAGECONFIG[pxp] = " \ + BUILD_IMPLEMENTATION=pxp, \ + , \ + imx-pxp-g2d wayland-native wayland wayland-protocols, \ + , \ + , \ + dpu gpu-drm gpu-fbdev" + +EXTRA_OEMAKE += " \ + SDKTARGETSYSROOT=${STAGING_DIR_HOST} \ + ${PACKAGECONFIG_CONFARGS} \ +" + +do_install() { + oe_runmake install DESTDIR=${D} +} + +FILES:${PN} += "/opt" + +PACKAGE_ARCH = "${MACHINE_SOCARCH}" + +COMPATIBLE_MACHINE = "(imxgpu2d|mx93-nxp-bsp)" diff --git a/recipes-graphics/imx-g2d/imx-gpu-g2d_6.4.11.p2.2.bb b/recipes-graphics/imx-g2d/imx-gpu-g2d_6.4.11.p2.2.bb new file mode 100644 index 00000000..b9a7d938 --- /dev/null +++ b/recipes-graphics/imx-g2d/imx-gpu-g2d_6.4.11.p2.2.bb @@ -0,0 +1,44 @@ +# Copyright (C) 2016 Freescale Semiconductor +# Copyright 2017-2022 NXP +# Copyright 2018 (C) O.S. Systems Software LTDA. +# Released under the MIT license (see COPYING.MIT for the terms) + +DESCRIPTION = "G2D library using i.MX GPU" +LICENSE = "Proprietary" +LIC_FILES_CHKSUM = "file://COPYING;md5=2827219e81f28aba7c6a569f7c437fa7" +DEPENDS = "libgal-imx" +PROVIDES = "virtual/libg2d" + +SRC_URI = "${FSL_MIRROR}/${IMX_BIN_NAME}.bin;name=${TARGET_ARCH};fsl-eula=true" +IMX_BIN_NAME = "${BP}-${TARGET_ARCH}-${IMX_SRCREV_ABBREV}" +IMX_SRCREV_ABBREV = "fd0148d" +SRC_URI[aarch64.md5sum] = "ebc4cb8fdfa0b8ef9b11d7bb0fd4710f" +SRC_URI[aarch64.sha256sum] = "1cedc606be965b01300613ccea81b4fd589d940306bb1caa30a37c41928616ec" +SRC_URI[arm.md5sum] = "77233957a27ae4da3f01d33b3fbc69d9" +SRC_URI[arm.sha256sum] = "bc168b19096a997251e7137f82ffcff404c61709cf5f227c53a099f631569f76" + +S = "${WORKDIR}/${IMX_BIN_NAME}" + +inherit fsl-eula-unpack + +SOC_INSTALL_DIR = "SOC_INSTALL_DIR_NOT_SET" +SOC_INSTALL_DIR:mx8mm-nxp-bsp = "mx8mm" + +do_install () { + install -d ${D}${libdir} + install -d ${D}${includedir} + cp -d ${S}/g2d/usr/lib/*.so* ${D}${libdir} + if [ -d ${S}/g2d/usr/lib/${SOC_INSTALL_DIR} ]; then + cp -d ${S}/g2d/usr/lib/${SOC_INSTALL_DIR}/*.so* ${D}${libdir} + fi + cp -Pr ${S}/g2d/usr/include/* ${D}${includedir} +} + +# The packaged binaries have been stripped of debug info, so disable +# operations accordingly. +INHIBIT_PACKAGE_DEBUG_SPLIT = "1" +INHIBIT_PACKAGE_STRIP = "1" +INHIBIT_SYSROOT_STRIP = "1" + +PACKAGE_ARCH = "${MACHINE_SOCARCH}" +COMPATIBLE_MACHINE = "(imxgpu2d)" diff --git a/recipes-graphics/imx-g2d/imx-pxp-g2d_git.bb b/recipes-graphics/imx-g2d/imx-pxp-g2d_git.bb new file mode 100644 index 00000000..dedee983 --- /dev/null +++ b/recipes-graphics/imx-g2d/imx-pxp-g2d_git.bb @@ -0,0 +1,28 @@ +# Copyright (C) 2016 Freescale Semiconductor +# Copyright 2017-2023 NXP +# Released under the MIT license (see COPYING.MIT for the terms) + +DESCRIPTION = "G2D library using i.MX PXP" +LICENSE = "Proprietary" +LIC_FILES_CHKSUM = "file://LICENSE.txt;md5=2827219e81f28aba7c6a569f7c437fa7" + +PROVIDES += "virtual/libg2d" + +PV = "2.1.0+git${SRCPV}" + +SRC_URI = "${IMX_PXP_G2D_SRC};branch=${SRCBRANCH}" +IMX_PXP_G2D_SRC ?= "git://github.com/nxp-imx/imx-g2d-pxp.git;protocol=https" +SRCBRANCH ?= "imx_2.1" +SRCREV = "f3adab05bd0cbb7c38578110d772e8ddf52b4e8e" + +S = "${WORKDIR}/git" + +inherit use-imx-headers + +EXTRA_OEMAKE = "PLATFORM=IMX93 INCLUDE='-I${STAGING_INCDIR_IMX}' DEST_DIR=${D}" + +do_install() { + oe_runmake install +} + +COMPATIBLE_MACHINE = "(mx93-nxp-bsp)" diff --git a/recipes-graphics/imx-gpu-apitrace/imx-gpu-apitrace/0001-dlsym-workaround-glibc-2.34-build-failure.patch b/recipes-graphics/imx-gpu-apitrace/imx-gpu-apitrace/0001-dlsym-workaround-glibc-2.34-build-failure.patch new file mode 100644 index 00000000..2ed5587f --- /dev/null +++ b/recipes-graphics/imx-gpu-apitrace/imx-gpu-apitrace/0001-dlsym-workaround-glibc-2.34-build-failure.patch @@ -0,0 +1,30 @@ +From d11884c88eac803c174f759414d0162154450b6a Mon Sep 17 00:00:00 2001 +From: Andrey Zhizhikin <andrey.z@gmail.com> +Date: Thu, 2 Sep 2021 09:43:33 +0000 +Subject: [PATCH] dlsym: workaround glibc 2.34 build failure + +As suggested in [1], upstream component does not have a solution for the +issue, and therefore for glibc version >= 2.34 dlsym wrappers should be +skipped. + +Link: [1]: https://github.com/apitrace/apitrace/issues/756 + +Upstream-Status: Pending +Signed-off-by: Andrey Zhizhikin <andrey.z@gmail.com> +--- + wrappers/dlsym.cpp | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +Index: git/wrappers/dlsym.cpp +=================================================================== +--- git.orig/wrappers/dlsym.cpp ++++ git/wrappers/dlsym.cpp +@@ -34,7 +34,7 @@ + #include "os.hpp" + + +-#if defined(__GLIBC__) && !defined(__UCLIBC__) ++#if defined(__GLIBC__) && !defined(__UCLIBC__) && !(__GLIBC__ == 2 && __GLIBC_MINOR__ >= 34) + + + #include <dlfcn.h> diff --git a/recipes-graphics/imx-gpu-apitrace/imx-gpu-apitrace/0001-switch-from-python2-to-python3.patch b/recipes-graphics/imx-gpu-apitrace/imx-gpu-apitrace/0001-switch-from-python2-to-python3.patch deleted file mode 100644 index 27382c34..00000000 --- a/recipes-graphics/imx-gpu-apitrace/imx-gpu-apitrace/0001-switch-from-python2-to-python3.patch +++ /dev/null @@ -1,10004 +0,0 @@ -From bfa1b7c7e675f198f4573325f1252e91f80f0b4d Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Piotr=20Podsiad=C5=82y?= <ppodsiadly@mykolab.com> -Date: Thu, 3 Jan 2019 20:39:55 +0100 -Subject: [PATCH 1/4] switch from python2 to python3 - -Upstream-Status: Backport [https://github.com/apitrace/apitrace/commit/0b8b019952f2668a5e8786cc2d331062b958f02e] - -(cherry picked from commit 0b8b019952f2668a5e8786cc2d331062b958f02e) -Signed-off-by: Andrey Zhizhikin <andrey.zhizhikin@leica-geosystems.com> ---- - CMakeLists.txt | 7 +- - cli/CMakeLists.txt | 2 +- - dispatch/CMakeLists.txt | 2 +- - dispatch/__init__.py | 2 +- - dispatch/dispatch.py | 56 +- - dispatch/glproc.py | 204 +++---- - retrace/CMakeLists.txt | 14 +- - retrace/d3d9retrace.py | 248 ++++---- - retrace/ddrawretrace.py | 102 ++-- - retrace/dllretrace.py | 46 +- - retrace/dxgiretrace.py | 370 +++++------ - retrace/dxgistate_so.py | 98 +-- - retrace/glretrace.py | 660 ++++++++++---------- - retrace/glstate_params.py | 556 ++++++++--------- - retrace/retrace.py | 300 ++++----- - scripts/convert.py | 4 +- - scripts/jsondiff.py | 16 +- - scripts/jsonextractimages.py | 2 +- - scripts/leaks.py | 163 +++++ - scripts/profileshader.py | 18 +- - scripts/retracediff.py | 6 +- - scripts/snapdiff.py | 7 +- - scripts/tracediff.py | 16 +- - scripts/unpickle.py | 16 +- - specs/cglapi.py | 6 +- - specs/d2d1.py | 6 +- - specs/d3d.py | 8 +- - specs/d3d10.py | 4 +- - specs/d3d10sdklayers.py | 2 +- - specs/d3d11.py | 4 +- - specs/d3d11sdklayers.py | 2 +- - specs/d3d8.py | 6 +- - specs/d3d8caps.py | 4 +- - specs/d3d8types.py | 2 +- - specs/d3d9.py | 6 +- - specs/d3d9caps.py | 4 +- - specs/d3d9types.py | 2 +- - specs/d3dcaps.py | 4 +- - specs/d3dtypes.py | 2 +- - specs/dcommon.py | 2 +- - specs/dcomp.py | 303 +++++++++ - specs/ddraw.py | 2 +- - specs/debug.py | 2 +- - specs/dwrite.py | 4 +- - specs/dxgi.py | 2 +- - specs/dxva2.py | 2 +- - specs/eglapi.py | 6 +- - specs/eglenum.py | 2 +- - specs/glapi.py | 6 +- - specs/glparams.py | 4 +- - specs/gltypes.py | 2 +- - specs/glxapi.py | 4 +- - specs/scripts/c2api.py | 40 +- - specs/scripts/cxx2api.py | 488 +++++++++++++++ - specs/scripts/spec2api.py | 6 +- - specs/scripts/txt2api.py | 8 +- - specs/scripts/xml2api.py | 6 +- - specs/scripts/xml2enum.py | 4 +- - specs/scripts/xml2glparams.py | 4 +- - specs/stdapi.py | 43 +- - specs/wglapi.py | 6 +- - specs/wglenum.py | 2 +- - specs/winapi.py | 2 +- - wrappers/CMakeLists.txt | 18 +- - wrappers/cgltrace.py | 74 +-- - wrappers/d2d1trace.py | 18 +- - wrappers/d3d8trace.py | 36 +- - wrappers/d3d9trace.py | 62 +- - wrappers/ddrawtrace.py | 12 +- - wrappers/dlltrace.py | 36 +- - wrappers/dxgitrace.py | 98 +-- - wrappers/egltrace.py | 420 ++++++------- - wrappers/gltrace.py | 1080 ++++++++++++++++----------------- - wrappers/glxtrace.py | 54 +- - wrappers/trace.py | 707 ++++++++++----------- - wrappers/wgltrace.py | 86 +-- - 76 files changed, 3803 insertions(+), 2825 deletions(-) - create mode 100755 scripts/leaks.py - create mode 100644 specs/dcomp.py - create mode 100755 specs/scripts/cxx2api.py - -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 900028c6..03ffd07c 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -104,10 +104,7 @@ else () - endmacro() - endif () - --find_host_package (PythonInterp 2.7 REQUIRED) --if (NOT PYTHON_VERSION_MAJOR EQUAL 2) -- message (FATAL_ERROR "Python 2.x required and requested, but Python ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR} found.") --endif () -+find_host_package(Python3 COMPONENTS Interpreter REQUIRED) - - find_package (Threads) - -@@ -591,7 +588,7 @@ set (CPACK_PACKAGE_VERSION_MINOR "0") - - # Use current date in YYYYMMDD format as patch number - execute_process ( -- COMMAND ${PYTHON_EXECUTABLE} -c "import time, sys; sys.stdout.write(time.strftime('%Y%m%d'))" -+ COMMAND ${Python3_EXECUTABLE} -c "import time, sys; sys.stdout.write(time.strftime('%Y%m%d'))" - OUTPUT_VARIABLE CPACK_PACKAGE_VERSION_PATCH - ) - -diff --git a/cli/CMakeLists.txt b/cli/CMakeLists.txt -index 9b621bb1..eb5d485d 100644 ---- a/cli/CMakeLists.txt -+++ b/cli/CMakeLists.txt -@@ -13,7 +13,7 @@ add_definitions( - if (WIN32) - add_definitions (-DAPITRACE_PYTHON_EXECUTABLE="python") - else () -- add_definitions (-DAPITRACE_PYTHON_EXECUTABLE="${PYTHON_EXECUTABLE}") -+ add_definitions (-DAPITRACE_PYTHON_EXECUTABLE="${Python3_EXECUTABLE}") - endif () - - add_executable (apitrace -diff --git a/dispatch/CMakeLists.txt b/dispatch/CMakeLists.txt -index d023e6e9..e51eec48 100644 ---- a/dispatch/CMakeLists.txt -+++ b/dispatch/CMakeLists.txt -@@ -7,7 +7,7 @@ add_custom_command ( - OUTPUT - ${CMAKE_CURRENT_BINARY_DIR}/glproc.hpp - ${CMAKE_CURRENT_BINARY_DIR}/glproc.cpp -- COMMAND ${PYTHON_EXECUTABLE} -+ COMMAND ${Python3_EXECUTABLE} - ${CMAKE_CURRENT_SOURCE_DIR}/glproc.py - ${CMAKE_CURRENT_BINARY_DIR}/glproc.hpp - ${CMAKE_CURRENT_BINARY_DIR}/glproc.cpp -diff --git a/dispatch/__init__.py b/dispatch/__init__.py -index b872135e..d8e8596e 100644 ---- a/dispatch/__init__.py -+++ b/dispatch/__init__.py -@@ -1 +1 @@ --from dispatch import * -+from .dispatch import * -diff --git a/dispatch/dispatch.py b/dispatch/dispatch.py -index 9e778561..e1dd8bc9 100644 ---- a/dispatch/dispatch.py -+++ b/dispatch/dispatch.py -@@ -58,18 +58,18 @@ class Dispatcher: - # define standard name aliases for convenience, but only when not - # tracing, as that would cause symbol clashing with the tracing - # functions -- print '#ifdef RETRACE' -+ print('#ifdef RETRACE') - for function in module.functions: -- print '#define %s _%s' % (function.name, function.name) -- print '#endif /* RETRACE */' -- print -+ print('#define %s _%s' % (function.name, function.name)) -+ print('#endif /* RETRACE */') -+ print() - - def dispatchFunctionDecl(self, module, function): - ptype = function_pointer_type(function) - pvalue = function_pointer_value(function) -- print 'typedef ' + function.prototype('* %s' % ptype) + ';' -- print 'extern %s %s;' % (ptype, pvalue) -- print -+ print('typedef ' + function.prototype('* %s' % ptype) + ';') -+ print('extern %s %s;' % (ptype, pvalue)) -+ print() - - def dispatchModuleImpl(self, module): - for function in module.functions: -@@ -84,19 +84,19 @@ class Dispatcher: - else: - ret = 'return ' - -- print 'static ' + function.prototype('_fail_' + function.name) + ' {' -+ print('static ' + function.prototype('_fail_' + function.name) + ' {') - self.failFunction(function) -- print '}' -- print -+ print('}') -+ print() - -- print 'static ' + function.prototype('_get_' + function.name) + ' {' -+ print('static ' + function.prototype('_get_' + function.name) + ' {') - self.invokeGetProcAddress(module, function) -- print ' %s%s(%s);' % (ret, pvalue, ', '.join([str(arg.name) for arg in function.args])) -- print '}' -- print -+ print(' %s%s(%s);' % (ret, pvalue, ', '.join([str(arg.name) for arg in function.args]))) -+ print('}') -+ print() - -- print '%s %s = &%s;' % (ptype, pvalue, '_get_' + function.name) -- print -+ print('%s %s = &%s;' % (ptype, pvalue, '_get_' + function.name)) -+ print() - - def getProcAddressName(self, module, function): - raise NotImplementedError -@@ -105,25 +105,25 @@ class Dispatcher: - ptype = function_pointer_type(function) - pvalue = function_pointer_value(function) - getProcAddressName = self.getProcAddressName(module, function) -- print ' %s _ptr;' % (ptype,) -- print ' _ptr = (%s)%s("%s");' % (ptype, getProcAddressName, function.name) -- print ' if (!_ptr) {' -- print ' _ptr = &%s;' % ('_fail_' + function.name) -- print ' }' -- print ' %s = _ptr;' % (pvalue,) -+ print(' %s _ptr;' % (ptype,)) -+ print(' _ptr = (%s)%s("%s");' % (ptype, getProcAddressName, function.name)) -+ print(' if (!_ptr) {') -+ print(' _ptr = &%s;' % ('_fail_' + function.name)) -+ print(' }') -+ print(' %s = _ptr;' % (pvalue,)) - - def failFunction(self, function): -- print r' const char *_name = "%s";' % function.name -+ print(r' const char *_name = "%s";' % function.name) - if function.type is stdapi.Void or function.fail is not None: -- print r' os::log("warning: ignoring call to unavailable function %s\n", _name);' -+ print(r' os::log("warning: ignoring call to unavailable function %s\n", _name);') - if function.type is stdapi.Void: - assert function.fail is None -- print ' return;' -+ print(' return;') - else: - assert function.fail is not None -- print ' return %s;' % function.fail -+ print(' return %s;' % function.fail) - else: -- print r' os::log("error: unavailable function %s\n", _name);' -- print r' os::abort();' -+ print(r' os::log("error: unavailable function %s\n", _name);') -+ print(r' os::abort();') - - -diff --git a/dispatch/glproc.py b/dispatch/glproc.py -index f26a4f7d..93bba232 100644 ---- a/dispatch/glproc.py -+++ b/dispatch/glproc.py -@@ -506,15 +506,15 @@ class GlDispatcher(Dispatcher): - if sys.platform == 'darwin': - # Fallback to EXT_debug_label on MacOSX, some enums need to be translated. - if function.name in ('glObjectLabel', 'glObjectLabelKHR'): -- print r' if (translateDebugLabelIdentifier(identifier)) {' -- print r' _glLabelObjectEXT(identifier, name, length < 0 ? 0 : length, length == 0 ? "" : label);' -- print r' return;' -- print r' }' -+ print(r' if (translateDebugLabelIdentifier(identifier)) {') -+ print(r' _glLabelObjectEXT(identifier, name, length < 0 ? 0 : length, length == 0 ? "" : label);') -+ print(r' return;') -+ print(r' }') - if function.name in ('glGetObjectLabel', 'glGetObjectLabelKHR'): -- print r' if (translateDebugLabelIdentifier(identifier)) {' -- print r' _glGetObjectLabelEXT(identifier, name, bufSize, length, label);' -- print r' return;' -- print r' }' -+ print(r' if (translateDebugLabelIdentifier(identifier)) {') -+ print(r' _glGetObjectLabelEXT(identifier, name, bufSize, length, label);') -+ print(r' return;') -+ print(r' }') - if function.name in ( - # GL_KHR_debug - 'glDebugMessageControl', -@@ -549,25 +549,25 @@ class GlDispatcher(Dispatcher): - ): - return - if function.name.startswith('glGetObjectLabel'): -- print r' if (length != 0) *length = 0;' -- print r' if (label != 0 && bufSize > 0) *label = 0;' -+ print(r' if (length != 0) *length = 0;') -+ print(r' if (label != 0 && bufSize > 0) *label = 0;') - return - if function.name == 'glGetDebugMessageLogAMD': -- print r' if (categories != 0) *categories = 0;' -- print r' if (ids != 0) *ids = 0;' -- print r' if (severities != 0) *severities = 0;' -- print r' if (lengths != 0) *lengths = 0;' -- print r' if (message != 0 && bufsize > 0) *message = 0;' -- print r' return 0;' -+ print(r' if (categories != 0) *categories = 0;') -+ print(r' if (ids != 0) *ids = 0;') -+ print(r' if (severities != 0) *severities = 0;') -+ print(r' if (lengths != 0) *lengths = 0;') -+ print(r' if (message != 0 && bufsize > 0) *message = 0;') -+ print(r' return 0;') - return - if function.name.startswith('glGetDebugMessageLog'): -- print r' if (sources != 0) *sources = 0;' -- print r' if (types != 0) *types = 0;' -- print r' if (ids != 0) *ids = 0;' -- print r' if (severities != 0) *severities = 0;' -- print r' if (lengths != 0) *lengths = 0;' -- print r' if (messageLog != 0 && bufsize > 0) *messageLog = 0;' -- print r' return 0;' -+ print(r' if (sources != 0) *sources = 0;') -+ print(r' if (types != 0) *types = 0;') -+ print(r' if (ids != 0) *ids = 0;') -+ print(r' if (severities != 0) *severities = 0;') -+ print(r' if (lengths != 0) *lengths = 0;') -+ print(r' if (messageLog != 0 && bufsize > 0) *messageLog = 0;') -+ print(r' return 0;') - return - - Dispatcher.failFunction(self, function) -@@ -577,96 +577,96 @@ if __name__ == '__main__': - decl, impl = sys.argv[1:] - - sys.stdout = open(decl, 'wt') -- print -- print '#pragma once' -- print -- print '#include "glimports.hpp"' -- print -- print '#if defined(_WIN32)' -- print 'extern HMODULE _libGlHandle;' -- print '#else' -- print 'extern void * _libGlHandle;' -- print '#endif' -- print -- print 'void * _getPublicProcAddress(const char *procName);' -- print 'void * _getPrivateProcAddress(const char *procName);' -- print -+ print() -+ print('#pragma once') -+ print() -+ print('#include "glimports.hpp"') -+ print() -+ print('#if defined(_WIN32)') -+ print('extern HMODULE _libGlHandle;') -+ print('#else') -+ print('extern void * _libGlHandle;') -+ print('#endif') -+ print() -+ print('void * _getPublicProcAddress(const char *procName);') -+ print('void * _getPrivateProcAddress(const char *procName);') -+ print() - dispatcher = GlDispatcher() -- print -+ print() - dispatcher.dispatchModuleDecl(eglapi) -- print -- print '#if defined(_WIN32)' -- print -+ print() -+ print('#if defined(_WIN32)') -+ print() - dispatcher.dispatchModuleDecl(wglapi) -- print -- print '#elif defined(__APPLE__)' -- print -+ print() -+ print('#elif defined(__APPLE__)') -+ print() - dispatcher.dispatchModuleDecl(cglapi) -- print -- print '#elif defined(HAVE_X11)' -- print -+ print() -+ print('#elif defined(HAVE_X11)') -+ print() - dispatcher.dispatchModuleDecl(glxapi) -- print -- print '#endif' -- print -+ print() -+ print('#endif') -+ print() - dispatcher.dispatchModuleDecl(glapi) -- print -+ print() - - sys.stdout = open(impl, 'wt') -- print -- print '#include "glproc.hpp"' -- print '#include "os.hpp"' -- print -+ print() -+ print('#include "glproc.hpp"') -+ print('#include "os.hpp"') -+ print() - dispatcher = GlDispatcher() -- print -+ print() - dispatcher.dispatchModuleImpl(eglapi) -- print -- print '#if defined(_WIN32)' -- print -+ print() -+ print('#if defined(_WIN32)') -+ print() - dispatcher.dispatchModuleImpl(wglapi) -- print -- print '#elif defined(__APPLE__)' -- print -- print 'static inline bool' -- print 'translateDebugLabelIdentifier(GLenum & identifier)' -- print '{' -- print ' switch (identifier) {' -- print ' case GL_TEXTURE:' -- print ' case GL_FRAMEBUFFER:' -- print ' case GL_RENDERBUFFER:' -- print ' case GL_SAMPLER:' -- print ' case GL_TRANSFORM_FEEDBACK:' -- print ' return true;' -- print ' case GL_BUFFER:' -- print ' identifier = GL_BUFFER_OBJECT_EXT;' -- print ' return true;' -- print ' case GL_SHADER:' -- print ' identifier = GL_SHADER_OBJECT_EXT;' -- print ' return true;' -- print ' case GL_PROGRAM:' -- print ' identifier = GL_PROGRAM_OBJECT_EXT;' -- print ' return true;' -- print ' case GL_VERTEX_ARRAY:' -- print ' identifier = GL_VERTEX_ARRAY_OBJECT_EXT;' -- print ' return true;' -- print ' case GL_QUERY:' -- print ' identifier = GL_QUERY_OBJECT_EXT;' -- print ' return true;' -- print ' case GL_PROGRAM_PIPELINE:' -- print ' identifier = GL_PROGRAM_PIPELINE_OBJECT_EXT;' -- print ' return true;' -- print ' default:' -- print ' return false;' -- print ' }' -- print '}' -- print -+ print() -+ print('#elif defined(__APPLE__)') -+ print() -+ print('static inline bool') -+ print('translateDebugLabelIdentifier(GLenum & identifier)') -+ print('{') -+ print(' switch (identifier) {') -+ print(' case GL_TEXTURE:') -+ print(' case GL_FRAMEBUFFER:') -+ print(' case GL_RENDERBUFFER:') -+ print(' case GL_SAMPLER:') -+ print(' case GL_TRANSFORM_FEEDBACK:') -+ print(' return true;') -+ print(' case GL_BUFFER:') -+ print(' identifier = GL_BUFFER_OBJECT_EXT;') -+ print(' return true;') -+ print(' case GL_SHADER:') -+ print(' identifier = GL_SHADER_OBJECT_EXT;') -+ print(' return true;') -+ print(' case GL_PROGRAM:') -+ print(' identifier = GL_PROGRAM_OBJECT_EXT;') -+ print(' return true;') -+ print(' case GL_VERTEX_ARRAY:') -+ print(' identifier = GL_VERTEX_ARRAY_OBJECT_EXT;') -+ print(' return true;') -+ print(' case GL_QUERY:') -+ print(' identifier = GL_QUERY_OBJECT_EXT;') -+ print(' return true;') -+ print(' case GL_PROGRAM_PIPELINE:') -+ print(' identifier = GL_PROGRAM_PIPELINE_OBJECT_EXT;') -+ print(' return true;') -+ print(' default:') -+ print(' return false;') -+ print(' }') -+ print('}') -+ print() - dispatcher.dispatchModuleImpl(cglapi) -- print -- print '#elif defined(HAVE_X11)' -- print -+ print() -+ print('#elif defined(HAVE_X11)') -+ print() - dispatcher.dispatchModuleImpl(glxapi) -- print -- print '#endif' -- print -+ print() -+ print('#endif') -+ print() - dispatcher.dispatchModuleImpl(glapi) -- print -+ print() -diff --git a/retrace/CMakeLists.txt b/retrace/CMakeLists.txt -index c0c4f316..2475abb8 100644 ---- a/retrace/CMakeLists.txt -+++ b/retrace/CMakeLists.txt -@@ -14,7 +14,7 @@ add_definitions (-DRETRACE) - - add_custom_command ( - OUTPUT glretrace_gl.cpp -- COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/glretrace.py > ${CMAKE_CURRENT_BINARY_DIR}/glretrace_gl.cpp -+ COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/glretrace.py > ${CMAKE_CURRENT_BINARY_DIR}/glretrace_gl.cpp - DEPENDS - glretrace.py - retrace.py -@@ -25,7 +25,7 @@ add_custom_command ( - - add_custom_command ( - OUTPUT glstate_params.cpp -- COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/glstate_params.py > ${CMAKE_CURRENT_BINARY_DIR}/glstate_params.cpp -+ COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/glstate_params.py > ${CMAKE_CURRENT_BINARY_DIR}/glstate_params.cpp - DEPENDS - glstate_params.py - ${CMAKE_SOURCE_DIR}/specs/glparams.py -@@ -273,7 +273,7 @@ if (WIN32) - include_directories (BEFORE SYSTEM ${DirectX_D3D_INCLUDE_DIR}) - add_custom_command ( - OUTPUT d3dretrace_ddraw.cpp -- COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/ddrawretrace.py > ${CMAKE_CURRENT_BINARY_DIR}/d3dretrace_ddraw.cpp -+ COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/ddrawretrace.py > ${CMAKE_CURRENT_BINARY_DIR}/d3dretrace_ddraw.cpp - DEPENDS - ddrawretrace.py - dllretrace.py -@@ -306,7 +306,7 @@ if (WIN32) - endif () - add_custom_command ( - OUTPUT d3dretrace_d3d8.cpp -- COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d9retrace.py d3d8 ${HAVE_D3D8} > ${CMAKE_CURRENT_BINARY_DIR}/d3dretrace_d3d8.cpp -+ COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d9retrace.py d3d8 ${HAVE_D3D8} > ${CMAKE_CURRENT_BINARY_DIR}/d3dretrace_d3d8.cpp - DEPENDS - d3d9retrace.py - dllretrace.py -@@ -327,7 +327,7 @@ if (WIN32) - endif () - add_custom_command ( - OUTPUT d3dretrace_d3d9.cpp -- COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d9retrace.py d3d9 ${HAVE_D3D9} > ${CMAKE_CURRENT_BINARY_DIR}/d3dretrace_d3d9.cpp -+ COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d9retrace.py d3d9 ${HAVE_D3D9} > ${CMAKE_CURRENT_BINARY_DIR}/d3dretrace_d3d9.cpp - DEPENDS - d3d9retrace.py - dllretrace.py -@@ -359,7 +359,7 @@ if (WIN32) - ) - add_custom_command ( - OUTPUT dxgistate_so.cpp -- COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/dxgistate_so.py > ${CMAKE_CURRENT_BINARY_DIR}/dxgistate_so.cpp -+ COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/dxgistate_so.py > ${CMAKE_CURRENT_BINARY_DIR}/dxgistate_so.cpp - DEPENDS - ${CMAKE_CURRENT_SOURCE_DIR}/dxgistate_so.py - ${CMAKE_SOURCE_DIR}/specs/d3d11.py -@@ -372,7 +372,7 @@ if (WIN32) - ) - add_custom_command ( - OUTPUT d3dretrace_dxgi.cpp -- COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/dxgiretrace.py > ${CMAKE_CURRENT_BINARY_DIR}/d3dretrace_dxgi.cpp -+ COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/dxgiretrace.py > ${CMAKE_CURRENT_BINARY_DIR}/d3dretrace_dxgi.cpp - DEPENDS - dxgiretrace.py - dllretrace.py -diff --git a/retrace/d3d9retrace.py b/retrace/d3d9retrace.py -index 7313acc9..22364476 100644 ---- a/retrace/d3d9retrace.py -+++ b/retrace/d3d9retrace.py -@@ -35,32 +35,32 @@ from specs.stdapi import API - class D3DRetracer(Retracer): - - def retraceApi(self, api): -- print '// Swizzling mapping for lock addresses' -- print 'typedef std::pair<void *, UINT> MappingKey;' -- print 'static std::map<MappingKey, void *> _maps;' -- print -+ print('// Swizzling mapping for lock addresses') -+ print('typedef std::pair<void *, UINT> MappingKey;') -+ print('static std::map<MappingKey, void *> _maps;') -+ print() - - Retracer.retraceApi(self, api) - - def invokeFunction(self, function): - if function.name in ('Direct3DCreate9', 'Direct3DCreate9Ex'): -- print 'if (retrace::debug >= 2 && !g_szD3D9DllName && LoadLibraryA("d3d9d.dll")) {' -- print ' /*' -- print ' * D3D9D only works for simple applications, it will often report bogus errors' -- print ' * on complex traces, or traces which use unofficial D3D9 features.' -- print ' */' -- print ' g_szD3D9DllName = "d3d9d.dll";' -- print ' SDKVersion |= 0x80000000;' -- print '} else {' -- print ' SDKVersion &= ~0x80000000;' -- print '}' -+ print('if (retrace::debug >= 2 && !g_szD3D9DllName && LoadLibraryA("d3d9d.dll")) {') -+ print(' /*') -+ print(' * D3D9D only works for simple applications, it will often report bogus errors') -+ print(' * on complex traces, or traces which use unofficial D3D9 features.') -+ print(' */') -+ print(' g_szD3D9DllName = "d3d9d.dll";') -+ print(' SDKVersion |= 0x80000000;') -+ print('} else {') -+ print(' SDKVersion &= ~0x80000000;') -+ print('}') - - # d3d8d.dll can be found in the Aug 2007 DXSDK. It works on XP, but - # not on Windows 7. - if function.name in ('Direct3DCreate8'): -- print 'if (retrace::debug >= 2 && !g_szD3D8DllName && LoadLibraryA("d3d8d.dll")) {' -- print ' g_szD3D8DllName = "d3d8d.dll";' -- print '}' -+ print('if (retrace::debug >= 2 && !g_szD3D8DllName && LoadLibraryA("d3d8d.dll")) {') -+ print(' g_szD3D8DllName = "d3d8d.dll";') -+ print('}') - - Retracer.invokeFunction(self, function) - -@@ -73,37 +73,37 @@ class D3DRetracer(Retracer): - # keep track of the last used device for state dumping - if interface.name in ('IDirect3DDevice9', 'IDirect3DDevice9Ex'): - if method.name == 'Release': -- print r' if (call.ret->toUInt() == 0) {' -- print r' d3d9Dumper.unbindDevice(_this);' -- print r' }' -+ print(r' if (call.ret->toUInt() == 0) {') -+ print(r' d3d9Dumper.unbindDevice(_this);') -+ print(r' }') - else: -- print r' d3d9Dumper.bindDevice(_this);' -+ print(r' d3d9Dumper.bindDevice(_this);') - if interface.name in ('IDirect3DDevice8', 'IDirect3DDevice8Ex'): - if method.name == 'Release': -- print r' if (call.ret->toUInt() == 0) {' -- print r' d3d8Dumper.unbindDevice(_this);' -- print r' }' -+ print(r' if (call.ret->toUInt() == 0) {') -+ print(r' d3d8Dumper.unbindDevice(_this);') -+ print(r' }') - else: -- print r' d3d8Dumper.bindDevice(_this);' -+ print(r' d3d8Dumper.bindDevice(_this);') - - # create windows as neccessary - if method.name in ('CreateDevice', 'CreateDeviceEx', 'CreateAdditionalSwapChain'): -- print r' HWND hWnd = d3dretrace::createWindow(pPresentationParameters->BackBufferWidth, pPresentationParameters->BackBufferHeight);' -- print r' pPresentationParameters->hDeviceWindow = hWnd;' -+ print(r' HWND hWnd = d3dretrace::createWindow(pPresentationParameters->BackBufferWidth, pPresentationParameters->BackBufferHeight);') -+ print(r' pPresentationParameters->hDeviceWindow = hWnd;') - if 'hFocusWindow' in method.argNames(): -- print r' hFocusWindow = hWnd;' -+ print(r' hFocusWindow = hWnd;') - - # force windowed mode -- print r' if (retrace::forceWindowed) {' -- print r' pPresentationParameters->Windowed = TRUE;' -- print r' pPresentationParameters->FullScreen_RefreshRateInHz = 0;' -+ print(r' if (retrace::forceWindowed) {') -+ print(r' pPresentationParameters->Windowed = TRUE;') -+ print(r' pPresentationParameters->FullScreen_RefreshRateInHz = 0;') - if interface.name.startswith('IDirect3D8'): -- print r' pPresentationParameters->FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT;' -- print r' }' -+ print(r' pPresentationParameters->FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT;') -+ print(r' }') - if 'BehaviorFlags' in method.argNames(): -- print r' if (retrace::dumpingState) {' -- print r' BehaviorFlags &= ~D3DCREATE_PUREDEVICE;' -- print r' }' -+ print(r' if (retrace::dumpingState) {') -+ print(r' BehaviorFlags &= ~D3DCREATE_PUREDEVICE;') -+ print(r' }') - - # On D3D8, ensure we use BackBufferFormat compatible with the - # current DisplayFormat. -@@ -113,76 +113,76 @@ class D3DRetracer(Retracer): - # valid values for BackBufferFormat include D3DFMT_X1R5G5B5 and - # D3DFMT_A1R5G5B5, but exclude D3DFMT_R5G6B5. - if interface.name.startswith('IDirect3D8'): -- print r' if (pPresentationParameters->Windowed) {' -- print r' D3DDISPLAYMODE Mode;' -- print r' HRESULT hr;' -- print r' hr = _this->GetAdapterDisplayMode(Adapter, &Mode);' -- print r' assert(SUCCEEDED(hr));' -- print r' hr = _this->CheckDeviceType(Adapter, DeviceType, Mode.Format, pPresentationParameters->BackBufferFormat, pPresentationParameters->Windowed);' -- print r' if (hr == D3DERR_NOTAVAILABLE) {' -- print r' retrace::warning(call) << "forcing back buffer format to match display mode format\n";' -- print r' pPresentationParameters->BackBufferFormat = Mode.Format;' -- print r' }' -- print r' }' -+ print(r' if (pPresentationParameters->Windowed) {') -+ print(r' D3DDISPLAYMODE Mode;') -+ print(r' HRESULT hr;') -+ print(r' hr = _this->GetAdapterDisplayMode(Adapter, &Mode);') -+ print(r' assert(SUCCEEDED(hr));') -+ print(r' hr = _this->CheckDeviceType(Adapter, DeviceType, Mode.Format, pPresentationParameters->BackBufferFormat, pPresentationParameters->Windowed);') -+ print(r' if (hr == D3DERR_NOTAVAILABLE) {') -+ print(r' retrace::warning(call) << "forcing back buffer format to match display mode format\n";') -+ print(r' pPresentationParameters->BackBufferFormat = Mode.Format;') -+ print(r' }') -+ print(r' }') - - if method.name in self.createDeviceMethodNames: - # override the device type -- print r' switch (retrace::driver) {' -- print r' case retrace::DRIVER_HARDWARE:' -- print r' DeviceType = D3DDEVTYPE_HAL;' -- print r' break;' -- print r' case retrace::DRIVER_SOFTWARE:' -- print r' case retrace::DRIVER_REFERENCE:' -- print r' DeviceType = D3DDEVTYPE_REF;' -- print r' break;' -- print r' case retrace::DRIVER_NULL:' -+ print(r' switch (retrace::driver) {') -+ print(r' case retrace::DRIVER_HARDWARE:') -+ print(r' DeviceType = D3DDEVTYPE_HAL;') -+ print(r' break;') -+ print(r' case retrace::DRIVER_SOFTWARE:') -+ print(r' case retrace::DRIVER_REFERENCE:') -+ print(r' DeviceType = D3DDEVTYPE_REF;') -+ print(r' break;') -+ print(r' case retrace::DRIVER_NULL:') - if interface.name.startswith('IDirect3D9'): -- print r' DeviceType = D3DDEVTYPE_NULLREF;' -+ print(r' DeviceType = D3DDEVTYPE_NULLREF;') - else: -- print r' retrace::warning(call) << "null driver not supported\n";' -- print r' break;' -- print r' case retrace::DRIVER_MODULE:' -- print r' retrace::warning(call) << "driver module not supported\n";' -- print r' break;' -- print r' default:' -- print r' assert(0);' -- print r' /* fall-through */' -- print r' case retrace::DRIVER_DEFAULT:' -- print r' break;' -- print r' }' -+ print(r' retrace::warning(call) << "null driver not supported\n";') -+ print(r' break;') -+ print(r' case retrace::DRIVER_MODULE:') -+ print(r' retrace::warning(call) << "driver module not supported\n";') -+ print(r' break;') -+ print(r' default:') -+ print(r' assert(0);') -+ print(r' /* fall-through */') -+ print(r' case retrace::DRIVER_DEFAULT:') -+ print(r' break;') -+ print(r' }') - - if method.name in ('Reset', 'ResetEx'): - # force windowed mode -- print r' if (retrace::forceWindowed) {' -- print r' pPresentationParameters->Windowed = TRUE;' -- print r' pPresentationParameters->FullScreen_RefreshRateInHz = 0;' -- print r' }' -+ print(r' if (retrace::forceWindowed) {') -+ print(r' pPresentationParameters->Windowed = TRUE;') -+ print(r' pPresentationParameters->FullScreen_RefreshRateInHz = 0;') -+ print(r' }') - # resize window -- print r' if (pPresentationParameters->Windowed) {' -- print r' d3dretrace::resizeWindow(pPresentationParameters->hDeviceWindow, pPresentationParameters->BackBufferWidth, pPresentationParameters->BackBufferHeight);' -- print r' }' -+ print(r' if (pPresentationParameters->Windowed) {') -+ print(r' d3dretrace::resizeWindow(pPresentationParameters->hDeviceWindow, pPresentationParameters->BackBufferWidth, pPresentationParameters->BackBufferHeight);') -+ print(r' }') - - # notify frame has been completed - if method.name in ('Present', 'PresentEx'): - if interface.name.startswith('IDirect3DSwapChain9'): -- print r' d3d9scDumper.bindDevice(_this);' -- print r' retrace::frameComplete(call);' -- print r' hDestWindowOverride = NULL;' -+ print(r' d3d9scDumper.bindDevice(_this);') -+ print(r' retrace::frameComplete(call);') -+ print(r' hDestWindowOverride = NULL;') - - # Ensure textures can be locked when dumping - # TODO: Pre-check with CheckDeviceFormat - if method.name in ('CreateTexture', 'CreateCubeTexture', 'CreateVolumeTexture'): -- print r' if (retrace::dumpingState &&' -- print r' Pool == D3DPOOL_DEFAULT &&' -- print r' !(Usage & (D3DUSAGE_RENDERTARGET|D3DUSAGE_DEPTHSTENCIL))) {' -- print r' Usage |= D3DUSAGE_DYNAMIC;' -- print r' }' -+ print(r' if (retrace::dumpingState &&') -+ print(r' Pool == D3DPOOL_DEFAULT &&') -+ print(r' !(Usage & (D3DUSAGE_RENDERTARGET|D3DUSAGE_DEPTHSTENCIL))) {') -+ print(r' Usage |= D3DUSAGE_DYNAMIC;') -+ print(r' }') - - if 'pSharedHandle' in method.argNames(): -- print r' if (pSharedHandle) {' -- print r' retrace::warning(call) << "shared surfaces unsupported\n";' -- print r' pSharedHandle = NULL;' -- print r' }' -+ print(r' if (pSharedHandle) {') -+ print(r' retrace::warning(call) << "shared surfaces unsupported\n";') -+ print(r' pSharedHandle = NULL;') -+ print(r' }') - - if method.name in ('Lock', 'LockRect', 'LockBox'): - # Reset _DONOTWAIT flags. Otherwise they may fail, and we have no -@@ -190,7 +190,7 @@ class D3DRetracer(Retracer): - mapFlagsArg = method.getArgByName('Flags') - for flag in mapFlagsArg.type.values: - if flag.endswith('_DONOTWAIT'): -- print r' Flags &= ~%s;' % flag -+ print(r' Flags &= ~%s;' % flag) - - Retracer.invokeInterfaceMethod(self, interface, method) - -@@ -201,7 +201,7 @@ class D3DRetracer(Retracer): - - # process events after presents - if method.name == 'Present': -- print r' d3dretrace::processEvents();' -+ print(r' d3dretrace::processEvents();') - - def mapping_subkey(): - if 'Level' in method.argNames(): -@@ -210,35 +210,35 @@ class D3DRetracer(Retracer): - return ('0',) - - if method.name in ('Lock', 'LockRect', 'LockBox'): -- print ' VOID *_pbData = NULL;' -- print ' size_t _MappedSize = 0;' -- print ' if (!(Flags & D3DLOCK_READONLY)) {' -- print ' _getMapInfo(_this, %s, _pbData, _MappedSize);' % ', '.join(method.argNames()[:-1]) -- print ' }' -- print ' if (_MappedSize) {' -- print ' _maps[MappingKey(_this, %s)] = _pbData;' % mapping_subkey() -+ print(' VOID *_pbData = NULL;') -+ print(' size_t _MappedSize = 0;') -+ print(' if (!(Flags & D3DLOCK_READONLY)) {') -+ print(' _getMapInfo(_this, %s, _pbData, _MappedSize);' % ', '.join(method.argNames()[:-1])) -+ print(' }') -+ print(' if (_MappedSize) {') -+ print(' _maps[MappingKey(_this, %s)] = _pbData;' % mapping_subkey()) - self.checkPitchMismatch(method) -- print ' } else {' -- print ' return;' -- print ' }' -+ print(' } else {') -+ print(' return;') -+ print(' }') - - if method.name in ('Unlock', 'UnlockRect', 'UnlockBox'): -- print ' VOID *_pbData = 0;' -- print ' MappingKey _mappingKey(_this, %s);' % mapping_subkey() -- print ' _pbData = _maps[_mappingKey];' -- print ' if (_pbData) {' -- print ' retrace::delRegionByPointer(_pbData);' -- print ' _maps[_mappingKey] = 0;' -- print ' }' -+ print(' VOID *_pbData = 0;') -+ print(' MappingKey _mappingKey(_this, %s);' % mapping_subkey()) -+ print(' _pbData = _maps[_mappingKey];') -+ print(' if (_pbData) {') -+ print(' retrace::delRegionByPointer(_pbData);') -+ print(' _maps[_mappingKey] = 0;') -+ print(' }') - - - def main(): -- print r'#include <string.h>' -- print -- print r'#include <iostream>' -- print -- print r'#include "d3dretrace.hpp"' -- print -+ print(r'#include <string.h>') -+ print() -+ print(r'#include <iostream>') -+ print() -+ print(r'#include "d3dretrace.hpp"') -+ print() - - moduleName = sys.argv[1] - support = int(sys.argv[2]) -@@ -249,24 +249,24 @@ def main(): - if moduleName == 'd3d9': - from specs.d3d9 import d3d9, d3dperf - from specs.dxva2 import dxva2 -- print r'#include "d3d9imports.hpp"' -- print r'#include "d3d9size.hpp"' -- print r'#include "dxva2imports.hpp"' -+ print(r'#include "d3d9imports.hpp"') -+ print(r'#include "d3d9size.hpp"') -+ print(r'#include "dxva2imports.hpp"') - d3d9.mergeModule(d3dperf) - api.addModule(d3d9) - api.addModule(dxva2) -- print -- print '''static d3dretrace::D3DDumper<IDirect3DDevice9> d3d9Dumper;''' -- print '''static d3dretrace::D3DDumper<IDirect3DSwapChain9> d3d9scDumper;''' -- print -+ print() -+ print('''static d3dretrace::D3DDumper<IDirect3DDevice9> d3d9Dumper;''') -+ print('''static d3dretrace::D3DDumper<IDirect3DSwapChain9> d3d9scDumper;''') -+ print() - elif moduleName == 'd3d8': - from specs.d3d8 import d3d8 -- print r'#include "d3d8imports.hpp"' -- print r'#include "d3d8size.hpp"' -+ print(r'#include "d3d8imports.hpp"') -+ print(r'#include "d3d8size.hpp"') - api.addModule(d3d8) -- print -- print '''static d3dretrace::D3DDumper<IDirect3DDevice8> d3d8Dumper;''' -- print -+ print() -+ print('''static d3dretrace::D3DDumper<IDirect3DDevice8> d3d8Dumper;''') -+ print() - else: - assert False - -diff --git a/retrace/ddrawretrace.py b/retrace/ddrawretrace.py -index 4f2ff944..863283fd 100644 ---- a/retrace/ddrawretrace.py -+++ b/retrace/ddrawretrace.py -@@ -37,12 +37,12 @@ from specs.ddraw import DDCREATE_LPGUID - class D3DRetracer(Retracer): - - def retraceApi(self, api): -- print '// Swizzling mapping for lock addresses' -- print 'static std::map<void *, void *> _maps;' -- print -+ print('// Swizzling mapping for lock addresses') -+ print('static std::map<void *, void *> _maps;') -+ print() - # TODO: Keep a table of windows -- print 'static HWND g_hWnd;' -- print -+ print('static HWND g_hWnd;') -+ print() - - Retracer.retraceApi(self, api) - -@@ -50,20 +50,20 @@ class D3DRetracer(Retracer): - # keep track of the last used device for state dumping - if interface.name in ('IDirect3DDevice7',): - if method.name == 'Release': -- print r' if (call.ret->toUInt() == 0) {' -- print r' d3d7Dumper.unbindDevice(_this);' -- print r' }' -+ print(r' if (call.ret->toUInt() == 0) {') -+ print(r' d3d7Dumper.unbindDevice(_this);') -+ print(r' }') - else: -- print r' d3d7Dumper.bindDevice(_this);' -+ print(r' d3d7Dumper.bindDevice(_this);') - - # create windows as neccessary - hWndArg = method.getArgByType(HWND) - if hWndArg is not None: - # FIXME: Try to guess the window size (e.g., from IDirectDrawSurface7::Blt) -- print r' if (!g_hWnd) {' -- print r' g_hWnd = d3dretrace::createWindow(512, 512);' -- print r' }' -- print r' %s = g_hWnd;' % hWndArg.name -+ print(r' if (!g_hWnd) {') -+ print(r' g_hWnd = d3dretrace::createWindow(512, 512);') -+ print(r' }') -+ print(r' %s = g_hWnd;' % hWndArg.name) - - - if method.name == 'Lock': -@@ -71,74 +71,74 @@ class D3DRetracer(Retracer): - # way to cope with it (other than retry). - mapFlagsArg = method.getArgByName('dwFlags') - if mapFlagsArg is not None: -- print r' dwFlags &= DDLOCK_DONOTWAIT;' -- print r' dwFlags |= DDLOCK_WAIT;' -+ print(r' dwFlags &= DDLOCK_DONOTWAIT;') -+ print(r' dwFlags |= DDLOCK_WAIT;') - - Retracer.invokeInterfaceMethod(self, interface, method) - - if method.name == 'CreateDevice': -- print r' if (FAILED(_result)) {' -- print r' exit(1);' -- print r' }' -+ print(r' if (FAILED(_result)) {') -+ print(r' exit(1);') -+ print(r' }') - - # notify frame has been completed - # process events after presents - if interface.name == 'IDirectDrawSurface7' and method.name == 'Blt': -- print r' DDSCAPS2 ddsCaps;' -- print r' if (SUCCEEDED(_this->GetCaps(&ddsCaps)) &&' -- print r' (ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)) {' -- print r' retrace::frameComplete(call);' -- print r' d3dretrace::processEvents();' -- print r' }' -+ print(r' DDSCAPS2 ddsCaps;') -+ print(r' if (SUCCEEDED(_this->GetCaps(&ddsCaps)) &&') -+ print(r' (ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)) {') -+ print(r' retrace::frameComplete(call);') -+ print(r' d3dretrace::processEvents();') -+ print(r' }') - - if method.name == 'Lock': -- print ' VOID *_pbData = NULL;' -- print ' size_t _MappedSize = 0;' -+ print(' VOID *_pbData = NULL;') -+ print(' size_t _MappedSize = 0;') - # FIXME: determine the mapping size - #print ' _getMapInfo(_this, %s, _pbData, _MappedSize);' % ', '.join(method.argNames()[:-1]) -- print ' if (_MappedSize) {' -- print ' _maps[_this] = _pbData;' -+ print(' if (_MappedSize) {') -+ print(' _maps[_this] = _pbData;') - # TODO: check pitches match -- print ' } else {' -- print ' return;' -- print ' }' -+ print(' } else {') -+ print(' return;') -+ print(' }') - - if method.name == 'Unlock': -- print ' VOID *_pbData = 0;' -- print ' _pbData = _maps[_this];' -- print ' if (_pbData) {' -- print ' retrace::delRegionByPointer(_pbData);' -- print ' _maps[_this] = 0;' -- print ' }' -+ print(' VOID *_pbData = 0;') -+ print(' _pbData = _maps[_this];') -+ print(' if (_pbData) {') -+ print(' retrace::delRegionByPointer(_pbData);') -+ print(' _maps[_this] = 0;') -+ print(' }') - - def extractArg(self, function, arg, arg_type, lvalue, rvalue): - # Handle DDCREATE_* flags - if arg.type is DDCREATE_LPGUID: -- print ' if (%s.toArray()) {' % rvalue -+ print(' if (%s.toArray()) {' % rvalue) - Retracer.extractArg(self, function, arg, arg_type, lvalue, rvalue) -- print ' } else {' -- print ' %s = static_cast<%s>(%s.toPointer());' % (lvalue, arg_type, rvalue) -- print ' }' -+ print(' } else {') -+ print(' %s = static_cast<%s>(%s.toPointer());' % (lvalue, arg_type, rvalue)) -+ print(' }') - return - - Retracer.extractArg(self, function, arg, arg_type, lvalue, rvalue) - - - def main(): -- print r'#include <string.h>' -- print -- print r'#include <iostream>' -- print -- print r'#include "d3dretrace.hpp"' -- print -+ print(r'#include <string.h>') -+ print() -+ print(r'#include <iostream>') -+ print() -+ print(r'#include "d3dretrace.hpp"') -+ print() - - api = API() - -- print r'#include "d3dimports.hpp"' -+ print(r'#include "d3dimports.hpp"') - api.addModule(ddraw) -- print -- print '''static d3dretrace::D3DDumper<IDirect3DDevice7> d3d7Dumper;''' -- print -+ print() -+ print('''static d3dretrace::D3DDumper<IDirect3DDevice7> d3d7Dumper;''') -+ print() - - retracer = D3DRetracer() - retracer.table_name = 'd3dretrace::ddraw_callbacks' -diff --git a/retrace/dllretrace.py b/retrace/dllretrace.py -index c818b0a9..ad9db9a4 100644 ---- a/retrace/dllretrace.py -+++ b/retrace/dllretrace.py -@@ -33,29 +33,29 @@ class DllDispatcher(Dispatcher): - - def dispatchModule(self, module): - tag = module.name.upper() -- print r'const char *g_sz%sDllName = NULL;' % (tag,) -- print r'HMODULE g_h%sModule = NULL;' % (tag,) -- print r'' -- print r'static PROC' -- print r'_get%sProcAddress(LPCSTR lpProcName) {' % tag -- print r' if (!g_h%sModule) {' % tag -- print r' if (g_sz%sDllName) {' % tag -- print r' g_h%sModule = LoadLibraryA(g_sz%sDllName);' % (tag, tag) -- print r' if (!g_h%sModule) {' % tag -- print r' os::log("warning: failed to load %%s\n", g_sz%sDllName);' % tag -- print r' }' -- print r' }' -- print r' if (!g_h%sModule) {' % tag -- print r' g_h%sModule = LoadLibraryA("%s.dll");' % (tag, module.name) -- print r' }' -- print r' if (!g_h%sModule) {' % tag -- print r' os::log("error: failed to load %s.dll\n");' % module.name -- print r' exit(1);' -- print r' }' -- print r' }' -- print r' return GetProcAddress(g_h%sModule, lpProcName);' % tag -- print r'}' -- print r'' -+ print(r'const char *g_sz%sDllName = NULL;' % (tag,)) -+ print(r'HMODULE g_h%sModule = NULL;' % (tag,)) -+ print(r'') -+ print(r'static PROC') -+ print(r'_get%sProcAddress(LPCSTR lpProcName) {' % tag) -+ print(r' if (!g_h%sModule) {' % tag) -+ print(r' if (g_sz%sDllName) {' % tag) -+ print(r' g_h%sModule = LoadLibraryA(g_sz%sDllName);' % (tag, tag)) -+ print(r' if (!g_h%sModule) {' % tag) -+ print(r' os::log("warning: failed to load %%s\n", g_sz%sDllName);' % tag) -+ print(r' }') -+ print(r' }') -+ print(r' if (!g_h%sModule) {' % tag) -+ print(r' g_h%sModule = LoadLibraryA("%s.dll");' % (tag, module.name)) -+ print(r' }') -+ print(r' if (!g_h%sModule) {' % tag) -+ print(r' os::log("error: failed to load %s.dll\n");' % module.name) -+ print(r' exit(1);') -+ print(r' }') -+ print(r' }') -+ print(r' return GetProcAddress(g_h%sModule, lpProcName);' % tag) -+ print(r'}') -+ print(r'') - - Dispatcher.dispatchModule(self, module) - -diff --git a/retrace/dxgiretrace.py b/retrace/dxgiretrace.py -index 799e3df9..8986a767 100755 ---- a/retrace/dxgiretrace.py -+++ b/retrace/dxgiretrace.py -@@ -40,10 +40,10 @@ from specs.d3d11 import d3d11 - class D3DRetracer(Retracer): - - def retraceApi(self, api): -- print '// Swizzling mapping for lock addresses, mapping a (pDeviceContext, pResource, Subresource) -> void *' -- print 'typedef std::pair< IUnknown *, UINT > SubresourceKey;' -- print 'static std::map< IUnknown *, std::map< SubresourceKey, void * > > g_Maps;' -- print -+ print('// Swizzling mapping for lock addresses, mapping a (pDeviceContext, pResource, Subresource) -> void *') -+ print('typedef std::pair< IUnknown *, UINT > SubresourceKey;') -+ print('static std::map< IUnknown *, std::map< SubresourceKey, void * > > g_Maps;') -+ print() - self.table_name = 'd3dretrace::dxgi_callbacks' - - Retracer.retraceApi(self, api) -@@ -61,41 +61,41 @@ class D3DRetracer(Retracer): - if function.name in self.createDeviceFunctionNames: - # create windows as neccessary - if 'pSwapChainDesc' in function.argNames(): -- print r' d3dretrace::createWindowForSwapChain(pSwapChainDesc);' -+ print(r' d3dretrace::createWindowForSwapChain(pSwapChainDesc);') - - # Compensate for the fact we don't trace DXGI object creation - if function.name.startswith('D3D11CreateDevice'): -- print r' if (DriverType == D3D_DRIVER_TYPE_UNKNOWN && !pAdapter) {' -- print r' DriverType = D3D_DRIVER_TYPE_HARDWARE;' -- print r' }' -+ print(r' if (DriverType == D3D_DRIVER_TYPE_UNKNOWN && !pAdapter) {') -+ print(r' DriverType = D3D_DRIVER_TYPE_HARDWARE;') -+ print(r' }') - - if function.name.startswith('D3D10CreateDevice'): - # Toggle debugging -- print r' Flags &= ~D3D10_CREATE_DEVICE_DEBUG;' -- print r' if (retrace::debug) {' -- print r' HMODULE hD3d10SdkLayers = LoadLibraryA("d3d10sdklayers");' -- print r' if (hD3d10SdkLayers) {' -- print r' FreeLibrary(hD3d10SdkLayers);' -- print r' Flags |= D3D10_CREATE_DEVICE_DEBUG;' -- print r' } else {' -- print r' retrace::warning(call) << "Direct3D 10.x SDK Debug Layer (d3d10sdklayers.dll) not available, continuing without debug output\n";' -- print r' }' -- print r' }' -+ print(r' Flags &= ~D3D10_CREATE_DEVICE_DEBUG;') -+ print(r' if (retrace::debug) {') -+ print(r' HMODULE hD3d10SdkLayers = LoadLibraryA("d3d10sdklayers");') -+ print(r' if (hD3d10SdkLayers) {') -+ print(r' FreeLibrary(hD3d10SdkLayers);') -+ print(r' Flags |= D3D10_CREATE_DEVICE_DEBUG;') -+ print(r' } else {') -+ print(r' retrace::warning(call) << "Direct3D 10.x SDK Debug Layer (d3d10sdklayers.dll) not available, continuing without debug output\n";') -+ print(r' }') -+ print(r' }') - - # Force driver - self.forceDriver('D3D10_DRIVER_TYPE') - - if function.name.startswith('D3D11CreateDevice'): - # Toggle debugging -- print r' Flags &= ~D3D11_CREATE_DEVICE_DEBUG;' -- print r' if (retrace::debug) {' -- print r' HRESULT hr = D3D11CreateDevice(NULL, D3D_DRIVER_TYPE_NULL, 0, D3D11_CREATE_DEVICE_DEBUG, NULL, 0, D3D11_SDK_VERSION, NULL, NULL, NULL);' -- print r' if (SUCCEEDED(hr)) {' -- print r' Flags |= D3D11_CREATE_DEVICE_DEBUG;' -- print r' } else {' -- print r' retrace::warning(call) << "Direct3D 11.x SDK Debug Layer (d3d11*sdklayers.dll) not available, continuing without debug output\n";' -- print r' }' -- print r' }' -+ print(r' Flags &= ~D3D11_CREATE_DEVICE_DEBUG;') -+ print(r' if (retrace::debug) {') -+ print(r' HRESULT hr = D3D11CreateDevice(NULL, D3D_DRIVER_TYPE_NULL, 0, D3D11_CREATE_DEVICE_DEBUG, NULL, 0, D3D11_SDK_VERSION, NULL, NULL, NULL);') -+ print(r' if (SUCCEEDED(hr)) {') -+ print(r' Flags |= D3D11_CREATE_DEVICE_DEBUG;') -+ print(r' } else {') -+ print(r' retrace::warning(call) << "Direct3D 11.x SDK Debug Layer (d3d11*sdklayers.dll) not available, continuing without debug output\n";') -+ print(r' }') -+ print(r' }') - - # Force driver - self.forceDriver('D3D_DRIVER_TYPE') -@@ -108,15 +108,15 @@ class D3DRetracer(Retracer): - if interface is not None: - getDeviceRemovedReasonMethod = interface.getMethodByName("GetDeviceRemovedReason") - if getDeviceRemovedReasonMethod is not None: -- print r' if (FAILED(_result)) {' -- print r' retrace::failed(call, _result);' -- print r' if (_result == DXGI_ERROR_DEVICE_REMOVED) {' -- print r' HRESULT _reason = _this->GetDeviceRemovedReason();' -- print r' retrace::failed(call, _reason);' -- print r' exit(1);' -- print r' }' -- print r' return;' -- print r' }' -+ print(r' if (FAILED(_result)) {') -+ print(r' retrace::failed(call, _result);') -+ print(r' if (_result == DXGI_ERROR_DEVICE_REMOVED) {') -+ print(r' HRESULT _reason = _this->GetDeviceRemovedReason();') -+ print(r' retrace::failed(call, _reason);') -+ print(r' exit(1);') -+ print(r' }') -+ print(r' return;') -+ print(r' }') - return - - Retracer.checkResult(self, interface, methodOrFunction) -@@ -124,112 +124,112 @@ class D3DRetracer(Retracer): - def forceDriver(self, enum): - # This can only work when pAdapter is NULL. For non-NULL pAdapter we - # need to override inside the EnumAdapters call below -- print r' if (pAdapter == NULL) {' -- print r' switch (retrace::driver) {' -- print r' case retrace::DRIVER_HARDWARE:' -- print r' DriverType = %s_HARDWARE;' % enum -- print r' Software = NULL;' -- print r' break;' -- print r' case retrace::DRIVER_SOFTWARE:' -- print r' DriverType = %s_WARP;' % enum -- print r' Software = NULL;' -- print r' break;' -- print r' case retrace::DRIVER_REFERENCE:' -- print r' DriverType = %s_REFERENCE;' % enum -- print r' Software = NULL;' -- print r' break;' -- print r' case retrace::DRIVER_NULL:' -- print r' DriverType = %s_NULL;' % enum -- print r' Software = NULL;' -- print r' break;' -- print r' case retrace::DRIVER_MODULE:' -- print r' DriverType = %s_SOFTWARE;' % enum -- print r' Software = LoadLibraryA(retrace::driverModule);' -- print r' if (!Software) {' -- print r' retrace::warning(call) << "failed to load " << retrace::driverModule << "\n";' -- print r' }' -- print r' break;' -- print r' default:' -- print r' assert(0);' -- print r' /* fall-through */' -- print r' case retrace::DRIVER_DEFAULT:' -- print r' if (DriverType == %s_SOFTWARE) {' % enum -- print r' Software = LoadLibraryA("d3d10warp");' -- print r' if (!Software) {' -- print r' retrace::warning(call) << "failed to load d3d10warp.dll\n";' -- print r' }' -- print r' }' -- print r' break;' -- print r' }' -- print r' } else {' -- print r' Software = NULL;' -- print r' }' -+ print(r' if (pAdapter == NULL) {') -+ print(r' switch (retrace::driver) {') -+ print(r' case retrace::DRIVER_HARDWARE:') -+ print(r' DriverType = %s_HARDWARE;' % enum) -+ print(r' Software = NULL;') -+ print(r' break;') -+ print(r' case retrace::DRIVER_SOFTWARE:') -+ print(r' DriverType = %s_WARP;' % enum) -+ print(r' Software = NULL;') -+ print(r' break;') -+ print(r' case retrace::DRIVER_REFERENCE:') -+ print(r' DriverType = %s_REFERENCE;' % enum) -+ print(r' Software = NULL;') -+ print(r' break;') -+ print(r' case retrace::DRIVER_NULL:') -+ print(r' DriverType = %s_NULL;' % enum) -+ print(r' Software = NULL;') -+ print(r' break;') -+ print(r' case retrace::DRIVER_MODULE:') -+ print(r' DriverType = %s_SOFTWARE;' % enum) -+ print(r' Software = LoadLibraryA(retrace::driverModule);') -+ print(r' if (!Software) {') -+ print(r' retrace::warning(call) << "failed to load " << retrace::driverModule << "\n";') -+ print(r' }') -+ print(r' break;') -+ print(r' default:') -+ print(r' assert(0);') -+ print(r' /* fall-through */') -+ print(r' case retrace::DRIVER_DEFAULT:') -+ print(r' if (DriverType == %s_SOFTWARE) {' % enum) -+ print(r' Software = LoadLibraryA("d3d10warp");') -+ print(r' if (!Software) {') -+ print(r' retrace::warning(call) << "failed to load d3d10warp.dll\n";') -+ print(r' }') -+ print(r' }') -+ print(r' break;') -+ print(r' }') -+ print(r' } else {') -+ print(r' Software = NULL;') -+ print(r' }') - - def invokeInterfaceMethod(self, interface, method): - # keep track of the last used device for state dumping - if interface.name in ('ID3D10Device', 'ID3D10Device1'): - if method.name == 'Release': -- print r' if (call.ret->toUInt() == 0) {' -- print r' d3d10Dumper.unbindDevice(_this);' -- print r' }' -+ print(r' if (call.ret->toUInt() == 0) {') -+ print(r' d3d10Dumper.unbindDevice(_this);') -+ print(r' }') - else: -- print r' d3d10Dumper.bindDevice(_this);' -+ print(r' d3d10Dumper.bindDevice(_this);') - if interface.name.startswith('ID3D11DeviceContext'): - if method.name == 'Release': -- print r' if (call.ret->toUInt() == 0) {' -- print r' d3d11Dumper.unbindDevice(_this);' -- print r' }' -+ print(r' if (call.ret->toUInt() == 0) {') -+ print(r' d3d11Dumper.unbindDevice(_this);') -+ print(r' }') - else: -- print r' if (_this->GetType() == D3D11_DEVICE_CONTEXT_IMMEDIATE) {' -- print r' d3d11Dumper.bindDevice(_this);' -- print r' }' -+ print(r' if (_this->GetType() == D3D11_DEVICE_CONTEXT_IMMEDIATE) {') -+ print(r' d3d11Dumper.bindDevice(_this);') -+ print(r' }') - - # intercept private interfaces - if method.name == 'QueryInterface': -- print r' if (!d3dretrace::overrideQueryInterface(_this, riid, ppvObj, &_result)) {' -+ print(r' if (!d3dretrace::overrideQueryInterface(_this, riid, ppvObj, &_result)) {') - Retracer.invokeInterfaceMethod(self, interface, method) -- print r' }' -+ print(r' }') - return - - # create windows as neccessary - if method.name == 'CreateSwapChain': -- print r' d3dretrace::createWindowForSwapChain(pDesc);' -+ print(r' d3dretrace::createWindowForSwapChain(pDesc);') - if method.name == 'CreateSwapChainForHwnd': -- print r' WindowHandle = d3dretrace::createWindow(pDesc->Width, pDesc->Height);' -- print r' // DXGI_SCALING_NONE is only supported on Win8 and beyond' -- print r' if (pDesc->Scaling == DXGI_SCALING_NONE && !IsWindows8OrGreater()) {' -- print r' pDesc->Scaling = DXGI_SCALING_STRETCH;' -- print r' }' -+ print(r' WindowHandle = d3dretrace::createWindow(pDesc->Width, pDesc->Height);') -+ print(r' // DXGI_SCALING_NONE is only supported on Win8 and beyond') -+ print(r' if (pDesc->Scaling == DXGI_SCALING_NONE && !IsWindows8OrGreater()) {') -+ print(r' pDesc->Scaling = DXGI_SCALING_STRETCH;') -+ print(r' }') - if method.name == 'CreateSwapChainForComposition': -- print r' HWND hWnd = d3dretrace::createWindow(pDesc->Width, pDesc->Height);' -- print r' _result = _this->CreateSwapChainForHwnd(pDevice, hWnd, pDesc, NULL, pRestrictToOutput, ppSwapChain);' -+ print(r' HWND hWnd = d3dretrace::createWindow(pDesc->Width, pDesc->Height);') -+ print(r' _result = _this->CreateSwapChainForHwnd(pDevice, hWnd, pDesc, NULL, pRestrictToOutput, ppSwapChain);') - self.checkResult(interface, method) - return - - if method.name == 'SetFullscreenState': -- print r' if (retrace::forceWindowed) {' -- print r' Fullscreen = FALSE;' -- print r' pTarget = NULL;' -- print r' }' -+ print(r' if (retrace::forceWindowed) {') -+ print(r' Fullscreen = FALSE;') -+ print(r' pTarget = NULL;') -+ print(r' }') - - # notify frame has been completed - if interface.name.startswith('IDXGISwapChain') and method.name.startswith('Present'): - if interface.name.startswith('IDXGISwapChainDWM'): -- print r' com_ptr<IDXGISwapChain> pSwapChain;' -- print r' if (SUCCEEDED(_this->QueryInterface(IID_IDXGISwapChain, (void **) &pSwapChain))) {' -- print r' dxgiDumper.bindDevice(pSwapChain);' -- print r' } else {' -- print r' assert(0);' -- print r' }' -+ print(r' com_ptr<IDXGISwapChain> pSwapChain;') -+ print(r' if (SUCCEEDED(_this->QueryInterface(IID_IDXGISwapChain, (void **) &pSwapChain))) {') -+ print(r' dxgiDumper.bindDevice(pSwapChain);') -+ print(r' } else {') -+ print(r' assert(0);') -+ print(r' }') - else: -- print r' dxgiDumper.bindDevice(_this);' -- print r' retrace::frameComplete(call);' -+ print(r' dxgiDumper.bindDevice(_this);') -+ print(r' retrace::frameComplete(call);') - - if 'pSharedResource' in method.argNames(): -- print r' if (pSharedResource) {' -- print r' retrace::warning(call) << "shared surfaces unsupported\n";' -- print r' pSharedResource = NULL;' -- print r' }' -+ print(r' if (pSharedResource) {') -+ print(r' retrace::warning(call) << "shared surfaces unsupported\n";') -+ print(r' pSharedResource = NULL;') -+ print(r' }') - - # Force driver - if interface.name.startswith('IDXGIFactory') and method.name.startswith('EnumAdapters'): -@@ -260,31 +260,31 @@ class D3DRetracer(Retracer): - return - - if interface.name.startswith('ID3D10Device') and method.name.startswith('OpenSharedResource'): -- print r' retrace::warning(call) << "replacing shared resource with checker pattern\n";' -- print r' _result = d3dretrace::createSharedResource(_this, ReturnedInterface, ppResource);' -+ print(r' retrace::warning(call) << "replacing shared resource with checker pattern\n";') -+ print(r' _result = d3dretrace::createSharedResource(_this, ReturnedInterface, ppResource);') - self.checkResult(interface, method) - return - if interface.name.startswith('ID3D11Device') and method.name == 'OpenSharedResource': - # Some applications (e.g., video playing in IE11) create shared resources within the same process. - # TODO: Generalize to other OpenSharedResource variants -- print r' retrace::map<HANDLE>::const_iterator it = _shared_handle_map.find(hResource);' -- print r' if (it == _shared_handle_map.end()) {' -- print r' retrace::warning(call) << "replacing shared resource with checker pattern\n";' -- print r' _result = d3dretrace::createSharedResource(_this, ReturnedInterface, ppResource);' -+ print(r' retrace::map<HANDLE>::const_iterator it = _shared_handle_map.find(hResource);') -+ print(r' if (it == _shared_handle_map.end()) {') -+ print(r' retrace::warning(call) << "replacing shared resource with checker pattern\n";') -+ print(r' _result = d3dretrace::createSharedResource(_this, ReturnedInterface, ppResource);') - self.checkResult(interface, method) -- print r' } else {' -- print r' hResource = it->second;' -+ print(r' } else {') -+ print(r' hResource = it->second;') - Retracer.invokeInterfaceMethod(self, interface, method) -- print r' }' -+ print(r' }') - return - if interface.name.startswith('ID3D11Device') and method.name.startswith('OpenSharedResource'): -- print r' retrace::warning(call) << "replacing shared resource with checker pattern\n";' -- print r' _result = d3dretrace::createSharedResource(_this, ReturnedInterface, ppResource);' -+ print(r' retrace::warning(call) << "replacing shared resource with checker pattern\n";') -+ print(r' _result = d3dretrace::createSharedResource(_this, ReturnedInterface, ppResource);') - if method.name == 'OpenSharedResourceByName': -- print r' (void)lpName;' -- print r' (void)dwDesiredAccess;' -+ print(r' (void)lpName;') -+ print(r' (void)dwDesiredAccess;') - else: -- print r' (void)hResource;' -+ print(r' (void)hResource;') - self.checkResult(interface, method) - return - -@@ -294,7 +294,7 @@ class D3DRetracer(Retracer): - mapFlagsArg = method.getArgByName('MapFlags') - for flag in mapFlagsArg.type.values: - if flag.endswith('_MAP_FLAG_DO_NOT_WAIT'): -- print r' MapFlags &= ~%s;' % flag -+ print(r' MapFlags &= ~%s;' % flag) - - if method.name.startswith('UpdateSubresource'): - # The D3D10 debug layer is buggy (or at least inconsistent with the -@@ -303,108 +303,108 @@ class D3DRetracer(Retracer): - # SrcDepthPitch is garbagge for non 3D textures. - # XXX: It also seems to expect padding bytes at the end of the last - # row, but we never record (or allocate) those... -- print r' if (retrace::debug && pDstBox && pDstBox->front == 0 && pDstBox->back == 1) {' -- print r' SrcDepthPitch = 0;' -- print r' }' -+ print(r' if (retrace::debug && pDstBox && pDstBox->front == 0 && pDstBox->back == 1) {') -+ print(r' SrcDepthPitch = 0;') -+ print(r' }') - - if method.name == 'SetGammaControl': - # This method is only supported while in full-screen mode -- print r' if (retrace::forceWindowed) {' -- print r' return;' -- print r' }' -+ print(r' if (retrace::forceWindowed) {') -+ print(r' return;') -+ print(r' }') - - Retracer.invokeInterfaceMethod(self, interface, method) - - if method.name in ('AcquireSync', 'ReleaseSync'): -- print r' if (SUCCEEDED(_result) && _result != S_OK) {' -- print r' retrace::warning(call) << " returned " << _result << "\n";' -- print r' }' -+ print(r' if (SUCCEEDED(_result) && _result != S_OK) {') -+ print(r' retrace::warning(call) << " returned " << _result << "\n";') -+ print(r' }') - - # process events after presents - if interface.name.startswith('IDXGISwapChain') and method.name.startswith('Present'): -- print r' d3dretrace::processEvents();' -+ print(r' d3dretrace::processEvents();') - - if method.name in ('Map', 'Unmap'): - if interface.name.startswith('ID3D11DeviceContext'): -- print ' void * & _pbData = g_Maps[_this][SubresourceKey(pResource, Subresource)];' -+ print(' void * & _pbData = g_Maps[_this][SubresourceKey(pResource, Subresource)];') - else: - subresourceArg = method.getArgByName('Subresource') - if subresourceArg is None: -- print ' UINT Subresource = 0;' -- print ' void * & _pbData = g_Maps[0][SubresourceKey(_this, Subresource)];' -+ print(' UINT Subresource = 0;') -+ print(' void * & _pbData = g_Maps[0][SubresourceKey(_this, Subresource)];') - - if method.name == 'Map': -- print ' _MAP_DESC _MapDesc;' -- print ' _getMapDesc(_this, %s, _MapDesc);' % ', '.join(method.argNames()) -- print ' size_t _MappedSize = _MapDesc.Size;' -- print ' if (_MapDesc.Size) {' -- print ' _pbData = _MapDesc.pData;' -+ print(' _MAP_DESC _MapDesc;') -+ print(' _getMapDesc(_this, %s, _MapDesc);' % ', '.join(method.argNames())) -+ print(' size_t _MappedSize = _MapDesc.Size;') -+ print(' if (_MapDesc.Size) {') -+ print(' _pbData = _MapDesc.pData;') - if interface.name.startswith('ID3D11DeviceContext'): - # Prevent false warnings on 1D and 2D resources, since the - # pitches are often junk there... -- print ' _normalizeMap(pResource, pMappedResource);' -+ print(' _normalizeMap(pResource, pMappedResource);') - self.checkPitchMismatch(method) - else: -- print ' _pbData = _MapDesc.pData;' -+ print(' _pbData = _MapDesc.pData;') - self.checkPitchMismatch(method) -- print ' } else {' -- print ' return;' -- print ' }' -+ print(' } else {') -+ print(' return;') -+ print(' }') - - if method.name == 'Unmap': -- print ' if (_pbData) {' -- print ' retrace::delRegionByPointer(_pbData);' -- print ' _pbData = 0;' -- print ' }' -+ print(' if (_pbData) {') -+ print(' retrace::delRegionByPointer(_pbData);') -+ print(' _pbData = 0;') -+ print(' }') - - # Attach shader byte code for lookup - if 'pShaderBytecode' in method.argNames(): - ppShader = method.args[-1] - assert ppShader.output -- print r' if (retrace::dumpingState && SUCCEEDED(_result)) {' -- print r' (*%s)->SetPrivateData(d3dstate::GUID_D3DSTATE, BytecodeLength, pShaderBytecode);' % ppShader.name -- print r' }' -+ print(r' if (retrace::dumpingState && SUCCEEDED(_result)) {') -+ print(r' (*%s)->SetPrivateData(d3dstate::GUID_D3DSTATE, BytecodeLength, pShaderBytecode);' % ppShader.name) -+ print(r' }') - - def extractArg(self, function, arg, arg_type, lvalue, rvalue): - # Set object names - if function.name == 'SetPrivateData' and arg.name == 'pData': - iid = function.args[0].name -- print r' if (%s != WKPDID_D3DDebugObjectName) {' % iid -- print r' return;' -- print r' }' -+ print(r' if (%s != WKPDID_D3DDebugObjectName) {' % iid) -+ print(r' return;') -+ print(r' }') - # Interpret argument as string - Retracer.extractArg(self, function, arg, LPCSTR, lvalue, rvalue) -- print r' assert(pData);' -- print r' assert(DataSize >= strlen((const char *)pData));' -- print r' // Some applications include the trailing zero terminator in the data' -- print r' DataSize = strlen((const char *)pData);' -+ print(r' assert(pData);') -+ print(r' assert(DataSize >= strlen((const char *)pData));') -+ print(r' // Some applications include the trailing zero terminator in the data') -+ print(r' DataSize = strlen((const char *)pData);') - return - - Retracer.extractArg(self, function, arg, arg_type, lvalue, rvalue) - - - def main(): -- print r'#define INITGUID' -- print -- print r'#include <string.h>' -- print -- print r'#include <iostream>' -- print -- print r'#include "d3dretrace.hpp"' -- print r'#include "os_version.hpp"' -- print -- print r'#include "d3dretrace_dxgi.hpp"' -- print r'#include "d3d10imports.hpp"' -- print r'#include "d3d10size.hpp"' -- print r'#include "d3d10state.hpp"' -- print r'#include "d3d11imports.hpp"' -- print r'#include "d3d11size.hpp"' -- print r'#include "d3dstate.hpp"' -- print -- print '''static d3dretrace::D3DDumper<IDXGISwapChain> dxgiDumper;''' -- print '''static d3dretrace::D3DDumper<ID3D10Device> d3d10Dumper;''' -- print '''static d3dretrace::D3DDumper<ID3D11DeviceContext> d3d11Dumper;''' -- print -+ print(r'#define INITGUID') -+ print() -+ print(r'#include <string.h>') -+ print() -+ print(r'#include <iostream>') -+ print() -+ print(r'#include "d3dretrace.hpp"') -+ print(r'#include "os_version.hpp"') -+ print() -+ print(r'#include "d3dretrace_dxgi.hpp"') -+ print(r'#include "d3d10imports.hpp"') -+ print(r'#include "d3d10size.hpp"') -+ print(r'#include "d3d10state.hpp"') -+ print(r'#include "d3d11imports.hpp"') -+ print(r'#include "d3d11size.hpp"') -+ print(r'#include "d3dstate.hpp"') -+ print() -+ print('''static d3dretrace::D3DDumper<IDXGISwapChain> dxgiDumper;''') -+ print('''static d3dretrace::D3DDumper<ID3D10Device> d3d10Dumper;''') -+ print('''static d3dretrace::D3DDumper<ID3D11DeviceContext> d3d11Dumper;''') -+ print() - - api = API() - api.addModule(dxgi) -diff --git a/retrace/dxgistate_so.py b/retrace/dxgistate_so.py -index 86f6db57..33745c8f 100644 ---- a/retrace/dxgistate_so.py -+++ b/retrace/dxgistate_so.py -@@ -48,9 +48,9 @@ class ValueDumper(stdapi.Visitor, stdapi.ExpanderMixin): - - def visitLiteral(self, literal, instance): - if literal.kind in ('SInt', 'UInt'): -- print ' writer.writeInt(%s);' % (instance) -+ print(' writer.writeInt(%s);' % (instance)) - elif literal.kind in ('Float',): -- print ' writer.writeFloat(%s);' % (instance) -+ print(' writer.writeFloat(%s);' % (instance)) - else: - raise NotImplementedError - -@@ -66,36 +66,36 @@ class ValueDumper(stdapi.Visitor, stdapi.ExpanderMixin): - # reinterpret_cast is necessary for GLubyte * <=> char * - instance = 'reinterpret_cast<%s>(%s)' % (cast, instance) - assert string.length is None -- print ' writer.write%s(%s);' % (suffix, instance) -+ print(' writer.write%s(%s);' % (suffix, instance)) - - def visitConst(self, const, instance): - self.visit(const.type, instance) - - def visitStruct(self, struct, instance): -- print ' writer.beginObject();' -+ print(' writer.beginObject();') - for member in struct.members: - memberType, memberName = member - if memberName is not None: -- print ' writer.beginMember("%s");' % memberName -+ print(' writer.beginMember("%s");' % memberName) - self.visitMember(member, instance) - if memberName is not None: -- print ' writer.endMember(); // %s' % memberName -- print ' writer.endObject();' -+ print(' writer.endMember(); // %s' % memberName) -+ print(' writer.endObject();') - - def visitArray(self, array, instance): - length = '_c' + array.type.tag - index = '_i' + array.type.tag - array_length = self.expand(array.length) -- print ' if (%s) {' % instance -- print ' size_t %s = %s > 0 ? %s : 0;' % (length, array_length, array_length) -- print ' writer.beginArray();' -- print ' for (size_t %s = 0; %s < %s; ++%s) {' % (index, index, length, index) -+ print(' if (%s) {' % instance) -+ print(' size_t %s = %s > 0 ? %s : 0;' % (length, array_length, array_length)) -+ print(' writer.beginArray();') -+ print(' for (size_t %s = 0; %s < %s; ++%s) {' % (index, index, length, index)) - self.visitElement(index, array.type, '(%s)[%s]' % (instance, index)) -- print ' }' -- print ' writer.endArray();' -- print ' } else {' -- print ' writer.writeNull();' -- print ' }' -+ print(' }') -+ print(' writer.endArray();') -+ print(' } else {') -+ print(' writer.writeNull();') -+ print(' }') - - def visitAttribArray(self, array, instance): - raise NotImplementedError -@@ -104,37 +104,37 @@ class ValueDumper(stdapi.Visitor, stdapi.ExpanderMixin): - raise NotImplementedError - - def visitEnum(self, enum, instance): -- print ' switch (%s) {' % instance -+ print(' switch (%s) {' % instance) - for value in enum.values: -- print ' case %s:' % value -- print ' writer.writeString("%s");' % value -- print ' break;' -- print ' default:' -- print ' writer.writeInt(%s);' % instance -- print ' break;' -- print ' }' -+ print(' case %s:' % value) -+ print(' writer.writeString("%s");' % value) -+ print(' break;') -+ print(' default:') -+ print(' writer.writeInt(%s);' % instance) -+ print(' break;') -+ print(' }') - - def visitBitmask(self, bitmask, instance): - # TODO - self.visit(bitmask.type, instance) - - def visitPointer(self, pointer, instance): -- print ' if (%s) {' % instance -- print ' writer.beginArray();' -+ print(' if (%s) {' % instance) -+ print(' writer.beginArray();') - self.visit(pointer.type, "*" + instance) -- print ' writer.endArray();' -- print ' } else {' -- print ' writer.writeNull();' -- print ' }' -+ print(' writer.endArray();') -+ print(' } else {') -+ print(' writer.writeNull();') -+ print(' }') - - def visitIntPointer(self, pointer, instance): -- print ' writer.writeInt((uintptr_t)%s);' % instance -+ print(' writer.writeInt((uintptr_t)%s);' % instance) - - def visitObjPointer(self, pointer, instance): -- print ' writer.writeInt((uintptr_t)%s);' % instance -+ print(' writer.writeInt((uintptr_t)%s);' % instance) - - def visitLinearPointer(self, pointer, instance): -- print ' writer.writeInt((uintptr_t)%s);' % instance -+ print(' writer.writeInt((uintptr_t)%s);' % instance) - - def visitReference(self, reference, instance): - self.visit(reference.type, instance) -@@ -146,23 +146,23 @@ class ValueDumper(stdapi.Visitor, stdapi.ExpanderMixin): - self.visit(alias.type, instance) - - def visitOpaque(self, opaque, instance): -- print ' writer.writeInt((uintptr_t)%s);' % instance -+ print(' writer.writeInt((uintptr_t)%s);' % instance) - - def visitInterface(self, interface, instance): - assert False - - def visitPolymorphic(self, polymorphic, instance): - switchExpr = self.expand(polymorphic.switchExpr) -- print ' switch (static_cast<int>(%s)) {' % switchExpr -+ print(' switch (static_cast<int>(%s)) {' % switchExpr) - for cases, type in polymorphic.iterSwitch(): - for case in cases: -- print ' %s:' % case -+ print(' %s:' % case) - caseInstance = instance - if type.expr is not None: - caseInstance = 'static_cast<%s>(%s)' % (type, caseInstance) - self.visit(type, caseInstance) -- print ' break;' -- print ' }' -+ print(' break;') -+ print(' }') - - - class Dumper: -@@ -187,8 +187,8 @@ class Dumper: - # Includes - for module in api.modules: - for header in module.headers: -- print header -- print -+ print(header) -+ print() - - # Generate the dumper functions - types = api.getAllTypes() -@@ -196,13 +196,13 @@ class Dumper: - self.dumpType(type) - - def dumpType(self, type): -- print r'void' -- print r'dumpStateObject(StateWriter &writer, const %s & so)' % type -- print r'{' -+ print(r'void') -+ print(r'dumpStateObject(StateWriter &writer, const %s & so)' % type) -+ print(r'{') - visitor = self.dumperFactory() - visitor.visit(type, 'so') -- print r'}' -- print -+ print(r'}') -+ print() - - def header(self): - pass -@@ -212,10 +212,10 @@ class Dumper: - - - if __name__ == '__main__': -- print r'#include "dxgistate_so.hpp"' -- print -- print r'#include "state_writer.hpp"' -- print -+ print(r'#include "dxgistate_so.hpp"') -+ print() -+ print(r'#include "state_writer.hpp"') -+ print() - - api = stdapi.API() - api.addModule(dxgi.dxgi) -diff --git a/retrace/glretrace.py b/retrace/glretrace.py -index 2ead195d..0dfe5c5b 100644 ---- a/retrace/glretrace.py -+++ b/retrace/glretrace.py -@@ -127,190 +127,190 @@ class GlRetracer(Retracer): - - # For backwards compatibility with old traces where non VBO drawing was supported - if (is_array_pointer or is_draw_arrays or is_draw_elements) and not is_draw_indirect: -- print ' if (retrace::parser->getVersion() < 1) {' -+ print(' if (retrace::parser->getVersion() < 1) {') - - if is_array_pointer or is_draw_arrays: -- print ' GLint _array_buffer = 0;' -- print ' glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &_array_buffer);' -- print ' if (!_array_buffer) {' -+ print(' GLint _array_buffer = 0;') -+ print(' glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &_array_buffer);') -+ print(' if (!_array_buffer) {') - self.failFunction(function) -- print ' }' -+ print(' }') - - if is_draw_elements: -- print ' GLint _element_array_buffer = 0;' -- print ' glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING, &_element_array_buffer);' -- print ' if (!_element_array_buffer) {' -+ print(' GLint _element_array_buffer = 0;') -+ print(' glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING, &_element_array_buffer);') -+ print(' if (!_element_array_buffer) {') - self.failFunction(function) -- print ' }' -+ print(' }') - -- print ' }' -+ print(' }') - - # When no pack buffer object is bound, the pack functions are no-ops. - if self.pack_function_regex.match(function.name): -- print ' GLint _pack_buffer = 0;' -- print ' glGetIntegerv(GL_PIXEL_PACK_BUFFER_BINDING, &_pack_buffer);' -- print ' if (!_pack_buffer) {' -- print ' return;' -- print ' }' -+ print(' GLint _pack_buffer = 0;') -+ print(' glGetIntegerv(GL_PIXEL_PACK_BUFFER_BINDING, &_pack_buffer);') -+ print(' if (!_pack_buffer) {') -+ print(' return;') -+ print(' }') - - # Pre-snapshots - if self.bind_framebuffer_function_regex.match(function.name): -- print ' assert(call.flags & trace::CALL_FLAG_SWAP_RENDERTARGET);' -+ print(' assert(call.flags & trace::CALL_FLAG_SWAP_RENDERTARGET);') - if function.name == 'glStringMarkerGREMEDY': - return - if function.name == 'glFrameTerminatorGREMEDY': -- print ' glretrace::frame_complete(call);' -+ print(' glretrace::frame_complete(call);') - return - - Retracer.retraceFunctionBody(self, function) - - # Post-snapshots - if function.name in ('glFlush', 'glFinish'): -- print ' if (!retrace::doubleBuffer) {' -- print ' glretrace::frame_complete(call);' -- print ' }' -+ print(' if (!retrace::doubleBuffer) {') -+ print(' glretrace::frame_complete(call);') -+ print(' }') - if is_draw_arrays or is_draw_elements or is_misc_draw: -- print ' assert(call.flags & trace::CALL_FLAG_RENDER);' -+ print(' assert(call.flags & trace::CALL_FLAG_RENDER);') - - - def invokeFunction(self, function): - if function.name == "glTexDirectVIVMap" or function.name == "glTexDirectMapVIV" or function.name == "glTexDirectTiledMapVIV": -- print '#if defined(HAVE_VIVANTE_G2D)' -- print ' GLint tex;' -- print ' glGetIntegerv(GL_TEXTURE_BINDING_2D, &tex);' -- print ' int32_t size = 0;' -- print ' switch(format){' -- print ' case GL_VIV_YV12:' -- print ' case GL_VIV_I420:' -- print ' case GL_VIV_NV12:' -- print ' case GL_VIV_NV21:' -- print ' size=width * height * 3 / 2;' -- print ' break;' -- print ' case GL_RGBA:' -- print ' case GL_BGRA_EXT:' -- print ' size=width * height * 4;' -- print ' break;' -- print ' case GL_RGB:' -- print ' size=width * height *3;' -- print ' break;' -- print ' case GL_VIV_YUY2:' -- print ' case GL_VIV_UYVY:' -- print ' case GL_RGB565_OES:' -- print ' case GL_LUMINANCE8_ALPHA8_EXT:' -- print ' size=width * height *2;' -- print ' break;' -- print ' case GL_ALPHA:' -- print ' size=width * height;' -- print ' break;' -- print ' default:' -- print ' break;' -- print ' }' -- print ' if(tex != 0)' -- print ' {' -- print ' GLuint pindex = *(GLuint*)Logical;' -- print ' TEXDIRECTVIVDATA &data = _directTextureDataMap[tex];' -- print ' if(data.privateData == 0) // new entry' -- print ' {' -- print ' data.privateData = alloc_dma_buffer(size, (uintptr_t*)&data.logical, &data.physical);' -- print ' data.index = pindex;' -- print ' data.size = size;' -- print ' retrace::addRegion(call,data.index,data.logical,size);' -- print ' }' -- print ' else // already have one; check size and index' -- print ' {' -- print ' if((size!=data.size)||(pindex!=data.index))' -- print ' {' -- print ' retrace::delRegionByPointer(data.logical);' -- print ' free_dma_buffer(data.privateData);' -- print ' data.privateData = alloc_dma_buffer(size, (uintptr_t*)&data.logical, &data.physical);' -- print ' data.index = pindex;' -- print ' data.size = size;' -- print ' retrace::addRegion(call,data.index,data.logical,size);' -- print ' }' -- print ' }' -- print ' *Logical = data.logical;' -- print ' *Physical = data.physical;' -- print ' }' -- print '#endif /* HAVE_VIVANTE_G2D */' -+ print('#if defined(HAVE_VIVANTE_G2D)') -+ print(' GLint tex;') -+ print(' glGetIntegerv(GL_TEXTURE_BINDING_2D, &tex);') -+ print(' int32_t size = 0;') -+ print(' switch(format){') -+ print(' case GL_VIV_YV12:') -+ print(' case GL_VIV_I420:') -+ print(' case GL_VIV_NV12:') -+ print(' case GL_VIV_NV21:') -+ print(' size=width * height * 3 / 2;') -+ print(' break;') -+ print(' case GL_RGBA:') -+ print(' case GL_BGRA_EXT:') -+ print(' size=width * height * 4;') -+ print(' break;') -+ print(' case GL_RGB:') -+ print(' size=width * height *3;') -+ print(' break;') -+ print(' case GL_VIV_YUY2:') -+ print(' case GL_VIV_UYVY:') -+ print(' case GL_RGB565_OES:') -+ print(' case GL_LUMINANCE8_ALPHA8_EXT:') -+ print(' size=width * height *2;') -+ print(' break;') -+ print(' case GL_ALPHA:') -+ print(' size=width * height;') -+ print(' break;') -+ print(' default:') -+ print(' break;') -+ print(' }') -+ print(' if(tex != 0)') -+ print(' {') -+ print(' GLuint pindex = *(GLuint*)Logical;') -+ print(' TEXDIRECTVIVDATA &data = _directTextureDataMap[tex];') -+ print(' if(data.privateData == 0) // new entry') -+ print(' {') -+ print(' data.privateData = alloc_dma_buffer(size, (uintptr_t*)&data.logical, &data.physical);') -+ print(' data.index = pindex;') -+ print(' data.size = size;') -+ print(' retrace::addRegion(call,data.index,data.logical,size);') -+ print(' }') -+ print(' else // already have one; check size and index') -+ print(' {') -+ print(' if((size!=data.size)||(pindex!=data.index))') -+ print(' {') -+ print(' retrace::delRegionByPointer(data.logical);') -+ print(' free_dma_buffer(data.privateData);') -+ print(' data.privateData = alloc_dma_buffer(size, (uintptr_t*)&data.logical, &data.physical);') -+ print(' data.index = pindex;') -+ print(' data.size = size;') -+ print(' retrace::addRegion(call,data.index,data.logical,size);') -+ print(' }') -+ print(' }') -+ print(' *Logical = data.logical;') -+ print(' *Physical = data.physical;') -+ print(' }') -+ print('#endif /* HAVE_VIVANTE_G2D */') - # Infer the drawable size from GL calls - if function.name == "glViewport": -- print ' glretrace::updateDrawable(x + width, y + height);' -+ print(' glretrace::updateDrawable(x + width, y + height);') - if function.name == "glViewportArray": - # We are concerned about drawables so only care for the first viewport -- print ' if (first == 0 && count > 0) {' -- print ' GLfloat x = v[0], y = v[1], w = v[2], h = v[3];' -- print ' glretrace::updateDrawable(x + w, y + h);' -- print ' }' -+ print(' if (first == 0 && count > 0) {') -+ print(' GLfloat x = v[0], y = v[1], w = v[2], h = v[3];') -+ print(' glretrace::updateDrawable(x + w, y + h);') -+ print(' }') - if function.name == "glViewportIndexedf": -- print ' if (index == 0) {' -- print ' glretrace::updateDrawable(x + w, y + h);' -- print ' }' -+ print(' if (index == 0) {') -+ print(' glretrace::updateDrawable(x + w, y + h);') -+ print(' }') - if function.name == "glViewportIndexedfv": -- print ' if (index == 0) {' -- print ' GLfloat x = v[0], y = v[1], w = v[2], h = v[3];' -- print ' glretrace::updateDrawable(x + w, y + h);' -- print ' }' -+ print(' if (index == 0) {') -+ print(' GLfloat x = v[0], y = v[1], w = v[2], h = v[3];') -+ print(' glretrace::updateDrawable(x + w, y + h);') -+ print(' }') - if function.name in ('glBlitFramebuffer', 'glBlitFramebufferEXT'): - # Some applications do all their rendering in a framebuffer, and - # then just blit to the drawable without ever calling glViewport. -- print ' glretrace::updateDrawable(std::max(dstX0, dstX1), std::max(dstY0, dstY1));' -+ print(' glretrace::updateDrawable(std::max(dstX0, dstX1), std::max(dstY0, dstY1));') - - if function.name.startswith('gl') and not function.name.startswith('glX'): - # The Windows OpenGL runtime will skip calls when there's no - # context bound to the current context, but this might cause - # crashes on other systems, particularly with NVIDIA Linux drivers. -- print r' glretrace::Context *currentContext = glretrace::getCurrentContext();' -- print r' if (!currentContext) {' -- print r' if (retrace::debug) {' -- print r' retrace::warning(call) << "no current context\n";' -- print r' }' -- print r'#ifndef _WIN32' -- print r' return;' -- print r'#endif' -- print r' }' -+ print(r' glretrace::Context *currentContext = glretrace::getCurrentContext();') -+ print(r' if (!currentContext) {') -+ print(r' if (retrace::debug) {') -+ print(r' retrace::warning(call) << "no current context\n";') -+ print(r' }') -+ print(r'#ifndef _WIN32') -+ print(r' return;') -+ print(r'#endif') -+ print(r' }') - - if function.name == "glEnd": -- print r' if (currentContext) {' -- print r' currentContext->insideBeginEnd = false;' -- print r' }' -+ print(r' if (currentContext) {') -+ print(r' currentContext->insideBeginEnd = false;') -+ print(r' }') - - if function.name == 'memcpy': -- print ' if (!dest || !src || !n) return;' -+ print(' if (!dest || !src || !n) return;') - - # Skip glEnable/Disable(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB) as we don't - # faithfully set the CONTEXT_DEBUG_BIT_ARB flags on context creation. - if function.name in ('glEnable', 'glDisable'): -- print ' if (cap == GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB) return;' -+ print(' if (cap == GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB) return;') - - # Destroy the buffer mapping - if self.unmap_function_regex.match(function.name): -- print r' GLvoid *ptr = NULL;' -+ print(r' GLvoid *ptr = NULL;') - if function.name == 'glUnmapBuffer': -- print r' glGetBufferPointerv(target, GL_BUFFER_MAP_POINTER, &ptr);' -+ print(r' glGetBufferPointerv(target, GL_BUFFER_MAP_POINTER, &ptr);') - elif function.name == 'glUnmapBufferARB': -- print r' glGetBufferPointervARB(target, GL_BUFFER_MAP_POINTER_ARB, &ptr);' -+ print(r' glGetBufferPointervARB(target, GL_BUFFER_MAP_POINTER_ARB, &ptr);') - elif function.name == 'glUnmapBufferOES': -- print r' glGetBufferPointervOES(target, GL_BUFFER_MAP_POINTER_OES, &ptr);' -+ print(r' glGetBufferPointervOES(target, GL_BUFFER_MAP_POINTER_OES, &ptr);') - elif function.name == 'glUnmapNamedBuffer': -- print r' glGetNamedBufferPointerv(buffer, GL_BUFFER_MAP_POINTER, &ptr);' -+ print(r' glGetNamedBufferPointerv(buffer, GL_BUFFER_MAP_POINTER, &ptr);') - elif function.name == 'glUnmapNamedBufferEXT': -- print r' glGetNamedBufferPointervEXT(buffer, GL_BUFFER_MAP_POINTER, &ptr);' -+ print(r' glGetNamedBufferPointervEXT(buffer, GL_BUFFER_MAP_POINTER, &ptr);') - elif function.name == 'glUnmapObjectBufferATI': - # TODO - pass - else: - assert False -- print r' if (ptr) {' -- print r' retrace::delRegionByPointer(ptr);' -- print r' } else {' -- print r' retrace::warning(call) << "failed to get mapped pointer\n";' -- print r' }' -+ print(r' if (ptr) {') -+ print(r' retrace::delRegionByPointer(ptr);') -+ print(r' } else {') -+ print(r' retrace::warning(call) << "failed to get mapped pointer\n";') -+ print(r' }') - - if function.name in ('glBindProgramPipeline', 'glBindProgramPipelineEXT'): - # Note if glBindProgramPipeline has ever been called -- print r' if (pipeline) {' -- print r' _pipelineHasBeenBound = true;' -- print r' }' -+ print(r' if (pipeline) {') -+ print(r' _pipelineHasBeenBound = true;') -+ print(r' }') - - is_draw_arrays = self.draw_arrays_function_regex.match(function.name) is not None - is_draw_elements = self.draw_elements_function_regex.match(function.name) is not None -@@ -325,240 +325,240 @@ class GlRetracer(Retracer): - - # Keep track of active program for call lists - if function.name in ('glUseProgram', 'glUseProgramObjectARB'): -- print r' if (currentContext) {' -- print r' currentContext->activeProgram = call.arg(0).toUInt();' -- print r' }' -+ print(r' if (currentContext) {') -+ print(r' currentContext->activeProgram = call.arg(0).toUInt();') -+ print(r' }') - - # Only profile if not inside a list as the queries get inserted into list - if function.name == 'glNewList': -- print r' if (currentContext) {' -- print r' currentContext->insideList = true;' -- print r' }' -+ print(r' if (currentContext) {') -+ print(r' currentContext->insideList = true;') -+ print(r' }') - - if function.name == 'glEndList': -- print r' if (currentContext) {' -- print r' currentContext->insideList = false;' -- print r' }' -+ print(r' if (currentContext) {') -+ print(r' currentContext->insideList = false;') -+ print(r' }') - - if function.name == 'glBegin' or \ - is_draw_arrays or \ - is_draw_elements or \ - function.name.startswith('glBeginTransformFeedback'): -- print r' if (retrace::debug) {' -- print r' _validateActiveProgram(call);' -- print r' }' -+ print(r' if (retrace::debug) {') -+ print(r' _validateActiveProgram(call);') -+ print(r' }') - - if function.name != 'glEnd': -- print r' if (currentContext && !currentContext->insideList && !currentContext->insideBeginEnd && retrace::profiling) {' -+ print(r' if (currentContext && !currentContext->insideList && !currentContext->insideBeginEnd && retrace::profiling) {') - if profileDraw: -- print r' glretrace::beginProfile(call, true);' -+ print(r' glretrace::beginProfile(call, true);') - else: -- print r' glretrace::beginProfile(call, false);' -- print r' }' -+ print(r' glretrace::beginProfile(call, false);') -+ print(r' }') - - if function.name in ('glCreateShaderProgramv', 'glCreateShaderProgramEXT', 'glCreateShaderProgramvEXT'): - # When dumping state, break down glCreateShaderProgram* so that the - # shader source can be recovered. -- print r' if (retrace::dumpingState) {' -- print r' GLuint _shader = glCreateShader(type);' -- print r' if (_shader) {' -+ print(r' if (retrace::dumpingState) {') -+ print(r' GLuint _shader = glCreateShader(type);') -+ print(r' if (_shader) {') - if not function.name.startswith('glCreateShaderProgramv'): -- print r' GLsizei count = 1;' -- print r' const GLchar **strings = &string;' -- print r' glShaderSource(_shader, count, strings, NULL);' -- print r' glCompileShader(_shader);' -- print r' const GLuint _program = glCreateProgram();' -- print r' if (_program) {' -- print r' GLint compiled = GL_FALSE;' -- print r' glGetShaderiv(_shader, GL_COMPILE_STATUS, &compiled);' -+ print(r' GLsizei count = 1;') -+ print(r' const GLchar **strings = &string;') -+ print(r' glShaderSource(_shader, count, strings, NULL);') -+ print(r' glCompileShader(_shader);') -+ print(r' const GLuint _program = glCreateProgram();') -+ print(r' if (_program) {') -+ print(r' GLint compiled = GL_FALSE;') -+ print(r' glGetShaderiv(_shader, GL_COMPILE_STATUS, &compiled);') - if function.name == 'glCreateShaderProgramvEXT': -- print r' glProgramParameteriEXT(_program, GL_PROGRAM_SEPARABLE, GL_TRUE);' -+ print(r' glProgramParameteriEXT(_program, GL_PROGRAM_SEPARABLE, GL_TRUE);') - else: -- print r' glProgramParameteri(_program, GL_PROGRAM_SEPARABLE, GL_TRUE);' -- print r' if (compiled) {' -- print r' glAttachShader(_program, _shader);' -- print r' glLinkProgram(_program);' -- print r' if (false) glDetachShader(_program, _shader);' -- print r' }' -- print r' // TODO: append shader info log to program info log' -- print r' }' -- print r' glDeleteShader(_shader);' -- print r' _result = _program;' -- print r' } else {' -- print r' _result = 0;' -- print r' }' -- print r' } else {' -+ print(r' glProgramParameteri(_program, GL_PROGRAM_SEPARABLE, GL_TRUE);') -+ print(r' if (compiled) {') -+ print(r' glAttachShader(_program, _shader);') -+ print(r' glLinkProgram(_program);') -+ print(r' if (false) glDetachShader(_program, _shader);') -+ print(r' }') -+ print(r' // TODO: append shader info log to program info log') -+ print(r' }') -+ print(r' glDeleteShader(_shader);') -+ print(r' _result = _program;') -+ print(r' } else {') -+ print(r' _result = 0;') -+ print(r' }') -+ print(r' } else {') - Retracer.invokeFunction(self, function) -- print r' }' -+ print(r' }') - elif function.name in ('glDetachShader', 'glDetachObjectARB'): -- print r' if (!retrace::dumpingState) {' -+ print(r' if (!retrace::dumpingState) {') - Retracer.invokeFunction(self, function) -- print r' }' -+ print(r' }') - elif function.name == 'glClientWaitSync': -- print r' _result = glretrace::clientWaitSync(call, sync, flags, timeout);' -- print r' (void)_result;' -+ print(r' _result = glretrace::clientWaitSync(call, sync, flags, timeout);') -+ print(r' (void)_result;') - elif function.name == 'glGetSynciv': -- print r' if (pname == GL_SYNC_STATUS &&' -- print r' bufSize >= 1 &&' -- print r' values != NULL &&' -- print r' call.arg(4)[0].toSInt() == GL_SIGNALED) {' -- print r' // Fence was signalled, so ensure it happened here' -- print r' glretrace::blockOnFence(call, sync, GL_SYNC_FLUSH_COMMANDS_BIT);' -- print r' (void)length;' -- print r' }' -+ print(r' if (pname == GL_SYNC_STATUS &&') -+ print(r' bufSize >= 1 &&') -+ print(r' values != NULL &&') -+ print(r' call.arg(4)[0].toSInt() == GL_SIGNALED) {') -+ print(r' // Fence was signalled, so ensure it happened here') -+ print(r' glretrace::blockOnFence(call, sync, GL_SYNC_FLUSH_COMMANDS_BIT);') -+ print(r' (void)length;') -+ print(r' }') - else: - Retracer.invokeFunction(self, function) - - if function.name == "glBegin": -- print ' if (currentContext) {' -- print ' currentContext->insideBeginEnd = true;' -- print ' }' -+ print(' if (currentContext) {') -+ print(' currentContext->insideBeginEnd = true;') -+ print(' }') - - if function.name == "glTexDirectVIV": -- print '#if defined(HAVE_VIVANTE_G2D)' -- print ' int32_t ysize = 0;' -- print ' int32_t usize = 0;' -- print ' int32_t vsize = 0;' -- print ' switch(format){' -- print ' case GL_VIV_YV12:' -- print ' case GL_VIV_I420:' -- print ' ysize=width * height;' -- print ' usize=ysize/4;' -- print ' vsize=usize;' -- print ' break;' -- print ' case GL_VIV_NV12:' -- print ' case GL_VIV_NV21:' -- print ' ysize=width * height;' -- print ' usize=ysize/2;' -- print ' vsize=0;' -- print ' break;' -- print ' case GL_RGBA:' -- print ' case GL_BGRA_EXT:' -- print ' ysize=width * height *4;' -- print ' usize=0;' -- print ' vsize=0;' -- print ' break;' -- print ' case GL_RGB:' -- print ' ysize=width * height *3;' -- print ' usize=0;' -- print ' vsize=0;' -- print ' break;' -- print ' case GL_VIV_YUY2:' -- print ' case GL_VIV_UYVY:' -- print ' case GL_RGB565_OES:' -- print ' ysize=width * height *2;' -- print ' usize=0;' -- print ' vsize=0;' -- print ' break;' -- print ' default:' -- print ' break;' -- print ' }' -- print ' const trace::Array * arrayGLvoid = (call.arg(4)).toArray();' -- print ' if(ysize > 0)' -- print ' retrace::addRegion(call,(*arrayGLvoid->values[0]).toUInt(),(GLvoid*)pixels[0], ysize);' -- print ' if(usize > 0)' -- print ' retrace::addRegion(call,(*arrayGLvoid->values[1]).toUInt(),(GLvoid*)pixels[1], usize);' -- print ' if(vsize > 0)' -- print ' retrace::addRegion(call,(*arrayGLvoid->values[2]).toUInt(),(GLvoid*)pixels[2], vsize);' -- print '#endif /* HAVE_VIVANTE_G2D */' -- -- print r' if (currentContext && !currentContext->insideList && !currentContext->insideBeginEnd && retrace::profiling) {' -+ print('#if defined(HAVE_VIVANTE_G2D)') -+ print(' int32_t ysize = 0;') -+ print(' int32_t usize = 0;') -+ print(' int32_t vsize = 0;') -+ print(' switch(format){') -+ print(' case GL_VIV_YV12:') -+ print(' case GL_VIV_I420:') -+ print(' ysize=width * height;') -+ print(' usize=ysize/4;') -+ print(' vsize=usize;') -+ print(' break;') -+ print(' case GL_VIV_NV12:') -+ print(' case GL_VIV_NV21:') -+ print(' ysize=width * height;') -+ print(' usize=ysize/2;') -+ print(' vsize=0;') -+ print(' break;') -+ print(' case GL_RGBA:') -+ print(' case GL_BGRA_EXT:') -+ print(' ysize=width * height *4;') -+ print(' usize=0;') -+ print(' vsize=0;') -+ print(' break;') -+ print(' case GL_RGB:') -+ print(' ysize=width * height *3;') -+ print(' usize=0;') -+ print(' vsize=0;') -+ print(' break;') -+ print(' case GL_VIV_YUY2:') -+ print(' case GL_VIV_UYVY:') -+ print(' case GL_RGB565_OES:') -+ print(' ysize=width * height *2;') -+ print(' usize=0;') -+ print(' vsize=0;') -+ print(' break;') -+ print(' default:') -+ print(' break;') -+ print(' }') -+ print(' const trace::Array * arrayGLvoid = (call.arg(4)).toArray();') -+ print(' if(ysize > 0)') -+ print(' retrace::addRegion(call,(*arrayGLvoid->values[0]).toUInt(),(GLvoid*)pixels[0], ysize);') -+ print(' if(usize > 0)') -+ print(' retrace::addRegion(call,(*arrayGLvoid->values[1]).toUInt(),(GLvoid*)pixels[1], usize);') -+ print(' if(vsize > 0)') -+ print(' retrace::addRegion(call,(*arrayGLvoid->values[2]).toUInt(),(GLvoid*)pixels[2], vsize);') -+ print('#endif /* HAVE_VIVANTE_G2D */') -+ -+ print(r' if (currentContext && !currentContext->insideList && !currentContext->insideBeginEnd && retrace::profiling) {') - if profileDraw: -- print r' glretrace::endProfile(call, true);' -+ print(r' glretrace::endProfile(call, true);') - else: -- print r' glretrace::endProfile(call, false);' -- print r' }' -+ print(r' glretrace::endProfile(call, false);') -+ print(r' }') - - # Error checking - if function.name.startswith('gl'): - # glGetError is not allowed inside glBegin/glEnd -- print ' if (retrace::debug && currentContext && !currentContext->insideBeginEnd) {' -- print ' glretrace::checkGlError(call);' -+ print(' if (retrace::debug && currentContext && !currentContext->insideBeginEnd) {') -+ print(' glretrace::checkGlError(call);') - if function.name in ('glProgramStringARB', 'glLoadProgramNV'): -- print r' GLint error_position = -1;' -- print r' glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &error_position);' -- print r' if (error_position != -1) {' -- print r' const char *error_string = (const char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB);' -- print r' retrace::warning(call) << "error in position " << error_position << ": " << error_string << "\n";' -- print r' }' -+ print(r' GLint error_position = -1;') -+ print(r' glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &error_position);') -+ print(r' if (error_position != -1) {') -+ print(r' const char *error_string = (const char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB);') -+ print(r' retrace::warning(call) << "error in position " << error_position << ": " << error_string << "\n";') -+ print(r' }') - if function.name == 'glCompileShader': -- print r' GLint compile_status = 0;' -- print r' glGetShaderiv(shader, GL_COMPILE_STATUS, &compile_status);' -- print r' if (!compile_status) {' -- print r' retrace::warning(call) << "compilation failed\n";' -- print r' }' -- print r' GLint info_log_length = 0;' -- print r' glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &info_log_length);' -- print r' if (info_log_length > 1) {' -- print r' GLchar *infoLog = new GLchar[info_log_length];' -- print r' glGetShaderInfoLog(shader, info_log_length, NULL, infoLog);' -- print r' retrace::warning(call) << infoLog << "\n";' -- print r' delete [] infoLog;' -- print r' }' -+ print(r' GLint compile_status = 0;') -+ print(r' glGetShaderiv(shader, GL_COMPILE_STATUS, &compile_status);') -+ print(r' if (!compile_status) {') -+ print(r' retrace::warning(call) << "compilation failed\n";') -+ print(r' }') -+ print(r' GLint info_log_length = 0;') -+ print(r' glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &info_log_length);') -+ print(r' if (info_log_length > 1) {') -+ print(r' GLchar *infoLog = new GLchar[info_log_length];') -+ print(r' glGetShaderInfoLog(shader, info_log_length, NULL, infoLog);') -+ print(r' retrace::warning(call) << infoLog << "\n";') -+ print(r' delete [] infoLog;') -+ print(r' }') - if function.name in ('glLinkProgram', 'glCreateShaderProgramv', 'glCreateShaderProgramEXT', 'glCreateShaderProgramvEXT', 'glProgramBinary', 'glProgramBinaryOES'): - if function.name.startswith('glCreateShaderProgram'): -- print r' GLuint program = _result;' -- print r' GLint link_status = 0;' -- print r' glGetProgramiv(program, GL_LINK_STATUS, &link_status);' -- print r' if (!link_status) {' -- print r' retrace::warning(call) << "link failed\n";' -- print r' }' -- print r' GLint info_log_length = 0;' -- print r' glGetProgramiv(program, GL_INFO_LOG_LENGTH, &info_log_length);' -- print r' if (info_log_length > 1) {' -- print r' GLchar *infoLog = new GLchar[info_log_length];' -- print r' glGetProgramInfoLog(program, info_log_length, NULL, infoLog);' -- print r' retrace::warning(call) << infoLog << "\n";' -- print r' delete [] infoLog;' -- print r' }' -+ print(r' GLuint program = _result;') -+ print(r' GLint link_status = 0;') -+ print(r' glGetProgramiv(program, GL_LINK_STATUS, &link_status);') -+ print(r' if (!link_status) {') -+ print(r' retrace::warning(call) << "link failed\n";') -+ print(r' }') -+ print(r' GLint info_log_length = 0;') -+ print(r' glGetProgramiv(program, GL_INFO_LOG_LENGTH, &info_log_length);') -+ print(r' if (info_log_length > 1) {') -+ print(r' GLchar *infoLog = new GLchar[info_log_length];') -+ print(r' glGetProgramInfoLog(program, info_log_length, NULL, infoLog);') -+ print(r' retrace::warning(call) << infoLog << "\n";') -+ print(r' delete [] infoLog;') -+ print(r' }') - if function.name == 'glCompileShaderARB': -- print r' GLint compile_status = 0;' -- print r' glGetObjectParameterivARB(shaderObj, GL_OBJECT_COMPILE_STATUS_ARB, &compile_status);' -- print r' if (!compile_status) {' -- print r' retrace::warning(call) << "compilation failed\n";' -- print r' }' -- print r' GLint info_log_length = 0;' -- print r' glGetObjectParameterivARB(shaderObj, GL_OBJECT_INFO_LOG_LENGTH_ARB, &info_log_length);' -- print r' if (info_log_length > 1) {' -- print r' GLchar *infoLog = new GLchar[info_log_length];' -- print r' glGetInfoLogARB(shaderObj, info_log_length, NULL, infoLog);' -- print r' retrace::warning(call) << infoLog << "\n";' -- print r' delete [] infoLog;' -- print r' }' -+ print(r' GLint compile_status = 0;') -+ print(r' glGetObjectParameterivARB(shaderObj, GL_OBJECT_COMPILE_STATUS_ARB, &compile_status);') -+ print(r' if (!compile_status) {') -+ print(r' retrace::warning(call) << "compilation failed\n";') -+ print(r' }') -+ print(r' GLint info_log_length = 0;') -+ print(r' glGetObjectParameterivARB(shaderObj, GL_OBJECT_INFO_LOG_LENGTH_ARB, &info_log_length);') -+ print(r' if (info_log_length > 1) {') -+ print(r' GLchar *infoLog = new GLchar[info_log_length];') -+ print(r' glGetInfoLogARB(shaderObj, info_log_length, NULL, infoLog);') -+ print(r' retrace::warning(call) << infoLog << "\n";') -+ print(r' delete [] infoLog;') -+ print(r' }') - if function.name == 'glLinkProgramARB': -- print r' GLint link_status = 0;' -- print r' glGetObjectParameterivARB(programObj, GL_OBJECT_LINK_STATUS_ARB, &link_status);' -- print r' if (!link_status) {' -- print r' retrace::warning(call) << "link failed\n";' -- print r' }' -- print r' GLint info_log_length = 0;' -- print r' glGetObjectParameterivARB(programObj, GL_OBJECT_INFO_LOG_LENGTH_ARB, &info_log_length);' -- print r' if (info_log_length > 1) {' -- print r' GLchar *infoLog = new GLchar[info_log_length];' -- print r' glGetInfoLogARB(programObj, info_log_length, NULL, infoLog);' -- print r' retrace::warning(call) << infoLog << "\n";' -- print r' delete [] infoLog;' -- print r' }' -+ print(r' GLint link_status = 0;') -+ print(r' glGetObjectParameterivARB(programObj, GL_OBJECT_LINK_STATUS_ARB, &link_status);') -+ print(r' if (!link_status) {') -+ print(r' retrace::warning(call) << "link failed\n";') -+ print(r' }') -+ print(r' GLint info_log_length = 0;') -+ print(r' glGetObjectParameterivARB(programObj, GL_OBJECT_INFO_LOG_LENGTH_ARB, &info_log_length);') -+ print(r' if (info_log_length > 1) {') -+ print(r' GLchar *infoLog = new GLchar[info_log_length];') -+ print(r' glGetInfoLogARB(programObj, info_log_length, NULL, infoLog);') -+ print(r' retrace::warning(call) << infoLog << "\n";') -+ print(r' delete [] infoLog;') -+ print(r' }') - if self.map_function_regex.match(function.name): -- print r' if (!_result) {' -- print r' retrace::warning(call) << "failed to map buffer\n";' -- print r' }' -+ print(r' if (!_result) {') -+ print(r' retrace::warning(call) << "failed to map buffer\n";') -+ print(r' }') - if self.unmap_function_regex.match(function.name) and function.type is not stdapi.Void: -- print r' if (!_result) {' -- print r' retrace::warning(call) << "failed to unmap buffer\n";' -- print r' }' -+ print(r' if (!_result) {') -+ print(r' retrace::warning(call) << "failed to unmap buffer\n";') -+ print(r' }') - if function.name in ('glGetAttribLocation', 'glGetAttribLocationARB'): -- print r' GLint _origResult = call.ret->toSInt();' -- print r' if (_result != _origResult) {' -- print r' retrace::warning(call) << "vertex attrib location mismatch " << _origResult << " -> " << _result << "\n";' -- print r' }' -+ print(r' GLint _origResult = call.ret->toSInt();') -+ print(r' if (_result != _origResult) {') -+ print(r' retrace::warning(call) << "vertex attrib location mismatch " << _origResult << " -> " << _result << "\n";') -+ print(r' }') - if function.name in ('glCheckFramebufferStatus', 'glCheckFramebufferStatusEXT', 'glCheckNamedFramebufferStatus', 'glCheckNamedFramebufferStatusEXT'): -- print r' GLint _origResult = call.ret->toSInt();' -- print r' if (_origResult == GL_FRAMEBUFFER_COMPLETE &&' -- print r' _result != GL_FRAMEBUFFER_COMPLETE) {' -- print r' retrace::warning(call) << "incomplete framebuffer (" << glstate::enumToString(_result) << ")\n";' -- print r' }' -- print ' }' -+ print(r' GLint _origResult = call.ret->toSInt();') -+ print(r' if (_origResult == GL_FRAMEBUFFER_COMPLETE &&') -+ print(r' _result != GL_FRAMEBUFFER_COMPLETE) {') -+ print(r' retrace::warning(call) << "incomplete framebuffer (" << glstate::enumToString(_result) << ")\n";') -+ print(r' }') -+ print(' }') - - # Query the buffer length for whole buffer mappings - if self.map_function_regex.match(function.name): -@@ -566,23 +566,23 @@ class GlRetracer(Retracer): - assert 'BufferRange' in function.name - else: - assert 'BufferRange' not in function.name -- print r' GLint length = 0;' -+ print(r' GLint length = 0;') - if function.name in ('glMapBuffer', 'glMapBufferOES'): -- print r' glGetBufferParameteriv(target, GL_BUFFER_SIZE, &length);' -+ print(r' glGetBufferParameteriv(target, GL_BUFFER_SIZE, &length);') - elif function.name == 'glMapBufferARB': -- print r' glGetBufferParameterivARB(target, GL_BUFFER_SIZE_ARB, &length);' -+ print(r' glGetBufferParameterivARB(target, GL_BUFFER_SIZE_ARB, &length);') - elif function.name == 'glMapNamedBuffer': -- print r' glGetNamedBufferParameteriv(buffer, GL_BUFFER_SIZE, &length);' -+ print(r' glGetNamedBufferParameteriv(buffer, GL_BUFFER_SIZE, &length);') - elif function.name == 'glMapNamedBufferEXT': -- print r' glGetNamedBufferParameterivEXT(buffer, GL_BUFFER_SIZE, &length);' -+ print(r' glGetNamedBufferParameterivEXT(buffer, GL_BUFFER_SIZE, &length);') - elif function.name == 'glMapObjectBufferATI': -- print r' glGetObjectBufferivATI(buffer, GL_OBJECT_BUFFER_SIZE_ATI, &length);' -+ print(r' glGetObjectBufferivATI(buffer, GL_OBJECT_BUFFER_SIZE_ATI, &length);') - else: - assert False - - def extractArg(self, function, arg, arg_type, lvalue, rvalue): - if function.name in self.array_pointer_function_names and arg.name == 'pointer': -- print ' %s = static_cast<%s>(retrace::toPointer(%s, true));' % (lvalue, arg_type, rvalue) -+ print(' %s = static_cast<%s>(retrace::toPointer(%s, true));' % (lvalue, arg_type, rvalue)) - return - - if self.draw_elements_function_regex.match(function.name) and arg.name == 'indices' or\ -@@ -594,18 +594,18 @@ class GlRetracer(Retracer): - # object. - if self.pack_function_regex.match(function.name) and arg.output: - assert isinstance(arg_type, (stdapi.Pointer, stdapi.Array, stdapi.Blob, stdapi.Opaque)) -- print ' %s = static_cast<%s>((%s).toPointer());' % (lvalue, arg_type, rvalue) -+ print(' %s = static_cast<%s>((%s).toPointer());' % (lvalue, arg_type, rvalue)) - return - - if (arg.type.depends(glapi.GLlocation) or \ - arg.type.depends(glapi.GLsubroutine)) \ - and 'program' not in function.argNames(): - # Determine the active program for uniforms swizzling -- print ' GLint program = _getActiveProgram();' -+ print(' GLint program = _getActiveProgram();') - - if arg.type is glapi.GLlocationARB \ - and 'programObj' not in function.argNames(): -- print ' GLhandleARB programObj = glGetHandleARB(GL_PROGRAM_OBJECT_ARB);' -+ print(' GLhandleARB programObj = glGetHandleARB(GL_PROGRAM_OBJECT_ARB);') - - Retracer.extractArg(self, function, arg, arg_type, lvalue, rvalue) - -@@ -613,28 +613,28 @@ class GlRetracer(Retracer): - if arg.name == 'samples': - if function.name == 'glRasterSamplesEXT': - assert arg.type is glapi.GLuint -- print ' GLint max_samples = 0;' -- print ' glGetIntegerv(GL_MAX_RASTER_SAMPLES_EXT, &max_samples);' -- print ' if (samples > static_cast<GLuint>(max_samples)) {' -- print ' samples = static_cast<GLuint>(max_samples);' -- print ' }' -+ print(' GLint max_samples = 0;') -+ print(' glGetIntegerv(GL_MAX_RASTER_SAMPLES_EXT, &max_samples);') -+ print(' if (samples > static_cast<GLuint>(max_samples)) {') -+ print(' samples = static_cast<GLuint>(max_samples);') -+ print(' }') - else: - assert arg.type is glapi.GLsizei -- print ' GLint max_samples = 0;' -- print ' glGetIntegerv(GL_MAX_SAMPLES, &max_samples);' -- print ' if (samples > max_samples) {' -- print ' samples = max_samples;' -- print ' }' -+ print(' GLint max_samples = 0;') -+ print(' glGetIntegerv(GL_MAX_SAMPLES, &max_samples);') -+ print(' if (samples > max_samples) {') -+ print(' samples = max_samples;') -+ print(' }') - - # These parameters are referred beyond the call life-time - # TODO: Replace ad-hoc solution for bindable parameters with general one - if function.name in ('glFeedbackBuffer', 'glSelectBuffer') and arg.output: -- print ' _allocator.bind(%s);' % arg.name -+ print(' _allocator.bind(%s);' % arg.name) - - - - if __name__ == '__main__': -- print r''' -+ print(r''' - #include <string.h> - - #include "glproc.hpp" -@@ -692,13 +692,13 @@ static void free_dma_buffer(void *buf) - - #endif /* HAVE_VIVANTE_G2D */ - --''' -+''') - api = stdapi.API() - api.addModule(glapi.glapi) - retracer = GlRetracer() - retracer.retraceApi(api) - -- print r''' -+ print(r''' - static GLint - _getActiveProgram(void) - { -@@ -771,4 +771,4 @@ _validateActiveProgram(trace::Call &call) - } - } - --''' -+''') -diff --git a/retrace/glstate_params.py b/retrace/glstate_params.py -index fb49ff9a..bc90f66b 100755 ---- a/retrace/glstate_params.py -+++ b/retrace/glstate_params.py -@@ -134,17 +134,17 @@ class StateGetter(Visitor): - elem_type = self.inflector.reduced_type(type) - inflection = self.inflector.inflect(type) - if inflection.endswith('v' + self.inflector.suffix): -- print ' %s %s = 0;' % (elem_type, temp_name) -- print ' %s(%s, &%s);' % (inflection, ', '.join(args), temp_name) -+ print(' %s %s = 0;' % (elem_type, temp_name)) -+ print(' %s(%s, &%s);' % (inflection, ', '.join(args), temp_name)) - else: -- print ' %s %s = %s(%s);' % (elem_type, temp_name, inflection, ', '.join(args)) -+ print(' %s %s = %s(%s);' % (elem_type, temp_name, inflection, ', '.join(args))) - return temp_name - - def visitString(self, string, args): - temp_name = self.temp_name(args) - inflection = self.inflector.inflect(string) - assert not inflection.endswith('v' + self.inflector.suffix) -- print ' %s %s = (%s)%s(%s);' % (string, temp_name, string, inflection, ', '.join(args)) -+ print(' %s %s = (%s)%s(%s);' % (string, temp_name, string, inflection, ', '.join(args))) - return temp_name - - def visitAlias(self, alias, args): -@@ -166,28 +166,28 @@ class StateGetter(Visitor): - array_length = array.length - if isinstance(array_length, int): - # Static integer length -- print ' %s %s[%s + 1];' % (elem_type, temp_name, array_length) -+ print(' %s %s[%s + 1];' % (elem_type, temp_name, array_length)) - else: - # Put the length in a variable to avoid recomputing it every time -- print ' size_t _%s_length = %s;' % (temp_name, array_length) -+ print(' size_t _%s_length = %s;' % (temp_name, array_length)) - array_length = '_%s_length' % temp_name - # Allocate a dynamic sized array -- print ' %s *%s = _allocator.alloc<%s>(%s + 1);' % (elem_type, temp_name, elem_type, array_length) -- print ' memset(%s, 0, %s * sizeof *%s);' % (temp_name, array_length, temp_name) -- print ' %s[%s] = (%s)0xdeadc0de;' % (temp_name, array_length, elem_type) -- print ' if (%s) {' % array_length -- print ' %s(%s, %s);' % (inflection, ', '.join(args), temp_name) -- print ' }' -+ print(' %s *%s = _allocator.alloc<%s>(%s + 1);' % (elem_type, temp_name, elem_type, array_length)) -+ print(' memset(%s, 0, %s * sizeof *%s);' % (temp_name, array_length, temp_name)) -+ print(' %s[%s] = (%s)0xdeadc0de;' % (temp_name, array_length, elem_type)) -+ print(' if (%s) {' % array_length) -+ print(' %s(%s, %s);' % (inflection, ', '.join(args), temp_name)) -+ print(' }') - # Simple buffer overflow detection -- print ' assert(%s[%s] == (%s)0xdeadc0de);' % (temp_name, array_length, elem_type) -+ print(' assert(%s[%s] == (%s)0xdeadc0de);' % (temp_name, array_length, elem_type)) - return temp_name - - def visitOpaque(self, pointer, args): - temp_name = self.temp_name(args) - inflection = self.inflector.inflect(pointer) - assert inflection.endswith('v' + self.inflector.suffix) -- print ' GLvoid *%s;' % temp_name -- print ' %s(%s, &%s);' % (inflection, ', '.join(args), temp_name) -+ print(' GLvoid *%s;' % temp_name) -+ print(' %s(%s, &%s);' % (inflection, ', '.join(args), temp_name)) - return temp_name - - -@@ -236,26 +236,26 @@ class JsonWriter(Visitor): - - def visitLiteral(self, literal, instance): - if literal.kind == 'Bool': -- print ' writer.writeBool(%s);' % instance -+ print(' writer.writeBool(%s);' % instance) - elif literal.kind in ('SInt', 'Uint'): -- print ' writer.writeInt(%s);' % instance -+ print(' writer.writeInt(%s);' % instance) - elif literal.kind in ('Float', 'Double'): -- print ' writer.writeFloat(%s);' % instance -+ print(' writer.writeFloat(%s);' % instance) - else: - raise NotImplementedError - - def visitString(self, string, instance): - assert string.length is None -- print ' writer.writeString((const char *)%s);' % instance -+ print(' writer.writeString((const char *)%s);' % instance) - - def visitEnum(self, enum, instance): - if enum is GLboolean: -- print ' dumpBoolean(writer, %s);' % instance -+ print(' dumpBoolean(writer, %s);' % instance) - elif enum is GLenum: -- print ' dumpEnum(writer, %s);' % instance -+ print(' dumpEnum(writer, %s);' % instance) - else: - assert False -- print ' writer.writeInt(%s);' % instance -+ print(' writer.writeInt(%s);' % instance) - - def visitBitmask(self, bitmask, instance): - raise NotImplementedError -@@ -264,18 +264,18 @@ class JsonWriter(Visitor): - self.visit(alias.type, instance) - - def visitOpaque(self, opaque, instance): -- print ' writer.writeInt((size_t)%s);' % instance -+ print(' writer.writeInt((size_t)%s);' % instance) - - __index = 0 - - def visitArray(self, array, instance): - index = '_i%u' % JsonWriter.__index - JsonWriter.__index += 1 -- print ' writer.beginArray();' -- print ' for (unsigned %s = 0; %s < %s; ++%s) {' % (index, index, array.length, index) -+ print(' writer.beginArray();') -+ print(' for (unsigned %s = 0; %s < %s; ++%s) {' % (index, index, array.length, index)) - self.visit(array.type, '%s[%s]' % (instance, index)) -- print ' }' -- print ' writer.endArray();' -+ print(' }') -+ print(' writer.endArray();') - - - -@@ -287,75 +287,75 @@ class StateDumper: - pass - - def dump(self): -- print '#include <assert.h>' -- print '#include <string.h>' -- print -- print '#include "state_writer.hpp"' -- print '#include "scoped_allocator.hpp"' -- print '#include "glproc.hpp"' -- print '#include "glsize.hpp"' -- print '#include "glstate.hpp"' -- print '#include "glstate_internal.hpp"' -- print -- print 'namespace glstate {' -- print -- -- print 'const char *' -- print 'enumToString(GLenum pname)' -- print '{' -- print ' switch (pname) {' -+ print('#include <assert.h>') -+ print('#include <string.h>') -+ print() -+ print('#include "state_writer.hpp"') -+ print('#include "scoped_allocator.hpp"') -+ print('#include "glproc.hpp"') -+ print('#include "glsize.hpp"') -+ print('#include "glstate.hpp"') -+ print('#include "glstate_internal.hpp"') -+ print() -+ print('namespace glstate {') -+ print() -+ -+ print('const char *') -+ print('enumToString(GLenum pname)') -+ print('{') -+ print(' switch (pname) {') - for name in GLenum.values: -- print ' case %s:' % name -- print ' return "%s";' % name -- print ' default:' -- print ' return NULL;' -- print ' }' -- print '}' -- print -- -- print 'static void' -- print 'dumpTextureTargetParameters(StateWriter &writer, Context &context, GLenum target, GLuint texture)' -- print '{' -- print ' writer.beginMember(enumToString(target));' -- print ' writer.beginObject();' -- print ' dumpObjectLabel(writer, context, GL_TEXTURE, texture, "GL_TEXTURE_LABEL");' -+ print(' case %s:' % name) -+ print(' return "%s";' % name) -+ print(' default:') -+ print(' return NULL;') -+ print(' }') -+ print('}') -+ print() -+ -+ print('static void') -+ print('dumpTextureTargetParameters(StateWriter &writer, Context &context, GLenum target, GLuint texture)') -+ print('{') -+ print(' writer.beginMember(enumToString(target));') -+ print(' writer.beginObject();') -+ print(' dumpObjectLabel(writer, context, GL_TEXTURE, texture, "GL_TEXTURE_LABEL");') - # ARB_texture_buffer forbids glGetTexParameter and - # glGetTexLevelParameter for TEXTURE_BUFFER, but - # ARB_texture_buffer_range introduced parameters which can be queries - # with glGetTexLevelParameter... -- print ' if (target != GL_TEXTURE_BUFFER) {' -+ print(' if (target != GL_TEXTURE_BUFFER) {') - self.dump_atoms(glGetTexParameter, 'target') -- print ' }' -- print ' if (!context.ES) {' -- print ' GLenum levelTarget;' -- print ' if (target == GL_TEXTURE_CUBE_MAP ||' -- print ' target == GL_TEXTURE_CUBE_MAP_ARRAY) {' -- print ' // Must pick a face' -- print ' levelTarget = GL_TEXTURE_CUBE_MAP_POSITIVE_X;' -- print ' } else {' -- print ' levelTarget = target;' -- print ' }' -+ print(' }') -+ print(' if (!context.ES) {') -+ print(' GLenum levelTarget;') -+ print(' if (target == GL_TEXTURE_CUBE_MAP ||') -+ print(' target == GL_TEXTURE_CUBE_MAP_ARRAY) {') -+ print(' // Must pick a face') -+ print(' levelTarget = GL_TEXTURE_CUBE_MAP_POSITIVE_X;') -+ print(' } else {') -+ print(' levelTarget = target;') -+ print(' }') - self.dump_atoms(glGetTexLevelParameter, 'levelTarget', '0') -- print ' }' -- print ' writer.endObject();' -- print ' writer.endMember(); // target' -- print '}' -- print -- -- print 'static void' -- print 'dumpFramebufferAttachementParameters(StateWriter &writer, Context &context, GLenum target, GLenum attachment)' -- print '{' -+ print(' }') -+ print(' writer.endObject();') -+ print(' writer.endMember(); // target') -+ print('}') -+ print() -+ -+ print('static void') -+ print('dumpFramebufferAttachementParameters(StateWriter &writer, Context &context, GLenum target, GLenum attachment)') -+ print('{') - self.dump_attachment_parameters('target', 'attachment') -- print '}' -- print -- -- print 'void dumpParameters(StateWriter &writer, Context &context)' -- print '{' -- print ' ScopedAllocator _allocator;' -- print ' (void)_allocator;' -- print -- print ' writer.beginMember("parameters");' -- print ' writer.beginObject();' -+ print('}') -+ print() -+ -+ print('void dumpParameters(StateWriter &writer, Context &context)') -+ print('{') -+ print(' ScopedAllocator _allocator;') -+ print(' (void)_allocator;') -+ print() -+ print(' writer.beginMember("parameters");') -+ print(' writer.beginObject();') - - self.dump_atoms(glGet) - -@@ -368,58 +368,58 @@ class StateDumper: - self.dump_framebuffer_parameters() - self.dump_labels() - -- print ' writer.endObject();' -- print ' writer.endMember(); // parameters' -- print '}' -- print -+ print(' writer.endObject();') -+ print(' writer.endMember(); // parameters') -+ print('}') -+ print() - -- print '} /*namespace glstate */' -+ print('} /*namespace glstate */') - - def dump_material_params(self): -- print ' if (!context.ES) {' -+ print(' if (!context.ES) {') - for face in ['GL_FRONT', 'GL_BACK']: -- print ' writer.beginMember("%s");' % face -- print ' writer.beginObject();' -+ print(' writer.beginMember("%s");' % face) -+ print(' writer.beginObject();') - self.dump_atoms(glGetMaterial, face) -- print ' writer.endObject();' -- print ' }' -- print -+ print(' writer.endObject();') -+ print(' }') -+ print() - - def dump_light_params(self): -- print ' GLint max_lights = 0;' -- print ' _glGetIntegerv(GL_MAX_LIGHTS, &max_lights);' -- print ' for (GLint index = 0; index < max_lights; ++index) {' -- print ' GLenum light = GL_LIGHT0 + index;' -- print ' if (glIsEnabled(light)) {' -- print ' char name[32];' -- print ' snprintf(name, sizeof name, "GL_LIGHT%i", index);' -- print ' writer.beginMember(name);' -- print ' writer.beginObject();' -+ print(' GLint max_lights = 0;') -+ print(' _glGetIntegerv(GL_MAX_LIGHTS, &max_lights);') -+ print(' for (GLint index = 0; index < max_lights; ++index) {') -+ print(' GLenum light = GL_LIGHT0 + index;') -+ print(' if (glIsEnabled(light)) {') -+ print(' char name[32];') -+ print(' snprintf(name, sizeof name, "GL_LIGHT%i", index);') -+ print(' writer.beginMember(name);') -+ print(' writer.beginObject();') - self.dump_atoms(glGetLight, ' GL_LIGHT0 + index') -- print ' writer.endObject();' -- print ' writer.endMember(); // GL_LIGHTi' -- print ' }' -- print ' }' -- print -+ print(' writer.endObject();') -+ print(' writer.endMember(); // GL_LIGHTi') -+ print(' }') -+ print(' }') -+ print() - - def dump_sampler_params(self): -- print ' // GL_SAMPLER_BINDING' -- print ' if (context.ARB_sampler_objects) {' -- print ' GLint sampler_binding = 0;' -- print ' glGetIntegerv(GL_SAMPLER_BINDING, &sampler_binding);' -- print ' writer.beginMember("GL_SAMPLER_BINDING");' -- print ' writer.writeInt(sampler_binding);' -- print ' writer.endMember();' -- print ' if (sampler_binding) {' -- print ' writer.beginMember("GL_SAMPLER");' -- print ' writer.beginObject();' -- print ' dumpObjectLabel(writer, context, GL_SAMPLER, sampler_binding, "GL_SAMPLER_LABEL");' -+ print(' // GL_SAMPLER_BINDING') -+ print(' if (context.ARB_sampler_objects) {') -+ print(' GLint sampler_binding = 0;') -+ print(' glGetIntegerv(GL_SAMPLER_BINDING, &sampler_binding);') -+ print(' writer.beginMember("GL_SAMPLER_BINDING");') -+ print(' writer.writeInt(sampler_binding);') -+ print(' writer.endMember();') -+ print(' if (sampler_binding) {') -+ print(' writer.beginMember("GL_SAMPLER");') -+ print(' writer.beginObject();') -+ print(' dumpObjectLabel(writer, context, GL_SAMPLER, sampler_binding, "GL_SAMPLER_LABEL");') - for _, _, name in glGetSamplerParameter.iter(): - self.dump_atom(glGetSamplerParameter, 'sampler_binding', name) -- print ' writer.endObject();' -- print ' writer.endMember(); // GL_SAMPLER' -- print ' }' -- print ' }' -+ print(' writer.endObject();') -+ print(' writer.endMember(); // GL_SAMPLER') -+ print(' }') -+ print(' }') - - def texenv_param_target(self, name): - if name == 'GL_TEXTURE_LOD_BIAS': -@@ -431,34 +431,34 @@ class StateDumper: - - def dump_texenv_params(self): - for target in ['GL_TEXTURE_ENV', 'GL_TEXTURE_FILTER_CONTROL', 'GL_POINT_SPRITE']: -- print ' if (!context.ES) {' -- print ' writer.beginMember("%s");' % target -- print ' writer.beginObject();' -+ print(' if (!context.ES) {') -+ print(' writer.beginMember("%s");' % target) -+ print(' writer.beginObject();') - for _, _, name in glGetTexEnv.iter(): - if self.texenv_param_target(name) == target: - self.dump_atom(glGetTexEnv, target, name) -- print ' writer.endObject();' -- print ' }' -+ print(' writer.endObject();') -+ print(' }') - - def dump_vertex_attribs(self): -- print ' GLint max_vertex_attribs = 0;' -- print ' _glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &max_vertex_attribs);' -- print ' for (GLint index = 0; index < max_vertex_attribs; ++index) {' -- print ' char name[32];' -- print ' snprintf(name, sizeof name, "GL_VERTEX_ATTRIB_ARRAY%i", index);' -- print ' writer.beginMember(name);' -- print ' writer.beginObject();' -+ print(' GLint max_vertex_attribs = 0;') -+ print(' _glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &max_vertex_attribs);') -+ print(' for (GLint index = 0; index < max_vertex_attribs; ++index) {') -+ print(' char name[32];') -+ print(' snprintf(name, sizeof name, "GL_VERTEX_ATTRIB_ARRAY%i", index);') -+ print(' writer.beginMember(name);') -+ print(' writer.beginObject();') - self.dump_atoms(glGetVertexAttrib, 'index') - - # Dump vertex attrib buffer label -- print ' GLint buffer_binding = 0;' -- print ' glGetVertexAttribiv(index, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, &buffer_binding);' -- print ' dumpObjectLabel(writer, context, GL_BUFFER, buffer_binding, "GL_VERTEX_ATTRIB_ARRAY_BUFFER_LABEL");' -+ print(' GLint buffer_binding = 0;') -+ print(' glGetVertexAttribiv(index, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, &buffer_binding);') -+ print(' dumpObjectLabel(writer, context, GL_BUFFER, buffer_binding, "GL_VERTEX_ATTRIB_ARRAY_BUFFER_LABEL");') - -- print ' writer.endObject();' -- print ' writer.endMember(); // GL_VERTEX_ATTRIB_ARRAYi' -- print ' }' -- print -+ print(' writer.endObject();') -+ print(' writer.endMember(); // GL_VERTEX_ATTRIB_ARRAYi') -+ print(' }') -+ print() - - object_bindings = [ - ('GL_BUFFER', 'GL_ARRAY_BUFFER_BINDING'), -@@ -488,11 +488,11 @@ class StateDumper: - member_name = object_binding.replace('BINDING', 'LABEL') - if member_name == object_binding: - member_name += '_LABEL' -- print ' {' -- print ' GLint binding = 0;' -- print ' glGetIntegerv(%s, &binding);' % object_binding -- print ' dumpObjectLabel(writer, context, %s, binding, "%s");' % (object_type, member_name) -- print ' }' -+ print(' {') -+ print(' GLint binding = 0;') -+ print(' glGetIntegerv(%s, &binding);' % object_binding) -+ print(' dumpObjectLabel(writer, context, %s, binding, "%s");' % (object_type, member_name)) -+ print(' }') - - program_targets = [ - 'GL_FRAGMENT_PROGRAM_ARB', -@@ -501,12 +501,12 @@ class StateDumper: - - def dump_program_params(self): - for target in self.program_targets: -- print ' if (glIsEnabled(%s)) {' % target -- print ' writer.beginMember("%s");' % target -- print ' writer.beginObject();' -+ print(' if (glIsEnabled(%s)) {' % target) -+ print(' writer.beginMember("%s");' % target) -+ print(' writer.beginObject();') - self.dump_atoms(glGetProgramARB, target) -- print ' writer.endObject();' -- print ' }' -+ print(' writer.endObject();') -+ print(' }') - - buffer_targets = [ - ('GL_ARRAY_BUFFER', 'GL_ARRAY_BUFFER_BINDING', None), -@@ -529,135 +529,135 @@ class StateDumper: - def dump_buffer_parameters(self): - # general binding points - for target, binding, max_bindings in self.buffer_targets: -- print ' // %s' % target -- print ' {' -- print ' writer.beginMember("%s");' % target -- print ' writer.beginObject();' -- print ' GLint buffer = 0;' -- print ' glGetIntegerv(%s, &buffer);' % binding -- print ' if (buffer) {' -+ print(' // %s' % target) -+ print(' {') -+ print(' writer.beginMember("%s");' % target) -+ print(' writer.beginObject();') -+ print(' GLint buffer = 0;') -+ print(' glGetIntegerv(%s, &buffer);' % binding) -+ print(' if (buffer) {') - self.dump_atoms(glGetBufferParameter, target) -- print ' }' -+ print(' }') - if max_bindings is not None: - # indexed binding points - start = target + '_START' - size = target + '_SIZE' -- print ' GLint max_bindings = 0;' -- print ' glGetIntegerv(%s, &max_bindings);' % max_bindings -- print ' if (max_bindings) {' -- print ' writer.beginMember("i");' -- print ' writer.beginArray();' -- print ' for (GLint i = 0; i < max_bindings; ++i) {' -- print ' writer.beginObject();' -+ print(' GLint max_bindings = 0;') -+ print(' glGetIntegerv(%s, &max_bindings);' % max_bindings) -+ print(' if (max_bindings) {') -+ print(' writer.beginMember("i");') -+ print(' writer.beginArray();') -+ print(' for (GLint i = 0; i < max_bindings; ++i) {') -+ print(' writer.beginObject();') - for pname in [binding, start, size]: - self.dump_atom(glGet_i, pname, 'i') -- print ' writer.endObject();' -- print ' }' -- print ' writer.endArray();' -- print ' writer.endMember();' -- print ' }' -+ print(' writer.endObject();') -+ print(' }') -+ print(' writer.endArray();') -+ print(' writer.endMember();') -+ print(' }') - -- print ' writer.endObject();' -- print ' writer.endMember();' -- print ' }' -- print -+ print(' writer.endObject();') -+ print(' writer.endMember();') -+ print(' }') -+ print() - - def dump_texture_parameters(self): -- print ' {' -- print ' GLint active_texture = GL_TEXTURE0;' -- print ' glGetIntegerv(GL_ACTIVE_TEXTURE, &active_texture);' -- print ' GLint max_texture_coords = 0;' -- print ' if (!context.core) {' -- print ' glGetIntegerv(GL_MAX_TEXTURE_COORDS, &max_texture_coords);' -- print ' }' -- print ' GLint max_combined_texture_image_units = 0;' -- print ' glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &max_combined_texture_image_units);' -- print ' max_combined_texture_image_units = std::max(max_combined_texture_image_units, 2);' -- print ' GLint max_units = std::max(max_combined_texture_image_units, max_texture_coords);' -- print ' for (GLint unit = 0; unit < max_units; ++unit) {' -- print ' char name[32];' -- print ' snprintf(name, sizeof name, "GL_TEXTURE%i", unit);' -- print ' writer.beginMember(name);' -- print ' glActiveTexture(GL_TEXTURE0 + unit);' -- print ' writer.beginObject();' -- print -+ print(' {') -+ print(' GLint active_texture = GL_TEXTURE0;') -+ print(' glGetIntegerv(GL_ACTIVE_TEXTURE, &active_texture);') -+ print(' GLint max_texture_coords = 0;') -+ print(' if (!context.core) {') -+ print(' glGetIntegerv(GL_MAX_TEXTURE_COORDS, &max_texture_coords);') -+ print(' }') -+ print(' GLint max_combined_texture_image_units = 0;') -+ print(' glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &max_combined_texture_image_units);') -+ print(' max_combined_texture_image_units = std::max(max_combined_texture_image_units, 2);') -+ print(' GLint max_units = std::max(max_combined_texture_image_units, max_texture_coords);') -+ print(' for (GLint unit = 0; unit < max_units; ++unit) {') -+ print(' char name[32];') -+ print(' snprintf(name, sizeof name, "GL_TEXTURE%i", unit);') -+ print(' writer.beginMember(name);') -+ print(' glActiveTexture(GL_TEXTURE0 + unit);') -+ print(' writer.beginObject();') -+ print() - self.dump_atoms(glGet_texture) -- print -- print ' for (unsigned i = 0; i < numTextureTargets; ++i) {' -- print ' GLenum target = textureTargets[i];' -- print ' GLboolean enabled = GL_FALSE;' -- print ' if (unit < max_texture_coords &&' -- print ' (target == GL_TEXTURE_1D ||' -- print ' target == GL_TEXTURE_2D ||' -- print ' target == GL_TEXTURE_3D ||' -- print ' target == GL_TEXTURE_CUBE_MAP ||' -- print ' target == GL_TEXTURE_RECTANGLE)) {' -- print ' glGetBooleanv(target, &enabled);' -- print ' writer.beginMember(enumToString(target));' -- print ' dumpBoolean(writer, enabled);' -- print ' writer.endMember();' -- print ' }' -- print ' GLint texture = 0;' -- print ' GLenum binding = getTextureBinding(target);' -- print ' glGetIntegerv(binding, &texture);' -- print ' if (enabled || texture) {' -- print ' dumpTextureTargetParameters(writer, context, target, texture);' -- print ' }' -- print ' }' -- print -+ print() -+ print(' for (unsigned i = 0; i < numTextureTargets; ++i) {') -+ print(' GLenum target = textureTargets[i];') -+ print(' GLboolean enabled = GL_FALSE;') -+ print(' if (unit < max_texture_coords &&') -+ print(' (target == GL_TEXTURE_1D ||') -+ print(' target == GL_TEXTURE_2D ||') -+ print(' target == GL_TEXTURE_3D ||') -+ print(' target == GL_TEXTURE_CUBE_MAP ||') -+ print(' target == GL_TEXTURE_RECTANGLE)) {') -+ print(' glGetBooleanv(target, &enabled);') -+ print(' writer.beginMember(enumToString(target));') -+ print(' dumpBoolean(writer, enabled);') -+ print(' writer.endMember();') -+ print(' }') -+ print(' GLint texture = 0;') -+ print(' GLenum binding = getTextureBinding(target);') -+ print(' glGetIntegerv(binding, &texture);') -+ print(' if (enabled || texture) {') -+ print(' dumpTextureTargetParameters(writer, context, target, texture);') -+ print(' }') -+ print(' }') -+ print() - self.dump_sampler_params() -- print -- print ' if (unit < max_texture_coords) {' -+ print() -+ print(' if (unit < max_texture_coords) {') - self.dump_texenv_params() -- print ' }' -- print ' writer.endObject();' -- print ' writer.endMember(); // GL_TEXTUREi' -- print ' }' -- print ' glActiveTexture(active_texture);' -- print ' }' -- print -+ print(' }') -+ print(' writer.endObject();') -+ print(' writer.endMember(); // GL_TEXTUREi') -+ print(' }') -+ print(' glActiveTexture(active_texture);') -+ print(' }') -+ print() - - def dump_framebuffer_parameters(self): -- print ' {' -- print ' GLint max_color_attachments = 0;' -- print ' glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS, &max_color_attachments);' -- print ' GLint framebuffer;' -+ print(' {') -+ print(' GLint max_color_attachments = 0;') -+ print(' glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS, &max_color_attachments);') -+ print(' GLint framebuffer;') - for target, binding in framebuffer_targets: -- print ' // %s' % target -- print ' framebuffer = 0;' -- print ' glGetIntegerv(%s, &framebuffer);' % binding -- print ' if (framebuffer) {' -- print ' writer.beginMember("%s");' % target -- print ' writer.beginObject();' -- print ' dumpObjectLabel(writer, context, GL_FRAMEBUFFER, framebuffer, "GL_FRAMEBUFFER_LABEL");' -- print ' for (GLint i = 0; i < max_color_attachments; ++i) {' -- print ' GLint color_attachment = GL_COLOR_ATTACHMENT0 + i;' -- print ' dumpFramebufferAttachementParameters(writer, context, %s, color_attachment);' % target -- print ' }' -- print ' dumpFramebufferAttachementParameters(writer, context, %s, GL_DEPTH_ATTACHMENT);' % target -- print ' dumpFramebufferAttachementParameters(writer, context, %s, GL_STENCIL_ATTACHMENT);' % target -- print ' writer.endObject();' -- print ' writer.endMember(); // %s' % target -- print ' }' -- print -- print ' }' -- print -+ print(' // %s' % target) -+ print(' framebuffer = 0;') -+ print(' glGetIntegerv(%s, &framebuffer);' % binding) -+ print(' if (framebuffer) {') -+ print(' writer.beginMember("%s");' % target) -+ print(' writer.beginObject();') -+ print(' dumpObjectLabel(writer, context, GL_FRAMEBUFFER, framebuffer, "GL_FRAMEBUFFER_LABEL");') -+ print(' for (GLint i = 0; i < max_color_attachments; ++i) {') -+ print(' GLint color_attachment = GL_COLOR_ATTACHMENT0 + i;') -+ print(' dumpFramebufferAttachementParameters(writer, context, %s, color_attachment);' % target) -+ print(' }') -+ print(' dumpFramebufferAttachementParameters(writer, context, %s, GL_DEPTH_ATTACHMENT);' % target) -+ print(' dumpFramebufferAttachementParameters(writer, context, %s, GL_STENCIL_ATTACHMENT);' % target) -+ print(' writer.endObject();') -+ print(' writer.endMember(); // %s' % target) -+ print(' }') -+ print() -+ print(' }') -+ print() - - def dump_attachment_parameters(self, target, attachment): -- print ' {' -- print ' GLint object_type = GL_NONE;' -- print ' glGetFramebufferAttachmentParameteriv(%s, %s, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &object_type);' % (target, attachment) -- print ' if (object_type != GL_NONE) {' -- print ' writer.beginMember(enumToString(%s));' % attachment -- print ' writer.beginObject();' -+ print(' {') -+ print(' GLint object_type = GL_NONE;') -+ print(' glGetFramebufferAttachmentParameteriv(%s, %s, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &object_type);' % (target, attachment)) -+ print(' if (object_type != GL_NONE) {') -+ print(' writer.beginMember(enumToString(%s));' % attachment) -+ print(' writer.beginObject();') - self.dump_atoms(glGetFramebufferAttachmentParameter, target, attachment) -- print ' GLint object_name = 0;' -- print ' glGetFramebufferAttachmentParameteriv(%s, %s, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, &object_name);' % (target, attachment) -- print ' dumpObjectLabel(writer, context, object_type, object_name, "GL_FRAMEBUFFER_ATTACHMENT_OBJECT_LABEL");' -- print ' writer.endObject();' -- print ' writer.endMember(); // GL_x_ATTACHMENT' -- print ' }' -- print ' }' -+ print(' GLint object_name = 0;') -+ print(' glGetFramebufferAttachmentParameteriv(%s, %s, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, &object_name);' % (target, attachment)) -+ print(' dumpObjectLabel(writer, context, object_type, object_name, "GL_FRAMEBUFFER_ATTACHMENT_OBJECT_LABEL");') -+ print(' writer.endObject();') -+ print(' writer.endMember(); // GL_x_ATTACHMENT') -+ print(' }') -+ print(' }') - - def dump_atoms(self, getter, *args): - for _, _, name in getter.iter(): -@@ -666,20 +666,20 @@ class StateDumper: - def dump_atom(self, getter, *args): - name = args[getter.pnameIdx] - -- print ' // %s' % name -- print ' {' -- print ' flushErrors();' -+ print(' // %s' % name) -+ print(' {') -+ print(' flushErrors();') - type, value = getter(*args) -- print ' if (glGetError() != GL_NO_ERROR) {' -+ print(' if (glGetError() != GL_NO_ERROR) {') - #print ' std::cerr << "warning: %s(%s) failed\\n";' % (inflection, name) -- print ' flushErrors();' -- print ' } else {' -- print ' writer.beginMember("%s");' % name -+ print(' flushErrors();') -+ print(' } else {') -+ print(' writer.beginMember("%s");' % name) - JsonWriter().visit(type, value) -- print ' writer.endMember();' -- print ' }' -- print ' }' -- print -+ print(' writer.endMember();') -+ print(' }') -+ print(' }') -+ print() - - - if __name__ == '__main__': -diff --git a/retrace/retrace.py b/retrace/retrace.py -index 164944ed..0149817c 100644 ---- a/retrace/retrace.py -+++ b/retrace/retrace.py -@@ -69,10 +69,10 @@ class ValueAllocator(stdapi.Visitor): - pass - - def visitArray(self, array, lvalue, rvalue): -- print ' %s = _allocator.allocArray<%s>(&%s);' % (lvalue, array.type, rvalue) -+ print(' %s = _allocator.allocArray<%s>(&%s);' % (lvalue, array.type, rvalue)) - - def visitPointer(self, pointer, lvalue, rvalue): -- print ' %s = _allocator.allocArray<%s>(&%s);' % (lvalue, pointer.type, rvalue) -+ print(' %s = _allocator.allocArray<%s>(&%s);' % (lvalue, pointer.type, rvalue)) - - def visitIntPointer(self, pointer, lvalue, rvalue): - pass -@@ -109,7 +109,7 @@ class ValueAllocator(stdapi.Visitor): - class ValueDeserializer(stdapi.Visitor, stdapi.ExpanderMixin): - - def visitLiteral(self, literal, lvalue, rvalue): -- print ' %s = (%s).to%s();' % (lvalue, rvalue, literal.kind) -+ print(' %s = (%s).to%s();' % (lvalue, rvalue, literal.kind)) - - def visitConst(self, const, lvalue, rvalue): - self.visit(const.type, lvalue, rvalue) -@@ -118,7 +118,7 @@ class ValueDeserializer(stdapi.Visitor, stdapi.ExpanderMixin): - self.visit(alias.type, lvalue, rvalue) - - def visitEnum(self, enum, lvalue, rvalue): -- print ' %s = static_cast<%s>((%s).toSInt());' % (lvalue, enum, rvalue) -+ print(' %s = static_cast<%s>((%s).toSInt());' % (lvalue, enum, rvalue)) - - def visitBitmask(self, bitmask, lvalue, rvalue): - self.visit(bitmask.type, lvalue, rvalue) -@@ -127,50 +127,50 @@ class ValueDeserializer(stdapi.Visitor, stdapi.ExpanderMixin): - tmp = '_a_' + array.tag + '_' + str(self.seq) - self.seq += 1 - -- print ' const trace::Array *%s = (%s).toArray();' % (tmp, rvalue) -- print ' if (%s) {' % (tmp,) -+ print(' const trace::Array *%s = (%s).toArray();' % (tmp, rvalue)) -+ print(' if (%s) {' % (tmp,)) - - length = '%s->values.size()' % (tmp,) - if self.insideStruct: - if isinstance(array.length, int): - # Member is an array -- print r' static_assert( std::is_array< std::remove_reference< decltype( %s ) >::type >::value , "lvalue must be an array" );' % lvalue -- print r' static_assert( std::extent< std::remove_reference< decltype( %s ) >::type >::value == %s, "array size mismatch" );' % (lvalue, array.length) -- print r' assert( %s );' % (tmp,) -- print r' assert( %s->size() == %s );' % (tmp, array.length) -+ print(r' static_assert( std::is_array< std::remove_reference< decltype( %s ) >::type >::value , "lvalue must be an array" );' % lvalue) -+ print(r' static_assert( std::extent< std::remove_reference< decltype( %s ) >::type >::value == %s, "array size mismatch" );' % (lvalue, array.length)) -+ print(r' assert( %s );' % (tmp,)) -+ print(r' assert( %s->size() == %s );' % (tmp, array.length)) - length = str(array.length) - else: - # Member is a pointer to an array, hence must be allocated -- print r' static_assert( std::is_pointer< std::remove_reference< decltype( %s ) >::type >::value , "lvalue must be a pointer" );' % lvalue -- print r' %s = _allocator.allocArray<%s>(&%s);' % (lvalue, array.type, rvalue) -+ print(r' static_assert( std::is_pointer< std::remove_reference< decltype( %s ) >::type >::value , "lvalue must be a pointer" );' % lvalue) -+ print(r' %s = _allocator.allocArray<%s>(&%s);' % (lvalue, array.type, rvalue)) - - index = '_j' + array.tag -- print ' for (size_t {i} = 0; {i} < {length}; ++{i}) {{'.format(i = index, length = length) -+ print(' for (size_t {i} = 0; {i} < {length}; ++{i}) {{'.format(i = index, length = length)) - try: - self.visit(array.type, '%s[%s]' % (lvalue, index), '*%s->values[%s]' % (tmp, index)) - finally: -- print ' }' -- print ' }' -+ print(' }') -+ print(' }') - - def visitPointer(self, pointer, lvalue, rvalue): - tmp = '_a_' + pointer.tag + '_' + str(self.seq) - self.seq += 1 - -- print ' if (%s) {' % (lvalue,) -- print ' const trace::Array *%s = (%s).toArray();' % (tmp, rvalue) -+ print(' if (%s) {' % (lvalue,)) -+ print(' const trace::Array *%s = (%s).toArray();' % (tmp, rvalue)) - try: - self.visit(pointer.type, '%s[0]' % (lvalue,), '*%s->values[0]' % (tmp,)) - finally: -- print ' }' -+ print(' }') - - def visitIntPointer(self, pointer, lvalue, rvalue): -- print ' %s = static_cast<%s>((%s).toPointer());' % (lvalue, pointer, rvalue) -+ print(' %s = static_cast<%s>((%s).toPointer());' % (lvalue, pointer, rvalue)) - - def visitObjPointer(self, pointer, lvalue, rvalue): -- print ' %s = retrace::asObjPointer<%s>(call, %s);' % (lvalue, pointer.type, rvalue) -+ print(' %s = retrace::asObjPointer<%s>(call, %s);' % (lvalue, pointer.type, rvalue)) - - def visitLinearPointer(self, pointer, lvalue, rvalue): -- print ' %s = static_cast<%s>(retrace::toPointer(%s));' % (lvalue, pointer, rvalue) -+ print(' %s = static_cast<%s>(retrace::toPointer(%s));' % (lvalue, pointer, rvalue)) - - def visitReference(self, reference, lvalue, rvalue): - self.visit(reference.type, lvalue, rvalue); -@@ -179,23 +179,23 @@ class ValueDeserializer(stdapi.Visitor, stdapi.ExpanderMixin): - #OpaqueValueDeserializer().visit(handle.type, lvalue, rvalue); - self.visit(handle.type, lvalue, rvalue); - new_lvalue = lookupHandle(handle, lvalue) -- print ' if (retrace::verbosity >= 2) {' -- print ' std::cout << "%s " << size_t(%s) << " <- " << size_t(%s) << "\\n";' % (handle.name, lvalue, new_lvalue) -- print ' }' -+ print(' if (retrace::verbosity >= 2) {') -+ print(' std::cout << "%s " << size_t(%s) << " <- " << size_t(%s) << "\\n";' % (handle.name, lvalue, new_lvalue)) -+ print(' }') - if (new_lvalue.startswith('_program_map') or new_lvalue.startswith('_shader_map')): -- print 'if (glretrace::supportsARBShaderObjects) {' -- print ' %s = _handleARB_map[%s];' % (lvalue, lvalue) -- print '} else {' -- print ' %s = %s;' % (lvalue, new_lvalue) -- print '}' -+ print('if (glretrace::supportsARBShaderObjects) {') -+ print(' %s = _handleARB_map[%s];' % (lvalue, lvalue)) -+ print('} else {') -+ print(' %s = %s;' % (lvalue, new_lvalue)) -+ print('}') - else: -- print ' %s = %s;' % (lvalue, new_lvalue) -+ print(' %s = %s;' % (lvalue, new_lvalue)) - - def visitBlob(self, blob, lvalue, rvalue): -- print ' %s = static_cast<%s>((%s).toPointer());' % (lvalue, blob, rvalue) -+ print(' %s = static_cast<%s>((%s).toPointer());' % (lvalue, blob, rvalue)) - - def visitString(self, string, lvalue, rvalue): -- print ' %s = (%s)((%s).toString());' % (lvalue, string.expr, rvalue) -+ print(' %s = (%s)((%s).toString());' % (lvalue, string.expr, rvalue)) - - seq = 0 - -@@ -207,8 +207,8 @@ class ValueDeserializer(stdapi.Visitor, stdapi.ExpanderMixin): - - self.insideStruct += 1 - -- print ' const trace::Struct *%s = (%s).toStruct();' % (tmp, rvalue) -- print ' assert(%s);' % (tmp) -+ print(' const trace::Struct *%s = (%s).toStruct();' % (tmp, rvalue)) -+ print(' assert(%s);' % (tmp)) - for i in range(len(struct.members)): - member = struct.members[i] - self.visitMember(member, lvalue, '*%s->members[%s]' % (tmp, i)) -@@ -218,24 +218,24 @@ class ValueDeserializer(stdapi.Visitor, stdapi.ExpanderMixin): - def visitPolymorphic(self, polymorphic, lvalue, rvalue): - if polymorphic.defaultType is None: - switchExpr = self.expand(polymorphic.switchExpr) -- print r' switch (%s) {' % switchExpr -+ print(r' switch (%s) {' % switchExpr) - for cases, type in polymorphic.iterSwitch(): - for case in cases: -- print r' %s:' % case -+ print(r' %s:' % case) - caseLvalue = lvalue - if type.expr is not None: - caseLvalue = 'static_cast<%s>(%s)' % (type, caseLvalue) -- print r' {' -+ print(r' {') - try: - self.visit(type, caseLvalue, rvalue) - finally: -- print r' }' -- print r' break;' -+ print(r' }') -+ print(r' break;') - if polymorphic.defaultType is None: -- print r' default:' -- print r' retrace::warning(call) << "unexpected polymorphic case" << %s << "\n";' % (switchExpr,) -- print r' break;' -- print r' }' -+ print(r' default:') -+ print(r' retrace::warning(call) << "unexpected polymorphic case" << %s << "\n";' % (switchExpr,)) -+ print(r' break;') -+ print(r' }') - else: - self.visit(polymorphic.defaultType, lvalue, rvalue) - -@@ -250,7 +250,7 @@ class OpaqueValueDeserializer(ValueDeserializer): - in the context of handles.''' - - def visitOpaque(self, opaque, lvalue, rvalue): -- print ' %s = static_cast<%s>(retrace::toPointer(%s));' % (lvalue, opaque, rvalue) -+ print(' %s = static_cast<%s>(retrace::toPointer(%s));' % (lvalue, opaque, rvalue)) - - - class SwizzledValueRegistrator(stdapi.Visitor, stdapi.ExpanderMixin): -@@ -270,67 +270,67 @@ class SwizzledValueRegistrator(stdapi.Visitor, stdapi.ExpanderMixin): - pass - - def visitArray(self, array, lvalue, rvalue): -- print ' const trace::Array *_a%s = (%s).toArray();' % (array.tag, rvalue) -- print ' if (_a%s) {' % (array.tag) -+ print(' const trace::Array *_a%s = (%s).toArray();' % (array.tag, rvalue)) -+ print(' if (_a%s) {' % (array.tag)) - length = '_a%s->values.size()' % array.tag - index = '_j' + array.tag -- print ' for (size_t {i} = 0; {i} < {length}; ++{i}) {{'.format(i = index, length = length) -+ print(' for (size_t {i} = 0; {i} < {length}; ++{i}) {{'.format(i = index, length = length)) - try: - self.visit(array.type, '%s[%s]' % (lvalue, index), '*_a%s->values[%s]' % (array.tag, index)) - finally: -- print ' }' -- print ' }' -+ print(' }') -+ print(' }') - - def visitPointer(self, pointer, lvalue, rvalue): -- print ' const trace::Array *_a%s = (%s).toArray();' % (pointer.tag, rvalue) -- print ' if (_a%s) {' % (pointer.tag) -+ print(' const trace::Array *_a%s = (%s).toArray();' % (pointer.tag, rvalue)) -+ print(' if (_a%s) {' % (pointer.tag)) - try: - self.visit(pointer.type, '%s[0]' % (lvalue,), '*_a%s->values[0]' % (pointer.tag,)) - finally: -- print ' }' -+ print(' }') - - def visitIntPointer(self, pointer, lvalue, rvalue): - pass - - def visitObjPointer(self, pointer, lvalue, rvalue): -- print r' retrace::addObj(call, %s, %s);' % (rvalue, lvalue) -+ print(r' retrace::addObj(call, %s, %s);' % (rvalue, lvalue)) - - def visitLinearPointer(self, pointer, lvalue, rvalue): - assert pointer.size is not None - if pointer.size is not None: -- print r' retrace::addRegion(call, (%s).toUIntPtr(), %s, %s);' % (rvalue, lvalue, pointer.size) -+ print(r' retrace::addRegion(call, (%s).toUIntPtr(), %s, %s);' % (rvalue, lvalue, pointer.size)) - - def visitReference(self, reference, lvalue, rvalue): - pass - - def visitHandle(self, handle, lvalue, rvalue): -- print ' %s _origResult;' % handle.type -+ print(' %s _origResult;' % handle.type) - OpaqueValueDeserializer().visit(handle.type, '_origResult', rvalue); - if handle.range is None: - rvalue = "_origResult" - entry = lookupHandle(handle, rvalue, True) - if (entry.startswith('_program_map') or entry.startswith('_shader_map')): -- print 'if (glretrace::supportsARBShaderObjects) {' -- print ' _handleARB_map[%s] = %s;' % (rvalue, lvalue) -- print '} else {' -- print ' %s = %s;' % (entry, lvalue) -- print '}' -+ print('if (glretrace::supportsARBShaderObjects) {') -+ print(' _handleARB_map[%s] = %s;' % (rvalue, lvalue)) -+ print('} else {') -+ print(' %s = %s;' % (entry, lvalue)) -+ print('}') - else: -- print " %s = %s;" % (entry, lvalue) -- print ' if (retrace::verbosity >= 2) {' -- print ' std::cout << "{handle.name} " << {rvalue} << " -> " << {lvalue} << "\\n";'.format(**locals()) -- print ' }' -+ print(" %s = %s;" % (entry, lvalue)) -+ print(' if (retrace::verbosity >= 2) {') -+ print(' std::cout << "{handle.name} " << {rvalue} << " -> " << {lvalue} << "\\n";'.format(**locals())) -+ print(' }') - else: - i = '_h' + handle.tag - lvalue = "%s + %s" % (lvalue, i) - rvalue = "_origResult + %s" % (i,) - entry = lookupHandle(handle, rvalue) -- print ' for ({handle.type} {i} = 0; {i} < {handle.range}; ++{i}) {{'.format(**locals()) -- print ' {entry} = {lvalue};'.format(**locals()) -- print ' if (retrace::verbosity >= 2) {' -- print ' std::cout << "{handle.name} " << ({rvalue}) << " -> " << ({lvalue}) << "\\n";'.format(**locals()) -- print ' }' -- print ' }' -+ print(' for ({handle.type} {i} = 0; {i} < {handle.range}; ++{i}) {{'.format(**locals())) -+ print(' {entry} = {lvalue};'.format(**locals())) -+ print(' if (retrace::verbosity >= 2) {') -+ print(' std::cout << "{handle.name} " << ({rvalue}) << " -> " << ({lvalue}) << "\\n";'.format(**locals())) -+ print(' }') -+ print(' }') - - def visitBlob(self, blob, lvalue, rvalue): - pass -@@ -344,9 +344,9 @@ class SwizzledValueRegistrator(stdapi.Visitor, stdapi.ExpanderMixin): - tmp = '_s_' + struct.tag + '_' + str(self.seq) - self.seq += 1 - -- print ' const trace::Struct *%s = (%s).toStruct();' % (tmp, rvalue) -- print ' assert(%s);' % (tmp,) -- print ' (void)%s;' % (tmp,) -+ print(' const trace::Struct *%s = (%s).toStruct();' % (tmp, rvalue)) -+ print(' assert(%s);' % (tmp,)) -+ print(' (void)%s;' % (tmp,)) - for i in range(len(struct.members)): - member = struct.members[i] - self.visitMember(member, lvalue, '*%s->members[%s]' % (tmp, i)) -@@ -362,16 +362,16 @@ class SwizzledValueRegistrator(stdapi.Visitor, stdapi.ExpanderMixin): - class Retracer: - - def retraceFunction(self, function): -- print 'static void retrace_%s(trace::Call &call) {' % function.name -+ print('static void retrace_%s(trace::Call &call) {' % function.name) - self.retraceFunctionBody(function) -- print '}' -- print -+ print('}') -+ print() - - def retraceInterfaceMethod(self, interface, method): -- print 'static void retrace_%s__%s(trace::Call &call) {' % (interface.name, method.name) -+ print('static void retrace_%s__%s(trace::Call &call) {' % (interface.name, method.name)) - self.retraceInterfaceMethodBody(interface, method) -- print '}' -- print -+ print('}') -+ print() - - def retraceFunctionBody(self, function): - assert function.sideeffects -@@ -409,38 +409,38 @@ class Retracer: - assert function.type is not stdapi.Void - - if str(function.type) == 'HRESULT': -- print r' if (call.ret && FAILED(call.ret->toSInt())) {' -- print r' return;' -- print r' }' -+ print(r' if (call.ret && FAILED(call.ret->toSInt())) {') -+ print(r' return;') -+ print(r' }') - - def deserializeThisPointer(self, interface): -- print r' %s *_this;' % (interface.name,) -- print r' _this = retrace::asObjPointer<%s>(call, call.arg(0));' % (interface.name,) -- print r' if (!_this) {' -- print r' return;' -- print r' }' -+ print(r' %s *_this;' % (interface.name,)) -+ print(r' _this = retrace::asObjPointer<%s>(call, call.arg(0));' % (interface.name,)) -+ print(r' if (!_this) {') -+ print(r' return;') -+ print(r' }') - - def deserializeArgs(self, function): -- print ' retrace::ScopedAllocator _allocator;' -- print ' (void)_allocator;' -+ print(' retrace::ScopedAllocator _allocator;') -+ print(' (void)_allocator;') - success = True - for arg in function.args: - arg_type = arg.type.mutable() -- print ' %s %s;' % (arg_type, arg.name) -+ print(' %s %s;' % (arg_type, arg.name)) - rvalue = 'call.arg(%u)' % (arg.index,) - lvalue = arg.name - try: - self.extractArg(function, arg, arg_type, lvalue, rvalue) - except UnsupportedType: - success = False -- print ' memset(&%s, 0, sizeof %s); // FIXME' % (arg.name, arg.name) -- print -+ print(' memset(&%s, 0, sizeof %s); // FIXME' % (arg.name, arg.name)) -+ print() - - if not success: -- print ' if (1) {' -+ print(' if (1) {') - self.failFunction(function) - sys.stderr.write('warning: unsupported %s call\n' % function.name) -- print ' }' -+ print(' }') - - def swizzleValues(self, function): - for arg in function.args: -@@ -451,7 +451,7 @@ class Retracer: - try: - self.regiterSwizzledValue(arg_type, lvalue, rvalue) - except UnsupportedType: -- print ' // XXX: %s' % arg.name -+ print(' // XXX: %s' % arg.name) - if function.type is not stdapi.Void: - rvalue = '*call.ret' - lvalue = '_result' -@@ -459,15 +459,15 @@ class Retracer: - self.regiterSwizzledValue(function.type, lvalue, rvalue) - except UnsupportedType: - raise -- print ' // XXX: result' -+ print(' // XXX: result') - - def failFunction(self, function): -- print ' if (retrace::verbosity >= 0) {' -- print ' retrace::unsupported(call);' -- print ' }' -+ print(' if (retrace::verbosity >= 0) {') -+ print(' retrace::unsupported(call);') -+ print(' }') - # MGS-469: GPU hangs when retracing OGLESParticles on mx6sx - # Workaround: do not `return` -- #print ' return;' -+ #print(' return;') - - def extractArg(self, function, arg, arg_type, lvalue, rvalue): - ValueAllocator().visit(arg_type, lvalue, rvalue) -@@ -487,22 +487,22 @@ class Retracer: - - def declareRet(self, function): - if function.type is not stdapi.Void: -- print ' %s _result;' % (function.type) -+ print(' %s _result;' % (function.type)) - - def invokeFunction(self, function): - arg_names = ", ".join(function.argNames()) - if function.type is not stdapi.Void: -- print ' _result = %s(%s);' % (function.name, arg_names) -+ print(' _result = %s(%s);' % (function.name, arg_names)) - self.checkResult(None, function) - else: -- print ' %s(%s);' % (function.name, arg_names) -+ print(' %s(%s);' % (function.name, arg_names)) - - def invokeInterfaceMethod(self, interface, method): - arg_names = ", ".join(method.argNames()) - if method.type is not stdapi.Void: -- print ' _result = _this->%s(%s);' % (method.name, arg_names) -+ print(' _result = _this->%s(%s);' % (method.name, arg_names)) - else: -- print ' _this->%s(%s);' % (method.name, arg_names) -+ print(' _this->%s(%s);' % (method.name, arg_names)) - - # Adjust reference count when QueryInterface fails. This is - # particularly useful when replaying traces on older Direct3D runtimes -@@ -511,12 +511,12 @@ class Retracer: - # - # TODO: Generalize to other methods that return interfaces - if method.name == 'QueryInterface': -- print r' if (FAILED(_result)) {' -- print r' IUnknown *pObj = retrace::asObjPointer<IUnknown>(call, *call.arg(2).toArray()->values[0]);' -- print r' if (pObj) {' -- print r' pObj->AddRef();' -- print r' }' -- print r' }' -+ print(r' if (FAILED(_result)) {') -+ print(r' IUnknown *pObj = retrace::asObjPointer<IUnknown>(call, *call.arg(2).toArray()->values[0]);') -+ print(r' if (pObj) {') -+ print(r' pObj->AddRef();') -+ print(r' }') -+ print(r' }') - - if method.type is not stdapi.Void: - self.checkResult(interface, method) -@@ -524,28 +524,28 @@ class Retracer: - # Debug COM reference counting. Disabled by default as reported - # reference counts depend on internal implementation details. - if method.name in ('AddRef', 'Release'): -- print r' if (0) retrace::checkMismatch(call, "cRef", call.ret, _result);' -+ print(r' if (0) retrace::checkMismatch(call, "cRef", call.ret, _result);') - - # On release our reference when we reach Release() == 0 call in the - # trace. - if method.name == 'Release': -- print r' ULONG _orig_result = call.ret->toUInt();' -- print r' if (_orig_result == 0 || _result == 0) {' -- print r' if (_orig_result != 0) {' -- print r' retrace::warning(call) << "unexpected object destruction\n";' -- print r' }' -- print r' retrace::delObj(call.arg(0));' -- print r' }' -+ print(r' ULONG _orig_result = call.ret->toUInt();') -+ print(r' if (_orig_result == 0 || _result == 0) {') -+ print(r' if (_orig_result != 0) {') -+ print(r' retrace::warning(call) << "unexpected object destruction\n";') -+ print(r' }') -+ print(r' retrace::delObj(call.arg(0));') -+ print(r' }') - - def checkResult(self, interface, methodOrFunction): - assert methodOrFunction.type is not stdapi.Void - if str(methodOrFunction.type) == 'HRESULT': -- print r' if (FAILED(_result)) {' -- print r' retrace::failed(call, _result);' -- print r' return;' -- print r' }' -+ print(r' if (FAILED(_result)) {') -+ print(r' retrace::failed(call, _result);') -+ print(r' return;') -+ print(r' }') - else: -- print r' (void)_result;' -+ print(r' (void)_result;') - - def checkPitchMismatch(self, method): - # Warn for mismatches in 2D/3D mappings. -@@ -554,19 +554,19 @@ class Retracer: - if outArg.output \ - and isinstance(outArg.type, stdapi.Pointer) \ - and isinstance(outArg.type.type, stdapi.Struct): -- print r' const trace::Array *_%s = call.arg(%u).toArray();' % (outArg.name, outArg.index) -- print r' if (%s) {' % outArg.name -- print r' const trace::Struct *_struct = _%s->values[0]->toStruct();' % (outArg.name) -- print r' if (_struct) {' -+ print(r' const trace::Array *_%s = call.arg(%u).toArray();' % (outArg.name, outArg.index)) -+ print(r' if (%s) {' % outArg.name) -+ print(r' const trace::Struct *_struct = _%s->values[0]->toStruct();' % (outArg.name)) -+ print(r' if (_struct) {') - struct = outArg.type.type - for memberIndex in range(len(struct.members)): - memberType, memberName = struct.members[memberIndex] - if memberName.endswith('Pitch'): -- print r' if (%s->%s) {' % (outArg.name, memberName) -- print r' retrace::checkMismatch(call, "%s", _struct->members[%u], %s->%s);' % (memberName, memberIndex, outArg.name, memberName) -- print r' }' -- print r' }' -- print r' }' -+ print(r' if (%s->%s) {' % (outArg.name, memberName)) -+ print(r' retrace::checkMismatch(call, "%s", _struct->members[%u], %s->%s);' % (memberName, memberIndex, outArg.name, memberName)) -+ print(r' }') -+ print(r' }') -+ print(r' }') - - def filterFunction(self, function): - return True -@@ -575,11 +575,11 @@ class Retracer: - - def retraceApi(self, api): - -- print '#include "os_time.hpp"' -- print '#include "trace_parser.hpp"' -- print '#include "retrace.hpp"' -- print '#include "retrace_swizzle.hpp"' -- print -+ print('#include "os_time.hpp"') -+ print('#include "trace_parser.hpp"') -+ print('#include "retrace.hpp"') -+ print('#include "retrace_swizzle.hpp"') -+ print() - - types = api.getAllTypes() - handles = [type for type in types if isinstance(type, stdapi.Handle)] -@@ -587,14 +587,14 @@ class Retracer: - for handle in handles: - if handle.name not in handle_names: - if handle.key is None: -- print 'static retrace::map<%s> _%s_map;' % (handle.type, handle.name) -+ print('static retrace::map<%s> _%s_map;' % (handle.type, handle.name)) - else: - key_name, key_type = handle.key -- print 'static std::map<%s, retrace::map<%s> > _%s_map;' % (key_type, handle.type, handle.name) -+ print('static std::map<%s, retrace::map<%s> > _%s_map;' % (key_type, handle.type, handle.name)) - handle_names.add(handle.name) -- print -+ print() - -- functions = filter(self.filterFunction, api.getAllFunctions()) -+ functions = list(filter(self.filterFunction, api.getAllFunctions())) - for function in functions: - if function.sideeffects and not function.internal: - self.retraceFunction(function) -@@ -604,20 +604,20 @@ class Retracer: - if method.sideeffects and not method.internal: - self.retraceInterfaceMethod(interface, method) - -- print 'const retrace::Entry %s[] = {' % self.table_name -+ print('const retrace::Entry %s[] = {' % self.table_name) - for function in functions: - if not function.internal: - if function.sideeffects: -- print ' {"%s", &retrace_%s},' % (function.name, function.name) -+ print(' {"%s", &retrace_%s},' % (function.name, function.name)) - else: -- print ' {"%s", &retrace::ignore},' % (function.name,) -+ print(' {"%s", &retrace::ignore},' % (function.name,)) - for interface in interfaces: - for base, method in interface.iterBaseMethods(): - if method.sideeffects: -- print ' {"%s::%s", &retrace_%s__%s},' % (interface.name, method.name, base.name, method.name) -+ print(' {"%s::%s", &retrace_%s__%s},' % (interface.name, method.name, base.name, method.name)) - else: -- print ' {"%s::%s", &retrace::ignore},' % (interface.name, method.name) -- print ' {NULL, NULL}' -- print '};' -- print -+ print(' {"%s::%s", &retrace::ignore},' % (interface.name, method.name)) -+ print(' {NULL, NULL}') -+ print('};') -+ print() - -diff --git a/scripts/convert.py b/scripts/convert.py -index 5f338d80..83df70ce 100755 ---- a/scripts/convert.py -+++ b/scripts/convert.py -@@ -100,9 +100,9 @@ def detectApiFromCsv(inCsv): - import csv - csvReader = csv.reader(open(inCsv, 'rt'), ) - for row in csvReader: -- print row -+ print(row) - event = row[2] -- print event -+ print(event) - if event.startswith("Direct3DCreate9"): - return "d3d9" - if event.startswith("CreateDXGIFactory"): -diff --git a/scripts/jsondiff.py b/scripts/jsondiff.py -index 3b1f9110..25c4840e 100755 ---- a/scripts/jsondiff.py -+++ b/scripts/jsondiff.py -@@ -36,7 +36,7 @@ import sys - def strip_object_hook(obj): - if '__class__' in obj: - return None -- for name in obj.keys(): -+ for name in list(obj.keys()): - if name.startswith('__') and name.endswith('__'): - del obj[name] - return obj -@@ -80,7 +80,7 @@ class Dumper(Visitor): - def visitObject(self, node): - self.enter_object() - -- members = node.keys() -+ members = list(node.keys()) - members.sort() - for i in range(len(members)): - name = members[i] -@@ -148,8 +148,8 @@ class Comparer(Visitor): - return False - if len(a) != len(b) and not self.ignore_added: - return False -- ak = a.keys() -- bk = b.keys() -+ ak = list(a.keys()) -+ bk = list(b.keys()) - ak.sort() - bk.sort() - if ak != bk and not self.ignore_added: -@@ -175,8 +175,8 @@ class Comparer(Visitor): - return True - - def visitValue(self, a, b): -- if isinstance(a, float) and isinstance(b, (int, long, float)) or \ -- isinstance(b, float) and isinstance(a, (int, long, float)): -+ if isinstance(a, float) and isinstance(b, (int, float)) or \ -+ isinstance(b, float) and isinstance(a, (int, float)): - if a is b: - # NaNs take this path - return True -@@ -208,7 +208,7 @@ class Differ(Visitor): - self.dumper.enter_object() - names = set(a.keys()) - if not self.comparer.ignore_added: -- names.update(b.keys()) -+ names.update(list(b.keys())) - names = list(names) - names.sort() - -@@ -284,7 +284,7 @@ class Differ(Visitor): - self.dumper.visit(b) - - def isMultilineString(self, value): -- return isinstance(value, basestring) and '\n' in value -+ return isinstance(value, str) and '\n' in value - - - # -diff --git a/scripts/jsonextractimages.py b/scripts/jsonextractimages.py -index ea1c927d..917ee7e4 100755 ---- a/scripts/jsonextractimages.py -+++ b/scripts/jsonextractimages.py -@@ -38,7 +38,7 @@ pngSignature = "\x89\x50\x4E\x47\x0D\x0A\x1A\x0A" - - - def dumpSurfaces(state, memberName): -- for name, imageObj in state[memberName].iteritems(): -+ for name, imageObj in state[memberName].items(): - data = imageObj['__data__'] - data = base64.b64decode(data) - -diff --git a/scripts/leaks.py b/scripts/leaks.py -new file mode 100755 -index 00000000..325af1e2 ---- /dev/null -+++ b/scripts/leaks.py -@@ -0,0 +1,163 @@ -+#!/usr/bin/env python -+########################################################################## -+# -+# Copyright 2014-2016 VMware, Inc. -+# 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. -+# -+##########################################################################/ -+ -+ -+import subprocess -+import sys -+import os.path -+import optparse -+import re -+ -+import unpickle -+ -+ -+class LeakDetector(unpickle.Unpickler): -+ -+ def __init__(self, apitrace, trace): -+ -+ cmd = [apitrace, 'pickle', '--symbolic', trace] -+ p = subprocess.Popen(args = cmd, stdout = subprocess.PIPE) -+ -+ unpickle.Unpickler.__init__(self, p.stdout) -+ -+ self.numContexts = 0 -+ -+ # a map of maps -+ self.objectDicts = {} -+ -+ def parse(self): -+ unpickle.Unpickler.parse(self) -+ -+ # Reached the end of the trace -- dump any live objects -+ self.dumpLeaks("<EOF>") -+ -+ genDelRegExp = re.compile('^gl(Gen|Delete)(Buffers|Textures|FrameBuffers|RenderBuffers)[A-Z]*$') -+ -+ def handleCall(self, call): -+ # Ignore calls without side effects -+ if call.flags & unpickle.CALL_FLAG_NO_SIDE_EFFECTS: -+ return -+ -+ # Dump call for debugging: -+ if 0: -+ sys.stderr.write('%s\n' % call) -+ -+ mo = self.genDelRegExp.match(call.functionName) -+ if mo: -+ verb = mo.group(1) -+ subject = mo.group(2) -+ -+ subject = subject.lower().rstrip('s') -+ objectDict = self.objectDicts.setdefault(subject, {}) -+ -+ if verb == 'Gen': -+ self.handleGenerate(call, objectDict) -+ elif verb == 'Delete': -+ self.handleDelete(call, objectDict) -+ else: -+ assert 0 -+ -+ # TODO: Track labels via glObjectLabel* calls -+ -+ if call.functionName in [ -+ 'CGLCreateContext', -+ 'eglCreateContext', -+ 'glXCreateContext', -+ 'glXCreateNewContext', -+ 'glXCreateContextAttribsARB', -+ 'glXCreateContextWithConfigSGIX', -+ 'wglCreateContext', -+ 'wglCreateContextAttribsARB', -+ ]: -+ # FIXME: Ignore failing context creation calls -+ self.numContexts += 1 -+ -+ if call.functionName in [ -+ 'CGLDestroyContext', -+ 'glXDestroyContext', -+ 'eglDestroyContext', -+ 'wglDeleteContext', -+ ]: -+ assert self.numContexts > 0 -+ self.numContexts -= 1 -+ if self.numContexts == 0: -+ self.dumpLeaks(call.no) -+ -+ def handleGenerate(self, call, objectDict): -+ n, names = call.argValues() -+ for i in range(n): -+ name = names[i] -+ objectDict[name] = call.no -+ # TODO: Keep track of call stack backtrace too -+ -+ def handleDelete(self, call, objectDict): -+ n, names = call.argValues() -+ for i in range(n): -+ name = names[i] -+ try: -+ del objectDict[name] -+ except KeyError: -+ # Ignore if texture name was never generated -+ pass -+ -+ def dumpLeaks(self, currentCallNo): -+ for kind, objectDict in self.objectDicts.items(): -+ self.dumpNamespaceLeaks(currentCallNo, objectDict, kind) -+ -+ def dumpNamespaceLeaks(self, currentCallNo, objectDict, kind): -+ for name, creationCallNo in (sorted(iter(objectDict.items()),key=lambda t: t[1])): -+ sys.stderr.write('%u: error: %s %u was not destroyed until %s\n' % (creationCallNo, kind, name, currentCallNo)) -+ objectDict.clear() -+ -+ -+def main(): -+ '''Main program. -+ ''' -+ -+ # Parse command line options -+ optparser = optparse.OptionParser( -+ usage='\n\t%prog [options] TRACE', -+ version='%%prog') -+ optparser.add_option( -+ '-a', '--apitrace', metavar='PROGRAM', -+ type='string', dest='apitrace', default='apitrace', -+ help='apitrace command [default: %default]') -+ -+ options, args = optparser.parse_args(sys.argv[1:]) -+ if len(args) != 1: -+ optparser.error("incorrect number of arguments") -+ -+ inTrace = args[0] -+ if not os.path.isfile(inTrace): -+ sys.stderr.write("error: `%s` does not exist\n" % inTrace) -+ sys.exit(1) -+ -+ detector = LeakDetector(options.apitrace, inTrace) -+ detector.parse() -+ -+ -+if __name__ == '__main__': -+ main() -diff --git a/scripts/profileshader.py b/scripts/profileshader.py -index 3c490a0e..5c2a58fb 100755 ---- a/scripts/profileshader.py -+++ b/scripts/profileshader.py -@@ -58,13 +58,13 @@ def process(stream, groupField): - continue - - if fields[callCol] == 'call': -- callId = long(fields[callIdCol]) -- duration = long(fields[gpuDuraCol]) -+ callId = int(fields[callIdCol]) -+ duration = int(fields[gpuDuraCol]) - group = fields[groupCol] - - maxGroupLen = max(maxGroupLen, len(group)) - -- if times.has_key(group): -+ if group in times: - times[group]['draws'] += 1 - times[group]['duration'] += duration - -@@ -74,7 +74,7 @@ def process(stream, groupField): - else: - times[group] = {'draws': 1, 'duration': duration, 'longest': callId, 'longestDuration': duration} - -- times = sorted(times.items(), key=lambda x: x[1]['duration'], reverse=True) -+ times = sorted(list(times.items()), key=lambda x: x[1]['duration'], reverse=True) - - if groupField == 'program': - groupTitle = 'Shader[id]' -@@ -84,9 +84,9 @@ def process(stream, groupField): - groupTitle = groupField.center(maxGroupLen) - groupLine = '-' * maxGroupLen - -- print '+-%s-+--------------+--------------------+--------------+-------------+' % groupLine -- print '| %s | Draws [#] | Duration [ns] v | Per Call[ns] | Longest[id] |' % groupTitle -- print '+-%s-+--------------+--------------------+--------------+-------------+' % groupLine -+ print('+-%s-+--------------+--------------------+--------------+-------------+' % groupLine) -+ print('| %s | Draws [#] | Duration [ns] v | Per Call[ns] | Longest[id] |' % groupTitle) -+ print('+-%s-+--------------+--------------------+--------------+-------------+' % groupLine) - - for group in times: - id = str(group[0]).rjust(maxGroupLen) -@@ -94,9 +94,9 @@ def process(stream, groupField): - dura = str(group[1]['duration']).rjust(18) - perCall = str(group[1]['duration'] / group[1]['draws']).rjust(12) - longest = str(group[1]['longest']).rjust(11) -- print "| %s | %s | %s | %s | %s |" % (id, draw, dura, perCall, longest) -+ print("| %s | %s | %s | %s | %s |" % (id, draw, dura, perCall, longest)) - -- print '+-%s-+--------------+--------------------+--------------+-------------+' % groupLine -+ print('+-%s-+--------------+--------------------+--------------+-------------+' % groupLine) - - - def main(): -diff --git a/scripts/retracediff.py b/scripts/retracediff.py -index bb5aa7f5..8105f536 100755 ---- a/scripts/retracediff.py -+++ b/scripts/retracediff.py -@@ -83,12 +83,12 @@ class Retracer: - self.retraceExe, - ] + args + self.args - if self.env: -- for name, value in self.env.iteritems(): -+ for name, value in self.env.items(): - sys.stderr.write('%s=%s ' % (name, value)) - sys.stderr.write(' '.join(cmd) + '\n') - try: - return subprocess.Popen(cmd, env=self.env, stdout=stdout, stderr=NULL) -- except OSError, ex: -+ except OSError as ex: - sys.stderr.write('error: failed to execute %s: %s\n' % (cmd[0], ex.strerror)) - sys.exit(1) - -@@ -160,7 +160,7 @@ def read_pnm(stream): - while line.startswith('#'): - comment += line[1:] - line = stream.readline() -- width, height = map(int, line.strip().split()) -+ width, height = list(map(int, line.strip().split())) - maximum = int(stream.readline().strip()) - if bytesPerChannel == 1: - assert maximum == 255 -diff --git a/scripts/snapdiff.py b/scripts/snapdiff.py -index 59ec870e..b0d5f757 100755 ---- a/scripts/snapdiff.py -+++ b/scripts/snapdiff.py -@@ -40,6 +40,7 @@ from PIL import Image - from PIL import ImageChops - from PIL import ImageEnhance - from PIL import ImageFilter -+from functools import reduce - - - thumbSize = 320 -@@ -50,12 +51,12 @@ class Comparer: - '''Image comparer.''' - - def __init__(self, ref_image, src_image, alpha = False): -- if isinstance(ref_image, basestring): -+ if isinstance(ref_image, str): - self.ref_im = Image.open(ref_image) - else: - self.ref_im = ref_image - -- if isinstance(src_image, basestring): -+ if isinstance(src_image, str): - self.src_im = Image.open(src_image) - else: - self.src_im = src_image -@@ -106,7 +107,7 @@ class Comparer: - # Compute absolute error - - if self.size_mismatch(): -- return sys.maxint -+ return sys.maxsize - - # TODO: this is approximate due to the grayscale conversion - h = self.diff.convert('L').histogram() -diff --git a/scripts/tracediff.py b/scripts/tracediff.py -index f111322a..0cd9c8c6 100755 ---- a/scripts/tracediff.py -+++ b/scripts/tracediff.py -@@ -237,7 +237,7 @@ class BlobReplacer(Rebuilder): - return Blob(len(obj), hash(str(obj))) - - def visitCall(self, call): -- call.args = map(self.visit, call.args) -+ call.args = list(map(self.visit, call.args)) - call.ret = self.visit(call.ret) - - -@@ -312,7 +312,7 @@ class PythonDiffer(Differ): - elif tag == 'equal': - self.equal(alo, ahi, blo, bhi) - else: -- raise ValueError, 'unknown tag %s' % (tag,) -+ raise ValueError('unknown tag %s' % (tag,)) - - def isjunk(self, call): - return call.functionName == 'glGetError' and call.ret in ('GL_NO_ERROR', 0) -@@ -338,12 +338,12 @@ class PythonDiffer(Differ): - elif tag == 'equal': - self.replace_similar(_alo, _ahi, _blo, _bhi) - else: -- raise ValueError, 'unknown tag %s' % (tag,) -+ raise ValueError('unknown tag %s' % (tag,)) - - def replace_similar(self, alo, ahi, blo, bhi): - assert alo < ahi and blo < bhi - assert ahi - alo == bhi - blo -- for i in xrange(0, bhi - blo): -+ for i in range(0, bhi - blo): - self.highlighter.write('| ') - a_call = self.a[alo + i] - b_call = self.b[blo + i] -@@ -355,7 +355,7 @@ class PythonDiffer(Differ): - self.highlighter.write('(') - sep = '' - numArgs = max(len(a_call.args), len(b_call.args)) -- for j in xrange(numArgs): -+ for j in range(numArgs): - self.highlighter.write(sep) - try: - a_argName, a_argVal = a_call.args[j] -@@ -402,7 +402,7 @@ class PythonDiffer(Differ): - def delete(self, alo, ahi, blo, bhi): - assert alo < ahi - assert blo == bhi -- for i in xrange(alo, ahi): -+ for i in range(alo, ahi): - call = self.a[i] - self.highlighter.write('- ') - self.dumpCallNos(call.no, None) -@@ -413,7 +413,7 @@ class PythonDiffer(Differ): - def insert(self, alo, ahi, blo, bhi): - assert alo == ahi - assert blo < bhi -- for i in xrange(blo, bhi): -+ for i in range(blo, bhi): - call = self.b[i] - self.highlighter.write('+ ') - self.dumpCallNos(None, call.no) -@@ -425,7 +425,7 @@ class PythonDiffer(Differ): - return - assert alo < ahi and blo < bhi - assert ahi - alo == bhi - blo -- for i in xrange(0, bhi - blo): -+ for i in range(0, bhi - blo): - self.highlighter.write(' ') - a_call = self.a[alo + i] - b_call = self.b[blo + i] -diff --git a/scripts/unpickle.py b/scripts/unpickle.py -index 334c1a01..86891d29 100755 ---- a/scripts/unpickle.py -+++ b/scripts/unpickle.py -@@ -38,7 +38,7 @@ import optparse - import sys - import time - import re --import cPickle as pickle -+import pickle as pickle - - - # Same as trace_model.hpp's call flags -@@ -58,7 +58,7 @@ CALL_FLAG_MARKER_POP = (1 << 10) - class Pointer(long): - - def __str__(self): -- if self == 0L: -+ if self == 0: - return 'NULL' - else: - return hex(self).rstrip('L') -@@ -73,7 +73,7 @@ class Visitor: - self.dispatch[type(None)] = self.visitNone - self.dispatch[bool] = self.visitBool - self.dispatch[int] = self.visitInt -- self.dispatch[long] = self.visitInt -+ self.dispatch[int] = self.visitInt - self.dispatch[float] = self.visitFloat - self.dispatch[str] = self.visitStr - self.dispatch[tuple] = self.visitTuple -@@ -140,18 +140,18 @@ class Dumper(Visitor): - return repr(obj) - - def visitTuple(self, obj): -- return '(' + ', '.join(itertools.imap(self.visit, obj)) + ')' -+ return '(' + ', '.join(map(self.visit, obj)) + ')' - - def visitList(self, obj): - if len(obj) == 1: - return '&' + self.visit(obj[0]) -- return '{' + ', '.join(itertools.imap(self.visit, obj)) + '}' -+ return '{' + ', '.join(map(self.visit, obj)) + '}' - - def visitItems(self, items): - return ', '.join(['%s = %s' % (name, self.visit(value)) for name, value in items]) - - def visitDict(self, obj): -- return '{' + self.visitItems(obj.iteritems()) + '}' -+ return '{' + self.visitItems(iter(obj.items())) + '}' - - def visitByteArray(self, obj): - return 'blob(%u)' % len(obj) -@@ -167,7 +167,7 @@ class Hasher(Visitor): - return obj - - def visitIterable(self, obj): -- return tuple(itertools.imap(self.visit, obj)) -+ return tuple(map(self.visit, obj)) - - def visitByteArray(self, obj): - return str(obj) -@@ -268,7 +268,7 @@ class Counter(Unpickler): - def parse(self): - Unpickler.parse(self) - -- functionFrequencies = self.functionFrequencies.items() -+ functionFrequencies = list(self.functionFrequencies.items()) - functionFrequencies.sort(lambda (name1, freq1), (name2, freq2): cmp(freq1, freq2)) - for name, frequency in functionFrequencies: - sys.stdout.write('%8u %s\n' % (frequency, name)) -diff --git a/specs/cglapi.py b/specs/cglapi.py -index 69faeeb4..5d61886f 100644 ---- a/specs/cglapi.py -+++ b/specs/cglapi.py -@@ -29,9 +29,9 @@ http://developer.apple.com/library/mac/#documentation/GraphicsImaging/Reference/ - """ - - --from stdapi import * --from glapi import * --from glapi import glapi -+from .stdapi import * -+from .glapi import * -+from .glapi import glapi - - IOSurfaceRef = Opaque("IOSurfaceRef") - CGLContextObj = Opaque("CGLContextObj") -diff --git a/specs/d2d1.py b/specs/d2d1.py -index dacbea69..9bae43c5 100644 ---- a/specs/d2d1.py -+++ b/specs/d2d1.py -@@ -25,9 +25,9 @@ - ##########################################################################/ - - --from winapi import * --from dxgi import DXGI_FORMAT, IDXGISurface --from dwrite import * -+from .winapi import * -+from .dxgi import DXGI_FORMAT, IDXGISurface -+from .dwrite import * - - - -diff --git a/specs/d3d.py b/specs/d3d.py -index 0dde09f4..4b7244b2 100644 ---- a/specs/d3d.py -+++ b/specs/d3d.py -@@ -25,10 +25,10 @@ - - """d3d.h""" - --from winapi import * --from ddraw import * --from d3dtypes import * --from d3dcaps import * -+from .winapi import * -+from .ddraw import * -+from .d3dtypes import * -+from .d3dcaps import * - - d3dnextFlags = Flags(DWORD, [ - "D3DNEXT_NEXT", -diff --git a/specs/d3d10.py b/specs/d3d10.py -index 2161a5fd..e22bc230 100644 ---- a/specs/d3d10.py -+++ b/specs/d3d10.py -@@ -24,8 +24,8 @@ - ##########################################################################/ - - --from dxgi import * --from d3d10sdklayers import * -+from .dxgi import * -+from .d3d10sdklayers import * - - - HRESULT = MAKE_HRESULT([ -diff --git a/specs/d3d10sdklayers.py b/specs/d3d10sdklayers.py -index aad53f04..82beb721 100644 ---- a/specs/d3d10sdklayers.py -+++ b/specs/d3d10sdklayers.py -@@ -24,7 +24,7 @@ - ##########################################################################/ - - --from dxgi import * -+from .dxgi import * - - - D3D10_DEBUG_FEATURE = Flags(UINT, [ -diff --git a/specs/d3d11.py b/specs/d3d11.py -index f704b062..0a28caa3 100644 ---- a/specs/d3d11.py -+++ b/specs/d3d11.py -@@ -24,8 +24,8 @@ - ##########################################################################/ - - --from dxgi import * --from d3d11sdklayers import * -+from .dxgi import * -+from .d3d11sdklayers import * - - - HRESULT = MAKE_HRESULT([ -diff --git a/specs/d3d11sdklayers.py b/specs/d3d11sdklayers.py -index 907c4b09..97d07750 100644 ---- a/specs/d3d11sdklayers.py -+++ b/specs/d3d11sdklayers.py -@@ -24,7 +24,7 @@ - ##########################################################################/ - - --from dxgi import * -+from .dxgi import * - - - ID3D11DeviceChild = Interface("ID3D11DeviceChild", IUnknown) -diff --git a/specs/d3d8.py b/specs/d3d8.py -index 2dbf1140..400af498 100644 ---- a/specs/d3d8.py -+++ b/specs/d3d8.py -@@ -25,9 +25,9 @@ - - """d3d8.h""" - --from winapi import * --from d3d8types import * --from d3d8caps import * -+from .winapi import * -+from .d3d8types import * -+from .d3d8caps import * - - - D3DSHADER8 = Blob(Const(DWORD), "_shaderSize(pFunction)") -diff --git a/specs/d3d8caps.py b/specs/d3d8caps.py -index 1af1a19f..b7ee5873 100644 ---- a/specs/d3d8caps.py -+++ b/specs/d3d8caps.py -@@ -25,8 +25,8 @@ - - """d3d8caps.h""" - --from winapi import * --from d3d8types import * -+from .winapi import * -+from .d3d8types import * - - D3DCAPS = Flags(DWORD, [ - "D3DCAPS_READ_SCANLINE", -diff --git a/specs/d3d8types.py b/specs/d3d8types.py -index fe58a0cd..a2482328 100644 ---- a/specs/d3d8types.py -+++ b/specs/d3d8types.py -@@ -25,7 +25,7 @@ - - """d3d8types.h""" - --from winapi import * -+from .winapi import * - - D3DCOLOR = Alias("D3DCOLOR", DWORD) - -diff --git a/specs/d3d9.py b/specs/d3d9.py -index 21015149..68dcaca2 100644 ---- a/specs/d3d9.py -+++ b/specs/d3d9.py -@@ -25,9 +25,9 @@ - - """d3d9.h""" - --from winapi import * --from d3d9types import * --from d3d9caps import * -+from .winapi import * -+from .d3d9types import * -+from .d3d9caps import * - - - D3DSHADER9 = Blob(Const(DWORD), "_shaderSize(pFunction)") -diff --git a/specs/d3d9caps.py b/specs/d3d9caps.py -index b3582879..541263b6 100644 ---- a/specs/d3d9caps.py -+++ b/specs/d3d9caps.py -@@ -25,8 +25,8 @@ - - """d3d9caps.h""" - --from winapi import * --from d3d9types import * -+from .winapi import * -+from .d3d9types import * - - D3DVS20CAPS = Flags(DWORD, [ - "D3DVS20CAPS_PREDICATION", -diff --git a/specs/d3d9types.py b/specs/d3d9types.py -index 2545a767..c9847030 100644 ---- a/specs/d3d9types.py -+++ b/specs/d3d9types.py -@@ -26,7 +26,7 @@ - - """d3d9types.h""" - --from winapi import * -+from .winapi import * - - D3DCOLOR = Alias("D3DCOLOR", DWORD) - -diff --git a/specs/d3dcaps.py b/specs/d3dcaps.py -index 0fa9f1cc..88725067 100644 ---- a/specs/d3dcaps.py -+++ b/specs/d3dcaps.py -@@ -25,8 +25,8 @@ - - """d3dcaps.h""" - --from winapi import * --from d3dtypes import * -+from .winapi import * -+from .d3dtypes import * - - D3DTRANSFORMCAPS = Flags(DWORD, [ - "D3DTRANSFORMCAPS_CLIP", -diff --git a/specs/d3dtypes.py b/specs/d3dtypes.py -index e1507975..ba460022 100644 ---- a/specs/d3dtypes.py -+++ b/specs/d3dtypes.py -@@ -25,7 +25,7 @@ - - """d3dtypes.h""" - --from winapi import * -+from .winapi import * - - D3DVALUE = Float - LPD3DVALUE = Pointer(D3DVALUE) -diff --git a/specs/dcommon.py b/specs/dcommon.py -index 21659a5e..6324db3a 100644 ---- a/specs/dcommon.py -+++ b/specs/dcommon.py -@@ -24,7 +24,7 @@ - ##########################################################################/ - - --from winapi import * -+from .winapi import * - - - DWRITE_MEASURING_MODE = Enum("DWRITE_MEASURING_MODE", [ -diff --git a/specs/dcomp.py b/specs/dcomp.py -new file mode 100644 -index 00000000..b139a89e ---- /dev/null -+++ b/specs/dcomp.py -@@ -0,0 +1,303 @@ -+########################################################################## -+# -+# Copyright 2009-2016 VMware, Inc. -+# 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. -+# -+##########################################################################/ -+ -+ -+from .dxgi import * -+from .d2d1 import D2D_MATRIX_3X2_F, D2D_RECT_F -+from .d3d9types import D3DMATRIX -+from .d2d1 import D2D1_COMPOSITE_MODE -+ -+DCOMPOSITION_BITMAP_INTERPOLATION_MODE = Enum('DCOMPOSITION_BITMAP_INTERPOLATION_MODE', [ -+ 'DCOMPOSITION_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR', -+ 'DCOMPOSITION_BITMAP_INTERPOLATION_MODE_LINEAR', -+ 'DCOMPOSITION_BITMAP_INTERPOLATION_MODE_INHERIT', -+]) -+ -+DCOMPOSITION_BORDER_MODE = Enum('DCOMPOSITION_BORDER_MODE', [ -+ 'DCOMPOSITION_BORDER_MODE_SOFT', -+ 'DCOMPOSITION_BORDER_MODE_HARD', -+ 'DCOMPOSITION_BORDER_MODE_INHERIT', -+]) -+ -+DCOMPOSITION_COMPOSITE_MODE = Enum('DCOMPOSITION_COMPOSITE_MODE', [ -+ 'DCOMPOSITION_COMPOSITE_MODE_SOURCE_OVER', -+ 'DCOMPOSITION_COMPOSITE_MODE_DESTINATION_INVERT', -+ 'DCOMPOSITION_COMPOSITE_MODE_INHERIT', -+]) -+ -+DCOMPOSITION_FRAME_STATISTICS = Struct('DCOMPOSITION_FRAME_STATISTICS', [ -+ (LARGE_INTEGER, 'lastFrameTime'), -+ (DXGI_RATIONAL, 'currentCompositionRate'), -+ (LARGE_INTEGER, 'currentTime'), -+ (LARGE_INTEGER, 'timeFrequency'), -+ (LARGE_INTEGER, 'nextEstimatedFrameTime'), -+]) -+ -+COMPOSITIONOBJECT = Flags(DWORD, [ -+ 'COMPOSITIONOBJECT_ALL_ACCESS', # 0x0003 -+ 'COMPOSITIONOBJECT_READ', # 0x0001 -+ 'COMPOSITIONOBJECT_WRITE', # 0x0002 -+]) -+ -+IDCompositionAnimation = Interface('IDCompositionAnimation', IUnknown) -+IDCompositionDevice = Interface('IDCompositionDevice', IUnknown) -+IDCompositionTarget = Interface('IDCompositionTarget', IUnknown) -+IDCompositionVisual = Interface('IDCompositionVisual', IUnknown) -+IDCompositionEffect = Interface('IDCompositionEffect', IUnknown) -+IDCompositionEffectGroup = Interface('IDCompositionEffectGroup', IDCompositionEffect) -+IDCompositionTransform3D = Interface('IDCompositionTransform3D', IDCompositionEffect) -+IDCompositionTransform = Interface('IDCompositionTransform', IDCompositionTransform3D) -+IDCompositionTranslateTransform = Interface('IDCompositionTranslateTransform', IDCompositionTransform) -+IDCompositionTranslateTransform3D = Interface('IDCompositionTranslateTransform3D', IDCompositionTransform3D) -+IDCompositionScaleTransform = Interface('IDCompositionScaleTransform', IDCompositionTransform) -+IDCompositionScaleTransform3D = Interface('IDCompositionScaleTransform3D', IDCompositionTransform3D) -+IDCompositionRotateTransform = Interface('IDCompositionRotateTransform', IDCompositionTransform) -+IDCompositionRotateTransform3D = Interface('IDCompositionRotateTransform3D', IDCompositionTransform3D) -+IDCompositionSkewTransform = Interface('IDCompositionSkewTransform', IDCompositionTransform) -+IDCompositionMatrixTransform = Interface('IDCompositionMatrixTransform', IDCompositionTransform) -+IDCompositionMatrixTransform3D = Interface('IDCompositionMatrixTransform3D', IDCompositionTransform3D) -+IDCompositionClip = Interface('IDCompositionClip', IUnknown) -+IDCompositionRectangleClip = Interface('IDCompositionRectangleClip', IDCompositionClip) -+IDCompositionSurface = Interface('IDCompositionSurface', IUnknown) -+IDCompositionVirtualSurface = Interface('IDCompositionVirtualSurface', IDCompositionSurface) -+ -+IDCompositionAnimation.methods += [ -+ StdMethod(HRESULT, 'Reset', []), -+ StdMethod(HRESULT, 'SetAbsoluteBeginTime', [(LARGE_INTEGER, 'beginTime')]), -+ StdMethod(HRESULT, 'AddCubic', [(Double, 'beginOffset'), (Float, 'constantCoefficient'), (Float, 'linearCoefficient'), (Float, 'quadraticCoefficient'), (Float, 'cubicCoefficient')]), -+ StdMethod(HRESULT, 'AddSinusoidal', [(Double, 'beginOffset'), (Float, 'bias'), (Float, 'amplitude'), (Float, 'frequency'), (Float, 'phase')]), -+ StdMethod(HRESULT, 'AddRepeat', [(Double, 'beginOffset'), (Double, 'durationToRepeat')]), -+ StdMethod(HRESULT, 'End', [(Double, 'endOffset'), (Float, 'endValue')]), -+] -+ -+IDCompositionDevice.methods += [ -+ StdMethod(HRESULT, 'Commit', []), -+ StdMethod(HRESULT, 'WaitForCommitCompletion', []), -+ StdMethod(HRESULT, 'GetFrameStatistics', [Out(Pointer(DCOMPOSITION_FRAME_STATISTICS), 'statistics')]), -+ StdMethod(HRESULT, 'CreateTargetForHwnd', [(HWND, 'hwnd'), (BOOL, 'topmost'), Out(Pointer(ObjPointer(IDCompositionTarget)), 'target')]), -+ StdMethod(HRESULT, 'CreateVisual', [Out(Pointer(ObjPointer(IDCompositionVisual)), 'visual')]), -+ StdMethod(HRESULT, 'CreateSurface', [(UINT, 'width'), (UINT, 'height'), (DXGI_FORMAT, 'pixelFormat'), (DXGI_ALPHA_MODE, 'alphaMode'), Out(Pointer(ObjPointer(IDCompositionSurface)), 'surface')]), -+ StdMethod(HRESULT, 'CreateVirtualSurface', [(UINT, 'initialWidth'), (UINT, 'initialHeight'), (DXGI_FORMAT, 'pixelFormat'), (DXGI_ALPHA_MODE, 'alphaMode'), Out(Pointer(ObjPointer(IDCompositionVirtualSurface)), 'virtualSurface')]), -+ StdMethod(HRESULT, 'CreateSurfaceFromHandle', [(HANDLE, 'handle'), Out(Pointer(ObjPointer(IUnknown)), 'surface')]), -+ StdMethod(HRESULT, 'CreateSurfaceFromHwnd', [(HWND, 'hwnd'), Out(Pointer(ObjPointer(IUnknown)), 'surface')]), -+ StdMethod(HRESULT, 'CreateTranslateTransform', [Out(Pointer(ObjPointer(IDCompositionTranslateTransform)), 'translateTransform')]), -+ StdMethod(HRESULT, 'CreateScaleTransform', [Out(Pointer(ObjPointer(IDCompositionScaleTransform)), 'scaleTransform')]), -+ StdMethod(HRESULT, 'CreateRotateTransform', [Out(Pointer(ObjPointer(IDCompositionRotateTransform)), 'rotateTransform')]), -+ StdMethod(HRESULT, 'CreateSkewTransform', [Out(Pointer(ObjPointer(IDCompositionSkewTransform)), 'skewTransform')]), -+ StdMethod(HRESULT, 'CreateMatrixTransform', [Out(Pointer(ObjPointer(IDCompositionMatrixTransform)), 'matrixTransform')]), -+ StdMethod(HRESULT, 'CreateTransformGroup', [(Array(ObjPointer(IDCompositionTransform), 'elements'), 'transforms'), (UINT, 'elements'), Out(Pointer(ObjPointer(IDCompositionTransform)), 'transformGroup')]), -+ StdMethod(HRESULT, 'CreateTranslateTransform3D', [Out(Pointer(ObjPointer(IDCompositionTranslateTransform3D)), 'translateTransform3D')]), -+ StdMethod(HRESULT, 'CreateScaleTransform3D', [Out(Pointer(ObjPointer(IDCompositionScaleTransform3D)), 'scaleTransform3D')]), -+ StdMethod(HRESULT, 'CreateRotateTransform3D', [Out(Pointer(ObjPointer(IDCompositionRotateTransform3D)), 'rotateTransform3D')]), -+ StdMethod(HRESULT, 'CreateMatrixTransform3D', [Out(Pointer(ObjPointer(IDCompositionMatrixTransform3D)), 'matrixTransform3D')]), -+ StdMethod(HRESULT, 'CreateTransform3DGroup', [(Array(ObjPointer(IDCompositionTransform3D), 'elements'), 'transforms3D'), (UINT, 'elements'), Out(Pointer(ObjPointer(IDCompositionTransform3D)), 'transform3DGroup')]), -+ StdMethod(HRESULT, 'CreateEffectGroup', [Out(Pointer(ObjPointer(IDCompositionEffectGroup)), 'effectGroup')]), -+ StdMethod(HRESULT, 'CreateRectangleClip', [Out(Pointer(ObjPointer(IDCompositionRectangleClip)), 'clip')]), -+ StdMethod(HRESULT, 'CreateAnimation', [Out(Pointer(ObjPointer(IDCompositionAnimation)), 'animation')]), -+ StdMethod(HRESULT, 'CheckDeviceState', [Out(Pointer(BOOL), 'pfValid')]), -+] -+ -+IDCompositionTarget.methods += [ -+ StdMethod(HRESULT, 'SetRoot', [(ObjPointer(IDCompositionVisual), 'visual')]), -+] -+ -+IDCompositionVisual.methods += [ -+ StdMethod(HRESULT, 'SetOffsetX', [(Float, 'offsetX')], overloaded=True), -+ StdMethod(HRESULT, 'SetOffsetX', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), -+ StdMethod(HRESULT, 'SetOffsetY', [(Float, 'offsetY')], overloaded=True), -+ StdMethod(HRESULT, 'SetOffsetY', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), -+ StdMethod(HRESULT, 'SetTransform', [(Reference(Const(D2D_MATRIX_3X2_F)), 'matrix')], overloaded=True), -+ StdMethod(HRESULT, 'SetTransform', [(ObjPointer(IDCompositionTransform), 'transform')], overloaded=True), -+ StdMethod(HRESULT, 'SetTransformParent', [(ObjPointer(IDCompositionVisual), 'visual')]), -+ StdMethod(HRESULT, 'SetEffect', [(ObjPointer(IDCompositionEffect), 'effect')]), -+ StdMethod(HRESULT, 'SetBitmapInterpolationMode', [(DCOMPOSITION_BITMAP_INTERPOLATION_MODE, 'interpolationMode')]), -+ StdMethod(HRESULT, 'SetBorderMode', [(DCOMPOSITION_BORDER_MODE, 'borderMode')]), -+ StdMethod(HRESULT, 'SetClip', [(Reference(Const(D2D_RECT_F)), 'rect')], overloaded=True), -+ StdMethod(HRESULT, 'SetClip', [(ObjPointer(IDCompositionClip), 'clip')], overloaded=True), -+ StdMethod(HRESULT, 'SetContent', [(ObjPointer(IUnknown), 'content')]), -+ StdMethod(HRESULT, 'AddVisual', [(ObjPointer(IDCompositionVisual), 'visual'), (BOOL, 'insertAbove'), (ObjPointer(IDCompositionVisual), 'referenceVisual')]), -+ StdMethod(HRESULT, 'RemoveVisual', [(ObjPointer(IDCompositionVisual), 'visual')]), -+ StdMethod(HRESULT, 'RemoveAllVisuals', []), -+ StdMethod(HRESULT, 'SetCompositeMode', [(DCOMPOSITION_COMPOSITE_MODE, 'compositeMode')]), -+] -+ -+IDCompositionTransform.methods += [ -+] -+ -+IDCompositionTransform3D.methods += [ -+] -+ -+IDCompositionTranslateTransform.methods += [ -+ StdMethod(HRESULT, 'SetOffsetX', [(Float, 'offsetX')], overloaded=True), -+ StdMethod(HRESULT, 'SetOffsetX', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), -+ StdMethod(HRESULT, 'SetOffsetY', [(Float, 'offsetY')], overloaded=True), -+ StdMethod(HRESULT, 'SetOffsetY', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), -+] -+ -+IDCompositionTranslateTransform3D.methods += [ -+ StdMethod(HRESULT, 'SetOffsetX', [(Float, 'offsetX')], overloaded=True), -+ StdMethod(HRESULT, 'SetOffsetX', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), -+ StdMethod(HRESULT, 'SetOffsetY', [(Float, 'offsetY')], overloaded=True), -+ StdMethod(HRESULT, 'SetOffsetY', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), -+ StdMethod(HRESULT, 'SetOffsetZ', [(Float, 'offsetZ')], overloaded=True), -+ StdMethod(HRESULT, 'SetOffsetZ', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), -+] -+ -+IDCompositionScaleTransform.methods += [ -+ StdMethod(HRESULT, 'SetScaleX', [(Float, 'scaleX')], overloaded=True), -+ StdMethod(HRESULT, 'SetScaleX', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), -+ StdMethod(HRESULT, 'SetScaleY', [(Float, 'scaleY')], overloaded=True), -+ StdMethod(HRESULT, 'SetScaleY', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), -+ StdMethod(HRESULT, 'SetCenterX', [(Float, 'centerX')], overloaded=True), -+ StdMethod(HRESULT, 'SetCenterX', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), -+ StdMethod(HRESULT, 'SetCenterY', [(Float, 'centerY')], overloaded=True), -+ StdMethod(HRESULT, 'SetCenterY', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), -+] -+ -+IDCompositionScaleTransform3D.methods += [ -+ StdMethod(HRESULT, 'SetScaleX', [(Float, 'scaleX')], overloaded=True), -+ StdMethod(HRESULT, 'SetScaleX', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), -+ StdMethod(HRESULT, 'SetScaleY', [(Float, 'scaleY')], overloaded=True), -+ StdMethod(HRESULT, 'SetScaleY', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), -+ StdMethod(HRESULT, 'SetScaleZ', [(Float, 'scaleZ')], overloaded=True), -+ StdMethod(HRESULT, 'SetScaleZ', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), -+ StdMethod(HRESULT, 'SetCenterX', [(Float, 'centerX')], overloaded=True), -+ StdMethod(HRESULT, 'SetCenterX', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), -+ StdMethod(HRESULT, 'SetCenterY', [(Float, 'centerY')], overloaded=True), -+ StdMethod(HRESULT, 'SetCenterY', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), -+ StdMethod(HRESULT, 'SetCenterZ', [(Float, 'centerZ')], overloaded=True), -+ StdMethod(HRESULT, 'SetCenterZ', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), -+] -+ -+IDCompositionRotateTransform.methods += [ -+ StdMethod(HRESULT, 'SetAngle', [(Float, 'angle')], overloaded=True), -+ StdMethod(HRESULT, 'SetAngle', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), -+ StdMethod(HRESULT, 'SetCenterX', [(Float, 'centerX')], overloaded=True), -+ StdMethod(HRESULT, 'SetCenterX', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), -+ StdMethod(HRESULT, 'SetCenterY', [(Float, 'centerY')], overloaded=True), -+ StdMethod(HRESULT, 'SetCenterY', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), -+] -+ -+IDCompositionRotateTransform3D.methods += [ -+ StdMethod(HRESULT, 'SetAngle', [(Float, 'angle')], overloaded=True), -+ StdMethod(HRESULT, 'SetAngle', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), -+ StdMethod(HRESULT, 'SetAxisX', [(Float, 'axisX')], overloaded=True), -+ StdMethod(HRESULT, 'SetAxisX', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), -+ StdMethod(HRESULT, 'SetAxisY', [(Float, 'axisY')], overloaded=True), -+ StdMethod(HRESULT, 'SetAxisY', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), -+ StdMethod(HRESULT, 'SetAxisZ', [(Float, 'axisZ')], overloaded=True), -+ StdMethod(HRESULT, 'SetAxisZ', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), -+ StdMethod(HRESULT, 'SetCenterX', [(Float, 'centerX')], overloaded=True), -+ StdMethod(HRESULT, 'SetCenterX', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), -+ StdMethod(HRESULT, 'SetCenterY', [(Float, 'centerY')], overloaded=True), -+ StdMethod(HRESULT, 'SetCenterY', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), -+ StdMethod(HRESULT, 'SetCenterZ', [(Float, 'centerZ')], overloaded=True), -+ StdMethod(HRESULT, 'SetCenterZ', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), -+] -+ -+IDCompositionSkewTransform.methods += [ -+ StdMethod(HRESULT, 'SetAngleX', [(Float, 'angleX')], overloaded=True), -+ StdMethod(HRESULT, 'SetAngleX', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), -+ StdMethod(HRESULT, 'SetAngleY', [(Float, 'angleY')], overloaded=True), -+ StdMethod(HRESULT, 'SetAngleY', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), -+ StdMethod(HRESULT, 'SetCenterX', [(Float, 'centerX')], overloaded=True), -+ StdMethod(HRESULT, 'SetCenterX', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), -+ StdMethod(HRESULT, 'SetCenterY', [(Float, 'centerY')], overloaded=True), -+ StdMethod(HRESULT, 'SetCenterY', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), -+] -+ -+IDCompositionMatrixTransform.methods += [ -+ StdMethod(HRESULT, 'SetMatrix', [(Reference(Const(D2D_MATRIX_3X2_F)), 'matrix')]), -+ StdMethod(HRESULT, 'SetMatrixElement', [(Int, 'row'), (Int, 'column'), (Float, 'value')], overloaded=True), -+ StdMethod(HRESULT, 'SetMatrixElement', [(Int, 'row'), (Int, 'column'), (ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), -+] -+ -+IDCompositionMatrixTransform3D.methods += [ -+ StdMethod(HRESULT, 'SetMatrix', [(Reference(Const(D3DMATRIX)), 'matrix')]), -+ StdMethod(HRESULT, 'SetMatrixElement', [(Int, 'row'), (Int, 'column'), (Float, 'value')], overloaded=True), -+ StdMethod(HRESULT, 'SetMatrixElement', [(Int, 'row'), (Int, 'column'), (ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), -+] -+ -+IDCompositionEffect.methods += [ -+] -+ -+IDCompositionEffectGroup.methods += [ -+ StdMethod(HRESULT, 'SetOpacity', [(Float, 'opacity')], overloaded=True), -+ StdMethod(HRESULT, 'SetOpacity', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), -+ StdMethod(HRESULT, 'SetTransform3D', [(ObjPointer(IDCompositionTransform3D), 'transform3D')]), -+] -+ -+IDCompositionClip.methods += [ -+] -+ -+IDCompositionRectangleClip.methods += [ -+ StdMethod(HRESULT, 'SetLeft', [(Float, 'left')], overloaded=True), -+ StdMethod(HRESULT, 'SetLeft', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), -+ StdMethod(HRESULT, 'SetTop', [(Float, 'top')], overloaded=True), -+ StdMethod(HRESULT, 'SetTop', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), -+ StdMethod(HRESULT, 'SetRight', [(Float, 'right')], overloaded=True), -+ StdMethod(HRESULT, 'SetRight', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), -+ StdMethod(HRESULT, 'SetBottom', [(Float, 'bottom')], overloaded=True), -+ StdMethod(HRESULT, 'SetBottom', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), -+ StdMethod(HRESULT, 'SetTopLeftRadiusX', [(Float, 'radius')], overloaded=True), -+ StdMethod(HRESULT, 'SetTopLeftRadiusX', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), -+ StdMethod(HRESULT, 'SetTopLeftRadiusY', [(Float, 'radius')], overloaded=True), -+ StdMethod(HRESULT, 'SetTopLeftRadiusY', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), -+ StdMethod(HRESULT, 'SetTopRightRadiusX', [(Float, 'radius')], overloaded=True), -+ StdMethod(HRESULT, 'SetTopRightRadiusX', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), -+ StdMethod(HRESULT, 'SetTopRightRadiusY', [(Float, 'radius')], overloaded=True), -+ StdMethod(HRESULT, 'SetTopRightRadiusY', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), -+ StdMethod(HRESULT, 'SetBottomLeftRadiusX', [(Float, 'radius')], overloaded=True), -+ StdMethod(HRESULT, 'SetBottomLeftRadiusX', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), -+ StdMethod(HRESULT, 'SetBottomLeftRadiusY', [(Float, 'radius')], overloaded=True), -+ StdMethod(HRESULT, 'SetBottomLeftRadiusY', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), -+ StdMethod(HRESULT, 'SetBottomRightRadiusX', [(Float, 'radius')], overloaded=True), -+ StdMethod(HRESULT, 'SetBottomRightRadiusX', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), -+ StdMethod(HRESULT, 'SetBottomRightRadiusY', [(Float, 'radius')], overloaded=True), -+ StdMethod(HRESULT, 'SetBottomRightRadiusY', [(ObjPointer(IDCompositionAnimation), 'animation')], overloaded=True), -+] -+ -+IDCompositionSurface.methods += [ -+ # XXX: riid might be ID2D1DeviceContext -+ StdMethod(HRESULT, 'BeginDraw', [(Pointer(Const(RECT)), 'updateRect'), (REFIID, 'iid'), Out(Pointer(ObjPointer(Void)), 'updateObject'), Out(Pointer(POINT), 'updateOffset')]), -+ StdMethod(HRESULT, 'EndDraw', []), -+ StdMethod(HRESULT, 'SuspendDraw', []), -+ StdMethod(HRESULT, 'ResumeDraw', []), -+ StdMethod(HRESULT, 'Scroll', [(Pointer(Const(RECT)), 'scrollRect'), (Pointer(Const(RECT)), 'clipRect'), (Int, 'offsetX'), (Int, 'offsetY')]), -+] -+ -+IDCompositionVirtualSurface.methods += [ -+ StdMethod(HRESULT, 'Resize', [(UINT, 'width'), (UINT, 'height')]), -+ StdMethod(HRESULT, 'Trim', [(Array(Const(RECT), 'count'), 'rectangles'), (UINT, 'count')]), -+] -+ -+dcomp = Module('dcomp') -+dcomp.addFunctions([ -+ StdFunction(HRESULT, 'DCompositionCreateDevice', [(ObjPointer(IDXGIDevice), 'dxgiDevice'), (REFIID, 'iid'), Out(Pointer(ObjPointer(Void)), 'dcompositionDevice')]), -+ StdFunction(HRESULT, 'DCompositionCreateSurfaceHandle', [(COMPOSITIONOBJECT, 'desiredAccess'), (Pointer(SECURITY_ATTRIBUTES), 'securityAttributes'), Out(Pointer(HANDLE), 'surfaceHandle')]), -+]) -+dcomp.addInterfaces([ -+ IDCompositionDevice, -+]) -diff --git a/specs/ddraw.py b/specs/ddraw.py -index 99f542fe..5df48be0 100644 ---- a/specs/ddraw.py -+++ b/specs/ddraw.py -@@ -25,7 +25,7 @@ - - """ddraw.h""" - --from winapi import * -+from .winapi import * - - DirectDrawOptSurfaceDescFlags = Flags(DWORD, [ - "DDOSD_GUID", -diff --git a/specs/debug.py b/specs/debug.py -index 0a004741..6ef80f64 100644 ---- a/specs/debug.py -+++ b/specs/debug.py -@@ -49,7 +49,7 @@ def excepthook(type, value, tb): - import traceback, pdb - # we are NOT in interactive mode, print the exception... - traceback.print_exception(type, value, tb) -- print -+ print() - # ...then start the debugger in post-mortem mode. - pdb.pm() - -diff --git a/specs/dwrite.py b/specs/dwrite.py -index 60e5034c..be273f81 100644 ---- a/specs/dwrite.py -+++ b/specs/dwrite.py -@@ -24,8 +24,8 @@ - ##########################################################################/ - - --from winapi import * --from dcommon import * -+from .winapi import * -+from .dcommon import * - - - ID2D1SimplifiedGeometrySink = Interface("ID2D1SimplifiedGeometrySink", IUnknown) -diff --git a/specs/dxgi.py b/specs/dxgi.py -index 0e880548..040f3bc4 100644 ---- a/specs/dxgi.py -+++ b/specs/dxgi.py -@@ -25,7 +25,7 @@ - ##########################################################################/ - - --from winapi import * -+from .winapi import * - - - DXGI_FORMAT = Enum("DXGI_FORMAT", [ -diff --git a/specs/dxva2.py b/specs/dxva2.py -index 3936afac..65f5f0c0 100644 ---- a/specs/dxva2.py -+++ b/specs/dxva2.py -@@ -24,7 +24,7 @@ - ##########################################################################/ - - --from d3d9 import * -+from .d3d9 import * - - - HRESULT = MAKE_HRESULT(errors = [ -diff --git a/specs/eglapi.py b/specs/eglapi.py -index 8379e45e..e1edff06 100644 ---- a/specs/eglapi.py -+++ b/specs/eglapi.py -@@ -26,9 +26,9 @@ - """EGL API description.""" - - --from stdapi import * --from gltypes import * --from eglenum import * -+from .stdapi import * -+from .gltypes import * -+from .eglenum import * - - EGLNativeDisplayType = Opaque("EGLNativeDisplayType") - EGLNativeWindowType = Opaque("EGLNativeWindowType") -diff --git a/specs/eglenum.py b/specs/eglenum.py -index 8b10868d..e6290fb2 100644 ---- a/specs/eglenum.py -+++ b/specs/eglenum.py -@@ -28,7 +28,7 @@ - """EGL enum description""" - - --from stdapi import * -+from .stdapi import * - - # Most of the following content was produced in a semi-automated fashion by - # the scripts/eglenum.sed sed script. -diff --git a/specs/glapi.py b/specs/glapi.py -index c0e92b3c..8d20052e 100644 ---- a/specs/glapi.py -+++ b/specs/glapi.py -@@ -34,9 +34,9 @@ corner cases correctly. - """ - - --from stdapi import * --from gltypes import * --import glparams -+from .stdapi import * -+from .gltypes import * -+from . import glparams - - - def GlFunction(*args, **kwargs): -diff --git a/specs/glparams.py b/specs/glparams.py -index 1bed8a6b..5a036975 100644 ---- a/specs/glparams.py -+++ b/specs/glparams.py -@@ -27,9 +27,9 @@ - '''Describe GL parameters.''' - - --from stdapi import * -+from .stdapi import * - --from gltypes import * -+from .gltypes import * - - - # Shorthands for the types -diff --git a/specs/gltypes.py b/specs/gltypes.py -index a9ffc4a1..631eb868 100644 ---- a/specs/gltypes.py -+++ b/specs/gltypes.py -@@ -29,7 +29,7 @@ - - import platform - --from stdapi import * -+from .stdapi import * - - - GLboolean = Enum("GLboolean", [ -diff --git a/specs/glxapi.py b/specs/glxapi.py -index 0d3cd969..f4182799 100644 ---- a/specs/glxapi.py -+++ b/specs/glxapi.py -@@ -26,8 +26,8 @@ - """GLX API description.""" - - --from stdapi import * --from glapi import * -+from .stdapi import * -+from .glapi import * - - VisualID = Alias("VisualID", UInt32) - Display = Opaque("Display *") -diff --git a/specs/scripts/c2api.py b/specs/scripts/c2api.py -index 7deb2955..b8aaa81d 100755 ---- a/specs/scripts/c2api.py -+++ b/specs/scripts/c2api.py -@@ -122,7 +122,7 @@ class DeclParser: - self.consume() - type = 'Pointer(%s)' % type - name = self.consume() -- print '%s = Alias("%s", %s)' % (name, name, type) -+ print('%s = Alias("%s", %s)' % (name, name, type)) - if self.match(','): - self.consume() - else: -@@ -136,7 +136,7 @@ class DeclParser: - name = self.consume() - self.consume('{') - -- print '%s = Enum("%s", [' % (name, name) -+ print('%s = Enum("%s", [' % (name, name)) - - #value = 0 - while self.lookahead() != '}': -@@ -148,12 +148,12 @@ class DeclParser: - self.consume(',') - tags = self.parse_tags() - #print ' "%s",\t# %s' % (name, value) -- print ' "%s",' % (name,) -+ print(' "%s",' % (name,)) - #value += 1 - self.consume('}') - -- print '])' -- print -+ print('])') -+ print() - - def parse_value(self, ref_token, constructor): - self.consume(ref_token) -@@ -161,14 +161,14 @@ class DeclParser: - name = self.consume() - self.consume('{') - -- print '%s = %s(%s, [' % (name, constructor, type) -+ print('%s = %s(%s, [' % (name, constructor, type)) - - while self.lookahead() != '}': - name, value = self.parse_define() - self.consume('}') - -- print '])' -- print -+ print('])') -+ print() - - def parse_define(self): - self.consume('#') -@@ -176,18 +176,18 @@ class DeclParser: - name = self.consume() - value = self.consume() - #print ' "%s",\t# %s' % (name, value) -- print ' "%s",' % (name,) -+ print(' "%s",' % (name,)) - return name, value - - def parse_struct(self): - self.consume('struct') - name = self.consume() - -- print '%s = Struct("%s", [' % (name, name) -+ print('%s = Struct("%s", [' % (name, name)) - for type, name in self.parse_members(): -- print ' (%s, "%s"),' % (type, name) -- print '])' -- print -+ print(' (%s, "%s"),' % (type, name)) -+ print('])') -+ print() - - def parse_union(self): - self.consume('union') -@@ -226,8 +226,8 @@ class DeclParser: - base = self.consume() - self.consume('{') - -- print '%s = Interface("%s", %s)' % (name, name, base) -- print '%s.methods += [' % (name,) -+ print('%s = Interface("%s", %s)' % (name, name, base)) -+ print('%s.methods += [' % (name,)) - - while self.lookahead() != '}': - if self.lookahead() in ('public', 'private'): -@@ -238,8 +238,8 @@ class DeclParser: - self.consume(';') - self.consume('}') - -- print ']' -- print -+ print(']') -+ print() - - def parse_prototype(self, creator = 'Function'): - if self.match('extern', 'virtual'): -@@ -275,7 +275,7 @@ class DeclParser: - self.consume() - self.consume('0') - -- print ' %s(%s, "%s", [%s]%s),' % (creator, ret, name, ', '.join(args), extra) -+ print(' %s(%s, "%s", [%s]%s),' % (creator, ret, name, ', '.join(args), extra)) - - def parse_arg(self): - tags = self.parse_tags() -@@ -404,8 +404,8 @@ class DeclParser: - type = 'S' + type - elif short: - type = 'Short' -- elif long: -- type = 'Long' * long -+ elif int: -+ type = 'Long' * int - else: - type = 'Int' - if unsigned: -diff --git a/specs/scripts/cxx2api.py b/specs/scripts/cxx2api.py -new file mode 100755 -index 00000000..9720615d ---- /dev/null -+++ b/specs/scripts/cxx2api.py -@@ -0,0 +1,488 @@ -+#!/usr/bin/env python -+ -+ -+ -+copyright = ''' -+########################################################################## -+# -+# Copyright 2009-2016 VMware, Inc. -+# 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. -+# -+##########################################################################/ -+''' -+ -+ -+# -+# Generates API specs from headers using castxml/pygccxml. -+# -+# Usage: -+# -+# sudo apt-get install castxml mingw-w64-i686-dev -+# pip install 'pygccxml==1.9.1' -+# python specs/scripts/cxx2api.py -Idxsdk/Include -DD2D_USE_C_DEFINITIONS dcomp.h dcomptypes.h dcompanimation.h -+# -+# See also: -+# - http://pygccxml.readthedocs.org/en/develop/index.html -+# - https://github.com/CastXML/CastXML/blob/master/doc/manual/castxml.1.rst -+# -+ -+import os.path -+import sys -+import io as StringIO -+import subprocess -+ -+from pygccxml import utils -+from pygccxml import parser -+from pygccxml import declarations -+ -+from pygccxml.declarations import algorithm -+from pygccxml.declarations import decl_visitor -+from pygccxml.declarations import type_traits -+from pygccxml.declarations import type_visitor -+ -+ -+class decl_dumper_t(decl_visitor.decl_visitor_t): -+ -+ def __init__(self, decl = None): -+ decl_visitor.decl_visitor_t.__init__(self) -+ self.decl = decl -+ self.result = None -+ -+ def clone(self): -+ return decl_dumper_t(self.decl) -+ -+ def visit_class(self): -+ class_ = self.decl -+ assert class_.class_type in ('struct', 'union') -+ self.result = class_.name -+ -+ def visit_class_declaration(self): -+ class_ = self.decl -+ self.result = class_.name -+ -+ def visit_typedef(self): -+ typedef = self.decl -+ self.result = typedef.name -+ -+ def visit_enumeration(self): -+ self.result = self.decl.name -+ -+ -+def dump_decl(decl): -+ visitor = decl_dumper_t(decl) -+ algorithm.apply_visitor(visitor, decl) -+ return visitor.result -+ -+ -+class type_dumper_t(type_visitor.type_visitor_t): -+ -+ def __init__(self, type): -+ type_visitor.type_visitor_t.__init__(self) -+ self.type = type -+ self.result = None -+ -+ def clone(self): -+ return type_dumper_t(self.type) -+ -+ def visit_void(self): -+ self.result = 'Void' -+ -+ def visit_char(self): -+ self.result = 'Char' -+ -+ def visit_unsigned_char(self): -+ self.result = 'UChar' -+ -+ def visit_signed_char(self): -+ self.result = 'SChar' -+ -+ def visit_wchar(self): -+ raise NotImplementedError -+ -+ def visit_short_int(self): -+ self.result = 'Short' -+ -+ def visit_short_unsigned_int(self): -+ self.result = 'UShort' -+ -+ def visit_bool(self): -+ raise NotImplementedError -+ -+ def visit_int(self): -+ self.result = 'Int' -+ -+ def visit_unsigned_int(self): -+ self.result = 'UInt' -+ -+ def visit_long_int(self): -+ self.result = 'Long' -+ -+ def visit_long_unsigned_int(self): -+ self.result = 'ULong' -+ -+ def visit_long_long_int(self): -+ self.result = 'LongLong' -+ -+ def visit_long_long_unsigned_int(self): -+ self.result = 'ULongLong' -+ -+ def visit_float(self): -+ self.result = "Float" -+ -+ def visit_double(self): -+ self.result = "Double" -+ -+ def visit_array(self): -+ base_type = dump_type(self.type.base) -+ length = self.type.size -+ try: -+ int(length) -+ except ValueError: -+ length = '"%s"' % length -+ self.result = 'Array(%s, %s)' % (base_type, length) -+ -+ def visit_pointer(self): -+ base_type = dump_type(self.type.base) -+ # TODO: Use ObjPointer where appropriate -+ #if isinstance(self.type.base, declarations.cpptypes.declarated_t): -+ # decl = self.type.base.declaration -+ # if isinstance(decl, declarations.typedef.typedef_t): -+ # print(decl.type, type(decl.type)) -+ # if isinstance(decl, declarations.class_declaration.class_t): -+ # if decl.public_members: -+ # self.result = 'ObjPointer(%s)' % decl.name -+ # return -+ # if isinstance(decl, declarations.class_declaration.class_declaration_t): -+ # if decl.public_members: -+ # self.result = 'ObjPointer(%s)' % decl.name -+ # return -+ if base_type.startswith('IDComposition') or \ -+ base_type.startswith('IDXGI') or \ -+ base_type == 'IUnknown': -+ self.result = 'ObjPointer(%s)' % base_type -+ return -+ self.result = 'Pointer(%s)' % base_type -+ -+ def visit_reference(self): -+ base_type = dump_type(self.type.base) -+ if base_type == 'Const(IID)': -+ self.result = 'REFIID' -+ elif base_type == 'Const(GUID)': -+ self.result = 'REFGUID' -+ else: -+ self.result = 'Reference(%s)' % base_type -+ -+ def visit_const(self): -+ self.result = 'Const(%s)' % dump_type(self.type.base) -+ -+ def visit_declarated(self): -+ decl = self.type.declaration -+ self.result = dump_decl(decl) -+ -+ def visit_free_function_type(self): -+ self.result = 'Opaque("%s")' % self.type -+ -+ -+def dump_type(type): -+ visitor = type_dumper_t(type) -+ algorithm.apply_visitor(visitor, type) -+ # XXX: RECT becomes tagRECT somehow -+ if visitor.result == 'tagRECT': -+ return 'RECT' -+ return visitor.result -+ -+ -+def is_interface(class_): -+ if not class_.name.startswith('I'): -+ return -+ if len(class_.bases) != 1: -+ return False -+ # TODO: Ensure interface derives from IUnknown -+ return True -+ -+ -+class decl2_dumper_t(decl_visitor.decl_visitor_t): -+ -+ def __init__(self, name): -+ decl_visitor.decl_visitor_t.__init__(self) -+ -+ self.name = name -+ -+ # The current declaration -+ self.decl = None -+ -+ self.interfaces = StringIO.StringIO() -+ self.methods = StringIO.StringIO() -+ self.functions = StringIO.StringIO() -+ -+ def start(self): -+ print(copyright.strip()) -+ print() -+ print() -+ print(r'from winapi import *') -+ print() -+ -+ def finish(self): -+ sys.stdout.write(self.interfaces.getvalue()) -+ sys.stdout.write('\n') -+ sys.stdout.write(self.methods.getvalue()) -+ -+ name = self.name -+ sys.stdout.write('%s = Module(%r)\n' % (name, name)) -+ sys.stdout.write('%s.addFunctions([\n' % (name,)) -+ sys.stdout.write(self.functions.getvalue()) -+ sys.stdout.write('])\n\n') -+ -+ def clone(self): -+ return decl_dumper_t(self.decl) -+ -+ def visit_class(self): -+ class_ = self.decl -+ assert class_.class_type in ('struct', 'union') -+ -+ if is_interface(class_): -+ self.visit_interface() -+ elif class_.name != '': -+ self.visit_struct(class_.name, class_) -+ -+ def visit_struct(self, decl_name, decl): -+ struct = decl -+ print(r'%s = Struct(%r, [' % (decl_name, decl_name)) -+ for variable in struct.variables(allow_empty=True): -+ var_type = dump_type(variable.decl_type) -+ print(r' (%s, %r),' % (var_type, variable.name)) -+ print(r'])') -+ print() -+ -+ def visit_interface(self): -+ class_ = self.decl -+ assert len(class_.bases) == 1 -+ base = class_.bases[0] -+ -+ s = self.interfaces -+ s.write('%s = Interface(%r, %s)\n' % (class_.name, class_.name, base.related_class.name)) -+ -+ s = self.methods -+ s.write('%s.methods += [\n' % (class_.name,)) -+ for member in class_.public_members: -+ if member.virtuality != 'pure virtual': -+ continue -+ ret_type = dump_type(member.return_type) -+ arg_types = self.convert_args(member.arguments) -+ s.write(' StdMethod(%s, %r, [%s]),\n' % (ret_type, member.name, arg_types)) -+ s.write(']\n\n') -+ -+ def convert_args(self, args): -+ # TODO: use __attribute__ ((annotate ("out"))) -+ # See also: -+ # - https://github.com/CastXML/CastXML/issues/25 -+ # XXX: Requires a castxml version newer than the one in Ubuntu 15.10 -+ arg_types = [] -+ for arg in args: -+ if arg.attributes is not None: -+ sys.stderr.write('warning: found %s attribute %r\n' % (arg.name, arg.attributes)) -+ res_arg_type = dump_type(arg.decl_type) -+ res_arg = '(%s, %r)' % (res_arg_type, arg.name) -+ -+ # Infer output arguments -+ if res_arg_type.startswith('Pointer(') and \ -+ not res_arg_type.startswith('Pointer(Const('): -+ res_arg = 'Out' + res_arg -+ -+ arg_types.append(res_arg) -+ -+ arg_types = ', '.join(arg_types) -+ return arg_types -+ -+ def visit_class_declaration(self): -+ pass -+ -+ def visit_typedef(self): -+ typedef = self.decl -+ base_type = dump_type(typedef.decl_type) -+ if base_type == typedef.name: -+ # Ignore `typedef struct Foo Foo;` -+ return -+ if base_type == '': -+ if isinstance(typedef.decl_type, declarations.cpptypes.declarated_t): -+ base_decl = typedef.decl_type.declaration -+ self.visit_struct(typedef.name, base_decl) -+ return -+ print(r'%s = Alias(%r, %s)' % (typedef.name, typedef.name, base_type)) -+ print() -+ -+ def visit_enumeration(self): -+ enum = self.decl -+ print(r'%s = Enum(%r, [' % (enum.name, enum.name)) -+ for name, value in enum.values: -+ print(r' %r,' % (name,)) -+ print(r'])') -+ print() -+ -+ def visit_variable(self): -+ pass -+ -+ def visit_free_function(self): -+ function = self.decl -+ if function.has_inline: -+ return -+ -+ s = self.functions -+ ret_type = dump_type(function.return_type) -+ arg_types = self.convert_args(function.arguments) -+ s.write(' StdFunction(%s, %r, [%s]),\n' % (ret_type, function.name, arg_types)) -+ -+ def visit_free_operator(self): -+ pass -+ -+ -+def main(): -+ defines = [] -+ includes = [] -+ cxxflags = [ -+ '-Wno-unknown-attributes', -+ '-Wno-unused-value', -+ '-Wno-macro-redefined', -+ ] -+ compiler = 'g++' -+ -+ args = sys.argv[1:] -+ while args and args[0].startswith('-'): -+ arg = args.pop(0) -+ if arg.startswith('-I'): -+ include = arg[2:] -+ includes.append(include) -+ elif arg.startswith('-D'): -+ define = arg[2:] -+ defines.append(define) -+ else: -+ sys.stderr.write('error: unknown option %r\n' % arg) -+ sys.exit(1) -+ -+ winsdk = True -+ if winsdk: -+ # Set up Clang compiler flags to use MinGW runtime -+ # http://stackoverflow.com/a/19839946 -+ p = subprocess.Popen( -+ ["x86_64-w64-mingw32-g++", "-x", "c++", "-E", "-Wp,-v", '-', '-fsyntax-only'], -+ stdin=open(os.devnull, 'rt'), -+ stdout=open(os.devnull, 'wt'), -+ stderr=subprocess.PIPE) -+ includes.append('/usr/share/castxml/clang/include') -+ for line in p.stderr: -+ if line.startswith(' '): -+ include = line.strip() -+ if os.path.isdir(include): -+ if os.path.exists(os.path.join(include, 'ia32intrin.h')): -+ # XXX: We must use Clang's intrinsic headers -+ continue -+ includes.append(os.path.normpath(include)) -+ -+ winver = 0x0602 -+ -+ defines += [ -+ # emulate MinGW -+ '__MINGW32__', -+ '_WIN32', -+ '_WIN64', -+ '__declspec(x)=', -+ # Avoid namespace pollution when including windows.h -+ # http://support.microsoft.com/kb/166474 -+ 'WIN32_LEAN_AND_MEAN', -+ # Set Windows version to 8.1 -+ '_WIN32_WINNT=0x%04X' % winver, -+ 'WINVER=0x%04X' % winver, -+ 'NTDDI_VERSION=0x%04X0000' % winver, -+ # Prevent headers from requiring a rpcndr.h version beyond MinGW's -+ '__REQUIRED_RPCNDR_H_VERSION__=475', -+ # Avoid C++ helper classes -+ 'D3D10_NO_HELPERS', -+ 'D3D11_NO_HELPERS', -+ 'D3D11_VIDEO_NO_HELPERS', -+ ] -+ -+ # XXX: Change compiler? -+ #compiler = 'cl' -+ -+ # XXX: This doesn't seem to work well -+ cxxflags += [ -+ #'-m32', -+ #'-target', 'x86_64-pc-mingw32', -+ ] -+ -+ sys.stderr.write('Include path:\n') -+ for include in includes: -+ sys.stderr.write(' %s\n' % include) -+ sys.stderr.write('Definitions:\n') -+ for define in defines: -+ sys.stderr.write(' %s\n' % define) -+ -+ import logging -+ utils.loggers.set_level(logging.DEBUG) -+ -+ # Find the location of the xml generator (castxml or gccxml) -+ generator_path, generator_name = utils.find_xml_generator("castxml") -+ -+ # Configure the xml generator -+ config = parser.xml_generator_configuration_t( -+ xml_generator_path=generator_path, -+ xml_generator=generator_name, -+ define_symbols = defines, -+ include_paths = includes, -+ cflags = ' '.join(cxxflags), -+ compiler = compiler, -+ #keep_xml = True, -+ ) -+ -+ script_dir = os.path.dirname(__file__) -+ headers = [ -+ os.path.join(script_dir, '..', '..', 'compat', 'winsdk_compat.h'), -+ os.path.join(script_dir, 'cxx2api.h'), -+ ] -+ main_header = args[0] -+ headers.append(main_header) -+ -+ decls = parser.parse(headers, config, parser.COMPILATION_MODE.ALL_AT_ONCE) -+ global_ns = declarations.get_global_namespace(decls) -+ -+ def decl_filter(decl): -+ location = decl.location -+ if location is None: -+ return False -+ return os.path.basename(location.file_name) in list(map(os.path.basename, args)) -+ -+ module, _ = os.path.splitext(main_header) -+ visitor = decl2_dumper_t(module) -+ visitor.start() -+ for decl in global_ns.declarations: -+ if not decl_filter(decl): -+ continue -+ -+ if sys.stdout.isatty(): -+ print('# ' + str(decl)) -+ -+ visitor.decl = decl -+ algorithm.apply_visitor(visitor, decl) -+ visitor.finish() -+ -+ -+if __name__ == '__main__': -+ main() -diff --git a/specs/scripts/spec2api.py b/specs/scripts/spec2api.py -index f21b08d5..7fb395a4 100755 ---- a/specs/scripts/spec2api.py -+++ b/specs/scripts/spec2api.py -@@ -181,8 +181,8 @@ class SpecParser(LineParser): - category = self.prefix.upper() + '_' + category - if category != self.category: - if self.category is not None: -- print -- print ' # %s' % category -+ print() -+ print(' # %s' % category) - self.category = category - - if self.prefix == 'wgl': -@@ -190,7 +190,7 @@ class SpecParser(LineParser): - else: - constructor = 'GlFunction' - -- print ' %s(%s, "%s", [%s]%s),' % (constructor, ret_type, function_name, ', '.join(args), extra) -+ print(' %s(%s, "%s", [%s]%s),' % (constructor, ret_type, function_name, ', '.join(args), extra)) - - array_re = re.compile(r'^array\s+\[(.*)\]$') - -diff --git a/specs/scripts/txt2api.py b/specs/scripts/txt2api.py -index 6cd99dd9..e9469d3c 100755 ---- a/specs/scripts/txt2api.py -+++ b/specs/scripts/txt2api.py -@@ -31,7 +31,7 @@ - import sys - import re - import optparse --from urllib2 import urlopen -+from urllib.request import urlopen - - - def stderr(x): -@@ -116,7 +116,7 @@ class TxtParser(LineParser): - self.consume() - line = self.consume() - self.parse_section(line) -- print -+ print() - - def parse_section(self, name): - if name == 'Name Strings': -@@ -136,7 +136,7 @@ class TxtParser(LineParser): - name = line.strip() - if name.startswith('EGL_'): - self.prefix = '' -- print ' # %s' % name -+ print(' # %s' % name) - - def skip_c_comments(self): - while not self.eof(): -@@ -192,7 +192,7 @@ class TxtParser(LineParser): - args.append(arg) - if self.tokens[0] == ',': - self.tokens.pop(0) -- print ' GlFunction(%s, "%s", [%s]%s),' % (ret, name, ', '.join(args), extra) -+ print(' GlFunction(%s, "%s", [%s]%s),' % (ret, name, ', '.join(args), extra)) - - def parse_arg(self): - type = self.parse_type() -diff --git a/specs/scripts/xml2api.py b/specs/scripts/xml2api.py -index e3820e09..f09fe0bf 100755 ---- a/specs/scripts/xml2api.py -+++ b/specs/scripts/xml2api.py -@@ -126,7 +126,7 @@ def processRequire(node, filterName): - - - def printPrototypes(prototypes, extensionName, functionNames, skip=set()): -- print ' # %s' % extensionName -+ print(' # %s' % extensionName) - - if extensionName == 'GL_EXT_direct_state_access': - functionNames.sort() -@@ -134,9 +134,9 @@ def printPrototypes(prototypes, extensionName, functionNames, skip=set()): - for functionName in functionNames: - if functionName not in skip: - prototype = prototypes[functionName] -- print ' %s,' % prototype -+ print(' %s,' % prototype) - -- print -+ print() - - - def main(): -diff --git a/specs/scripts/xml2enum.py b/specs/scripts/xml2enum.py -index 6d49e11c..cb2c4ae9 100755 ---- a/specs/scripts/xml2enum.py -+++ b/specs/scripts/xml2enum.py -@@ -58,8 +58,8 @@ for arg in sys.argv[1:]: - params.setdefault(value, name) - - -- values = params.keys() -+ values = list(params.keys()) - values.sort() - for value in values: - name = params[value] -- print ' "%s",\t\t# 0x%04X' % (name, value) -+ print(' "%s",\t\t# 0x%04X' % (name, value)) -diff --git a/specs/scripts/xml2glparams.py b/specs/scripts/xml2glparams.py -index 7e2bc351..805aac86 100755 ---- a/specs/scripts/xml2glparams.py -+++ b/specs/scripts/xml2glparams.py -@@ -58,8 +58,8 @@ for arg in sys.argv[1:]: - params.setdefault(value, name) - - -- values = params.keys() -+ values = list(params.keys()) - values.sort() - for value in values: - name = params[value] -- print ' ("",\tX,\t1,\t"%s"),\t# 0x%04X' % (name, value) -+ print(' ("",\tX,\t1,\t"%s"),\t# 0x%04X' % (name, value)) -diff --git a/specs/stdapi.py b/specs/stdapi.py -index c72c264b..487b6c1e 100644 ---- a/specs/stdapi.py -+++ b/specs/stdapi.py -@@ -26,7 +26,9 @@ - """C basic types""" - - --import debug -+import sys -+ -+from . import debug - - - class Type: -@@ -266,6 +268,10 @@ class Bitmask(Type): - Flags = Bitmask - - -+def EnumFlags(name, values): -+ return Flags(Alias(name, UInt), values) -+ -+ - class Array(Type): - - def __init__(self, type_, length): -@@ -273,7 +279,7 @@ class Array(Type): - self.type = type_ - self.length = length - if not isinstance(length, int): -- assert isinstance(length, basestring) -+ assert isinstance(length, str) - # Check if length is actually a valid constant expression - try: - eval(length, {}, {}) -@@ -329,6 +335,10 @@ class Struct(Type): - def visit(self, visitor, *args, **kwargs): - return visitor.visitStruct(self, *args, **kwargs) - -+ def getMemberByName(self, name): -+ memberNames = [memberName for memberType, memberName in self.members] -+ return memberNames.index(name) -+ - - def Union(kindExpr, kindTypes, contextLess=True): - switchTypes = [] -@@ -372,7 +382,7 @@ def InOut(type, name): - - class Function: - -- def __init__(self, type, name, args, call = '', fail = None, sideeffects=True, internal=False): -+ def __init__(self, type, name, args, call = '', fail = None, sideeffects=True, internal=False, overloaded=False): - self.type = type - self.name = name - -@@ -394,6 +404,7 @@ class Function: - self.fail = fail - self.sideeffects = sideeffects - self.internal = internal -+ self.overloaded = overloaded - - def prototype(self, name=None): - if name is not None: -@@ -414,6 +425,17 @@ class Function: - s += ")" - return s - -+ def sigName(self): -+ name = self.name -+ if self.overloaded: -+ # suffix used to make overloaded functions/methods unique -+ suffix = ','.join([str(arg.type) for arg in self.args]) -+ suffix = suffix.replace(' *', '*') -+ suffix = suffix.replace(' &', '&') -+ suffix = '(' + suffix + ')' -+ name += suffix -+ return name -+ - def argNames(self): - return [arg.name for arg in self.args] - -@@ -463,14 +485,12 @@ class Interface(Type): - yield method - for method in self.methods: - yield method -- raise StopIteration - - def iterBases(self): - iface = self - while iface is not None: - yield iface - iface = iface.base -- raise StopIteration - - def hasBase(self, *bases): - for iface in self.iterBases(): -@@ -484,14 +504,13 @@ class Interface(Type): - yield iface, method - for method in self.methods: - yield self, method -- raise StopIteration - - - class Method(Function): - -- def __init__(self, type, name, args, call = '', const=False, sideeffects=True): -+ def __init__(self, type, name, args, call = '', const=False, sideeffects=True, overloaded=False): - assert call == '__stdcall' -- Function.__init__(self, type, name, args, call = call, sideeffects=sideeffects) -+ Function.__init__(self, type, name, args, call = call, sideeffects=sideeffects, overloaded=overloaded) - for index in range(len(self.args)): - self.args[index].index = index + 1 - self.const = const -@@ -576,7 +595,7 @@ class Polymorphic(Type): - else: - cases[i].append(case) - -- return zip(cases, types) -+ return list(zip(cases, types)) - - - def EnumPolymorphic(enumName, switchExpr, switchTypes, defaultType, contextLess=True): -@@ -734,7 +753,7 @@ class Rebuilder(Visitor): - if pointer_type is pointer.type: - return pointer - else: -- return LinearPointer(pointer_type) -+ return LinearPointer(pointer_type, self.size) - - def visitReference(self, reference): - reference_type = self.visit(reference.type) -@@ -792,7 +811,7 @@ class MutableRebuilder(Rebuilder): - - def visitReference(self, reference): - # Strip out references -- return reference.type -+ return self.visit(reference.type) - - - class Traverser(Visitor): -@@ -894,7 +913,7 @@ class ExpanderMixin: - - def expand(self, expr): - # Expand a C expression, replacing certain variables -- if not isinstance(expr, basestring): -+ if not isinstance(expr, str): - return expr - variables = {} - -diff --git a/specs/wglapi.py b/specs/wglapi.py -index f24a8d21..563f0269 100644 ---- a/specs/wglapi.py -+++ b/specs/wglapi.py -@@ -27,9 +27,9 @@ - """WGL API description""" - - --from glapi import * --from winapi import * --from wglenum import * -+from .glapi import * -+from .winapi import * -+from .wglenum import * - - - wglapi = Module("WGL") -diff --git a/specs/wglenum.py b/specs/wglenum.py -index ad9bbccf..6bc4e74d 100644 ---- a/specs/wglenum.py -+++ b/specs/wglenum.py -@@ -27,7 +27,7 @@ - """WGL enum description""" - - --from stdapi import * -+from .stdapi import * - - WGLenum = FakeEnum(Int, [ - "WGL_GPU_VENDOR_AMD", # 0x1F00 -diff --git a/specs/winapi.py b/specs/winapi.py -index 445039ff..e66d063a 100644 ---- a/specs/winapi.py -+++ b/specs/winapi.py -@@ -26,7 +26,7 @@ - """Win32 API type description.""" - - --from stdapi import * -+from .stdapi import * - - - SHORT = Alias("SHORT", Short) -diff --git a/wrappers/CMakeLists.txt b/wrappers/CMakeLists.txt -index 2ceac332..7a452ed4 100644 ---- a/wrappers/CMakeLists.txt -+++ b/wrappers/CMakeLists.txt -@@ -79,7 +79,7 @@ if (WIN32) - include_directories (BEFORE SYSTEM ${DirectX_D3D_INCLUDE_DIR}) - add_custom_command ( - OUTPUT ddrawtrace.cpp -- COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/ddrawtrace.py > ${CMAKE_CURRENT_BINARY_DIR}/ddrawtrace.cpp -+ COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/ddrawtrace.py > ${CMAKE_CURRENT_BINARY_DIR}/ddrawtrace.cpp - DEPENDS - ddrawtrace.py - dlltrace.py -@@ -109,7 +109,7 @@ if (WIN32) - include_directories (BEFORE SYSTEM ${DirectX_D3D9_INCLUDE_DIR} ${DirectX_D3D8_INCLUDE_DIR}) - add_custom_command ( - OUTPUT d3d8trace.cpp -- COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d8trace.py > ${CMAKE_CURRENT_BINARY_DIR}/d3d8trace.cpp -+ COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d8trace.py > ${CMAKE_CURRENT_BINARY_DIR}/d3d8trace.cpp - DEPENDS - d3d8trace.py - dlltrace.py -@@ -143,7 +143,7 @@ if (WIN32) - include_directories (BEFORE SYSTEM ${DirectX_D3D9_INCLUDE_DIR}) - add_custom_command ( - OUTPUT d3d9trace.cpp -- COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d9trace.py > ${CMAKE_CURRENT_BINARY_DIR}/d3d9trace.cpp -+ COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d9trace.py > ${CMAKE_CURRENT_BINARY_DIR}/d3d9trace.cpp - DEPENDS - d3d9trace.py - dlltrace.py -@@ -179,7 +179,7 @@ if (WIN32) - - add_custom_command ( - OUTPUT dxgitrace.cpp -- COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/dxgitrace.py > ${CMAKE_CURRENT_BINARY_DIR}/dxgitrace.cpp -+ COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/dxgitrace.py > ${CMAKE_CURRENT_BINARY_DIR}/dxgitrace.cpp - DEPENDS - dxgitrace.py - dlltrace.py -@@ -216,7 +216,7 @@ if (WIN32) - - add_custom_command ( - OUTPUT d2d1trace.cpp -- COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d2d1trace.py > ${CMAKE_CURRENT_BINARY_DIR}/d2d1trace.cpp -+ COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d2d1trace.py > ${CMAKE_CURRENT_BINARY_DIR}/d2d1trace.cpp - DEPENDS - d2d1trace.py - trace.py -@@ -241,7 +241,7 @@ if (WIN32) - # opengl32.dll - add_custom_command ( - OUTPUT wgltrace.cpp -- COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/wgltrace.py > ${CMAKE_CURRENT_BINARY_DIR}/wgltrace.cpp -+ COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/wgltrace.py > ${CMAKE_CURRENT_BINARY_DIR}/wgltrace.cpp - DEPENDS - wgltrace.py - gltrace.py -@@ -278,7 +278,7 @@ elseif (APPLE) - # OpenGL framework - add_custom_command ( - OUTPUT cgltrace.cpp -- COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/cgltrace.py > ${CMAKE_CURRENT_BINARY_DIR}/cgltrace.cpp -+ COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/cgltrace.py > ${CMAKE_CURRENT_BINARY_DIR}/cgltrace.cpp - DEPENDS - cgltrace.py - gltrace.py -@@ -322,7 +322,7 @@ elseif (X11_FOUND) - # libGL.so - add_custom_command ( - OUTPUT glxtrace.cpp -- COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/glxtrace.py > ${CMAKE_CURRENT_BINARY_DIR}/glxtrace.cpp -+ COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/glxtrace.py > ${CMAKE_CURRENT_BINARY_DIR}/glxtrace.cpp - DEPENDS - glxtrace.py - gltrace.py -@@ -372,7 +372,7 @@ if (ENABLE_EGL AND NOT WIN32 AND NOT APPLE) - # libEGL.so/libGL.so - add_custom_command ( - OUTPUT egltrace.cpp -- COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/egltrace.py > ${CMAKE_CURRENT_BINARY_DIR}/egltrace.cpp -+ COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/egltrace.py > ${CMAKE_CURRENT_BINARY_DIR}/egltrace.cpp - DEPENDS - egltrace.py - gltrace.py -diff --git a/wrappers/cgltrace.py b/wrappers/cgltrace.py -index 6c72f696..02b3c518 100644 ---- a/wrappers/cgltrace.py -+++ b/wrappers/cgltrace.py -@@ -43,55 +43,55 @@ class CglTracer(GlTracer): - if function.name == 'CGLReleaseContext': - # Unlike other GL APIs like EGL or GLX, CGL will make the context - # not current if it's the current context. -- print ' if (_CGLGetContextRetainCount(ctx) == 1) {' -- print ' if (gltrace::releaseContext((uintptr_t)ctx)) {' -- print ' if (_CGLGetCurrentContext() == ctx) {' -- print ' gltrace::clearContext();' -- print ' }' -- print ' }' -- print ' }' -+ print(' if (_CGLGetContextRetainCount(ctx) == 1) {') -+ print(' if (gltrace::releaseContext((uintptr_t)ctx)) {') -+ print(' if (_CGLGetCurrentContext() == ctx) {') -+ print(' gltrace::clearContext();') -+ print(' }') -+ print(' }') -+ print(' }') - - if function.name == 'CGLDestroyContext': - # The same rule applies here about the as for CGLReleaseContext. -- print ' if (gltrace::releaseContext((uintptr_t)ctx)) {' -- print ' if (_CGLGetCurrentContext() == ctx) {' -- print ' gltrace::clearContext();' -- print ' }' -- print ' }' -+ print(' if (gltrace::releaseContext((uintptr_t)ctx)) {') -+ print(' if (_CGLGetCurrentContext() == ctx) {') -+ print(' gltrace::clearContext();') -+ print(' }') -+ print(' }') - - GlTracer.traceFunctionImplBody(self, function) - - if function.name == 'CGLCreateContext': -- print ' if (_result == kCGLNoError) {' -- print ' gltrace::createContext((uintptr_t)*ctx);' -- print ' }' -+ print(' if (_result == kCGLNoError) {') -+ print(' gltrace::createContext((uintptr_t)*ctx);') -+ print(' }') - - if function.name == 'CGLSetCurrentContext': -- print ' if (_result == kCGLNoError) {' -- print ' if (ctx != NULL) {' -- print ' gltrace::setContext((uintptr_t)ctx);' -- print ' } else {' -- print ' gltrace::clearContext();' -- print ' }' -- print ' }' -+ print(' if (_result == kCGLNoError) {') -+ print(' if (ctx != NULL) {') -+ print(' gltrace::setContext((uintptr_t)ctx);') -+ print(' } else {') -+ print(' gltrace::clearContext();') -+ print(' }') -+ print(' }') - - if function.name == 'CGLRetainContext': -- print ' gltrace::retainContext((uintptr_t)ctx);' -+ print(' gltrace::retainContext((uintptr_t)ctx);') - - - if __name__ == '__main__': -- print -- print '#include <stdlib.h>' -- print '#include <string.h>' -- print -- print '#include "trace_writer_local.hpp"' -- print -- print '// To validate our prototypes' -- print '#define GL_GLEXT_PROTOTYPES' -- print -- print '#include "glproc.hpp"' -- print '#include "glsize.hpp"' -- print -+ print() -+ print('#include <stdlib.h>') -+ print('#include <string.h>') -+ print() -+ print('#include "trace_writer_local.hpp"') -+ print() -+ print('// To validate our prototypes') -+ print('#define GL_GLEXT_PROTOTYPES') -+ print() -+ print('#include "glproc.hpp"') -+ print('#include "glsize.hpp"') -+ print() - - module = Module() - module.mergeModule(cglapi) -@@ -101,7 +101,7 @@ if __name__ == '__main__': - tracer = CglTracer() - tracer.traceApi(api) - -- print r''' -+ print(r''' - - PUBLIC - void * gll_noop = 0; -@@ -130,4 +130,4 @@ _init(void) { - setenv("SDL_OPENGL_LIBRARY", "/System/Library/Frameworks/OpenGL.framework/OpenGL", 1); - } - --''' -+''') -diff --git a/wrappers/d2d1trace.py b/wrappers/d2d1trace.py -index 26223005..2176341f 100644 ---- a/wrappers/d2d1trace.py -+++ b/wrappers/d2d1trace.py -@@ -31,15 +31,15 @@ from specs.d2d1 import d2d1 - - - if __name__ == '__main__': -- print '#include "guids_defs.hpp"' -- print -- print '#include "trace_writer_local.hpp"' -- print '#include "os.hpp"' -- print -- print '#define DWRITE_EXPORT WINAPI' -- print -- print '#include "d2dimports.hpp"' -- print -+ print('#include "guids_defs.hpp"') -+ print() -+ print('#include "trace_writer_local.hpp"') -+ print('#include "os.hpp"') -+ print() -+ print('#define DWRITE_EXPORT WINAPI') -+ print() -+ print('#include "d2dimports.hpp"') -+ print() - - api = API() - api.addModule(d2d1) -diff --git a/wrappers/d3d8trace.py b/wrappers/d3d8trace.py -index 2903c48f..11afbca5 100644 ---- a/wrappers/d3d8trace.py -+++ b/wrappers/d3d8trace.py -@@ -34,7 +34,7 @@ class D3D8Tracer(DllTracer): - def serializeArgValue(self, function, arg): - # Dump shaders as strings - if arg.type is D3DSHADER8: -- print ' DumpShader(trace::localWriter, %s);' % (arg.name) -+ print(' DumpShader(trace::localWriter, %s);' % (arg.name)) - return - - DllTracer.serializeArgValue(self, function, arg) -@@ -55,32 +55,32 @@ class D3D8Tracer(DllTracer): - - def implementWrapperInterfaceMethodBody(self, interface, base, method): - if method.name in ('Unlock', 'UnlockRect', 'UnlockBox'): -- print ' if (_MappedSize && m_pbData) {' -+ print(' if (_MappedSize && m_pbData) {') - self.emit_memcpy('(LPBYTE)m_pbData', '_MappedSize') -- print ' }' -+ print(' }') - - DllTracer.implementWrapperInterfaceMethodBody(self, interface, base, method) - - if method.name in ('Lock', 'LockRect', 'LockBox'): - # FIXME: handle recursive locks -- print ' if (SUCCEEDED(_result) && !(Flags & D3DLOCK_READONLY)) {' -- print ' _getMapInfo(_this, %s, m_pbData, _MappedSize);' % ', '.join(method.argNames()[:-1]) -- print ' } else {' -- print ' m_pbData = NULL;' -- print ' _MappedSize = 0;' -- print ' }' -+ print(' if (SUCCEEDED(_result) && !(Flags & D3DLOCK_READONLY)) {') -+ print(' _getMapInfo(_this, %s, m_pbData, _MappedSize);' % ', '.join(method.argNames()[:-1])) -+ print(' } else {') -+ print(' m_pbData = NULL;') -+ print(' _MappedSize = 0;') -+ print(' }') - - - if __name__ == '__main__': -- print '#define INITGUID' -- print -- print '#include "trace_writer_local.hpp"' -- print '#include "os.hpp"' -- print -- print '#include "d3d8imports.hpp"' -- print '#include "d3d8size.hpp"' -- print '#include "d3d9shader.hpp"' -- print -+ print('#define INITGUID') -+ print() -+ print('#include "trace_writer_local.hpp"') -+ print('#include "os.hpp"') -+ print() -+ print('#include "d3d8imports.hpp"') -+ print('#include "d3d8size.hpp"') -+ print('#include "d3d9shader.hpp"') -+ print() - - api = API() - api.addModule(d3d8) -diff --git a/wrappers/d3d9trace.py b/wrappers/d3d9trace.py -index 0850ba3e..53d5152f 100644 ---- a/wrappers/d3d9trace.py -+++ b/wrappers/d3d9trace.py -@@ -35,7 +35,7 @@ class D3D9Tracer(DllTracer): - def serializeArgValue(self, function, arg): - # Dump shaders as strings - if arg.type is D3DSHADER9: -- print ' DumpShader(trace::localWriter, %s);' % (arg.name) -+ print(' DumpShader(trace::localWriter, %s);' % (arg.name)) - return - - DllTracer.serializeArgValue(self, function, arg) -@@ -72,49 +72,49 @@ class D3D9Tracer(DllTracer): - def implementWrapperInterfaceMethodBody(self, interface, base, method): - if method.name in ('Unlock', 'UnlockRect', 'UnlockBox'): - if interface.name in ['IDirect3DTexture9']: -- print ' std::map<UINT, std::pair<size_t, VOID *> >::iterator it = _MappedData.find(Level);' -- print ' if (it != _MappedData.end()) {' -+ print(' std::map<UINT, std::pair<size_t, VOID *> >::iterator it = _MappedData.find(Level);') -+ print(' if (it != _MappedData.end()) {') - self.emit_memcpy('(LPBYTE)it->second.second', 'it->second.first') -- print ' _MappedData.erase(it);' -- print ' }' -+ print(' _MappedData.erase(it);') -+ print(' }') - else: -- print ' if (_MappedSize && m_pbData) {' -+ print(' if (_MappedSize && m_pbData) {') - self.emit_memcpy('(LPBYTE)m_pbData', '_MappedSize') -- print ' }' -+ print(' }') - - DllTracer.implementWrapperInterfaceMethodBody(self, interface, base, method) - - if method.name in ('Lock', 'LockRect', 'LockBox'): - if interface.name in ['IDirect3DTexture9']: -- print ' if (SUCCEEDED(_result) && !(Flags & D3DLOCK_READONLY)) {' -- print ' size_t mappedSize;' -- print ' VOID * pbData;' -- print ' _getMapInfo(_this, %s, pbData, mappedSize);' % ', '.join(method.argNames()[:-1]) -- print ' _MappedData[Level] = std::make_pair(mappedSize, pbData);' -- print ' } else {' -- print ' _MappedData.erase(Level);' -- print ' }' -+ print(' if (SUCCEEDED(_result) && !(Flags & D3DLOCK_READONLY)) {') -+ print(' size_t mappedSize;') -+ print(' VOID * pbData;') -+ print(' _getMapInfo(_this, %s, pbData, mappedSize);' % ', '.join(method.argNames()[:-1])) -+ print(' _MappedData[Level] = std::make_pair(mappedSize, pbData);') -+ print(' } else {') -+ print(' _MappedData.erase(Level);') -+ print(' }') - else: - # FIXME: handle recursive locks -- print ' if (SUCCEEDED(_result) && !(Flags & D3DLOCK_READONLY)) {' -- print ' _getMapInfo(_this, %s, m_pbData, _MappedSize);' % ', '.join(method.argNames()[:-1]) -- print ' } else {' -- print ' m_pbData = NULL;' -- print ' _MappedSize = 0;' -- print ' }' -+ print(' if (SUCCEEDED(_result) && !(Flags & D3DLOCK_READONLY)) {') -+ print(' _getMapInfo(_this, %s, m_pbData, _MappedSize);' % ', '.join(method.argNames()[:-1])) -+ print(' } else {') -+ print(' m_pbData = NULL;') -+ print(' _MappedSize = 0;') -+ print(' }') - - - if __name__ == '__main__': -- print '#define INITGUID' -- print -- print '#include "trace_writer_local.hpp"' -- print '#include "os.hpp"' -- print -- print '#include "d3d9imports.hpp"' -- print '#include "d3d9size.hpp"' -- print '#include "d3d9shader.hpp"' -- print '#include "dxva2imports.hpp"' -- print -+ print('#define INITGUID') -+ print() -+ print('#include "trace_writer_local.hpp"') -+ print('#include "os.hpp"') -+ print() -+ print('#include "d3d9imports.hpp"') -+ print('#include "d3d9size.hpp"') -+ print('#include "d3d9shader.hpp"') -+ print('#include "dxva2imports.hpp"') -+ print() - - d3d9.mergeModule(d3dperf) - -diff --git a/wrappers/ddrawtrace.py b/wrappers/ddrawtrace.py -index 96602d21..da7ffbe7 100644 ---- a/wrappers/ddrawtrace.py -+++ b/wrappers/ddrawtrace.py -@@ -41,12 +41,12 @@ class DDrawTracer(DllTracer): - - - if __name__ == '__main__': -- print '#define INITGUID' -- print '#include "d3dimports.hpp"' -- print '#include "trace_writer_local.hpp"' -- print '#include "d3d7size.hpp"' -- print '#include "os.hpp"' -- print -+ print('#define INITGUID') -+ print('#include "d3dimports.hpp"') -+ print('#include "trace_writer_local.hpp"') -+ print('#include "d3d7size.hpp"') -+ print('#include "os.hpp"') -+ print() - - api = API() - api.addModule(ddraw) -diff --git a/wrappers/dlltrace.py b/wrappers/dlltrace.py -index 26962216..8ac18b0c 100644 ---- a/wrappers/dlltrace.py -+++ b/wrappers/dlltrace.py -@@ -37,24 +37,24 @@ class DllDispatcher(Dispatcher): - - def dispatchModule(self, module): - tag = module.name.upper() -- print r'HMODULE g_h%sModule = NULL;' % (tag,) -- print r'' -- print r'static PROC' -- print r'_get%sProcAddress(LPCSTR lpProcName) {' % tag -- print r' if (!g_h%sModule) {' % tag -- print r' char szDll[MAX_PATH] = {0};' -- print r' if (!GetSystemDirectoryA(szDll, MAX_PATH)) {' -- print r' return NULL;' -- print r' }' -- print r' strcat(szDll, "\\%s.dll");' % module.name -- print r' g_h%sModule = LoadLibraryA(szDll);' % tag -- print r' if (!g_h%sModule) {' % tag -- print r' return NULL;' -- print r' }' -- print r' }' -- print r' return GetProcAddress(g_h%sModule, lpProcName);' % tag -- print r'}' -- print r'' -+ print(r'HMODULE g_h%sModule = NULL;' % (tag,)) -+ print(r'') -+ print(r'static PROC') -+ print(r'_get%sProcAddress(LPCSTR lpProcName) {' % tag) -+ print(r' if (!g_h%sModule) {' % tag) -+ print(r' char szDll[MAX_PATH] = {0};') -+ print(r' if (!GetSystemDirectoryA(szDll, MAX_PATH)) {') -+ print(r' return NULL;') -+ print(r' }') -+ print(r' strcat(szDll, "\\%s.dll");' % module.name) -+ print(r' g_h%sModule = LoadLibraryA(szDll);' % tag) -+ print(r' if (!g_h%sModule) {' % tag) -+ print(r' return NULL;') -+ print(r' }') -+ print(r' }') -+ print(r' return GetProcAddress(g_h%sModule, lpProcName);' % tag) -+ print(r'}') -+ print(r'') - - Dispatcher.dispatchModule(self, module) - -diff --git a/wrappers/dxgitrace.py b/wrappers/dxgitrace.py -index 3edda2c2..134f45d7 100644 ---- a/wrappers/dxgitrace.py -+++ b/wrappers/dxgitrace.py -@@ -40,47 +40,47 @@ class D3DCommonTracer(DllTracer): - def serializeArgValue(self, function, arg): - # Dump shaders as strings - if isinstance(arg.type, stdapi.Blob) and arg.name.startswith('pShaderBytecode'): -- print ' DumpShader(trace::localWriter, %s, %s);' % (arg.name, arg.type.size) -+ print(' DumpShader(trace::localWriter, %s, %s);' % (arg.name, arg.type.size)) - return - - # Serialize the swapchain dimensions - if function.name == 'CreateSwapChain' and arg.name == 'pDesc' \ - or arg.name == 'pSwapChainDesc': -- print r' DXGI_SWAP_CHAIN_DESC *_pSwapChainDesc = NULL;' -- print r' DXGI_SWAP_CHAIN_DESC _SwapChainDesc;' -- print r' if (%s) {' % arg.name -- print r' _SwapChainDesc = *%s;' % arg.name -+ print(r' DXGI_SWAP_CHAIN_DESC *_pSwapChainDesc = NULL;') -+ print(r' DXGI_SWAP_CHAIN_DESC _SwapChainDesc;') -+ print(r' if (%s) {' % arg.name) -+ print(r' _SwapChainDesc = *%s;' % arg.name) - if function.name != 'CreateSwapChain' or not self.interface.name.endswith('DWM'): - # Obtain size from the window -- print r' RECT _rect;' -- print r' if (GetClientRect(%s->OutputWindow, &_rect)) {' % arg.name -- print r' if (%s->BufferDesc.Width == 0) {' % arg.name -- print r' _SwapChainDesc.BufferDesc.Width = _rect.right - _rect.left;' -- print r' }' -- print r' if (%s->BufferDesc.Height == 0) {' % arg.name -- print r' _SwapChainDesc.BufferDesc.Height = _rect.bottom - _rect.top;' -- print r' }' -- print r' }' -+ print(r' RECT _rect;') -+ print(r' if (GetClientRect(%s->OutputWindow, &_rect)) {' % arg.name) -+ print(r' if (%s->BufferDesc.Width == 0) {' % arg.name) -+ print(r' _SwapChainDesc.BufferDesc.Width = _rect.right - _rect.left;') -+ print(r' }') -+ print(r' if (%s->BufferDesc.Height == 0) {' % arg.name) -+ print(r' _SwapChainDesc.BufferDesc.Height = _rect.bottom - _rect.top;') -+ print(r' }') -+ print(r' }') - else: - # Obtain size from the output -- print r' DXGI_OUTPUT_DESC _OutputDesc;' -- print r' if (SUCCEEDED(pOutput->GetDesc(&_OutputDesc))) {' -- print r' _SwapChainDesc.BufferDesc.Width = _OutputDesc.DesktopCoordinates.right - _OutputDesc.DesktopCoordinates.left;' -- print r' _SwapChainDesc.BufferDesc.Height = _OutputDesc.DesktopCoordinates.bottom - _OutputDesc.DesktopCoordinates.top;' -- print r' }' -- print r' _pSwapChainDesc = &_SwapChainDesc;' -- print r' }' -+ print(r' DXGI_OUTPUT_DESC _OutputDesc;') -+ print(r' if (SUCCEEDED(pOutput->GetDesc(&_OutputDesc))) {') -+ print(r' _SwapChainDesc.BufferDesc.Width = _OutputDesc.DesktopCoordinates.right - _OutputDesc.DesktopCoordinates.left;') -+ print(r' _SwapChainDesc.BufferDesc.Height = _OutputDesc.DesktopCoordinates.bottom - _OutputDesc.DesktopCoordinates.top;') -+ print(r' }') -+ print(r' _pSwapChainDesc = &_SwapChainDesc;') -+ print(r' }') - self.serializeValue(arg.type, '_pSwapChainDesc') - return - - # Serialize object names - if function.name == 'SetPrivateData' and arg.name == 'pData': - iid = function.args[0].name -- print r' if (%s == WKPDID_D3DDebugObjectName) {' % iid -- print r' trace::localWriter.writeString(static_cast<const char *>(pData), DataSize);' -- print r' } else {' -+ print(r' if (%s == WKPDID_D3DDebugObjectName) {' % iid) -+ print(r' trace::localWriter.writeString(static_cast<const char *>(pData), DataSize);') -+ print(r' } else {') - DllTracer.serializeArgValue(self, function, arg) -- print r' }' -+ print(r' }') - return - - DllTracer.serializeArgValue(self, function, arg) -@@ -110,47 +110,47 @@ class D3DCommonTracer(DllTracer): - if method.getArgByName('pInitialData'): - pDesc1 = method.getArgByName('pDesc1') - if pDesc1 is not None: -- print r' %s pDesc = pDesc1;' % (pDesc1.type,) -+ print(r' %s pDesc = pDesc1;' % (pDesc1.type,)) - - if method.name in ('Map', 'Unmap'): - # On D3D11 Map/Unmap is not a resource method, but a context method instead. - resourceArg = method.getArgByName('pResource') - if resourceArg is None: -- print ' _MAP_DESC & _MapDesc = m_MapDesc;' -+ print(' _MAP_DESC & _MapDesc = m_MapDesc;') - else: -- print ' _MAP_DESC & _MapDesc = m_MapDescs[std::pair<%s, UINT>(pResource, Subresource)];' % resourceArg.type -+ print(' _MAP_DESC & _MapDesc = m_MapDescs[std::pair<%s, UINT>(pResource, Subresource)];' % resourceArg.type) - - if method.name == 'Unmap': -- print ' if (_MapDesc.Size && _MapDesc.pData) {' -+ print(' if (_MapDesc.Size && _MapDesc.pData) {') - self.emit_memcpy('_MapDesc.pData', '_MapDesc.Size') -- print ' }' -+ print(' }') - - DllTracer.implementWrapperInterfaceMethodBody(self, interface, base, method) - - if method.name == 'Map': - # NOTE: recursive locks are explicitely forbidden -- print ' if (SUCCEEDED(_result)) {' -- print ' _getMapDesc(_this, %s, _MapDesc);' % ', '.join(method.argNames()) -- print ' } else {' -- print ' _MapDesc.pData = NULL;' -- print ' _MapDesc.Size = 0;' -- print ' }' -+ print(' if (SUCCEEDED(_result)) {') -+ print(' _getMapDesc(_this, %s, _MapDesc);' % ', '.join(method.argNames())) -+ print(' } else {') -+ print(' _MapDesc.pData = NULL;') -+ print(' _MapDesc.Size = 0;') -+ print(' }') - - - if __name__ == '__main__': -- print r'#define INITGUID' -- print -- print r'#include "trace_writer_local.hpp"' -- print r'#include "os.hpp"' -- print -- print r'#include "d3dcommonshader.hpp"' -- print -- print r'#include "d3d10imports.hpp"' -- print r'#include "d3d10size.hpp"' -- print r'#include "d3d11imports.hpp"' -- print r'#include "d3d11size.hpp"' -- print r'#include "d3d9imports.hpp" // D3DPERF_*' -- print -+ print(r'#define INITGUID') -+ print() -+ print(r'#include "trace_writer_local.hpp"') -+ print(r'#include "os.hpp"') -+ print() -+ print(r'#include "d3dcommonshader.hpp"') -+ print() -+ print(r'#include "d3d10imports.hpp"') -+ print(r'#include "d3d10size.hpp"') -+ print(r'#include "d3d11imports.hpp"') -+ print(r'#include "d3d11size.hpp"') -+ print(r'#include "d3d9imports.hpp" // D3DPERF_*') -+ print() - - api = API() - api.addModule(dxgi.dxgi) -diff --git a/wrappers/egltrace.py b/wrappers/egltrace.py -index 1fcb0fd6..f5b61c0c 100644 ---- a/wrappers/egltrace.py -+++ b/wrappers/egltrace.py -@@ -50,239 +50,239 @@ class EglTracer(GlTracer): - - def traceFunctionImplBody(self, function): - if function.name == 'glTexDirectMapVIV': -- print ' // prevent loop call' -- print ' glTexDirectVIVMap(target, width, height, format, Logical, Physical);' -+ print(' // prevent loop call') -+ print(' glTexDirectVIVMap(target, width, height, format, Logical, Physical);') - return - - if function.name == 'glTexDirectInvalidateVIV': -- print ' // get current texture' -- print ' GLint tex = 0;' -- print ' int32_t size = 0;' -- print ' int32_t ysize = 0;' -- print ' int32_t usize = 0;' -- print ' int32_t vsize = 0;' -- print ' _glGetIntegerv(GL_TEXTURE_BINDING_2D, &tex);' -- print ' if(tex == 0)' -- print ' {' -- print ' return;' -- print ' }' -- print ' TEXDIRECTVIVDATA &data = _directTextureDataMap[tex];' -- print ' switch(data.format){' -- print ' case GL_VIV_YV12:' -- print ' case GL_VIV_I420:' -- print ' ysize=data.width * data.height;' -- print ' usize=ysize/4;' -- print ' vsize=usize;' -- print ' break;' -- print ' case GL_VIV_NV12:' -- print ' case GL_VIV_NV21:' -- print ' ysize=data.width * data.height;' -- print ' usize=ysize/2;' -- print ' vsize=0;' -- print ' break;' -- print ' case GL_RGBA:' -- print ' case GL_BGRA_EXT:' -- print ' ysize=data.width * data.height *4;' -- print ' usize=0;' -- print ' vsize=0;' -- print ' break;' -- print ' case GL_RGB:' -- print ' ysize=data.width * data.height *3;' -- print ' usize=0;' -- print ' vsize=0;' -- print ' break;' -- print ' case GL_VIV_YUY2:' -- print ' case GL_VIV_UYVY:' -- print ' case GL_RGB565_OES:' -- print ' case GL_LUMINANCE8_ALPHA8_EXT:' -- print ' ysize=data.width * data.height *2;' -- print ' usize=0;' -- print ' vsize=0;' -- print ' break;' -- print ' case GL_ALPHA:' -- print ' ysize=data.width * data.height;' -- print ' usize=0;' -- print ' vsize=0;' -- print ' break;' -- print ' default:' -- print ' return;' -- print ' }' -- print ' if (NULL==(GLvoid*)data.logical) {' -- print ' if (ysize > 0) {' -+ print(' // get current texture') -+ print(' GLint tex = 0;') -+ print(' int32_t size = 0;') -+ print(' int32_t ysize = 0;') -+ print(' int32_t usize = 0;') -+ print(' int32_t vsize = 0;') -+ print(' _glGetIntegerv(GL_TEXTURE_BINDING_2D, &tex);') -+ print(' if(tex == 0)') -+ print(' {') -+ print(' return;') -+ print(' }') -+ print(' TEXDIRECTVIVDATA &data = _directTextureDataMap[tex];') -+ print(' switch(data.format){') -+ print(' case GL_VIV_YV12:') -+ print(' case GL_VIV_I420:') -+ print(' ysize=data.width * data.height;') -+ print(' usize=ysize/4;') -+ print(' vsize=usize;') -+ print(' break;') -+ print(' case GL_VIV_NV12:') -+ print(' case GL_VIV_NV21:') -+ print(' ysize=data.width * data.height;') -+ print(' usize=ysize/2;') -+ print(' vsize=0;') -+ print(' break;') -+ print(' case GL_RGBA:') -+ print(' case GL_BGRA_EXT:') -+ print(' ysize=data.width * data.height *4;') -+ print(' usize=0;') -+ print(' vsize=0;') -+ print(' break;') -+ print(' case GL_RGB:') -+ print(' ysize=data.width * data.height *3;') -+ print(' usize=0;') -+ print(' vsize=0;') -+ print(' break;') -+ print(' case GL_VIV_YUY2:') -+ print(' case GL_VIV_UYVY:') -+ print(' case GL_RGB565_OES:') -+ print(' case GL_LUMINANCE8_ALPHA8_EXT:') -+ print(' ysize=data.width * data.height *2;') -+ print(' usize=0;') -+ print(' vsize=0;') -+ print(' break;') -+ print(' case GL_ALPHA:') -+ print(' ysize=data.width * data.height;') -+ print(' usize=0;') -+ print(' vsize=0;') -+ print(' break;') -+ print(' default:') -+ print(' return;') -+ print(' }') -+ print(' if (NULL==(GLvoid*)data.logical) {') -+ print(' if (ysize > 0) {') - self.emit_memcpy_opt('(GLvoid*)data.planes[0]', 'ysize') -- print ' }' -- print ' if (usize > 0) {' -+ print(' }') -+ print(' if (usize > 0) {') - self.emit_memcpy_opt('(GLvoid*)data.planes[1]', 'usize') -- print ' }' -- print ' if (vsize > 0) {' -+ print(' }') -+ print(' if (vsize > 0) {') - self.emit_memcpy_opt('(GLvoid*)data.planes[2]', 'vsize') -- print ' }' -- print ' } else {' -- print ' size = ysize + usize + vsize;' -- print ' if (size > 0) {' -+ print(' }') -+ print(' } else {') -+ print(' size = ysize + usize + vsize;') -+ print(' if (size > 0) {') - self.emit_memcpy_opt('(GLvoid*)data.logical', 'size') -- print ' }' -- print ' }' -+ print(' }') -+ print(' }') - - if function.name == 'eglGetProcAddress': -- print ' procname = __get_alias_func_name(procname);' -+ print(' procname = __get_alias_func_name(procname);') - - GlTracer.traceFunctionImplBody(self, function) - - if function.name == 'glTexDirectVIV': -- print ' // get current texture' -- print ' GLint tex = 0;' -- print ' _glGetIntegerv(GL_TEXTURE_BINDING_2D, &tex);' -- print ' if(tex != 0)' -- print ' {' -- print ' TEXDIRECTVIVDATA &data = _directTextureDataMap[tex];' -- print ' data.width = width;' -- print ' data.height = height;' -- print ' data.format = format;' -- print ' data.planes[0] = pixels[0];' -- print ' data.planes[1] = pixels[1];' -- print ' data.planes[2] = pixels[2];' -- print ' }' -+ print(' // get current texture') -+ print(' GLint tex = 0;') -+ print(' _glGetIntegerv(GL_TEXTURE_BINDING_2D, &tex);') -+ print(' if(tex != 0)') -+ print(' {') -+ print(' TEXDIRECTVIVDATA &data = _directTextureDataMap[tex];') -+ print(' data.width = width;') -+ print(' data.height = height;') -+ print(' data.format = format;') -+ print(' data.planes[0] = pixels[0];') -+ print(' data.planes[1] = pixels[1];') -+ print(' data.planes[2] = pixels[2];') -+ print(' }') - - if function.name == 'glTexDirectVIVMap' or function.name == 'glTexDirectTiledMapVIV': -- print ' // get current texture' -- print ' GLint tex = 0;' -- print ' _glGetIntegerv(GL_TEXTURE_BINDING_2D, &tex);' -- print ' if(tex != 0)' -- print ' {' -- print ' TEXDIRECTVIVDATA &data = _directTextureDataMap[tex];' -- print ' data.width = width;' -- print ' data.height = height;' -- print ' data.format = format;' -- print ' data.logical = *Logical; // Logical != NULL' -- print ' data.physical = *Physical;' -- print ' }' -+ print(' // get current texture') -+ print(' GLint tex = 0;') -+ print(' _glGetIntegerv(GL_TEXTURE_BINDING_2D, &tex);') -+ print(' if(tex != 0)') -+ print(' {') -+ print(' TEXDIRECTVIVDATA &data = _directTextureDataMap[tex];') -+ print(' data.width = width;') -+ print(' data.height = height;') -+ print(' data.format = format;') -+ print(' data.logical = *Logical; // Logical != NULL') -+ print(' data.physical = *Physical;') -+ print(' }') - - if function.name == 'eglCreateContext': -- print ' if (_result != EGL_NO_CONTEXT)' -- print ' gltrace::createContext((uintptr_t)_result);' -+ print(' if (_result != EGL_NO_CONTEXT)') -+ print(' gltrace::createContext((uintptr_t)_result);') - - if function.name == 'eglMakeCurrent': -- print r' if (_result) {' -- print r' // update the profile' -- print r' if (ctx != EGL_NO_CONTEXT) {' -- print r' gltrace::setContext((uintptr_t)ctx);' -- print r' gltrace::Context *tr = gltrace::getContext();' -- print r' EGLint api = EGL_OPENGL_ES_API;' -- print r' _eglQueryContext(dpy, ctx, EGL_CONTEXT_CLIENT_TYPE, &api);' -- print r' if (api == EGL_OPENGL_API) {' -- print r' assert(tr->profile.api == glprofile::API_GL);' -- print r' } else if (api == EGL_OPENGL_ES_API) {' -- print r' EGLint client_version = 1;' -- print r' _eglQueryContext(dpy, ctx, EGL_CONTEXT_CLIENT_VERSION, &client_version);' -- print r' if (tr->profile.api != glprofile::API_GLES ||' -- print r' tr->profile.major < client_version) {' -- print r' std::string version = tr->profile.str();' -- print r' os::log("apitrace: warning: eglMakeCurrent: expected OpenGL ES %i.x context, but got %s\n",' -- print r' client_version, version.c_str());' -- print r' }' -- print r' } else {' -- print r' assert(0);' -- print r' }' -- print r' } else {' -- print r' gltrace::clearContext();' -- print r' }' -- print r' }' -+ print(r' if (_result) {') -+ print(r' // update the profile') -+ print(r' if (ctx != EGL_NO_CONTEXT) {') -+ print(r' gltrace::setContext((uintptr_t)ctx);') -+ print(r' gltrace::Context *tr = gltrace::getContext();') -+ print(r' EGLint api = EGL_OPENGL_ES_API;') -+ print(r' _eglQueryContext(dpy, ctx, EGL_CONTEXT_CLIENT_TYPE, &api);') -+ print(r' if (api == EGL_OPENGL_API) {') -+ print(r' assert(tr->profile.api == glprofile::API_GL);') -+ print(r' } else if (api == EGL_OPENGL_ES_API) {') -+ print(r' EGLint client_version = 1;') -+ print(r' _eglQueryContext(dpy, ctx, EGL_CONTEXT_CLIENT_VERSION, &client_version);') -+ print(r' if (tr->profile.api != glprofile::API_GLES ||') -+ print(r' tr->profile.major < client_version) {') -+ print(r' std::string version = tr->profile.str();') -+ print(r' os::log("apitrace: warning: eglMakeCurrent: expected OpenGL ES %i.x context, but got %s\n",') -+ print(r' client_version, version.c_str());') -+ print(r' }') -+ print(r' } else {') -+ print(r' assert(0);') -+ print(r' }') -+ print(r' } else {') -+ print(r' gltrace::clearContext();') -+ print(r' }') -+ print(r' }') - - if function.name == 'eglDestroyContext': -- print ' if (_result) {' -- print ' gltrace::releaseContext((uintptr_t)ctx);' -- print ' }' -+ print(' if (_result) {') -+ print(' gltrace::releaseContext((uintptr_t)ctx);') -+ print(' }') - - if function.name == 'glEGLImageTargetTexture2DOES': -- print ' image_info *info = _EGLImageKHR_get_image_info(target, image);' -- print ' if (info) {' -- print ' GLint level = 0;' -- print ' GLint internalformat = info->internalformat;' -- print ' GLsizei width = info->width;' -- print ' GLsizei height = info->height;' -- print ' GLint border = 0;' -- print ' GLenum format = info->format;' -- print ' GLenum type = info->type;' -- print ' const GLvoid * pixels = info->pixels;' -+ print(' image_info *info = _EGLImageKHR_get_image_info(target, image);') -+ print(' if (info) {') -+ print(' GLint level = 0;') -+ print(' GLint internalformat = info->internalformat;') -+ print(' GLsizei width = info->width;') -+ print(' GLsizei height = info->height;') -+ print(' GLint border = 0;') -+ print(' GLenum format = info->format;') -+ print(' GLenum type = info->type;') -+ print(' const GLvoid * pixels = info->pixels;') - self.emitFakeTexture2D() -- print ' _EGLImageKHR_free_image_info(info);' -- print ' }' -+ print(' _EGLImageKHR_free_image_info(info);') -+ print(' }') - - - if __name__ == '__main__': -- print '#include <stdlib.h>' -- print '#include <string.h>' -- print -- print '#include "trace_writer_local.hpp"' -- print -- print '// To validate our prototypes' -- print '#define GL_GLEXT_PROTOTYPES' -- print '#define EGL_EGLEXT_PROTOTYPES' -- print -- print '#include "dlopen.hpp"' -- print '#include "glproc.hpp"' -- print '#include "glsize.hpp"' -- print '#include "eglsize.hpp"' -- print -- print 'static const char *__get_alias_func_name(const char *origFunName)' -- print '{' -- print ' /* Vivante driver uses alias name for following OES/EXT functions, that means dlsym for thoese functions will fail */' -- print ' static const char * __glExtProcAlias[][2] =' -- print ' {' -- print ' /* Extension API alias for GL_OES_texture_3D */' -- print ' {"glTexImage3DOES", "glTexImage3D"},' -- print ' {"glTexSubImage3DOES", "glTexSubImage3D"},' -- print ' {"glCopyTexSubImage3DOES", "glCopyTexSubImage3D"},' -- print ' {"glCompressedTexImage3DOES", "glCompressedTexImage3D"},' -- print ' {"glCompressedTexSubImage3DOES", "glCompressedTexSubImage3D"},' -- print -- print ' /* Extension API alias for GL_OES_get_program_binary */' -- print ' {"glGetProgramBinaryOES", "glGetProgramBinary"},' -- print ' {"glProgramBinaryOES", "glProgramBinary"},' -- print -- print ' /* Extension API alias for GL_OES_vertex_array_object */' -- print ' {"glBindVertexArrayOES", "glBindVertexArray"},' -- print ' {"glDeleteVertexArraysOES", "glDeleteVertexArrays"},' -- print ' {"glGenVertexArraysOES", "glGenVertexArrays"},' -- print ' {"glIsVertexArrayOES", "glIsVertexArray"},' -- print -- print ' /* Extension API alias for GL_OES_blend_minmax */' -- print ' {"glBlendEquationEXT", "glBlendEquation"}' -- print ' };' -- print -- print ' int count = sizeof(__glExtProcAlias) / sizeof(__glExtProcAlias[0]);' -- print ' int i;' -- print -- print ' for(i=0; i<count; i++)' -- print ' {' -- print ' if(strcmp(__glExtProcAlias[i][0], origFunName) == 0)' -- print ' return __glExtProcAlias[i][1];' -- print ' }' -- print -- print ' return origFunName;' -- print '}' -- -- print -- print 'typedef struct TexDirectVivData' -- print '{' -- print ' int width;' -- print ' int height;' -- print ' GLenum format;' -- print ' GLvoid*planes[3]; // used for glTexDirectVIV' -- print ' GLvoid*logical; // used for glTexDirectVIVMap/glTexDirectMapVIV/glTexDirectTiledMapVIV' -- print ' GLuint physical;' -- print '}TEXDIRECTVIVDATA;' -- print -- print 'static std::map<GLint, TEXDIRECTVIVDATA> _directTextureDataMap;' -- print -- print '#define GL_VIV_YV12 0x8FC0' -- print '#define GL_VIV_NV12 0x8FC1' -- print '#define GL_VIV_YUY2 0x8FC2' -- print '#define GL_VIV_UYVY 0x8FC3' -- print '#define GL_VIV_NV21 0x8FC4' -- print '#define GL_VIV_I420 0x8FC5' -- print -+ print('#include <stdlib.h>') -+ print('#include <string.h>') -+ print() -+ print('#include "trace_writer_local.hpp"') -+ print() -+ print('// To validate our prototypes') -+ print('#define GL_GLEXT_PROTOTYPES') -+ print('#define EGL_EGLEXT_PROTOTYPES') -+ print() -+ print('#include "dlopen.hpp"') -+ print('#include "glproc.hpp"') -+ print('#include "glsize.hpp"') -+ print('#include "eglsize.hpp"') -+ print() -+ print('static const char *__get_alias_func_name(const char *origFunName)') -+ print('{') -+ print(' /* Vivante driver uses alias name for following OES/EXT functions, that means dlsym for thoese functions will fail */') -+ print(' static const char * __glExtProcAlias[][2] =') -+ print(' {') -+ print(' /* Extension API alias for GL_OES_texture_3D */') -+ print(' {"glTexImage3DOES", "glTexImage3D"},') -+ print(' {"glTexSubImage3DOES", "glTexSubImage3D"},') -+ print(' {"glCopyTexSubImage3DOES", "glCopyTexSubImage3D"},') -+ print(' {"glCompressedTexImage3DOES", "glCompressedTexImage3D"},') -+ print(' {"glCompressedTexSubImage3DOES", "glCompressedTexSubImage3D"},') -+ print() -+ print(' /* Extension API alias for GL_OES_get_program_binary */') -+ print(' {"glGetProgramBinaryOES", "glGetProgramBinary"},') -+ print(' {"glProgramBinaryOES", "glProgramBinary"},') -+ print() -+ print(' /* Extension API alias for GL_OES_vertex_array_object */') -+ print(' {"glBindVertexArrayOES", "glBindVertexArray"},') -+ print(' {"glDeleteVertexArraysOES", "glDeleteVertexArrays"},') -+ print(' {"glGenVertexArraysOES", "glGenVertexArrays"},') -+ print(' {"glIsVertexArrayOES", "glIsVertexArray"},') -+ print() -+ print(' /* Extension API alias for GL_OES_blend_minmax */') -+ print(' {"glBlendEquationEXT", "glBlendEquation"}') -+ print(' };') -+ print() -+ print(' int count = sizeof(__glExtProcAlias) / sizeof(__glExtProcAlias[0]);') -+ print(' int i;') -+ print() -+ print(' for(i=0; i<count; i++)') -+ print(' {') -+ print(' if(strcmp(__glExtProcAlias[i][0], origFunName) == 0)') -+ print(' return __glExtProcAlias[i][1];') -+ print(' }') -+ print() -+ print(' return origFunName;') -+ print('}') -+ -+ print() -+ print('typedef struct TexDirectVivData') -+ print('{') -+ print(' int width;') -+ print(' int height;') -+ print(' GLenum format;') -+ print(' GLvoid*planes[3]; // used for glTexDirectVIV') -+ print(' GLvoid*logical; // used for glTexDirectVIVMap/glTexDirectMapVIV/glTexDirectTiledMapVIV') -+ print(' GLuint physical;') -+ print('}TEXDIRECTVIVDATA;') -+ print() -+ print('static std::map<GLint, TEXDIRECTVIVDATA> _directTextureDataMap;') -+ print() -+ print('#define GL_VIV_YV12 0x8FC0') -+ print('#define GL_VIV_NV12 0x8FC1') -+ print('#define GL_VIV_YUY2 0x8FC2') -+ print('#define GL_VIV_UYVY 0x8FC3') -+ print('#define GL_VIV_NV21 0x8FC4') -+ print('#define GL_VIV_I420 0x8FC5') -+ print() - - module = Module() - module.mergeModule(eglapi) -@@ -292,7 +292,7 @@ if __name__ == '__main__': - tracer = EglTracer() - tracer.traceApi(api) - -- print r''' -+ print(r''' - - - -@@ -453,8 +453,8 @@ void APIENTRY glWeightPointerOESBounds(GLint size, GLenum type, GLsizei stride, - #endif /* ANDROID */ - - --''' -- print r''' -+''') -+ print(r''' - /* - * let the GPU driver know that we are in apitrace - */ -@@ -464,4 +464,4 @@ int APIENTRY ApiTraceEnabled(void) { - return 1; - } - --''' -+''') -diff --git a/wrappers/gltrace.py b/wrappers/gltrace.py -index cf13ae18..02504148 100644 ---- a/wrappers/gltrace.py -+++ b/wrappers/gltrace.py -@@ -79,7 +79,7 @@ class TypeGetter(stdapi.Visitor): - suffix = 'iv' - arg_type = 'GLint' - else: -- print alias.expr -+ print(alias.expr) - assert False - function_name = self.prefix + suffix + self.ext_suffix - return function_name, arg_type -@@ -114,48 +114,48 @@ class GlTracer(Tracer): - def header(self, api): - Tracer.header(self, api) - -- print '#include <algorithm>' -- print -- print '#include "gltrace.hpp"' -- print -+ print('#include <algorithm>') -+ print() -+ print('#include "gltrace.hpp"') -+ print() - - # Which glVertexAttrib* variant to use -- print 'enum vertex_attrib {' -- print ' VERTEX_ATTRIB,' -- print ' VERTEX_ATTRIB_NV,' -- print '};' -- print -- print 'static vertex_attrib _get_vertex_attrib(void) {' -- print ' gltrace::Context *ctx = gltrace::getContext();' -- print ' if (ctx->user_arrays_nv) {' -- print ' GLboolean _vertex_program = GL_FALSE;' -- print ' _glGetBooleanv(GL_VERTEX_PROGRAM_ARB, &_vertex_program);' -- print ' if (_vertex_program) {' -- print ' if (ctx->user_arrays_nv) {' -- print ' GLint _vertex_program_binding_nv = _glGetInteger(GL_VERTEX_PROGRAM_BINDING_NV);' -- print ' if (_vertex_program_binding_nv) {' -- print ' return VERTEX_ATTRIB_NV;' -- print ' }' -- print ' }' -- print ' }' -- print ' }' -- print ' return VERTEX_ATTRIB;' -- print '}' -- print -+ print('enum vertex_attrib {') -+ print(' VERTEX_ATTRIB,') -+ print(' VERTEX_ATTRIB_NV,') -+ print('};') -+ print() -+ print('static vertex_attrib _get_vertex_attrib(void) {') -+ print(' gltrace::Context *ctx = gltrace::getContext();') -+ print(' if (ctx->user_arrays_nv) {') -+ print(' GLboolean _vertex_program = GL_FALSE;') -+ print(' _glGetBooleanv(GL_VERTEX_PROGRAM_ARB, &_vertex_program);') -+ print(' if (_vertex_program) {') -+ print(' if (ctx->user_arrays_nv) {') -+ print(' GLint _vertex_program_binding_nv = _glGetInteger(GL_VERTEX_PROGRAM_BINDING_NV);') -+ print(' if (_vertex_program_binding_nv) {') -+ print(' return VERTEX_ATTRIB_NV;') -+ print(' }') -+ print(' }') -+ print(' }') -+ print(' }') -+ print(' return VERTEX_ATTRIB;') -+ print('}') -+ print() - - self.defineShadowBufferHelper() - - # Whether we need user arrays -- print 'static inline bool _need_user_arrays(void)' -- print '{' -- print ' gltrace::Context *ctx = gltrace::getContext();' -- print ' if (!ctx->user_arrays) {' -- print ' return false;' -- print ' }' -- print -- print ' glprofile::Profile profile = ctx->profile;' -- print ' bool es1 = profile.es() && profile.major == 1;' -- print -+ print('static inline bool _need_user_arrays(void)') -+ print('{') -+ print(' gltrace::Context *ctx = gltrace::getContext();') -+ print(' if (!ctx->user_arrays) {') -+ print(' return false;') -+ print(' }') -+ print() -+ print(' glprofile::Profile profile = ctx->profile;') -+ print(' bool es1 = profile.es() && profile.major == 1;') -+ print() - - for camelcase_name, uppercase_name in self.arrays: - # in which profile is the array available? -@@ -166,120 +166,120 @@ class GlTracer(Tracer): - function_name = 'gl%sPointer' % camelcase_name - enable_name = 'GL_%s_ARRAY' % uppercase_name - binding_name = 'GL_%s_ARRAY_BUFFER_BINDING' % uppercase_name -- print ' // %s' % function_name -- print ' if (%s) {' % profile_check -+ print(' // %s' % function_name) -+ print(' if (%s) {' % profile_check) - self.array_prolog(api, uppercase_name) -- print ' if (_glIsEnabled(%s) &&' % enable_name -- print ' _glGetInteger(%s) == 0) {' % binding_name -+ print(' if (_glIsEnabled(%s) &&' % enable_name) -+ print(' _glGetInteger(%s) == 0) {' % binding_name) - self.array_cleanup(api, uppercase_name) -- print ' return true;' -- print ' }' -+ print(' return true;') -+ print(' }') - self.array_epilog(api, uppercase_name) -- print ' }' -- print -- -- print ' // ES1 does not support generic vertex attributes' -- print ' if (es1)' -- print ' return false;' -- print -- print ' vertex_attrib _vertex_attrib = _get_vertex_attrib();' -- print -- print ' // glVertexAttribPointer' -- print ' if (_vertex_attrib == VERTEX_ATTRIB) {' -- print ' GLint _max_vertex_attribs = _glGetInteger(GL_MAX_VERTEX_ATTRIBS);' -- print ' for (GLint index = 0; index < _max_vertex_attribs; ++index) {' -- print ' if (_glGetVertexAttribi(index, GL_VERTEX_ATTRIB_ARRAY_ENABLED) &&' -- print ' _glGetVertexAttribi(index, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING) == 0) {' -- print ' return true;' -- print ' }' -- print ' }' -- print ' }' -- print -- print ' // glVertexAttribPointerNV' -- print ' if (_vertex_attrib == VERTEX_ATTRIB_NV) {' -- print ' for (GLint index = 0; index < 16; ++index) {' -- print ' if (_glIsEnabled(GL_VERTEX_ATTRIB_ARRAY0_NV + index)) {' -- print ' return true;' -- print ' }' -- print ' }' -- print ' }' -- print -- -- print ' return false;' -- print '}' -- print -- -- print 'static void _trace_user_arrays(GLuint count);' -- print -- -- print '// whether glLockArraysEXT() has ever been called' -- print 'static bool _checkLockArraysEXT = false;' -- print -+ print(' }') -+ print() -+ -+ print(' // ES1 does not support generic vertex attributes') -+ print(' if (es1)') -+ print(' return false;') -+ print() -+ print(' vertex_attrib _vertex_attrib = _get_vertex_attrib();') -+ print() -+ print(' // glVertexAttribPointer') -+ print(' if (_vertex_attrib == VERTEX_ATTRIB) {') -+ print(' GLint _max_vertex_attribs = _glGetInteger(GL_MAX_VERTEX_ATTRIBS);') -+ print(' for (GLint index = 0; index < _max_vertex_attribs; ++index) {') -+ print(' if (_glGetVertexAttribi(index, GL_VERTEX_ATTRIB_ARRAY_ENABLED) &&') -+ print(' _glGetVertexAttribi(index, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING) == 0) {') -+ print(' return true;') -+ print(' }') -+ print(' }') -+ print(' }') -+ print() -+ print(' // glVertexAttribPointerNV') -+ print(' if (_vertex_attrib == VERTEX_ATTRIB_NV) {') -+ print(' for (GLint index = 0; index < 16; ++index) {') -+ print(' if (_glIsEnabled(GL_VERTEX_ATTRIB_ARRAY0_NV + index)) {') -+ print(' return true;') -+ print(' }') -+ print(' }') -+ print(' }') -+ print() -+ -+ print(' return false;') -+ print('}') -+ print() -+ -+ print('static void _trace_user_arrays(GLuint count);') -+ print() -+ -+ print('// whether glLockArraysEXT() has ever been called') -+ print('static bool _checkLockArraysEXT = false;') -+ print() - - # Buffer mappings -- print '// whether glMapBufferRange(GL_MAP_WRITE_BIT) has ever been called' -- print 'static bool _checkBufferMapRange = false;' -- print -- print '// whether glBufferParameteriAPPLE(GL_BUFFER_FLUSHING_UNMAP_APPLE, GL_FALSE) has ever been called' -- print 'static bool _checkBufferFlushingUnmapAPPLE = false;' -- print -+ print('// whether glMapBufferRange(GL_MAP_WRITE_BIT) has ever been called') -+ print('static bool _checkBufferMapRange = false;') -+ print() -+ print('// whether glBufferParameteriAPPLE(GL_BUFFER_FLUSHING_UNMAP_APPLE, GL_FALSE) has ever been called') -+ print('static bool _checkBufferFlushingUnmapAPPLE = false;') -+ print() - - # Generate a helper function to determine whether a parameter name - # refers to a symbolic value or not -- print 'static bool' -- print 'is_symbolic_pname(GLenum pname) {' -- print ' switch (pname) {' -+ print('static bool') -+ print('is_symbolic_pname(GLenum pname) {') -+ print(' switch (pname) {') - for function, type, count, name in glparams.parameters: - if type is glapi.GLenum: -- print ' case %s:' % name -- print ' return true;' -- print ' default:' -- print ' return false;' -- print ' }' -- print '}' -- print -+ print(' case %s:' % name) -+ print(' return true;') -+ print(' default:') -+ print(' return false;') -+ print(' }') -+ print('}') -+ print() - - # Generate a helper function to determine whether a parameter value is - # potentially symbolic or not; i.e., if the value can be represented in - # an enum or not -- print 'template<class T>' -- print 'static inline bool' -- print 'is_symbolic_param(T param) {' -- print ' return static_cast<T>(static_cast<GLenum>(param)) == param;' -- print '}' -- print -+ print('template<class T>') -+ print('static inline bool') -+ print('is_symbolic_param(T param) {') -+ print(' return static_cast<T>(static_cast<GLenum>(param)) == param;') -+ print('}') -+ print() - - # Generate a helper function to know how many elements a parameter has -- print 'static size_t' -- print '_gl_param_size(GLenum pname) {' -- print ' switch (pname) {' -+ print('static size_t') -+ print('_gl_param_size(GLenum pname) {') -+ print(' switch (pname) {') - for function, type, count, name in glparams.parameters: - if name == 'GL_PROGRAM_BINARY_FORMATS': - count = 0 - if type is not None: -- print ' case %s: return %s;' % (name, count) -- print ' default:' -- print r' os::log("apitrace: warning: %s: unknown GLenum 0x%04X\n", __FUNCTION__, pname);' -- print ' return 1;' -- print ' }' -- print '}' -- print -+ print(' case %s: return %s;' % (name, count)) -+ print(' default:') -+ print(r' os::log("apitrace: warning: %s: unknown GLenum 0x%04X\n", __FUNCTION__, pname);') -+ print(' return 1;') -+ print(' }') -+ print('}') -+ print() - - # states such as GL_UNPACK_ROW_LENGTH are not available in GLES -- print 'static inline bool' -- print 'can_unpack_subimage(void) {' -- print ' gltrace::Context *ctx = gltrace::getContext();' -- print ' return ctx->profile.desktop();' -- print '}' -- print -+ print('static inline bool') -+ print('can_unpack_subimage(void) {') -+ print(' gltrace::Context *ctx = gltrace::getContext();') -+ print(' return ctx->profile.desktop();') -+ print('}') -+ print() - - # VMWX_map_buffer_debug -- print r'extern "C" PUBLIC' -- print r'void APIENTRY' -- print r'glNotifyMappedBufferRangeVMWX(const void * start, GLsizeiptr length) {' -+ print(r'extern "C" PUBLIC') -+ print(r'void APIENTRY') -+ print(r'glNotifyMappedBufferRangeVMWX(const void * start, GLsizeiptr length) {') - self.emit_memcpy('start', 'length') -- print r'}' -- print -+ print(r'}') -+ print() - - getProcAddressFunctionNames = [] - -@@ -290,70 +290,70 @@ class GlTracer(Tracer): - argType = getProcAddressFunction.args[0].type - retType = getProcAddressFunction.type - -- print 'static %s _wrapProcAddress(%s procName, %s procPtr);' % (retType, argType, retType) -- print -+ print('static %s _wrapProcAddress(%s procName, %s procPtr);' % (retType, argType, retType)) -+ print() - - Tracer.traceApi(self, api) - -- print 'static %s _wrapProcAddress(%s procName, %s procPtr) {' % (retType, argType, retType) -+ print('static %s _wrapProcAddress(%s procName, %s procPtr) {' % (retType, argType, retType)) - - # Provide fallback functions to missing debug functions -- print ' if (!procPtr) {' -+ print(' if (!procPtr) {') - else_ = '' - for function_name in self.debug_functions: - if self.api.getFunctionByName(function_name): -- print ' %sif (strcmp("%s", (const char *)procName) == 0) {' % (else_, function_name) -- print ' return (%s)&%s;' % (retType, function_name) -- print ' }' -+ print(' %sif (strcmp("%s", (const char *)procName) == 0) {' % (else_, function_name)) -+ print(' return (%s)&%s;' % (retType, function_name)) -+ print(' }') - else_ = 'else ' -- print ' %s{' % else_ -- print ' return NULL;' -- print ' }' -- print ' }' -+ print(' %s{' % else_) -+ print(' return NULL;') -+ print(' }') -+ print(' }') - - for function in api.getAllFunctions(): - ptype = function_pointer_type(function) - pvalue = function_pointer_value(function) -- print ' if (strcmp("%s", (const char *)procName) == 0) {' % function.name -- print ' assert(procPtr != (%s)&%s);' % (retType, function.name) -- print ' %s = (%s)procPtr;' % (pvalue, ptype) -- print ' return (%s)&%s;' % (retType, function.name,) -- print ' }' -- print ' os::log("apitrace: warning: unknown function \\"%s\\"\\n", (const char *)procName);' -- print ' return procPtr;' -- print '}' -- print -+ print(' if (strcmp("%s", (const char *)procName) == 0) {' % function.name) -+ print(' assert(procPtr != (%s)&%s);' % (retType, function.name)) -+ print(' %s = (%s)procPtr;' % (pvalue, ptype)) -+ print(' return (%s)&%s;' % (retType, function.name,)) -+ print(' }') -+ print(' os::log("apitrace: warning: unknown function \\"%s\\"\\n", (const char *)procName);') -+ print(' return procPtr;') -+ print('}') -+ print() - else: - Tracer.traceApi(self, api) - - def defineShadowBufferHelper(self): -- print 'void _shadow_glGetBufferSubData(GLenum target, GLintptr offset,' -- print ' GLsizeiptr size, GLvoid *data)' -- print '{' -- print ' gltrace::Context *ctx = gltrace::getContext();' -- print ' if (!ctx->needsShadowBuffers() || target != GL_ELEMENT_ARRAY_BUFFER) {' -- print ' _glGetBufferSubData(target, offset, size, data);' -- print ' return;' -- print ' }' -- print -- print ' GLint buffer_binding = _glGetInteger(GL_ELEMENT_ARRAY_BUFFER_BINDING);' -- print ' if (buffer_binding > 0) {' -- print ' gltrace::Buffer & buf = ctx->buffers[buffer_binding];' -- print ' buf.getSubData(offset, size, data);' -- print ' }' -- print '}' -+ print('void _shadow_glGetBufferSubData(GLenum target, GLintptr offset,') -+ print(' GLsizeiptr size, GLvoid *data)') -+ print('{') -+ print(' gltrace::Context *ctx = gltrace::getContext();') -+ print(' if (!ctx->needsShadowBuffers() || target != GL_ELEMENT_ARRAY_BUFFER) {') -+ print(' _glGetBufferSubData(target, offset, size, data);') -+ print(' return;') -+ print(' }') -+ print() -+ print(' GLint buffer_binding = _glGetInteger(GL_ELEMENT_ARRAY_BUFFER_BINDING);') -+ print(' if (buffer_binding > 0) {') -+ print(' gltrace::Buffer & buf = ctx->buffers[buffer_binding];') -+ print(' buf.getSubData(offset, size, data);') -+ print(' }') -+ print('}') - - def shadowBufferMethod(self, method): - # Emit code to fetch the shadow buffer, and invoke a method -- print ' gltrace::Context *ctx = gltrace::getContext();' -- print ' if (ctx->needsShadowBuffers() && target == GL_ELEMENT_ARRAY_BUFFER) {' -- print ' GLint buffer_binding = _glGetInteger(GL_ELEMENT_ARRAY_BUFFER_BINDING);' -- print ' if (buffer_binding > 0) {' -- print ' gltrace::Buffer & buf = ctx->buffers[buffer_binding];' -- print ' buf.' + method + ';' -- print ' }' -- print ' }' -- print -+ print(' gltrace::Context *ctx = gltrace::getContext();') -+ print(' if (ctx->needsShadowBuffers() && target == GL_ELEMENT_ARRAY_BUFFER) {') -+ print(' GLint buffer_binding = _glGetInteger(GL_ELEMENT_ARRAY_BUFFER_BINDING);') -+ print(' if (buffer_binding > 0) {') -+ print(' gltrace::Buffer & buf = ctx->buffers[buffer_binding];') -+ print(' buf.' + method + ';') -+ print(' }') -+ print(' }') -+ print() - - def shadowBufferProlog(self, function): - if function.name == 'glBufferData': -@@ -363,12 +363,12 @@ class GlTracer(Tracer): - self.shadowBufferMethod('bufferSubData(offset, size, data)') - - if function.name == 'glDeleteBuffers': -- print ' gltrace::Context *ctx = gltrace::getContext();' -- print ' if (ctx->needsShadowBuffers()) {' -- print ' for (GLsizei i = 0; i < n; i++) {' -- print ' ctx->buffers.erase(buffer[i]);' -- print ' }' -- print ' }' -+ print(' gltrace::Context *ctx = gltrace::getContext();') -+ print(' if (ctx->needsShadowBuffers()) {') -+ print(' for (GLsizei i = 0; i < n; i++) {') -+ print(' ctx->buffers.erase(buffer[i]);') -+ print(' }') -+ print(' }') - - array_pointer_function_names = set(( - "glVertexPointer", -@@ -426,42 +426,42 @@ class GlTracer(Tracer): - def traceFunctionImplBody(self, function): - # Defer tracing of user array pointers... - if function.name in self.array_pointer_function_names: -- print ' GLint _array_buffer = _glGetInteger(GL_ARRAY_BUFFER_BINDING);' -- print ' if (!_array_buffer) {' -- print ' static bool warned = false;' -- print ' if (!warned) {' -- print ' warned = true;' -- print ' os::log("apitrace: warning: %s: call will be faked due to pointer to user memory (https://github.com/apitrace/apitrace/blob/master/docs/BUGS.markdown#tracing)\\n", __FUNCTION__);' -- print ' }' -- print ' gltrace::Context *ctx = gltrace::getContext();' -- print ' ctx->user_arrays = true;' -+ print(' GLint _array_buffer = _glGetInteger(GL_ARRAY_BUFFER_BINDING);') -+ print(' if (!_array_buffer) {') -+ print(' static bool warned = false;') -+ print(' if (!warned) {') -+ print(' warned = true;') -+ print(' os::log("apitrace: warning: %s: call will be faked due to pointer to user memory (https://github.com/apitrace/apitrace/blob/master/docs/BUGS.markdown#tracing)\\n", __FUNCTION__);') -+ print(' }') -+ print(' gltrace::Context *ctx = gltrace::getContext();') -+ print(' ctx->user_arrays = true;') - if function.name == "glVertexAttribPointerNV": -- print ' ctx->user_arrays_nv = true;' -+ print(' ctx->user_arrays_nv = true;') - self.invokeFunction(function) - - # And also break down glInterleavedArrays into the individual calls - if function.name == 'glInterleavedArrays': -- print -+ print() - - # Initialize the enable flags - for camelcase_name, uppercase_name in self.arrays: - flag_name = '_' + uppercase_name.lower() -- print ' GLboolean %s = GL_FALSE;' % flag_name -- print -+ print(' GLboolean %s = GL_FALSE;' % flag_name) -+ print() - - # Switch for the interleaved formats -- print ' switch (format) {' -+ print(' switch (format) {') - for format in self.interleaved_formats: -- print ' case %s:' % format -+ print(' case %s:' % format) - for camelcase_name, uppercase_name in self.arrays: - flag_name = '_' + uppercase_name.lower() - if format.find('_' + uppercase_name[0]) >= 0: -- print ' %s = GL_TRUE;' % flag_name -- print ' break;' -- print ' default:' -- print ' return;' -- print ' }' -- print -+ print(' %s = GL_TRUE;' % flag_name) -+ print(' break;') -+ print(' default:') -+ print(' return;') -+ print(' }') -+ print() - - # Emit fake glEnableClientState/glDisableClientState flags - for camelcase_name, uppercase_name in self.arrays: -@@ -469,16 +469,16 @@ class GlTracer(Tracer): - enable_name = 'GL_%s_ARRAY' % uppercase_name - - # Emit a fake function -- print ' {' -- print ' static const trace::FunctionSig &_sig = %s ? _glEnableClientState_sig : _glDisableClientState_sig;' % flag_name -- print ' unsigned _call = trace::localWriter.beginEnter(&_sig, true);' -- print ' trace::localWriter.beginArg(0);' -+ print(' {') -+ print(' static const trace::FunctionSig &_sig = %s ? _glEnableClientState_sig : _glDisableClientState_sig;' % flag_name) -+ print(' unsigned _call = trace::localWriter.beginEnter(&_sig, true);') -+ print(' trace::localWriter.beginArg(0);') - self.serializeValue(glapi.GLenum, enable_name) -- print ' trace::localWriter.endArg();' -- print ' trace::localWriter.endEnter();' -- print ' trace::localWriter.beginLeave(_call);' -- print ' trace::localWriter.endLeave();' -- print ' }' -+ print(' trace::localWriter.endArg();') -+ print(' trace::localWriter.endEnter();') -+ print(' trace::localWriter.beginLeave(_call);') -+ print(' trace::localWriter.endLeave();') -+ print(' }') - - # Warn about buggy glGet(GL_*ARRAY_SIZE) not returning GL_BGRA - buggyFunctions = { -@@ -489,224 +489,224 @@ class GlTracer(Tracer): - } - if function.name in buggyFunctions: - getter, extraArg, pname = buggyFunctions[function.name] -- print r' static bool _checked = false;' -- print r' if (!_checked && size == GL_BGRA) {' -- print r' GLint _size = 0;' -- print r' _%s(%s%s, &_size);' % (getter, extraArg, pname) -- print r' if (_size != GL_BGRA) {' -- print r' os::log("apitrace: warning: %s(%s) does not return GL_BGRA; trace will be incorrect (https://github.com/apitrace/apitrace/issues/261)\n");' % (getter, pname) -- print r' }' -- print r' _checked = true;' -- print r' }' -- -- print ' return;' -- print ' }' -+ print(r' static bool _checked = false;') -+ print(r' if (!_checked && size == GL_BGRA) {') -+ print(r' GLint _size = 0;') -+ print(r' _%s(%s%s, &_size);' % (getter, extraArg, pname)) -+ print(r' if (_size != GL_BGRA) {') -+ print(r' os::log("apitrace: warning: %s(%s) does not return GL_BGRA; trace will be incorrect (https://github.com/apitrace/apitrace/issues/261)\n");' % (getter, pname)) -+ print(r' }') -+ print(r' _checked = true;') -+ print(r' }') -+ -+ print(' return;') -+ print(' }') - - # ... to the draw calls - if self.draw_function_regex.match(function.name): - if not self.multi_draw_function_regex.match(function.name): -- print ' if (trace::localWriter.isIgnored()) {' -+ print(' if (trace::localWriter.isIgnored()) {') - self.invokeFunction(function) -- print ' return;' -- print ' }' -- print ' if (_need_user_arrays()) {' -+ print(' return;') -+ print(' }') -+ print(' if (_need_user_arrays()) {') - if 'Indirect' in function.name: -- print r' os::log("apitrace: warning: %s: indirect user arrays not supported\n");' % (function.name,) -+ print(r' os::log("apitrace: warning: %s: indirect user arrays not supported\n");' % (function.name,)) - else: - arg_names = ', '.join([arg.name for arg in function.args[1:]]) -- print ' GLuint _count = _%s_count(%s);' % (function.name, arg_names) -+ print(' GLuint _count = _%s_count(%s);' % (function.name, arg_names)) - # Some apps, in particular Quake3, can tell the driver to lock more - # vertices than those actually required for the draw call. -- print ' if (_checkLockArraysEXT) {' -- print ' GLuint _locked_count = _glGetInteger(GL_ARRAY_ELEMENT_LOCK_FIRST_EXT)' -- print ' + _glGetInteger(GL_ARRAY_ELEMENT_LOCK_COUNT_EXT);' -- print ' _count = std::max(_count, _locked_count);' -- print ' }' -- print ' _trace_user_arrays(_count);' -- print ' }' -+ print(' if (_checkLockArraysEXT) {') -+ print(' GLuint _locked_count = _glGetInteger(GL_ARRAY_ELEMENT_LOCK_FIRST_EXT)') -+ print(' + _glGetInteger(GL_ARRAY_ELEMENT_LOCK_COUNT_EXT);') -+ print(' _count = std::max(_count, _locked_count);') -+ print(' }') -+ print(' _trace_user_arrays(_count);') -+ print(' }') - if function.name == 'glLockArraysEXT': -- print ' _checkLockArraysEXT = true;' -+ print(' _checkLockArraysEXT = true;') - - # Warn if user arrays are used with glBegin/glArrayElement/glEnd. - if function.name == 'glBegin': -- print r' gltrace::Context *ctx = gltrace::getContext();' -- print r' ctx->userArraysOnBegin = _need_user_arrays();' -+ print(r' gltrace::Context *ctx = gltrace::getContext();') -+ print(r' ctx->userArraysOnBegin = _need_user_arrays();') - if function.name.startswith('glArrayElement'): -- print r' gltrace::Context *ctx = gltrace::getContext();' -- print r' if (ctx->userArraysOnBegin) {' -- print r' os::log("apitrace: warning: user arrays with glArrayElement not supported (https://github.com/apitrace/apitrace/issues/276)\n");' -- print r' ctx->userArraysOnBegin = false;' -- print r' }' -+ print(r' gltrace::Context *ctx = gltrace::getContext();') -+ print(r' if (ctx->userArraysOnBegin) {') -+ print(r' os::log("apitrace: warning: user arrays with glArrayElement not supported (https://github.com/apitrace/apitrace/issues/276)\n");') -+ print(r' ctx->userArraysOnBegin = false;') -+ print(r' }') - - # Emit a fake memcpy on buffer uploads - if function.name == 'glBufferParameteriAPPLE': -- print ' if (pname == GL_BUFFER_FLUSHING_UNMAP_APPLE && param == GL_FALSE) {' -- print ' _checkBufferFlushingUnmapAPPLE = true;' -- print ' }' -+ print(' if (pname == GL_BUFFER_FLUSHING_UNMAP_APPLE && param == GL_FALSE) {') -+ print(' _checkBufferFlushingUnmapAPPLE = true;') -+ print(' }') - if function.name in ('glUnmapBuffer', 'glUnmapBufferARB'): - if function.name.endswith('ARB'): - suffix = 'ARB' - else: - suffix = '' -- print ' GLint access_flags = 0;' -- print ' GLint access = 0;' -- print ' bool flush;' -- print ' // GLES3 does not have GL_BUFFER_ACCESS;' -- print ' if (_checkBufferMapRange) {' -- print ' _glGetBufferParameteriv%s(target, GL_BUFFER_ACCESS_FLAGS, &access_flags);' % suffix -- print ' flush = (access_flags & GL_MAP_WRITE_BIT) && !(access_flags & (GL_MAP_FLUSH_EXPLICIT_BIT | GL_MAP_PERSISTENT_BIT));' -- print ' } else {' -- print ' _glGetBufferParameteriv%s(target, GL_BUFFER_ACCESS, &access);' % suffix -- print ' flush = access != GL_READ_ONLY;' -- print ' }' -- print ' if (flush) {' -- print ' GLvoid *map = NULL;' -- print ' _glGetBufferPointerv%s(target, GL_BUFFER_MAP_POINTER, &map);' % suffix -- print ' if (map) {' -- print ' GLint length = -1;' -- print ' if (_checkBufferMapRange) {' -- print ' _glGetBufferParameteriv%s(target, GL_BUFFER_MAP_LENGTH, &length);' % suffix -- print ' if (length == -1) {' -- print ' // Mesa drivers refuse GL_BUFFER_MAP_LENGTH without GL 3.0 up-to' -- print ' // http://cgit.freedesktop.org/mesa/mesa/commit/?id=ffee498fb848b253a7833373fe5430f8c7ca0c5f' -- print ' static bool warned = false;' -- print ' if (!warned) {' -- print ' os::log("apitrace: warning: glGetBufferParameteriv%s(GL_BUFFER_MAP_LENGTH) failed\\n");' % suffix -- print ' warned = true;' -- print ' }' -- print ' }' -- print ' } else {' -- print ' length = 0;' -- print ' _glGetBufferParameteriv%s(target, GL_BUFFER_SIZE, &length);' % suffix -- print ' }' -- print ' if (_checkBufferFlushingUnmapAPPLE) {' -- print ' GLint flushing_unmap = GL_TRUE;' -- print ' _glGetBufferParameteriv%s(target, GL_BUFFER_FLUSHING_UNMAP_APPLE, &flushing_unmap);' % suffix -- print ' flush = flush && flushing_unmap;' -- print ' }' -- print ' if (flush && length > 0) {' -+ print(' GLint access_flags = 0;') -+ print(' GLint access = 0;') -+ print(' bool flush;') -+ print(' // GLES3 does not have GL_BUFFER_ACCESS;') -+ print(' if (_checkBufferMapRange) {') -+ print(' _glGetBufferParameteriv%s(target, GL_BUFFER_ACCESS_FLAGS, &access_flags);' % suffix) -+ print(' flush = (access_flags & GL_MAP_WRITE_BIT) && !(access_flags & (GL_MAP_FLUSH_EXPLICIT_BIT | GL_MAP_PERSISTENT_BIT));') -+ print(' } else {') -+ print(' _glGetBufferParameteriv%s(target, GL_BUFFER_ACCESS, &access);' % suffix) -+ print(' flush = access != GL_READ_ONLY;') -+ print(' }') -+ print(' if (flush) {') -+ print(' GLvoid *map = NULL;') -+ print(' _glGetBufferPointerv%s(target, GL_BUFFER_MAP_POINTER, &map);' % suffix) -+ print(' if (map) {') -+ print(' GLint length = -1;') -+ print(' if (_checkBufferMapRange) {') -+ print(' _glGetBufferParameteriv%s(target, GL_BUFFER_MAP_LENGTH, &length);' % suffix) -+ print(' if (length == -1) {') -+ print(' // Mesa drivers refuse GL_BUFFER_MAP_LENGTH without GL 3.0 up-to') -+ print(' // http://cgit.freedesktop.org/mesa/mesa/commit/?id=ffee498fb848b253a7833373fe5430f8c7ca0c5f') -+ print(' static bool warned = false;') -+ print(' if (!warned) {') -+ print(' os::log("apitrace: warning: glGetBufferParameteriv%s(GL_BUFFER_MAP_LENGTH) failed\\n");' % suffix) -+ print(' warned = true;') -+ print(' }') -+ print(' }') -+ print(' } else {') -+ print(' length = 0;') -+ print(' _glGetBufferParameteriv%s(target, GL_BUFFER_SIZE, &length);' % suffix) -+ print(' }') -+ print(' if (_checkBufferFlushingUnmapAPPLE) {') -+ print(' GLint flushing_unmap = GL_TRUE;') -+ print(' _glGetBufferParameteriv%s(target, GL_BUFFER_FLUSHING_UNMAP_APPLE, &flushing_unmap);' % suffix) -+ print(' flush = flush && flushing_unmap;') -+ print(' }') -+ print(' if (flush && length > 0) {') - self.emit_memcpy('map', 'length') -- print ' }' -- print ' }' -- print ' }' -+ print(' }') -+ print(' }') -+ print(' }') - if function.name == 'glUnmapBufferOES': -- print ' GLint access_flags = 0;' -- print ' GLint access = 0;' -- print ' bool flush;' -- print ' // GLES3 does not have GL_BUFFER_ACCESS;' -- print ' if (_checkBufferMapRange) {' -- print ' _glGetBufferParameteriv(target, GL_BUFFER_ACCESS_FLAGS, &access_flags);' -- print ' flush = (access_flags & GL_MAP_WRITE_BIT) && !(access_flags & (GL_MAP_FLUSH_EXPLICIT_BIT | GL_MAP_PERSISTENT_BIT));' -- print ' } else {' -- print ' _glGetBufferParameteriv(target, GL_BUFFER_ACCESS, &access);' -- print ' flush = access != GL_READ_ONLY;' -- print ' }' -- print ' if (flush) {' -- print ' GLvoid *map = NULL;' -- print ' _glGetBufferPointervOES(target, GL_BUFFER_MAP_POINTER, &map);' -- print ' if (map) {' -- print ' GLint length = 0;' -- print ' GLint offset = 0;' -- print ' if (_checkBufferMapRange) {' -- print ' _glGetBufferParameteriv(target, GL_BUFFER_MAP_LENGTH, &length);' -- print ' _glGetBufferParameteriv(target, GL_BUFFER_MAP_OFFSET, &offset);' -- print ' } else {' -- print ' _glGetBufferParameteriv(target, GL_BUFFER_SIZE, &length);' -- print ' }' -- print ' if (flush && length > 0) {' -+ print(' GLint access_flags = 0;') -+ print(' GLint access = 0;') -+ print(' bool flush;') -+ print(' // GLES3 does not have GL_BUFFER_ACCESS;') -+ print(' if (_checkBufferMapRange) {') -+ print(' _glGetBufferParameteriv(target, GL_BUFFER_ACCESS_FLAGS, &access_flags);') -+ print(' flush = (access_flags & GL_MAP_WRITE_BIT) && !(access_flags & (GL_MAP_FLUSH_EXPLICIT_BIT | GL_MAP_PERSISTENT_BIT));') -+ print(' } else {') -+ print(' _glGetBufferParameteriv(target, GL_BUFFER_ACCESS, &access);') -+ print(' flush = access != GL_READ_ONLY;') -+ print(' }') -+ print(' if (flush) {') -+ print(' GLvoid *map = NULL;') -+ print(' _glGetBufferPointervOES(target, GL_BUFFER_MAP_POINTER, &map);') -+ print(' if (map) {') -+ print(' GLint length = 0;') -+ print(' GLint offset = 0;') -+ print(' if (_checkBufferMapRange) {') -+ print(' _glGetBufferParameteriv(target, GL_BUFFER_MAP_LENGTH, &length);') -+ print(' _glGetBufferParameteriv(target, GL_BUFFER_MAP_OFFSET, &offset);') -+ print(' } else {') -+ print(' _glGetBufferParameteriv(target, GL_BUFFER_SIZE, &length);') -+ print(' }') -+ print(' if (flush && length > 0) {') - self.emit_memcpy('map', 'length') - self.shadowBufferMethod('bufferSubData(offset, length, map)') -- print ' }' -- print ' }' -- print ' }' -+ print(' }') -+ print(' }') -+ print(' }') - if function.name == 'glUnmapNamedBuffer': -- print ' GLint access_flags = 0;' -- print ' _glGetNamedBufferParameteriv(buffer, GL_BUFFER_ACCESS_FLAGS, &access_flags);' -- print ' if ((access_flags & GL_MAP_WRITE_BIT) &&' -- print ' !(access_flags & (GL_MAP_FLUSH_EXPLICIT_BIT | GL_MAP_PERSISTENT_BIT))) {' -- print ' GLvoid *map = NULL;' -- print ' _glGetNamedBufferPointerv(buffer, GL_BUFFER_MAP_POINTER, &map);' -- print ' GLint length = 0;' -- print ' _glGetNamedBufferParameteriv(buffer, GL_BUFFER_MAP_LENGTH, &length);' -- print ' if (map && length > 0) {' -+ print(' GLint access_flags = 0;') -+ print(' _glGetNamedBufferParameteriv(buffer, GL_BUFFER_ACCESS_FLAGS, &access_flags);') -+ print(' if ((access_flags & GL_MAP_WRITE_BIT) &&') -+ print(' !(access_flags & (GL_MAP_FLUSH_EXPLICIT_BIT | GL_MAP_PERSISTENT_BIT))) {') -+ print(' GLvoid *map = NULL;') -+ print(' _glGetNamedBufferPointerv(buffer, GL_BUFFER_MAP_POINTER, &map);') -+ print(' GLint length = 0;') -+ print(' _glGetNamedBufferParameteriv(buffer, GL_BUFFER_MAP_LENGTH, &length);') -+ print(' if (map && length > 0) {') - self.emit_memcpy('map', 'length') -- print ' }' -- print ' }' -+ print(' }') -+ print(' }') - if function.name == 'glUnmapNamedBufferEXT': -- print ' GLint access_flags = 0;' -- print ' _glGetNamedBufferParameterivEXT(buffer, GL_BUFFER_ACCESS_FLAGS, &access_flags);' -- print ' if ((access_flags & GL_MAP_WRITE_BIT) &&' -- print ' !(access_flags & (GL_MAP_FLUSH_EXPLICIT_BIT | GL_MAP_PERSISTENT_BIT))) {' -- print ' GLvoid *map = NULL;' -- print ' _glGetNamedBufferPointervEXT(buffer, GL_BUFFER_MAP_POINTER, &map);' -- print ' GLint length = 0;' -- print ' _glGetNamedBufferParameterivEXT(buffer, GL_BUFFER_MAP_LENGTH, &length);' -- print ' if (map && length > 0) {' -+ print(' GLint access_flags = 0;') -+ print(' _glGetNamedBufferParameterivEXT(buffer, GL_BUFFER_ACCESS_FLAGS, &access_flags);') -+ print(' if ((access_flags & GL_MAP_WRITE_BIT) &&') -+ print(' !(access_flags & (GL_MAP_FLUSH_EXPLICIT_BIT | GL_MAP_PERSISTENT_BIT))) {') -+ print(' GLvoid *map = NULL;') -+ print(' _glGetNamedBufferPointervEXT(buffer, GL_BUFFER_MAP_POINTER, &map);') -+ print(' GLint length = 0;') -+ print(' _glGetNamedBufferParameterivEXT(buffer, GL_BUFFER_MAP_LENGTH, &length);') -+ print(' if (map && length > 0) {') - self.emit_memcpy('map', 'length') -- print ' }' -- print ' }' -+ print(' }') -+ print(' }') - if function.name == 'glFlushMappedBufferRange': -- print ' GLvoid *map = NULL;' -- print ' _glGetBufferPointerv(target, GL_BUFFER_MAP_POINTER, &map);' -- print ' if (map && length > 0) {' -+ print(' GLvoid *map = NULL;') -+ print(' _glGetBufferPointerv(target, GL_BUFFER_MAP_POINTER, &map);') -+ print(' if (map && length > 0) {') - self.emit_memcpy('(const char *)map + offset', 'length') -- print ' }' -+ print(' }') - if function.name == 'glFlushMappedBufferRangeEXT': -- print ' GLvoid *map = NULL;' -- print ' _glGetBufferPointervOES(target, GL_BUFFER_MAP_POINTER_OES, &map);' -- print ' if (map && length > 0) {' -+ print(' GLvoid *map = NULL;') -+ print(' _glGetBufferPointervOES(target, GL_BUFFER_MAP_POINTER_OES, &map);') -+ print(' if (map && length > 0) {') - self.emit_memcpy('(const char *)map + offset', 'length') -- print ' }' -+ print(' }') - if function.name == 'glFlushMappedBufferRangeAPPLE': -- print ' GLvoid *map = NULL;' -- print ' _glGetBufferPointerv(target, GL_BUFFER_MAP_POINTER, &map);' -- print ' if (map && size > 0) {' -+ print(' GLvoid *map = NULL;') -+ print(' _glGetBufferPointerv(target, GL_BUFFER_MAP_POINTER, &map);') -+ print(' if (map && size > 0) {') - self.emit_memcpy('(const char *)map + offset', 'size') -- print ' }' -+ print(' }') - if function.name == 'glFlushMappedNamedBufferRange': -- print ' GLvoid *map = NULL;' -- print ' _glGetNamedBufferPointerv(buffer, GL_BUFFER_MAP_POINTER, &map);' -- print ' if (map && length > 0) {' -+ print(' GLvoid *map = NULL;') -+ print(' _glGetNamedBufferPointerv(buffer, GL_BUFFER_MAP_POINTER, &map);') -+ print(' if (map && length > 0) {') - self.emit_memcpy('(const char *)map + offset', 'length') -- print ' }' -+ print(' }') - if function.name == 'glFlushMappedNamedBufferRangeEXT': -- print ' GLvoid *map = NULL;' -- print ' _glGetNamedBufferPointervEXT(buffer, GL_BUFFER_MAP_POINTER, &map);' -- print ' if (map && length > 0) {' -+ print(' GLvoid *map = NULL;') -+ print(' _glGetNamedBufferPointervEXT(buffer, GL_BUFFER_MAP_POINTER, &map);') -+ print(' if (map && length > 0) {') - self.emit_memcpy('(const char *)map + offset', 'length') -- print ' }' -+ print(' }') - - # FIXME: We don't support coherent/pinned memory mappings - if function.name in ('glBufferStorage', 'glNamedBufferStorage', 'glNamedBufferStorageEXT'): -- print r' if (!(flags & GL_MAP_PERSISTENT_BIT)) {' -- print r' os::log("apitrace: warning: %s: MAP_NOTIFY_EXPLICIT_BIT_VMWX set w/o MAP_PERSISTENT_BIT\n", __FUNCTION__);' -- print r' }' -- print r' flags &= ~GL_MAP_NOTIFY_EXPLICIT_BIT_VMWX;' -+ print(r' if (!(flags & GL_MAP_PERSISTENT_BIT)) {') -+ print(r' os::log("apitrace: warning: %s: MAP_NOTIFY_EXPLICIT_BIT_VMWX set w/o MAP_PERSISTENT_BIT\n", __FUNCTION__);') -+ print(r' }') -+ print(r' flags &= ~GL_MAP_NOTIFY_EXPLICIT_BIT_VMWX;') - if function.name in ('glMapBufferRange', 'glMapBufferRangeEXT', 'glMapNamedBufferRange', 'glMapNamedBufferRangeEXT'): -- print r' if (access & GL_MAP_NOTIFY_EXPLICIT_BIT_VMWX) {' -- print r' if (!(access & GL_MAP_PERSISTENT_BIT)) {' -- print r' os::log("apitrace: warning: %s: MAP_NOTIFY_EXPLICIT_BIT_VMWX set w/o MAP_PERSISTENT_BIT\n", __FUNCTION__);' -- print r' }' -- print r' if (access & GL_MAP_FLUSH_EXPLICIT_BIT) {' -- print r' os::log("apitrace: warning: %s: MAP_NOTIFY_EXPLICIT_BIT_VMWX set w/ MAP_FLUSH_EXPLICIT_BIT\n", __FUNCTION__);' -- print r' }' -- print r' access &= ~GL_MAP_NOTIFY_EXPLICIT_BIT_VMWX;' -- print r' } else if (access & GL_MAP_COHERENT_BIT) {' -- print r' os::log("apitrace: warning: %s: MAP_COHERENT_BIT unsupported (https://github.com/apitrace/apitrace/issues/232)\n", __FUNCTION__);' -- print r' } else if ((access & GL_MAP_PERSISTENT_BIT) &&' -- print r' !(access & GL_MAP_FLUSH_EXPLICIT_BIT)) {' -- print r' os::log("apitrace: warning: %s: MAP_PERSISTENT_BIT w/o FLUSH_EXPLICIT_BIT unsupported (https://github.com/apitrace/apitrace/issues/232)\n", __FUNCTION__);' -- print r' }' -+ print(r' if (access & GL_MAP_NOTIFY_EXPLICIT_BIT_VMWX) {') -+ print(r' if (!(access & GL_MAP_PERSISTENT_BIT)) {') -+ print(r' os::log("apitrace: warning: %s: MAP_NOTIFY_EXPLICIT_BIT_VMWX set w/o MAP_PERSISTENT_BIT\n", __FUNCTION__);') -+ print(r' }') -+ print(r' if (access & GL_MAP_FLUSH_EXPLICIT_BIT) {') -+ print(r' os::log("apitrace: warning: %s: MAP_NOTIFY_EXPLICIT_BIT_VMWX set w/ MAP_FLUSH_EXPLICIT_BIT\n", __FUNCTION__);') -+ print(r' }') -+ print(r' access &= ~GL_MAP_NOTIFY_EXPLICIT_BIT_VMWX;') -+ print(r' } else if (access & GL_MAP_COHERENT_BIT) {') -+ print(r' os::log("apitrace: warning: %s: MAP_COHERENT_BIT unsupported (https://github.com/apitrace/apitrace/issues/232)\n", __FUNCTION__);') -+ print(r' } else if ((access & GL_MAP_PERSISTENT_BIT) &&') -+ print(r' !(access & GL_MAP_FLUSH_EXPLICIT_BIT)) {') -+ print(r' os::log("apitrace: warning: %s: MAP_PERSISTENT_BIT w/o FLUSH_EXPLICIT_BIT unsupported (https://github.com/apitrace/apitrace/issues/232)\n", __FUNCTION__);') -+ print(r' }') - if function.name in ('glBufferData', 'glBufferDataARB'): -- print r' if (target == GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD) {' -- print r' os::log("apitrace: warning: GL_AMD_pinned_memory not fully supported\n");' -- print r' }' -+ print(r' if (target == GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD) {') -+ print(r' os::log("apitrace: warning: GL_AMD_pinned_memory not fully supported\n");') -+ print(r' }') - - # TODO: We don't track GL_INTEL_map_texture mappings - if function.name == 'glMapTexture2DINTEL': -- print r' if (access & GL_MAP_WRITE_BIT) {' -- print r' os::log("apitrace: warning: GL_INTEL_map_texture not fully supported\n");' -- print r' }' -+ print(r' if (access & GL_MAP_WRITE_BIT) {') -+ print(r' os::log("apitrace: warning: GL_INTEL_map_texture not fully supported\n");') -+ print(r' }') - - # Don't leave vertex attrib locations to chance. Instead emit fake - # glBindAttribLocation calls to ensure that the same locations will be -@@ -715,40 +715,40 @@ class GlTracer(Tracer): - # many entry-points, including non-shader related ones. - if function.name == 'glLinkProgram': - Tracer.invokeFunction(self, function) -- print ' GLint active_attributes = 0;' -- print ' _glGetProgramiv(program, GL_ACTIVE_ATTRIBUTES, &active_attributes);' -- print ' for (GLint attrib = 0; attrib < active_attributes; ++attrib) {' -- print ' GLint size = 0;' -- print ' GLenum type = 0;' -- print ' GLchar name[256];' -+ print(' GLint active_attributes = 0;') -+ print(' _glGetProgramiv(program, GL_ACTIVE_ATTRIBUTES, &active_attributes);') -+ print(' for (GLint attrib = 0; attrib < active_attributes; ++attrib) {') -+ print(' GLint size = 0;') -+ print(' GLenum type = 0;') -+ print(' GLchar name[256];') - # TODO: Use ACTIVE_ATTRIBUTE_MAX_LENGTH instead of 256 -- print ' _glGetActiveAttrib(program, attrib, sizeof name, NULL, &size, &type, name);' -- print " if (name[0] != 'g' || name[1] != 'l' || name[2] != '_') {" -- print ' GLint location = _glGetAttribLocation(program, name);' -- print ' if (location >= 0) {' -+ print(' _glGetActiveAttrib(program, attrib, sizeof name, NULL, &size, &type, name);') -+ print(" if (name[0] != 'g' || name[1] != 'l' || name[2] != '_') {") -+ print(' GLint location = _glGetAttribLocation(program, name);') -+ print(' if (location >= 0) {') - bind_function = glapi.glapi.getFunctionByName('glBindAttribLocation') - self.fake_call(bind_function, ['program', 'location', 'name']) -- print ' }' -- print ' }' -- print ' }' -+ print(' }') -+ print(' }') -+ print(' }') - if function.name == 'glLinkProgramARB': - Tracer.invokeFunction(self, function) -- print ' GLint active_attributes = 0;' -- print ' _glGetObjectParameterivARB(programObj, GL_OBJECT_ACTIVE_ATTRIBUTES_ARB, &active_attributes);' -- print ' for (GLint attrib = 0; attrib < active_attributes; ++attrib) {' -- print ' GLint size = 0;' -- print ' GLenum type = 0;' -- print ' GLcharARB name[256];' -+ print(' GLint active_attributes = 0;') -+ print(' _glGetObjectParameterivARB(programObj, GL_OBJECT_ACTIVE_ATTRIBUTES_ARB, &active_attributes);') -+ print(' for (GLint attrib = 0; attrib < active_attributes; ++attrib) {') -+ print(' GLint size = 0;') -+ print(' GLenum type = 0;') -+ print(' GLcharARB name[256];') - # TODO: Use ACTIVE_ATTRIBUTE_MAX_LENGTH instead of 256 -- print ' _glGetActiveAttribARB(programObj, attrib, sizeof name, NULL, &size, &type, name);' -- print " if (name[0] != 'g' || name[1] != 'l' || name[2] != '_') {" -- print ' GLint location = _glGetAttribLocationARB(programObj, name);' -- print ' if (location >= 0) {' -+ print(' _glGetActiveAttribARB(programObj, attrib, sizeof name, NULL, &size, &type, name);') -+ print(" if (name[0] != 'g' || name[1] != 'l' || name[2] != '_') {") -+ print(' GLint location = _glGetAttribLocationARB(programObj, name);') -+ print(' if (location >= 0) {') - bind_function = glapi.glapi.getFunctionByName('glBindAttribLocationARB') - self.fake_call(bind_function, ['programObj', 'location', 'name']) -- print ' }' -- print ' }' -- print ' }' -+ print(' }') -+ print(' }') -+ print(' }') - - self.shadowBufferProlog(function) - -@@ -815,9 +815,9 @@ class GlTracer(Tracer): - # Force glProgramBinary to fail. Per ARB_get_program_binary this - # should signal the app that it needs to recompile. - if function.name in ('glProgramBinary', 'glProgramBinaryOES'): -- print r' binaryFormat = 0xDEADDEAD;' -- print r' binary = &binaryFormat;' -- print r' length = sizeof binaryFormat;' -+ print(r' binaryFormat = 0xDEADDEAD;') -+ print(r' binary = &binaryFormat;') -+ print(r' length = sizeof binaryFormat;') - - Tracer.invokeFunction(self, function) - -@@ -838,25 +838,25 @@ class GlTracer(Tracer): - # We may be faking KHR_debug, so ensure the pointer queries result is - # always zeroed to prevent dereference of unitialized pointers - if function.name == 'glGetPointerv': -- print ' if (params &&' -- print ' (pname == GL_DEBUG_CALLBACK_FUNCTION ||' -- print ' pname == GL_DEBUG_CALLBACK_USER_PARAM)) {' -- print ' *params = NULL;' -- print ' }' -+ print(' if (params &&') -+ print(' (pname == GL_DEBUG_CALLBACK_FUNCTION ||') -+ print(' pname == GL_DEBUG_CALLBACK_USER_PARAM)) {') -+ print(' *params = NULL;') -+ print(' }') - - if function.name in self.getProcAddressFunctionNames: - nameArg = function.args[0].name -- print ' if (strcmp("glNotifyMappedBufferRangeVMWX", (const char *)%s) == 0) {' % (nameArg,) -- print ' _result = (%s)&glNotifyMappedBufferRangeVMWX;' % (function.type,) -- print ' } else if (strcmp("glTexDirectVIV", (const char *)%s) == 0) {' % (nameArg,) -- print ' _result = (%s)&glTexDirectVIV;' % (function.type,) -- print ' } else if (strcmp("glTexDirectInvalidateVIV", (const char *)%s) == 0) {' % (nameArg,) -- print ' _result = (%s)&glTexDirectInvalidateVIV;' % (function.type,) -+ print(' if (strcmp("glNotifyMappedBufferRangeVMWX", (const char *)%s) == 0) {' % (nameArg,)) -+ print(' _result = (%s)&glNotifyMappedBufferRangeVMWX;' % (function.type,)) -+ print(' } else if (strcmp("glTexDirectVIV", (const char *)%s) == 0) {' % (nameArg,)) -+ print(' _result = (%s)&glTexDirectVIV;' % (function.type,)) -+ print(' } else if (strcmp("glTexDirectInvalidateVIV", (const char *)%s) == 0) {' % (nameArg,)) -+ print(' _result = (%s)&glTexDirectInvalidateVIV;' % (function.type,)) - for marker_function in self.marker_functions: - if self.api.getFunctionByName(marker_function): -- print ' } else if (strcmp("%s", (const char *)%s) == 0) {' % (marker_function, nameArg) -- print ' _result = (%s)&%s;' % (function.type, marker_function) -- print ' } else {' -+ print(' } else if (strcmp("%s", (const char *)%s) == 0) {' % (marker_function, nameArg)) -+ print(' _result = (%s)&%s;' % (function.type, marker_function)) -+ print(' } else {') - Tracer.doInvokeFunction(self, function) - - # Replace function addresses with ours -@@ -864,24 +864,24 @@ class GlTracer(Tracer): - # contain the addresses of the wrapper functions, and not the real - # functions, but in practice this should make no difference. - if function.name in self.getProcAddressFunctionNames: -- print ' _result = _wrapProcAddress(%s, _result);' % (nameArg,) -+ print(' _result = _wrapProcAddress(%s, _result);' % (nameArg,)) - -- print ' }' -+ print(' }') - return - - if function.name in ('glGetProgramBinary', 'glGetProgramBinaryOES'): -- print r' bufSize = 0;' -+ print(r' bufSize = 0;') - - Tracer.doInvokeFunction(self, function) - - if function.name == 'glGetProgramiv': -- print r' if (params && pname == GL_PROGRAM_BINARY_LENGTH) {' -- print r' *params = 0;' -- print r' }' -+ print(r' if (params && pname == GL_PROGRAM_BINARY_LENGTH) {') -+ print(r' *params = 0;') -+ print(r' }') - if function.name in ('glGetProgramBinary', 'glGetProgramBinaryOES'): -- print r' if (length) {' -- print r' *length = 0;' -- print r' }' -+ print(r' if (length) {') -+ print(r' *length = 0;') -+ print(r' }') - - buffer_targets = [ - 'ARRAY_BUFFER', -@@ -902,9 +902,9 @@ class GlTracer(Tracer): - - # Keep track of buffer mappings - if function.name in ('glMapBufferRange', 'glMapBufferRangeEXT'): -- print ' if (access & GL_MAP_WRITE_BIT) {' -- print ' _checkBufferMapRange = true;' -- print ' }' -+ print(' if (access & GL_MAP_WRITE_BIT) {') -+ print(' _checkBufferMapRange = true;') -+ print(' }') - - boolean_names = [ - 'GL_FALSE', -@@ -932,17 +932,17 @@ class GlTracer(Tracer): - and (isinstance(arg.type, stdapi.Blob) \ - or (isinstance(arg.type, stdapi.Const) \ - and isinstance(arg.type.type, stdapi.Blob))): -- print ' {' -- print ' gltrace::Context *ctx = gltrace::getContext();' -- print ' GLint _unpack_buffer = 0;' -- print ' if (ctx->profile.desktop())' -- print ' _glGetIntegerv(GL_PIXEL_UNPACK_BUFFER_BINDING, &_unpack_buffer);' -- print ' if (_unpack_buffer) {' -- print ' trace::localWriter.writePointer((uintptr_t)%s);' % arg.name -- print ' } else {' -+ print(' {') -+ print(' gltrace::Context *ctx = gltrace::getContext();') -+ print(' GLint _unpack_buffer = 0;') -+ print(' if (ctx->profile.desktop())') -+ print(' _glGetIntegerv(GL_PIXEL_UNPACK_BUFFER_BINDING, &_unpack_buffer);') -+ print(' if (_unpack_buffer) {') -+ print(' trace::localWriter.writePointer((uintptr_t)%s);' % arg.name) -+ print(' } else {') - Tracer.serializeArgValue(self, function, arg) -- print ' }' -- print ' }' -+ print(' }') -+ print(' }') - return - - # Several GL state functions take GLenum symbolic names as -@@ -953,11 +953,11 @@ class GlTracer(Tracer): - assert arg.index > 0 - assert function.args[arg.index - 1].name == 'pname' - assert function.args[arg.index - 1].type == glapi.GLenum -- print ' if (is_symbolic_pname(pname) && is_symbolic_param(%s)) {' % arg.name -+ print(' if (is_symbolic_pname(pname) && is_symbolic_param(%s)) {' % arg.name) - self.serializeValue(glapi.GLenum, arg.name) -- print ' } else {' -+ print(' } else {') - Tracer.serializeArgValue(self, function, arg) -- print ' }' -+ print(' }') - return - - Tracer.serializeArgValue(self, function, arg) -@@ -967,20 +967,20 @@ class GlTracer(Tracer): - - # A simple state tracker to track the pointer values - # update the state -- print 'static void _trace_user_arrays(GLuint count)' -- print '{' -- print ' gltrace::Context *ctx = gltrace::getContext();' -- print -- print ' glprofile::Profile profile = ctx->profile;' -- print ' bool es1 = profile.es() && profile.major == 1;' -- print -+ print('static void _trace_user_arrays(GLuint count)') -+ print('{') -+ print(' gltrace::Context *ctx = gltrace::getContext();') -+ print() -+ print(' glprofile::Profile profile = ctx->profile;') -+ print(' bool es1 = profile.es() && profile.major == 1;') -+ print() - - # Temporarily unbind the array buffer -- print ' GLint _array_buffer = _glGetInteger(GL_ARRAY_BUFFER_BINDING);' -- print ' if (_array_buffer) {' -+ print(' GLint _array_buffer = _glGetInteger(GL_ARRAY_BUFFER_BINDING);') -+ print(' if (_array_buffer) {') - self.fake_glBindBuffer(api, 'GL_ARRAY_BUFFER', '0') -- print ' }' -- print -+ print(' }') -+ print() - - for camelcase_name, uppercase_name in self.arrays: - # in which profile is the array available? -@@ -993,45 +993,45 @@ class GlTracer(Tracer): - binding_name = 'GL_%s_ARRAY_BUFFER_BINDING' % uppercase_name - function = api.getFunctionByName(function_name) - -- print ' // %s' % function.prototype() -- print ' if (%s) {' % profile_check -+ print(' // %s' % function.prototype()) -+ print(' if (%s) {' % profile_check) - self.array_trace_prolog(api, uppercase_name) - self.array_prolog(api, uppercase_name) -- print ' if (_glIsEnabled(%s)) {' % enable_name -- print ' GLint _binding = _glGetInteger(%s);' % binding_name -- print ' if (!_binding) {' -+ print(' if (_glIsEnabled(%s)) {' % enable_name) -+ print(' GLint _binding = _glGetInteger(%s);' % binding_name) -+ print(' if (!_binding) {') - - # Get the arguments via glGet* - for arg in function.args: - arg_get_enum = 'GL_%s_ARRAY_%s' % (uppercase_name, arg.name.upper()) - arg_get_function, arg_type = TypeGetter().visit(arg.type) -- print ' %s %s = 0;' % (arg_type, arg.name) -- print ' _%s(%s, &%s);' % (arg_get_function, arg_get_enum, arg.name) -+ print(' %s %s = 0;' % (arg_type, arg.name)) -+ print(' _%s(%s, &%s);' % (arg_get_function, arg_get_enum, arg.name)) - - arg_names = ', '.join([arg.name for arg in function.args[:-1]]) -- print ' size_t _size = _%s_size(%s, count);' % (function.name, arg_names) -+ print(' size_t _size = _%s_size(%s, count);' % (function.name, arg_names)) - - # Emit a fake function - self.array_trace_intermezzo(api, uppercase_name) -- print ' unsigned _call = trace::localWriter.beginEnter(&_%s_sig, true);' % (function.name,) -+ print(' unsigned _call = trace::localWriter.beginEnter(&_%s_sig, true);' % (function.name,)) - for arg in function.args: - assert not arg.output -- print ' trace::localWriter.beginArg(%u);' % (arg.index,) -+ print(' trace::localWriter.beginArg(%u);' % (arg.index,)) - if arg.name != 'pointer': - self.serializeValue(arg.type, arg.name) - else: -- print ' trace::localWriter.writeBlob((const void *)%s, _size);' % (arg.name) -- print ' trace::localWriter.endArg();' -+ print(' trace::localWriter.writeBlob((const void *)%s, _size);' % (arg.name)) -+ print(' trace::localWriter.endArg();') - -- print ' trace::localWriter.endEnter();' -- print ' trace::localWriter.beginLeave(_call);' -- print ' trace::localWriter.endLeave();' -- print ' }' -- print ' }' -+ print(' trace::localWriter.endEnter();') -+ print(' trace::localWriter.beginLeave(_call);') -+ print(' trace::localWriter.endLeave();') -+ print(' }') -+ print(' }') - self.array_epilog(api, uppercase_name) - self.array_trace_epilog(api, uppercase_name) -- print ' }' -- print -+ print(' }') -+ print() - - # Samething, but for glVertexAttribPointer* - # -@@ -1043,12 +1043,12 @@ class GlTracer(Tracer): - # This means that the implementations of these functions do not always - # alias, and they need to be considered independently. - # -- print ' // ES1 does not support generic vertex attributes' -- print ' if (es1)' -- print ' return;' -- print -- print ' vertex_attrib _vertex_attrib = _get_vertex_attrib();' -- print -+ print(' // ES1 does not support generic vertex attributes') -+ print(' if (es1)') -+ print(' return;') -+ print() -+ print(' vertex_attrib _vertex_attrib = _get_vertex_attrib();') -+ print() - for suffix in ['', 'NV']: - if suffix: - SUFFIX = '_' + suffix -@@ -1057,24 +1057,24 @@ class GlTracer(Tracer): - function_name = 'glVertexAttribPointer' + suffix - function = api.getFunctionByName(function_name) - -- print ' // %s' % function.prototype() -- print ' if (_vertex_attrib == VERTEX_ATTRIB%s) {' % SUFFIX -+ print(' // %s' % function.prototype()) -+ print(' if (_vertex_attrib == VERTEX_ATTRIB%s) {' % SUFFIX) - if suffix == 'NV': -- print ' GLint _max_vertex_attribs = 16;' -+ print(' GLint _max_vertex_attribs = 16;') - else: -- print ' GLint _max_vertex_attribs = _glGetInteger(GL_MAX_VERTEX_ATTRIBS);' -- print ' for (GLint index = 0; index < _max_vertex_attribs; ++index) {' -- print ' GLint _enabled = 0;' -+ print(' GLint _max_vertex_attribs = _glGetInteger(GL_MAX_VERTEX_ATTRIBS);') -+ print(' for (GLint index = 0; index < _max_vertex_attribs; ++index) {') -+ print(' GLint _enabled = 0;') - if suffix == 'NV': -- print ' _glGetIntegerv(GL_VERTEX_ATTRIB_ARRAY0_NV + index, &_enabled);' -+ print(' _glGetIntegerv(GL_VERTEX_ATTRIB_ARRAY0_NV + index, &_enabled);') - else: -- print ' _glGetVertexAttribiv%s(index, GL_VERTEX_ATTRIB_ARRAY_ENABLED%s, &_enabled);' % (suffix, SUFFIX) -- print ' if (_enabled) {' -- print ' GLint _binding = 0;' -+ print(' _glGetVertexAttribiv%s(index, GL_VERTEX_ATTRIB_ARRAY_ENABLED%s, &_enabled);' % (suffix, SUFFIX)) -+ print(' if (_enabled) {') -+ print(' GLint _binding = 0;') - if suffix != 'NV': - # It doesn't seem possible to use VBOs with NV_vertex_program. -- print ' _glGetVertexAttribiv%s(index, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING%s, &_binding);' % (suffix, SUFFIX) -- print ' if (!_binding) {' -+ print(' _glGetVertexAttribiv%s(index, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING%s, &_binding);' % (suffix, SUFFIX)) -+ print(' if (!_binding) {') - - # Get the arguments via glGet* - for arg in function.args[1:]: -@@ -1083,40 +1083,40 @@ class GlTracer(Tracer): - else: - arg_get_enum = 'GL_VERTEX_ATTRIB_ARRAY_%s%s' % (arg.name.upper(), SUFFIX) - arg_get_function, arg_type = TypeGetter('glGetVertexAttrib', False, suffix).visit(arg.type) -- print ' %s %s = 0;' % (arg_type, arg.name) -- print ' _%s(index, %s, &%s);' % (arg_get_function, arg_get_enum, arg.name) -+ print(' %s %s = 0;' % (arg_type, arg.name)) -+ print(' _%s(index, %s, &%s);' % (arg_get_function, arg_get_enum, arg.name)) - - arg_names = ', '.join([arg.name for arg in function.args[1:-1]]) -- print ' size_t _size = _%s_size(%s, count);' % (function.name, arg_names) -+ print(' size_t _size = _%s_size(%s, count);' % (function.name, arg_names)) - - # Emit a fake function -- print ' unsigned _call = trace::localWriter.beginEnter(&_%s_sig, true);' % (function.name,) -+ print(' unsigned _call = trace::localWriter.beginEnter(&_%s_sig, true);' % (function.name,)) - for arg in function.args: - assert not arg.output -- print ' trace::localWriter.beginArg(%u);' % (arg.index,) -+ print(' trace::localWriter.beginArg(%u);' % (arg.index,)) - if arg.name != 'pointer': - self.serializeValue(arg.type, arg.name) - else: -- print ' trace::localWriter.writeBlob((const void *)%s, _size);' % (arg.name) -- print ' trace::localWriter.endArg();' -+ print(' trace::localWriter.writeBlob((const void *)%s, _size);' % (arg.name)) -+ print(' trace::localWriter.endArg();') - -- print ' trace::localWriter.endEnter();' -- print ' trace::localWriter.beginLeave(_call);' -- print ' trace::localWriter.endLeave();' -- print ' }' -- print ' }' -- print ' }' -- print ' }' -- print -+ print(' trace::localWriter.endEnter();') -+ print(' trace::localWriter.beginLeave(_call);') -+ print(' trace::localWriter.endLeave();') -+ print(' }') -+ print(' }') -+ print(' }') -+ print(' }') -+ print() - - # Restore the original array_buffer -- print ' if (_array_buffer) {' -+ print(' if (_array_buffer) {') - self.fake_glBindBuffer(api, 'GL_ARRAY_BUFFER', '_array_buffer') -- print ' }' -- print -+ print(' }') -+ print() - -- print '}' -- print -+ print('}') -+ print() - - # - # Hooks for glTexCoordPointer, which is identical to the other array -@@ -1125,49 +1125,49 @@ class GlTracer(Tracer): - - def array_prolog(self, api, uppercase_name): - if uppercase_name == 'TEXTURE_COORD': -- print ' GLint max_units = 0;' -- print ' if (ctx->profile.desktop())' -- print ' _glGetIntegerv(GL_MAX_TEXTURE_COORDS, &max_units);' -- print ' else' -- print ' _glGetIntegerv(GL_MAX_TEXTURE_UNITS, &max_units);' -- print ' GLint client_active_texture = GL_TEXTURE0;' -- print ' if (max_units > 0) {' -- print ' _glGetIntegerv(GL_CLIENT_ACTIVE_TEXTURE, &client_active_texture);' -- print ' }' -- print ' GLint unit = 0;' -- print ' do {' -- print ' GLint texture = GL_TEXTURE0 + unit;' -- print ' if (max_units > 0) {' -- print ' _glClientActiveTexture(texture);' -- print ' }' -+ print(' GLint max_units = 0;') -+ print(' if (ctx->profile.desktop())') -+ print(' _glGetIntegerv(GL_MAX_TEXTURE_COORDS, &max_units);') -+ print(' else') -+ print(' _glGetIntegerv(GL_MAX_TEXTURE_UNITS, &max_units);') -+ print(' GLint client_active_texture = GL_TEXTURE0;') -+ print(' if (max_units > 0) {') -+ print(' _glGetIntegerv(GL_CLIENT_ACTIVE_TEXTURE, &client_active_texture);') -+ print(' }') -+ print(' GLint unit = 0;') -+ print(' do {') -+ print(' GLint texture = GL_TEXTURE0 + unit;') -+ print(' if (max_units > 0) {') -+ print(' _glClientActiveTexture(texture);') -+ print(' }') - - def array_trace_prolog(self, api, uppercase_name): - if uppercase_name == 'TEXTURE_COORD': -- print ' bool client_active_texture_dirty = false;' -+ print(' bool client_active_texture_dirty = false;') - - def array_epilog(self, api, uppercase_name): - if uppercase_name == 'TEXTURE_COORD': -- print ' } while (++unit < max_units);' -+ print(' } while (++unit < max_units);') - self.array_cleanup(api, uppercase_name) - - def array_cleanup(self, api, uppercase_name): - if uppercase_name == 'TEXTURE_COORD': -- print ' if (max_units > 0) {' -- print ' _glClientActiveTexture(client_active_texture);' -- print ' }' -+ print(' if (max_units > 0) {') -+ print(' _glClientActiveTexture(client_active_texture);') -+ print(' }') - - def array_trace_intermezzo(self, api, uppercase_name): - if uppercase_name == 'TEXTURE_COORD': -- print ' if (texture != client_active_texture || client_active_texture_dirty) {' -- print ' client_active_texture_dirty = true;' -+ print(' if (texture != client_active_texture || client_active_texture_dirty) {') -+ print(' client_active_texture_dirty = true;') - self.fake_glClientActiveTexture_call(api, "texture"); -- print ' }' -+ print(' }') - - def array_trace_epilog(self, api, uppercase_name): - if uppercase_name == 'TEXTURE_COORD': -- print ' if (client_active_texture_dirty) {' -+ print(' if (client_active_texture_dirty) {') - self.fake_glClientActiveTexture_call(api, "client_active_texture"); -- print ' }' -+ print(' }') - - def fake_glBindBuffer(self, api, target, buffer): - function = api.getFunctionByName('glBindBuffer') -@@ -1180,13 +1180,13 @@ class GlTracer(Tracer): - def emitFakeTexture2D(self): - function = glapi.glapi.getFunctionByName('glTexImage2D') - instances = function.argNames() -- print ' unsigned _fake_call = trace::localWriter.beginEnter(&_%s_sig, true);' % (function.name,) -+ print(' unsigned _fake_call = trace::localWriter.beginEnter(&_%s_sig, true);' % (function.name,)) - for arg in function.args: - assert not arg.output - self.serializeArg(function, arg) -- print ' trace::localWriter.endEnter();' -- print ' trace::localWriter.beginLeave(_fake_call);' -- print ' trace::localWriter.endLeave();' -+ print(' trace::localWriter.endEnter();') -+ print(' trace::localWriter.beginLeave(_fake_call);') -+ print(' trace::localWriter.endLeave();') - - - -diff --git a/wrappers/glxtrace.py b/wrappers/glxtrace.py -index f35d1fe9..b05028e2 100644 ---- a/wrappers/glxtrace.py -+++ b/wrappers/glxtrace.py -@@ -64,7 +64,7 @@ class GlxTracer(GlTracer): - - def traceFunctionImplBody(self, function): - if function.name in self.destroyContextFunctionNames: -- print ' gltrace::releaseContext((uintptr_t)ctx);' -+ print(' gltrace::releaseContext((uintptr_t)ctx);') - - if function.name == 'glXGetCurrentDisplay': - print ' if(_glXGetCurrentDisplay == &glXGetCurrentDisplay ){' -@@ -74,16 +74,16 @@ class GlxTracer(GlTracer): - GlTracer.traceFunctionImplBody(self, function) - - if function.name in self.createContextFunctionNames: -- print ' if (_result != NULL)' -- print ' gltrace::createContext((uintptr_t)_result);' -+ print(' if (_result != NULL)') -+ print(' gltrace::createContext((uintptr_t)_result);') - - if function.name in self.makeCurrentFunctionNames: -- print ' if (_result) {' -- print ' if (ctx != NULL)' -- print ' gltrace::setContext((uintptr_t)ctx);' -- print ' else' -- print ' gltrace::clearContext();' -- print ' }' -+ print(' if (_result) {') -+ print(' if (ctx != NULL)') -+ print(' gltrace::setContext((uintptr_t)ctx);') -+ print(' else') -+ print(' gltrace::clearContext();') -+ print(' }') - - if function.name == 'glXBindTexImageEXT': - # FIXME: glXBindTexImageEXT gets called frequently, so we should -@@ -92,7 +92,7 @@ class GlxTracer(GlTracer): - # emit emitFakeTexture2D when it changes - # - keep a global hash of the pixels - # FIXME: Handle mipmaps -- print r''' -+ print(r''' - unsigned glx_target = 0; - _glXQueryDrawable(display, drawable, GLX_TEXTURE_TARGET_EXT, &glx_target); - GLenum target; -@@ -152,29 +152,29 @@ class GlxTracer(GlTracer): - GLint row_stride = _align(width * 4, alignment); - GLvoid * pixels = malloc(height * row_stride); - _glGetTexImage(target, level, format, type, pixels); -- ''' -+ ''') - self.emitFakeTexture2D() -- print r''' -+ print(r''' - free(pixels); - } -- ''' -+ ''') - - - if __name__ == '__main__': -- print -- print '#include <stdlib.h>' -- print '#include <string.h>' -- print -- print '#include "trace_writer_local.hpp"' -- print -- print '// To validate our prototypes' -- print '#define GL_GLEXT_PROTOTYPES' -- print '#define GLX_GLXEXT_PROTOTYPES' -- print -- print '#include "dlopen.hpp"' -- print '#include "glproc.hpp"' -- print '#include "glsize.hpp"' -- print -+ print() -+ print('#include <stdlib.h>') -+ print('#include <string.h>') -+ print() -+ print('#include "trace_writer_local.hpp"') -+ print() -+ print('// To validate our prototypes') -+ print('#define GL_GLEXT_PROTOTYPES') -+ print('#define GLX_GLXEXT_PROTOTYPES') -+ print() -+ print('#include "dlopen.hpp"') -+ print('#include "glproc.hpp"') -+ print('#include "glsize.hpp"') -+ print() - - module = Module() - module.mergeModule(glxapi) -diff --git a/wrappers/trace.py b/wrappers/trace.py -index 7d1baa10..318f0990 100644 ---- a/wrappers/trace.py -+++ b/wrappers/trace.py -@@ -69,21 +69,21 @@ class ComplexValueSerializer(stdapi.OnceVisitor): - - def visitStruct(self, struct): - # Ensure member array has nonzero length to avoid MSVC error C2466 -- print 'static const char * _struct%s_members[%u] = {' % (struct.tag, max(len(struct.members), 1)) -+ print('static const char * _struct%s_members[%u] = {' % (struct.tag, max(len(struct.members), 1))) - for type, name, in struct.members: - if name is None: -- print ' "",' -+ print(' "",') - else: -- print ' "%s",' % (name,) -- print '};' -- print 'static const trace::StructSig _struct%s_sig = {' % (struct.tag,) -+ print(' "%s",' % (name,)) -+ print('};') -+ print('static const trace::StructSig _struct%s_sig = {' % (struct.tag,)) - if struct.name is None: - structName = '""' - else: - structName = '"%s"' % struct.name -- print ' %u, %s, %u, _struct%s_members' % (struct.id, structName, len(struct.members), struct.tag) -- print '};' -- print -+ print(' %u, %s, %u, _struct%s_members' % (struct.id, structName, len(struct.members), struct.tag)) -+ print('};') -+ print() - - def visitArray(self, array): - self.visit(array.type) -@@ -95,26 +95,26 @@ class ComplexValueSerializer(stdapi.OnceVisitor): - pass - - def visitEnum(self, enum): -- print 'static const trace::EnumValue _enum%s_values[] = {' % (enum.tag) -+ print('static const trace::EnumValue _enum%s_values[] = {' % (enum.tag)) - for value in enum.values: -- print ' {"%s", %s},' % (value, value) -- print '};' -- print -- print 'static const trace::EnumSig _enum%s_sig = {' % (enum.tag) -- print ' %u, %u, _enum%s_values' % (enum.id, len(enum.values), enum.tag) -- print '};' -- print -+ print(' {"%s", %s},' % (value, value)) -+ print('};') -+ print() -+ print('static const trace::EnumSig _enum%s_sig = {' % (enum.tag)) -+ print(' %u, %u, _enum%s_values' % (enum.id, len(enum.values), enum.tag)) -+ print('};') -+ print() - - def visitBitmask(self, bitmask): -- print 'static const trace::BitmaskFlag _bitmask%s_flags[] = {' % (bitmask.tag) -+ print('static const trace::BitmaskFlag _bitmask%s_flags[] = {' % (bitmask.tag)) - for value in bitmask.values: -- print ' {"%s", %s},' % (value, value) -- print '};' -- print -- print 'static const trace::BitmaskSig _bitmask%s_sig = {' % (bitmask.tag) -- print ' %u, %u, _bitmask%s_flags' % (bitmask.id, len(bitmask.values), bitmask.tag) -- print '};' -- print -+ print(' {"%s", %s},' % (value, value)) -+ print('};') -+ print() -+ print('static const trace::BitmaskSig _bitmask%s_sig = {' % (bitmask.tag)) -+ print(' %u, %u, _bitmask%s_flags' % (bitmask.id, len(bitmask.values), bitmask.tag)) -+ print('};') -+ print() - - def visitPointer(self, pointer): - self.visit(pointer.type) -@@ -146,16 +146,16 @@ class ComplexValueSerializer(stdapi.OnceVisitor): - def visitPolymorphic(self, polymorphic): - if not polymorphic.contextLess: - return -- print 'static void _write__%s(int selector, %s const & value) {' % (polymorphic.tag, polymorphic.expr) -- print ' switch (selector) {' -+ print('static void _write__%s(int selector, %s const & value) {' % (polymorphic.tag, polymorphic.expr)) -+ print(' switch (selector) {') - for cases, type in polymorphic.iterSwitch(): - for case in cases: -- print ' %s:' % case -+ print(' %s:' % case) - self.serializer.visit(type, '(%s)(value)' % (type,)) -- print ' break;' -- print ' }' -- print '}' -- print -+ print(' break;') -+ print(' }') -+ print('}') -+ print() - - - class ValueSerializer(stdapi.Visitor, stdapi.ExpanderMixin): -@@ -167,7 +167,7 @@ class ValueSerializer(stdapi.Visitor, stdapi.ExpanderMixin): - ''' - - def visitLiteral(self, literal, instance): -- print ' trace::localWriter.write%s(%s);' % (literal.kind, instance) -+ print(' trace::localWriter.write%s(%s);' % (literal.kind, instance)) - - def visitString(self, string, instance): - if not string.wide: -@@ -183,33 +183,33 @@ class ValueSerializer(stdapi.Visitor, stdapi.ExpanderMixin): - length = ', %s' % self.expand(string.length) - else: - length = '' -- print ' trace::localWriter.write%s(%s%s);' % (suffix, instance, length) -+ print(' trace::localWriter.write%s(%s%s);' % (suffix, instance, length)) - - def visitConst(self, const, instance): - self.visit(const.type, instance) - - def visitStruct(self, struct, instance): -- print ' trace::localWriter.beginStruct(&_struct%s_sig);' % (struct.tag,) -+ print(' trace::localWriter.beginStruct(&_struct%s_sig);' % (struct.tag,)) - for member in struct.members: - self.visitMember(member, instance) -- print ' trace::localWriter.endStruct();' -+ print(' trace::localWriter.endStruct();') - - def visitArray(self, array, instance): - length = '_c' + array.type.tag - index = '_i' + array.type.tag - array_length = self.expand(array.length) -- print ' if (%s) {' % instance -- print ' size_t %s = %s > 0 ? %s : 0;' % (length, array_length, array_length) -- print ' trace::localWriter.beginArray(%s);' % length -- print ' for (size_t %s = 0; %s < %s; ++%s) {' % (index, index, length, index) -- print ' trace::localWriter.beginElement();' -+ print(' if (%s) {' % instance) -+ print(' size_t %s = %s > 0 ? %s : 0;' % (length, array_length, array_length)) -+ print(' trace::localWriter.beginArray(%s);' % length) -+ print(' for (size_t %s = 0; %s < %s; ++%s) {' % (index, index, length, index)) -+ print(' trace::localWriter.beginElement();') - self.visitElement(index, array.type, '(%s)[%s]' % (instance, index)) -- print ' trace::localWriter.endElement();' -- print ' }' -- print ' trace::localWriter.endArray();' -- print ' } else {' -- print ' trace::localWriter.writeNull();' -- print ' }' -+ print(' trace::localWriter.endElement();') -+ print(' }') -+ print(' trace::localWriter.endArray();') -+ print(' } else {') -+ print(' trace::localWriter.writeNull();') -+ print(' }') - - def visitAttribArray(self, array, instance): - # For each element, decide if it is a key or a value (which depends on the previous key). -@@ -218,90 +218,90 @@ class ValueSerializer(stdapi.Visitor, stdapi.ExpanderMixin): - - # determine the array length which must be passed to writeArray() up front - count = '_c' + array.baseType.tag -- print ' {' -- print ' int %s;' % count -- print ' for (%(c)s = 0; %(array)s && %(array)s[%(c)s] != %(terminator)s; %(c)s += 2) {' \ -- % {'c': count, 'array': instance, 'terminator': array.terminator} -+ print(' {') -+ print(' int %s;' % count) -+ print(' for (%(c)s = 0; %(array)s && %(array)s[%(c)s] != %(terminator)s; %(c)s += 2) {' \ -+ % {'c': count, 'array': instance, 'terminator': array.terminator}) - if array.hasKeysWithoutValues: -- print ' switch (int(%(array)s[%(c)s])) {' % {'array': instance, 'c': count} -+ print(' switch (int(%(array)s[%(c)s])) {' % {'array': instance, 'c': count}) - for key, valueType in array.valueTypes: - if valueType is None: -- print ' case %s:' % key -- print ' %s--;' % count # the next value is a key again and checked if it's the terminator -- print ' break;' -- print ' }' -- print ' }' -- print ' %(c)s += %(array)s ? 1 : 0;' % {'c': count, 'array': instance} -- print ' trace::localWriter.beginArray(%s);' % count -+ print(' case %s:' % key) -+ print(' %s--;' % count) # the next value is a key again and checked if it's the terminator -+ print(' break;') -+ print(' }') -+ print(' }') -+ print(' %(c)s += %(array)s ? 1 : 0;' % {'c': count, 'array': instance}) -+ print(' trace::localWriter.beginArray(%s);' % count) - - # for each key / key-value pair write the key and the value, if the key requires one - - index = '_i' + array.baseType.tag -- print ' for (int %(i)s = 0; %(i)s < %(count)s; %(i)s++) {' % {'i': index, 'count': count} -- print ' trace::localWriter.beginElement();' -+ print(' for (int %(i)s = 0; %(i)s < %(count)s; %(i)s++) {' % {'i': index, 'count': count}) -+ print(' trace::localWriter.beginElement();') - self.visit(array.baseType, "%(array)s[%(i)s]" % {'array': instance, 'i': index}) -- print ' trace::localWriter.endElement();' -- print ' if (%(i)s + 1 >= %(count)s) {' % {'i': index, 'count': count} -- print ' break;' -- print ' }' -- print ' switch (int(%(array)s[%(i)s++])) {' % {'array': instance, 'i': index} -+ print(' trace::localWriter.endElement();') -+ print(' if (%(i)s + 1 >= %(count)s) {' % {'i': index, 'count': count}) -+ print(' break;') -+ print(' }') -+ print(' switch (int(%(array)s[%(i)s++])) {' % {'array': instance, 'i': index}) - # write generic value the usual way - for key, valueType in array.valueTypes: - if valueType is not None: -- print ' case %s:' % key -- print ' trace::localWriter.beginElement();' -+ print(' case %s:' % key) -+ print(' trace::localWriter.beginElement();') - self.visitElement(index, valueType, '(%(array)s)[%(i)s]' % {'array': instance, 'i': index}) -- print ' trace::localWriter.endElement();' -- print ' break;' -+ print(' trace::localWriter.endElement();') -+ print(' break;') - # known key with no value, just decrease the index so we treat the next value as a key - if array.hasKeysWithoutValues: - for key, valueType in array.valueTypes: - if valueType is None: -- print ' case %s:' % key -- print ' %s--;' % index -- print ' break;' -+ print(' case %s:' % key) -+ print(' %s--;' % index) -+ print(' break;') - # unknown key, write an int value -- print ' default:' -- print ' trace::localWriter.beginElement();' -- print ' os::log("apitrace: warning: %s: unknown key 0x%04X, interpreting value as int\\n", ' + \ -- '__FUNCTION__, int(%(array)s[%(i)s - 1]));' % {'array': instance, 'i': index} -- print ' trace::localWriter.writeSInt(%(array)s[%(i)s]);' % {'array': instance, 'i': index} -- print ' trace::localWriter.endElement();' -- print ' break;' -- print ' }' -- print ' }' -- print ' trace::localWriter.endArray();' -- print ' }' -+ print(' default:') -+ print(' trace::localWriter.beginElement();') -+ print(' os::log("apitrace: warning: %s: unknown key 0x%04X, interpreting value as int\\n", ' + \ -+ '__FUNCTION__, int(%(array)s[%(i)s - 1]));' % {'array': instance, 'i': index}) -+ print(' trace::localWriter.writeSInt(%(array)s[%(i)s]);' % {'array': instance, 'i': index}) -+ print(' trace::localWriter.endElement();') -+ print(' break;') -+ print(' }') -+ print(' }') -+ print(' trace::localWriter.endArray();') -+ print(' }') - - - def visitBlob(self, blob, instance): -- print ' trace::localWriter.writeBlob(%s, %s);' % (instance, self.expand(blob.size)) -+ print(' trace::localWriter.writeBlob(%s, %s);' % (instance, self.expand(blob.size))) - - def visitEnum(self, enum, instance): -- print ' trace::localWriter.writeEnum(&_enum%s_sig, %s);' % (enum.tag, instance) -+ print(' trace::localWriter.writeEnum(&_enum%s_sig, %s);' % (enum.tag, instance)) - - def visitBitmask(self, bitmask, instance): -- print ' trace::localWriter.writeBitmask(&_bitmask%s_sig, %s);' % (bitmask.tag, instance) -+ print(' trace::localWriter.writeBitmask(&_bitmask%s_sig, %s);' % (bitmask.tag, instance)) - - def visitPointer(self, pointer, instance): -- print ' if (%s) {' % instance -- print ' trace::localWriter.beginArray(1);' -- print ' trace::localWriter.beginElement();' -+ print(' if (%s) {' % instance) -+ print(' trace::localWriter.beginArray(1);') -+ print(' trace::localWriter.beginElement();') - self.visit(pointer.type, "*" + instance) -- print ' trace::localWriter.endElement();' -- print ' trace::localWriter.endArray();' -- print ' } else {' -- print ' trace::localWriter.writeNull();' -- print ' }' -+ print(' trace::localWriter.endElement();') -+ print(' trace::localWriter.endArray();') -+ print(' } else {') -+ print(' trace::localWriter.writeNull();') -+ print(' }') - - def visitIntPointer(self, pointer, instance): -- print ' trace::localWriter.writePointer((uintptr_t)%s);' % instance -+ print(' trace::localWriter.writePointer((uintptr_t)%s);' % instance) - - def visitObjPointer(self, pointer, instance): -- print ' trace::localWriter.writePointer((uintptr_t)%s);' % instance -+ print(' trace::localWriter.writePointer((uintptr_t)%s);' % instance) - - def visitLinearPointer(self, pointer, instance): -- print ' trace::localWriter.writePointer((uintptr_t)%s);' % instance -+ print(' trace::localWriter.writePointer((uintptr_t)%s);' % instance) - - def visitReference(self, reference, instance): - self.visit(reference.type, instance) -@@ -313,31 +313,31 @@ class ValueSerializer(stdapi.Visitor, stdapi.ExpanderMixin): - self.visit(alias.type, instance) - - def visitOpaque(self, opaque, instance): -- print ' trace::localWriter.writePointer((uintptr_t)%s);' % instance -+ print(' trace::localWriter.writePointer((uintptr_t)%s);' % instance) - - def visitInterface(self, interface, instance): - assert False - - def visitPolymorphic(self, polymorphic, instance): - if polymorphic.contextLess: -- print ' _write__%s(%s, %s);' % (polymorphic.tag, polymorphic.switchExpr, instance) -+ print(' _write__%s(%s, %s);' % (polymorphic.tag, polymorphic.switchExpr, instance)) - else: - switchExpr = self.expand(polymorphic.switchExpr) -- print ' switch (%s) {' % switchExpr -+ print(' switch (%s) {' % switchExpr) - for cases, type in polymorphic.iterSwitch(): - for case in cases: -- print ' %s:' % case -+ print(' %s:' % case) - caseInstance = instance - if type.expr is not None: - caseInstance = 'static_cast<%s>(%s)' % (type, caseInstance) - self.visit(type, caseInstance) -- print ' break;' -+ print(' break;') - if polymorphic.defaultType is None: -- print r' default:' -- print r' os::log("apitrace: warning: %%s: unexpected polymorphic case %%i\n", __FUNCTION__, (int)%s);' % (switchExpr,) -- print r' trace::localWriter.writeNull();' -- print r' break;' -- print ' }' -+ print(r' default:') -+ print(r' os::log("apitrace: warning: %%s: unexpected polymorphic case %%i\n", __FUNCTION__, (int)%s);' % (switchExpr,)) -+ print(r' trace::localWriter.writeNull();') -+ print(r' break;') -+ print(' }') - - - class WrapDecider(stdapi.Traverser): -@@ -369,16 +369,16 @@ class ValueWrapper(stdapi.Traverser, stdapi.ExpanderMixin): - - def visitArray(self, array, instance): - array_length = self.expand(array.length) -- print " if (%s) {" % instance -- print " for (size_t _i = 0, _s = %s; _i < _s; ++_i) {" % array_length -+ print(" if (%s) {" % instance) -+ print(" for (size_t _i = 0, _s = %s; _i < _s; ++_i) {" % array_length) - self.visitElement('_i', array.type, instance + "[_i]") -- print " }" -- print " }" -+ print(" }") -+ print(" }") - - def visitPointer(self, pointer, instance): -- print " if (%s) {" % instance -+ print(" if (%s) {" % instance) - self.visit(pointer.type, "*" + instance) -- print " }" -+ print(" }") - - def visitObjPointer(self, pointer, instance): - elem_type = pointer.type.mutable() -@@ -388,13 +388,13 @@ class ValueWrapper(stdapi.Traverser, stdapi.ExpanderMixin): - self.visitInterfacePointer(elem_type.type, instance) - else: - # All interfaces should at least implement IUnknown -- print " WrapIUnknown::_wrap(__FUNCTION__, (IUnknown **) &%s);" % (instance,) -+ print(" WrapIUnknown::_wrap(__FUNCTION__, (IUnknown **) &%s);" % (instance,)) - - def visitInterface(self, interface, instance): - raise NotImplementedError - - def visitInterfacePointer(self, interface, instance): -- print " Wrap%s::_wrap(__FUNCTION__, &%s);" % (interface.name, instance) -+ print(" Wrap%s::_wrap(__FUNCTION__, &%s);" % (interface.name, instance)) - - def visitPolymorphic(self, type, instance): - # XXX: There might be polymorphic values that need wrapping in the future -@@ -409,17 +409,17 @@ class ValueUnwrapper(ValueWrapper): - def visitStruct(self, struct, instance): - if not self.allocated: - # Argument is constant. We need to create a non const -- print ' {' -- print " %s * _t = static_cast<%s *>(alloca(sizeof *_t));" % (struct, struct) -- print ' *_t = %s;' % (instance,) -+ print(' {') -+ print(" %s * _t = static_cast<%s *>(alloca(sizeof *_t));" % (struct, struct)) -+ print(' *_t = %s;' % (instance,)) - assert instance.startswith('*') -- print ' %s = _t;' % (instance[1:],) -+ print(' %s = _t;' % (instance[1:],)) - instance = '*_t' - self.allocated = True - try: - return ValueWrapper.visitStruct(self, struct, instance) - finally: -- print ' }' -+ print(' }') - else: - return ValueWrapper.visitStruct(self, struct, instance) - -@@ -428,18 +428,18 @@ class ValueUnwrapper(ValueWrapper): - return ValueWrapper.visitArray(self, array, instance) - array_length = self.expand(array.length) - elem_type = array.type.mutable() -- print " if (%s && %s) {" % (instance, array_length) -- print " %s * _t = static_cast<%s *>(alloca(%s * sizeof *_t));" % (elem_type, elem_type, array_length) -- print " for (size_t _i = 0, _s = %s; _i < _s; ++_i) {" % array_length -- print " _t[_i] = %s[_i];" % instance -+ print(" if (%s && %s) {" % (instance, array_length)) -+ print(" %s * _t = static_cast<%s *>(alloca(%s * sizeof *_t));" % (elem_type, elem_type, array_length)) -+ print(" for (size_t _i = 0, _s = %s; _i < _s; ++_i) {" % array_length) -+ print(" _t[_i] = %s[_i];" % instance) - self.allocated = True - self.visit(array.type, "_t[_i]") -- print " }" -- print " %s = _t;" % instance -- print " }" -+ print(" }") -+ print(" %s = _t;" % instance) -+ print(" }") - - def visitInterfacePointer(self, interface, instance): -- print r' Wrap%s::_unwrap(__FUNCTION__, &%s);' % (interface.name, instance) -+ print(r' Wrap%s::_unwrap(__FUNCTION__, &%s);' % (interface.name, instance)) - - - def _getInterfaceHierarchy(allIfaces, baseIface, result): -@@ -479,14 +479,17 @@ class Tracer: - # Includes - for module in api.modules: - for header in module.headers: -- print header -- print -+ print(header) -+ print() - - # Generate the serializer functions - types = api.getAllTypes() - visitor = ComplexValueSerializer(self.serializerFactory()) -- map(visitor.visit, types) -- print -+ -+ for tp in types: -+ visitor.visit(tp) -+ -+ print() - - # Interfaces wrapers - self.traceInterfaces(api) -@@ -498,22 +501,22 @@ class Tracer: - self.traceFunctionDecl(function) - for function in api.getAllFunctions(): - self.traceFunctionImpl(function) -- print -+ print() - - self.footer(api) - - def header(self, api): -- print '#ifdef _WIN32' -- print '# include <malloc.h> // alloca' -- print '# ifndef alloca' -- print '# define alloca _alloca' -- print '# endif' -- print '#else' -- print '# include <alloca.h> // alloca' -- print '#endif' -- print -- print -- print 'static std::map<void *, void *> g_WrappedObjects;' -+ print('#ifdef _WIN32') -+ print('# include <malloc.h> // alloca') -+ print('# ifndef alloca') -+ print('# define alloca _alloca') -+ print('# endif') -+ print('#else') -+ print('# include <alloca.h> // alloca') -+ print('#endif') -+ print() -+ print() -+ print('static std::map<void *, void *> g_WrappedObjects;') - - def footer(self, api): - pass -@@ -523,11 +526,11 @@ class Tracer: - - if not function.internal: - if function.args: -- print 'static const char * _%s_args[%u] = {%s};' % (function.name, len(function.args), ', '.join(['"%s"' % arg.name for arg in function.args])) -+ print('static const char * _%s_args[%u] = {%s};' % (function.name, len(function.args), ', '.join(['"%s"' % arg.name for arg in function.args]))) - else: -- print 'static const char ** _%s_args = NULL;' % (function.name,) -- print 'static const trace::FunctionSig _%s_sig = {%u, "%s", %u, _%s_args};' % (function.name, self.getFunctionSigId(), function.name, len(function.args), function.name) -- print -+ print('static const char ** _%s_args = NULL;' % (function.name,)) -+ print('static const trace::FunctionSig _%s_sig = {%u, "%s", %u, _%s_args};' % (function.name, self.getFunctionSigId(), function.sigName(), len(function.args), function.name)) -+ print() - - def getFunctionSigId(self): - id = Tracer.__id -@@ -539,12 +542,12 @@ class Tracer: - - def traceFunctionImpl(self, function): - if self.isFunctionPublic(function): -- print 'extern "C" PUBLIC' -+ print('extern "C" PUBLIC') - else: -- print 'extern "C" PRIVATE' -- print function.prototype() + ' {' -+ print('extern "C" PRIVATE') -+ print(function.prototype() + ' {') - if function.type is not stdapi.Void: -- print ' %s _result;' % function.type -+ print(' %s _result;' % function.type) - - for arg in function.args: - if not arg.output: -@@ -555,43 +558,43 @@ class Tracer: - # XXX: wrapping should go here, but before we can do that we'll need to protect g_WrappedObjects with its own mutex - - if function.type is not stdapi.Void: -- print ' return _result;' -+ print(' return _result;') - -- print '}' -- print -+ print('}') -+ print() - - def traceFunctionImplBody(self, function): - multi_draw_function_regex = re.compile(r'^glMultiDraw(Arrays|Elements)([A-Z][a-zA-Z]*)?$' ) - if not function.internal: -- print ' unsigned _call = trace::localWriter.beginEnter(&_%s_sig);' % (function.name,) -+ print(' unsigned _call = trace::localWriter.beginEnter(&_%s_sig);' % (function.name,)) - for arg in function.args: - if not arg.output: - self.serializeArg(function, arg) -- print ' trace::localWriter.endEnter();' -+ print(' trace::localWriter.endEnter();') - - if self.multi_draw_function_regex.match(function.name): -- print ' trace::localWriter.beginIgnore();' -- print ' trace::localWriter.endIgnore();' -+ print(' trace::localWriter.beginIgnore();') -+ print(' trace::localWriter.endEnter();') - - self.invokeFunction(function) - - if self.multi_draw_function_regex.match(function.name): -- print ' trace::localWriter.beginTrace();' -- print ' trace::localWriter.endTrace();' -+ print(' trace::localWriter.beginTrace();') -+ print(' trace::localWriter.endTrace();') - - if not function.internal: -- print ' trace::localWriter.beginLeave(_call);' -- print ' if (%s) {' % self.wasFunctionSuccessful(function) -+ print(' trace::localWriter.beginLeave(_call);') -+ print(' if (%s) {' % self.wasFunctionSuccessful(function)) - for arg in function.args: - if arg.output: - self.serializeArg(function, arg) - self.wrapArg(function, arg) -- print ' }' -+ print(' }') - if function.type is not stdapi.Void: - self.serializeRet(function, "_result") - if function.type is not stdapi.Void: - self.wrapRet(function, "_result") -- print ' trace::localWriter.endLeave();' -+ print(' trace::localWriter.endLeave();') - - def invokeFunction(self, function): - self.doInvokeFunction(function) -@@ -603,7 +606,7 @@ class Tracer: - else: - result = '_result = ' - dispatch = prefix + function.name + suffix -- print ' %s%s(%s);' % (result, dispatch, ', '.join([str(arg.name) for arg in function.args])) -+ print(' %s%s(%s);' % (result, dispatch, ', '.join([str(arg.name) for arg in function.args]))) - - def wasFunctionSuccessful(self, function): - if function.type is stdapi.Void: -@@ -613,9 +616,9 @@ class Tracer: - return 'true' - - def serializeArg(self, function, arg): -- print ' trace::localWriter.beginArg(%u);' % (arg.index,) -+ print(' trace::localWriter.beginArg(%u);' % (arg.index,)) - self.serializeArgValue(function, arg) -- print ' trace::localWriter.endArg();' -+ print(' trace::localWriter.endArg();') - - def serializeArgValue(self, function, arg): - self.serializeValue(arg.type, arg.name) -@@ -641,9 +644,9 @@ class Tracer: - self.unwrapValue(arg.type, arg.name) - - def serializeRet(self, function, instance): -- print ' trace::localWriter.beginReturn();' -+ print(' trace::localWriter.beginReturn();') - self.serializeValue(function.type, instance) -- print ' trace::localWriter.endReturn();' -+ print(' trace::localWriter.endReturn();') - - def serializeValue(self, type, instance): - serializer = self.serializerFactory() -@@ -672,70 +675,72 @@ class Tracer: - if not interfaces: - return - -- print r'#include "guids.hpp"' -- print -+ print(r'#include "guids.hpp"') -+ print() - - map(self.declareWrapperInterface, interfaces) - - # Helper functions to wrap/unwrap interface pointers -- print r'static inline bool' -- print r'hasChildInterface(REFIID riid, IUnknown *pUnknown) {' -- print r' IUnknown *pObj = NULL;' -- print r' HRESULT hr = pUnknown->QueryInterface(riid, (VOID **)&pObj);' -- print r' if (FAILED(hr)) {' -- print r' return false;' -- print r' }' -- print r' assert(pObj);' -- print r' pObj->Release();' -- print r' return pUnknown == pObj;' -- print r'}' -- print -- print r'static inline const void *' -- print r'getVtbl(const void *pvObj) {' -- print r' return pvObj ? *(const void **)pvObj : NULL;' -- print r'}' -- print -+ print(r'static inline bool') -+ print(r'hasChildInterface(REFIID riid, IUnknown *pUnknown) {') -+ print(r' IUnknown *pObj = NULL;') -+ print(r' HRESULT hr = pUnknown->QueryInterface(riid, (VOID **)&pObj);') -+ print(r' if (FAILED(hr)) {') -+ print(r' return false;') -+ print(r' }') -+ print(r' assert(pObj);') -+ print(r' pObj->Release();') -+ print(r' return pUnknown == pObj;') -+ print(r'}') -+ print() -+ print(r'static inline const void *') -+ print(r'getVtbl(const void *pvObj) {') -+ print(r' return pvObj ? *(const void **)pvObj : NULL;') -+ print(r'}') -+ print() - - self.implementIidWrapper(api) - -- map(self.implementWrapperInterface, interfaces) -- print -+ for iface in interfaces: -+ self.implementWrapperInterface(iface) -+ -+ print() - - def declareWrapperInterface(self, interface): - wrapperInterfaceName = getWrapperInterfaceName(interface) -- print "class %s : public %s " % (wrapperInterfaceName, interface.name) -- print "{" -- print "private:" -- print " %s(%s * pInstance);" % (wrapperInterfaceName, interface.name) -- print " virtual ~%s();" % wrapperInterfaceName -- print "public:" -- print " static %s* _create(const char *entryName, %s * pInstance);" % (wrapperInterfaceName, interface.name) -- print " static void _wrap(const char *entryName, %s ** ppInstance);" % (interface.name,) -- print " static void _unwrap(const char *entryName, %s ** pInstance);" % (interface.name,) -- print -+ print("class %s : public %s " % (wrapperInterfaceName, interface.name)) -+ print("{") -+ print("private:") -+ print(" %s(%s * pInstance);" % (wrapperInterfaceName, interface.name)) -+ print(" virtual ~%s();" % wrapperInterfaceName) -+ print("public:") -+ print(" static %s* _create(const char *entryName, %s * pInstance);" % (wrapperInterfaceName, interface.name)) -+ print(" static void _wrap(const char *entryName, %s ** ppInstance);" % (interface.name,)) -+ print(" static void _unwrap(const char *entryName, %s ** pInstance);" % (interface.name,)) -+ print() - - methods = list(interface.iterMethods()) - for method in methods: -- print " " + method.prototype() + ";" -+ print(" " + method.prototype() + ";") - print - - for type, name, value in self.enumWrapperInterfaceVariables(interface): -- print ' %s %s;' % (type, name) -- print -- -- print r'private:' -- print r' void _dummy(unsigned i) const {' -- print r' os::log("error: %%s: unexpected virtual method %%i of instance pWrapper=%%p pvObj=%%p pVtbl=%%p\n", "%s", i, this, m_pInstance, m_pVtbl);' % interface.name -- print r' trace::localWriter.flush();' -- print r' os::abort();' -- print r' }' -- print -+ print(' %s %s;' % (type, name)) -+ print() -+ -+ print(r'private:') -+ print(r' void _dummy(unsigned i) const {') -+ print(r' os::log("error: %%s: unexpected virtual method %%i of instance pWrapper=%%p pvObj=%%p pVtbl=%%p\n", "%s", i, this, m_pInstance, m_pVtbl);' % interface.name) -+ print(r' trace::localWriter.flush();') -+ print(r' os::abort();') -+ print(r' }') -+ print() - for i in range(len(methods), 64): -- print r' virtual void _dummy%i(void) const { _dummy(%i); }' % (i, i) -- print -+ print(r' virtual void _dummy%i(void) const { _dummy(%i); }' % (i, i)) -+ print() - -- print "};" -- print -+ print("};") -+ print() - - def enumWrapperInterfaceVariables(self, interface): - return [ -@@ -751,101 +756,101 @@ class Tracer: - wrapperInterfaceName = getWrapperInterfaceName(iface) - - # Private constructor -- print '%s::%s(%s * pInstance) {' % (wrapperInterfaceName, wrapperInterfaceName, iface.name) -+ print('%s::%s(%s * pInstance) {' % (wrapperInterfaceName, wrapperInterfaceName, iface.name)) - for type, name, value in self.enumWrapperInterfaceVariables(iface): - if value is not None: -- print ' %s = %s;' % (name, value) -- print '}' -- print -+ print(' %s = %s;' % (name, value)) -+ print('}') -+ print() - - # Public constructor -- print '%s *%s::_create(const char *entryName, %s * pInstance) {' % (wrapperInterfaceName, wrapperInterfaceName, iface.name) -- print r' Wrap%s *pWrapper = new Wrap%s(pInstance);' % (iface.name, iface.name) -+ print('%s *%s::_create(const char *entryName, %s * pInstance) {' % (wrapperInterfaceName, wrapperInterfaceName, iface.name)) -+ print(r' Wrap%s *pWrapper = new Wrap%s(pInstance);' % (iface.name, iface.name)) - if debug: -- print r' os::log("%%s: created %s pvObj=%%p pWrapper=%%p pVtbl=%%p\n", entryName, pInstance, pWrapper, pWrapper->m_pVtbl);' % iface.name -- print r' g_WrappedObjects[pInstance] = pWrapper;' -- print r' return pWrapper;' -- print '}' -- print -+ print(r' os::log("%%s: created %s pvObj=%%p pWrapper=%%p pVtbl=%%p\n", entryName, pInstance, pWrapper, pWrapper->m_pVtbl);' % iface.name) -+ print(r' g_WrappedObjects[pInstance] = pWrapper;') -+ print(r' return pWrapper;') -+ print('}') -+ print() - - # Destructor -- print '%s::~%s() {' % (wrapperInterfaceName, wrapperInterfaceName) -+ print('%s::~%s() {' % (wrapperInterfaceName, wrapperInterfaceName)) - if debug: -- print r' os::log("%s::Release: deleted pvObj=%%p pWrapper=%%p pVtbl=%%p\n", m_pInstance, this, m_pVtbl);' % iface.name -- print r' g_WrappedObjects.erase(m_pInstance);' -- print '}' -- print -+ print(r' os::log("%s::Release: deleted pvObj=%%p pWrapper=%%p pVtbl=%%p\n", m_pInstance, this, m_pVtbl);' % iface.name) -+ print(r' g_WrappedObjects.erase(m_pInstance);') -+ print('}') -+ print() - - baseMethods = list(iface.iterBaseMethods()) - for base, method in baseMethods: - self.base = base - self.implementWrapperInterfaceMethod(iface, base, method) - -- print -+ print() - - # Wrap pointer - ifaces = self.api.getAllInterfaces() -- print r'void' -- print r'%s::_wrap(const char *entryName, %s **ppObj) {' % (wrapperInterfaceName, iface.name) -- print r' if (!ppObj) {' -- print r' return;' -- print r' }' -- print r' %s *pObj = *ppObj;' % (iface.name,) -- print r' if (!pObj) {' -- print r' return;' -- print r' }' -- print r' assert(hasChildInterface(IID_%s, pObj));' % iface.name -- print r' std::map<void *, void *>::const_iterator it = g_WrappedObjects.find(pObj);' -- print r' if (it != g_WrappedObjects.end()) {' -- print r' Wrap%s *pWrapper = (Wrap%s *)it->second;' % (iface.name, iface.name) -- print r' assert(pWrapper);' -- print r' assert(pWrapper->m_dwMagic == 0xd8365d6c);' -- print r' assert(pWrapper->m_pInstance == pObj);' -- print r' if (pWrapper->m_pVtbl == getVtbl(pObj) &&' -- print r' pWrapper->m_NumMethods >= %s) {' % len(baseMethods) -+ print(r'void') -+ print(r'%s::_wrap(const char *entryName, %s **ppObj) {' % (wrapperInterfaceName, iface.name)) -+ print(r' if (!ppObj) {') -+ print(r' return;') -+ print(r' }') -+ print(r' %s *pObj = *ppObj;' % (iface.name,)) -+ print(r' if (!pObj) {') -+ print(r' return;') -+ print(r' }') -+ print(r' assert(hasChildInterface(IID_%s, pObj));' % iface.name) -+ print(r' std::map<void *, void *>::const_iterator it = g_WrappedObjects.find(pObj);') -+ print(r' if (it != g_WrappedObjects.end()) {') -+ print(r' Wrap%s *pWrapper = (Wrap%s *)it->second;' % (iface.name, iface.name)) -+ print(r' assert(pWrapper);') -+ print(r' assert(pWrapper->m_dwMagic == 0xd8365d6c);') -+ print(r' assert(pWrapper->m_pInstance == pObj);') -+ print(r' if (pWrapper->m_pVtbl == getVtbl(pObj) &&') -+ print(r' pWrapper->m_NumMethods >= %s) {' % len(baseMethods)) - if debug: -- print r' os::log("%s: fetched pvObj=%p pWrapper=%p pVtbl=%p\n", entryName, pObj, pWrapper, pWrapper->m_pVtbl);' -- print r' *ppObj = pWrapper;' -- print r' return;' -- print r' }' -- print r' }' -+ print(r' os::log("%s: fetched pvObj=%p pWrapper=%p pVtbl=%p\n", entryName, pObj, pWrapper, pWrapper->m_pVtbl);') -+ print(r' *ppObj = pWrapper;') -+ print(r' return;') -+ print(r' }') -+ print(r' }') - for childIface in getInterfaceHierarchy(ifaces, iface): -- print r' if (hasChildInterface(IID_%s, pObj)) {' % (childIface.name,) -- print r' *ppObj = Wrap%s::_create(entryName, static_cast<%s *>(pObj));' % (childIface.name, childIface.name) -- print r' return;' -- print r' }' -- print r' *ppObj = Wrap%s::_create(entryName, pObj);' % iface.name -- print r'}' -- print -+ print(r' if (hasChildInterface(IID_%s, pObj)) {' % (childIface.name,)) -+ print(r' *ppObj = Wrap%s::_create(entryName, static_cast<%s *>(pObj));' % (childIface.name, childIface.name)) -+ print(r' return;') -+ print(r' }') -+ print(r' *ppObj = Wrap%s::_create(entryName, pObj);' % iface.name) -+ print(r'}') -+ print() - - # Unwrap pointer -- print r'void' -- print r'%s::_unwrap(const char *entryName, %s **ppObj) {' % (wrapperInterfaceName, iface.name) -- print r' if (!ppObj || !*ppObj) {' -- print r' return;' -- print r' }' -- print r' const %s *pWrapper = static_cast<const %s*>(*ppObj);' % (wrapperInterfaceName, getWrapperInterfaceName(iface)) -- print r' if (pWrapper && pWrapper->m_dwMagic == 0xd8365d6c) {' -- print r' *ppObj = pWrapper->m_pInstance;' -- print r' } else {' -- print r' os::log("apitrace: warning: %%s: unexpected %%s pointer %%p\n", entryName, "%s", *ppObj);' % iface.name -- print r' trace::localWriter.flush();' -- print r' }' -- print r'}' -- print -+ print(r'void') -+ print(r'%s::_unwrap(const char *entryName, %s **ppObj) {' % (wrapperInterfaceName, iface.name)) -+ print(r' if (!ppObj || !*ppObj) {') -+ print(r' return;') -+ print(r' }') -+ print(r' const %s *pWrapper = static_cast<const %s*>(*ppObj);' % (wrapperInterfaceName, getWrapperInterfaceName(iface))) -+ print(r' if (pWrapper && pWrapper->m_dwMagic == 0xd8365d6c) {') -+ print(r' *ppObj = pWrapper->m_pInstance;') -+ print(r' } else {') -+ print(r' os::log("apitrace: warning: %%s: unexpected %%s pointer %%p\n", entryName, "%s", *ppObj);' % iface.name) -+ print(r' trace::localWriter.flush();') -+ print(r' }') -+ print(r'}') -+ print() - - def implementWrapperInterfaceMethod(self, interface, base, method): - wrapperInterfaceName = getWrapperInterfaceName(interface) - -- print method.prototype(wrapperInterfaceName + '::' + method.name) + ' {' -+ print(method.prototype(wrapperInterfaceName + '::' + method.name) + ' {') - - if False: -- print r' os::log("%%s(%%p -> %%p)\n", "%s", this, m_pInstance);' % (wrapperInterfaceName + '::' + method.name) -+ print(r' os::log("%%s(%%p -> %%p)\n", "%s", this, m_pInstance);' % (wrapperInterfaceName + '::' + method.name)) - - if method.type is not stdapi.Void: -- print ' %s _result;' % method.type -+ print(' %s _result;' % method.type) - -- print ' %s *_this = static_cast<%s *>(m_pInstance);' % (base, base) -+ print(' %s *_this = static_cast<%s *>(m_pInstance);' % (base, base)) - for arg in method.args: - if not arg.output: - self.unwrapArg(method, arg) -@@ -855,36 +860,36 @@ class Tracer: - # XXX: wrapping should go here, but before we can do that we'll need to protect g_WrappedObjects with its own mutex - - if method.type is not stdapi.Void: -- print ' return _result;' -+ print(' return _result;') - -- print '}' -- print -+ print('}') -+ print() - - def implementWrapperInterfaceMethodBody(self, interface, base, method): - assert not method.internal - -- print ' static const char * _args[%u] = {%s};' % (len(method.args) + 1, ', '.join(['"this"'] + ['"%s"' % arg.name for arg in method.args])) -- print ' static const trace::FunctionSig _sig = {%u, "%s", %u, _args};' % (self.getFunctionSigId(), interface.name + '::' + method.name, len(method.args) + 1) -+ print(' static const char * _args[%u] = {%s};' % (len(method.args) + 1, ', '.join(['"this"'] + ['"%s"' % arg.name for arg in method.args]))) -+ print(' static const trace::FunctionSig _sig = {%u, "%s", %u, _args};' % (self.getFunctionSigId(), interface.name + '::' + method.name, len(method.args) + 1)) - -- print ' unsigned _call = trace::localWriter.beginEnter(&_sig);' -- print ' trace::localWriter.beginArg(0);' -- print ' trace::localWriter.writePointer((uintptr_t)m_pInstance);' -- print ' trace::localWriter.endArg();' -+ print(' unsigned _call = trace::localWriter.beginEnter(&_sig);') -+ print(' trace::localWriter.beginArg(0);') -+ print(' trace::localWriter.writePointer((uintptr_t)m_pInstance);') -+ print(' trace::localWriter.endArg();') - for arg in method.args: - if not arg.output: - self.serializeArg(method, arg) -- print ' trace::localWriter.endEnter();' -+ print(' trace::localWriter.endEnter();') - - self.invokeMethod(interface, base, method) - -- print ' trace::localWriter.beginLeave(_call);' -+ print(' trace::localWriter.beginLeave(_call);') - -- print ' if (%s) {' % self.wasFunctionSuccessful(method) -+ print(' if (%s) {' % self.wasFunctionSuccessful(method)) - for arg in method.args: - if arg.output: - self.serializeArg(method, arg) - self.wrapArg(method, arg) -- print ' }' -+ print(' }') - - if method.type is not stdapi.Void: - self.serializeRet(method, '_result') -@@ -893,51 +898,51 @@ class Tracer: - - if method.name == 'Release': - assert method.type is not stdapi.Void -- print r' if (!_result) {' -- print r' delete this;' -- print r' }' -+ print(r' if (!_result) {') -+ print(r' delete this;') -+ print(r' }') - -- print ' trace::localWriter.endLeave();' -+ print(' trace::localWriter.endLeave();') - - def implementIidWrapper(self, api): - ifaces = api.getAllInterfaces() - -- print r'static void' -- print r'warnIID(const char *entryName, REFIID riid, void *pvObj, const char *reason) {' -- print r' os::log("apitrace: warning: %s: %s IID %s\n",' -- print r' entryName, reason,' -- print r' getGuidName(riid));' -- print r' void * pVtbl = *(void **)pvObj;' -- print r' HMODULE hModule = 0;' -- print r' BOOL bRet = GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |' -- print r' GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,' -- print r' (LPCTSTR)pVtbl,' -- print r' &hModule);' -- print r' assert(bRet);' -- print r' if (bRet) {' -- print r' char szModule[MAX_PATH];' -- print r' DWORD dwRet = GetModuleFileNameA(hModule, szModule, sizeof szModule);' -- print r' assert(dwRet);' -- print r' if (dwRet) {' -- print r' DWORD dwOffset = (UINT_PTR)pVtbl - (UINT_PTR)hModule;' -- print r' os::log("apitrace: warning: pVtbl = %p (%s!+0x%0lx)\n", pVtbl, szModule, dwOffset);' -- print r' }' -- print r' }' -- print r'}' -- print -- print r'static void' -- print r'wrapIID(const char *entryName, REFIID riid, void * * ppvObj) {' -- print r' if (!ppvObj || !*ppvObj) {' -- print r' return;' -- print r' }' -+ print(r'static void') -+ print(r'warnIID(const char *entryName, REFIID riid, void *pvObj, const char *reason) {') -+ print(r' os::log("apitrace: warning: %s: %s IID %s\n",') -+ print(r' entryName, reason,') -+ print(r' getGuidName(riid));') -+ print(r' void * pVtbl = *(void **)pvObj;') -+ print(r' HMODULE hModule = 0;') -+ print(r' BOOL bRet = GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |') -+ print(r' GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,') -+ print(r' (LPCTSTR)pVtbl,') -+ print(r' &hModule);') -+ print(r' assert(bRet);') -+ print(r' if (bRet) {') -+ print(r' char szModule[MAX_PATH];') -+ print(r' DWORD dwRet = GetModuleFileNameA(hModule, szModule, sizeof szModule);') -+ print(r' assert(dwRet);') -+ print(r' if (dwRet) {') -+ print(r' DWORD dwOffset = (UINT_PTR)pVtbl - (UINT_PTR)hModule;') -+ print(r' os::log("apitrace: warning: pVtbl = %p (%s!+0x%0lx)\n", pVtbl, szModule, dwOffset);') -+ print(r' }') -+ print(r' }') -+ print(r'}') -+ print() -+ print(r'static void') -+ print(r'wrapIID(const char *entryName, REFIID riid, void * * ppvObj) {') -+ print(r' if (!ppvObj || !*ppvObj) {') -+ print(r' return;') -+ print(r' }') - for iface in ifaces: -- print r' if (riid == IID_%s) {' % (iface.name,) -- print r' Wrap%s::_wrap(entryName, (%s **) ppvObj);' % (iface.name, iface.name) -- print r' return;' -- print r' }' -- print r' warnIID(entryName, riid, *ppvObj, "unsupported");' -- print r'}' -- print -+ print(r' if (riid == IID_%s) {' % (iface.name,)) -+ print(r' Wrap%s::_wrap(entryName, (%s **) ppvObj);' % (iface.name, iface.name)) -+ print(r' return;') -+ print(r' }') -+ print(r' warnIID(entryName, riid, *ppvObj, "unsupported");') -+ print(r'}') -+ print() - - def wrapIid(self, function, riid, out): - # Cast output arg to `void **` if necessary -@@ -947,42 +952,42 @@ class Tracer: - assert isinstance(obj_type, stdapi.Interface) - out_name = 'reinterpret_cast<void * *>(%s)' % out_name - -- print r' if (%s && *%s) {' % (out.name, out.name) -+ print(r' if (%s && *%s) {' % (out.name, out.name)) - functionName = function.name - else_ = '' - if self.interface is not None: - functionName = self.interface.name + '::' + functionName -- print r' if (*%s == m_pInstance &&' % (out_name,) -- print r' (%s)) {' % ' || '.join('%s == IID_%s' % (riid.name, iface.name) for iface in self.interface.iterBases()) -- print r' *%s = this;' % (out_name,) -- print r' }' -+ print(r' if (*%s == m_pInstance &&' % (out_name,)) -+ print(r' (%s)) {' % ' || '.join('%s == IID_%s' % (riid.name, iface.name) for iface in self.interface.iterBases())) -+ print(r' *%s = this;' % (out_name,)) -+ print(r' }') - else_ = 'else ' -- print r' %s{' % else_ -- print r' wrapIID("%s", %s, %s);' % (functionName, riid.name, out_name) -- print r' }' -- print r' }' -+ print(r' %s{' % else_) -+ print(r' wrapIID("%s", %s, %s);' % (functionName, riid.name, out_name)) -+ print(r' }') -+ print(r' }') - - def invokeMethod(self, interface, base, method): - if method.type is stdapi.Void: - result = '' - else: - result = '_result = ' -- print ' %s_this->%s(%s);' % (result, method.name, ', '.join([str(arg.name) for arg in method.args])) -+ print(' %s_this->%s(%s);' % (result, method.name, ', '.join([str(arg.name) for arg in method.args]))) - - def emit_memcpy(self, ptr, size): -- print ' trace::fakeMemcpy(%s, %s);' % (ptr, size) -+ print(' trace::fakeMemcpy(%s, %s);' % (ptr, size)) - - def emit_memcpy_opt(self, ptr, size): -- print ' trace::fakeMemcpyOpt(%s, %s);' % (ptr, size) -+ print(' trace::fakeMemcpyOpt(%s, %s);' % (ptr, size)) - - def fake_call(self, function, args): -- print ' unsigned _fake_call = trace::localWriter.beginEnter(&_%s_sig, true);' % (function.name,) -+ print(' unsigned _fake_call = trace::localWriter.beginEnter(&_%s_sig, true);' % (function.name,)) - for arg, instance in zip(function.args, args): - assert not arg.output -- print ' trace::localWriter.beginArg(%u);' % (arg.index,) -+ print(' trace::localWriter.beginArg(%u);' % (arg.index,)) - self.serializeValue(arg.type, instance) -- print ' trace::localWriter.endArg();' -- print ' trace::localWriter.endEnter();' -- print ' trace::localWriter.beginLeave(_fake_call);' -- print ' trace::localWriter.endLeave();' -+ print(' trace::localWriter.endArg();') -+ print(' trace::localWriter.endEnter();') -+ print(' trace::localWriter.beginLeave(_fake_call);') -+ print(' trace::localWriter.endLeave();') - -diff --git a/wrappers/wgltrace.py b/wrappers/wgltrace.py -index bc79d774..be86c36e 100644 ---- a/wrappers/wgltrace.py -+++ b/wrappers/wgltrace.py -@@ -66,63 +66,65 @@ class WglTracer(GlTracer): - # wglCreateContext/wglCreateLayerContext to obtain a HGLRC that's - # recognizable by OPENGL32.DLL. Therefore we need to detect and - # dispatch internal calls, without further ado. -- print r' if (_reentrant) {' -+ print(r' if (_reentrant) {') - self.invokeFunction(function) - if function.type is not Void: -- print ' return _result;' -- print r' }' -- print r' ReentryScope _reentry;' -- print r' (void)_reentry;' -- print -+ print(' return _result;') -+ print(r' }') -+ print(r' ReentryScope _reentry;') -+ print(r' (void)_reentry;') -+ print() - - if function.name in self.destroyContextFunctionNames: - # Unlike other GL APIs like EGL or GLX, WGL will make the context - # inactive if it's currently the active context. -- print ' if (_wglGetCurrentContext() == hglrc) {' -- print ' gltrace::clearContext();' -- print ' }' -- print ' gltrace::releaseContext((uintptr_t)hglrc);' -+ print(' if (_wglGetCurrentContext() == hglrc) {') -+ print(' gltrace::clearContext();') -+ print(' }') -+ print(' gltrace::releaseContext((uintptr_t)hglrc);') - - GlTracer.traceFunctionImplBody(self, function) - - if function.name in self.createContextFunctionNames: -- print ' if (_result)' -- print ' gltrace::createContext((uintptr_t)_result);' -+ print(' if (_result)') -+ print(' gltrace::createContext((uintptr_t)_result);') - - if function.name in self.makeCurrentFunctionNames: -- print ' if (_result) {' -- print ' if (hglrc != NULL)' -- print ' gltrace::setContext((uintptr_t)hglrc);' -- print ' else' -- print ' gltrace::clearContext();' -- print ' }' -+ print(' if (_result) {') -+ print(' if (hglrc != NULL)') -+ print(' gltrace::setContext((uintptr_t)hglrc);') -+ print(' else') -+ print(' gltrace::clearContext();') -+ print(' }') - - - if __name__ == '__main__': -- print -- print '#define _GDI32_' -- print -- print '#include <string.h>' -- print '#include <windows.h>' -- print -- print '#include "trace_writer_local.hpp"' -- print '#include "os.hpp"' -- print -- print '// To validate our prototypes' -- print '#define GL_GLEXT_PROTOTYPES' -- print '#define WGL_GLXEXT_PROTOTYPES' -- print -- print '#include "glproc.hpp"' -- print '#include "glsize.hpp"' -- print -- print 'static OS_THREAD_SPECIFIC(uintptr_t) _reentrant;' -- print -- print '// Helper class to track reentries in function scope.' -- print 'struct ReentryScope {' -- print 'inline ReentryScope() { _reentrant = 1; }' -- print 'inline ~ReentryScope() { _reentrant = 0; }' -- print '};' -- print -+ print() -+ print('#define _GDI32_') -+ print() -+ print('#include <string.h>') -+ print('#include <windows.h>') -+ print() -+ print('#include <sstream>') -+ print() -+ print('#include "trace_writer_local.hpp"') -+ print('#include "os.hpp"') -+ print() -+ print('// To validate our prototypes') -+ print('#define GL_GLEXT_PROTOTYPES') -+ print('#define WGL_GLXEXT_PROTOTYPES') -+ print() -+ print('#include "glproc.hpp"') -+ print('#include "glsize.hpp"') -+ print() -+ print('static OS_THREAD_LOCAL uintptr_t _reentrant;') -+ print() -+ print('// Helper class to track reentries in function scope.') -+ print('struct ReentryScope {') -+ print('inline ReentryScope() { _reentrant = 1; }') -+ print('inline ~ReentryScope() { _reentrant = 0; }') -+ print('};') -+ print() - module = Module() - module.mergeModule(glapi) - module.mergeModule(wglapi) --- -2.17.1 - diff --git a/recipes-graphics/imx-gpu-apitrace/imx-gpu-apitrace/0002-specs-Tie-Python-2-3-conversion-loose-ends.patch b/recipes-graphics/imx-gpu-apitrace/imx-gpu-apitrace/0002-specs-Tie-Python-2-3-conversion-loose-ends.patch deleted file mode 100644 index 25141602..00000000 --- a/recipes-graphics/imx-gpu-apitrace/imx-gpu-apitrace/0002-specs-Tie-Python-2-3-conversion-loose-ends.patch +++ /dev/null @@ -1,169 +0,0 @@ -From a8791e3dca61500a382be84dc96973639b8bd182 Mon Sep 17 00:00:00 2001 -From: Jose Fonseca <jfonseca@vmware.com> -Date: Sun, 28 Apr 2019 14:13:01 +0100 -Subject: [PATCH 2/4] specs: Tie Python 2 ->3 conversion loose ends. - -Upstream-Status: Backport [https://github.com/apitrace/apitrace/commit/5b3c68cafaddc82c0f34bea8127582eee07ac3be] - -(cherry picked from commit 5b3c68cafaddc82c0f34bea8127582eee07ac3be) -Signed-off-by: Andrey Zhizhikin <andrey.zhizhikin@leica-geosystems.com> ---- - specs/scripts/Makefile | 16 ++++++++-------- - specs/scripts/c2api.py | 6 +++--- - specs/scripts/cxx2api.py | 2 +- - specs/scripts/spec2api.py | 2 +- - specs/scripts/txt2api.py | 8 +++++--- - specs/scripts/xml2api.py | 2 +- - specs/scripts/xml2enum.py | 2 +- - specs/scripts/xml2glparams.py | 2 +- - 8 files changed, 21 insertions(+), 19 deletions(-) - -diff --git a/specs/scripts/Makefile b/specs/scripts/Makefile -index 714a3deb..f03f36eb 100644 ---- a/specs/scripts/Makefile -+++ b/specs/scripts/Makefile -@@ -37,28 +37,28 @@ download: \ - wget -N https://www.opengl.org/registry/oldspecs/$@ - - glapi.py: xml2api.py gl.xml -- python $^ > $@ -+ python3 $^ > $@ - - glxapi.py: xml2api.py glx.xml -- python $^ > $@ -+ python3 $^ > $@ - - wglapi.py: xml2api.py wgl.xml -- python $^ > $@ -+ python3 $^ > $@ - - eglapi.py: xml2api.py egl.xml -- python $^ > $@ -+ python3 $^ > $@ - - glparams.py: xml2glparams.py gl.xml -- python $^ > $@ -+ python3 $^ > $@ - - glxenum.py: xml2enum.py glx.xml -- python $^ > $@ -+ python3 $^ > $@ - - wglenum.py: xml2enum.py wgl.xml -- python $^ > $@ -+ python3 $^ > $@ - - eglenum.py: xml2enum.py egl.xml -- python $^ > $@ -+ python3 $^ > $@ - - clean: - rm -f \ -diff --git a/specs/scripts/c2api.py b/specs/scripts/c2api.py -index b8aaa81d..208169d2 100755 ---- a/specs/scripts/c2api.py -+++ b/specs/scripts/c2api.py -@@ -1,4 +1,4 @@ --#!/usr/bin/env python -+#!/usr/bin/env python3 - ########################################################################## - # - # Copyright 2011 Jose Fonseca -@@ -404,8 +404,8 @@ class DeclParser: - type = 'S' + type - elif short: - type = 'Short' -- elif int: -- type = 'Long' * int -+ elif long: -+ type = 'Long' * long - else: - type = 'Int' - if unsigned: -diff --git a/specs/scripts/cxx2api.py b/specs/scripts/cxx2api.py -index 9720615d..8056de47 100755 ---- a/specs/scripts/cxx2api.py -+++ b/specs/scripts/cxx2api.py -@@ -1,4 +1,4 @@ --#!/usr/bin/env python -+#!/usr/bin/env python3 - - - -diff --git a/specs/scripts/spec2api.py b/specs/scripts/spec2api.py -index 7fb395a4..33a8d058 100755 ---- a/specs/scripts/spec2api.py -+++ b/specs/scripts/spec2api.py -@@ -1,4 +1,4 @@ --#!/usr/bin/env python -+#!/usr/bin/env python3 - ########################################################################## - # - # Copyright 2010 VMware, Inc. -diff --git a/specs/scripts/txt2api.py b/specs/scripts/txt2api.py -index e9469d3c..a32ca658 100755 ---- a/specs/scripts/txt2api.py -+++ b/specs/scripts/txt2api.py -@@ -1,4 +1,4 @@ --#!/usr/bin/env python -+#!/usr/bin/env python3 - ########################################################################## - # - # Copyright 2010 VMware, Inc. -@@ -28,6 +28,7 @@ - """Parser for OpenGL .txt extensions specification.""" - - -+import io - import sys - import re - import optparse -@@ -233,12 +234,13 @@ def main(): - - for arg in args: - if arg.startswith('http://') or arg.startswith('https://'): -- stream = urlopen(arg, 'rt') -+ stream = urlopen(arg) -+ stream = io.TextIOWrapper(stream, encoding='ascii') - else: - stream = open(arg, 'rt') - parser = TxtParser(stream, prefix = options.prefix) - parser.parse() -- -+ - - if __name__ == '__main__': - main() -diff --git a/specs/scripts/xml2api.py b/specs/scripts/xml2api.py -index f09fe0bf..6b4ec3b7 100755 ---- a/specs/scripts/xml2api.py -+++ b/specs/scripts/xml2api.py -@@ -1,4 +1,4 @@ --#!/usr/bin/env python -+#!/usr/bin/env python3 - ########################################################################## - # - # Copyright 2014 VMware, Inc -diff --git a/specs/scripts/xml2enum.py b/specs/scripts/xml2enum.py -index cb2c4ae9..f799b7b5 100755 ---- a/specs/scripts/xml2enum.py -+++ b/specs/scripts/xml2enum.py -@@ -1,4 +1,4 @@ --#!/usr/bin/env python -+#!/usr/bin/env python3 - ########################################################################## - # - # Copyright 2014 VMware, Inc -diff --git a/specs/scripts/xml2glparams.py b/specs/scripts/xml2glparams.py -index 805aac86..a651d896 100755 ---- a/specs/scripts/xml2glparams.py -+++ b/specs/scripts/xml2glparams.py -@@ -1,4 +1,4 @@ --#!/usr/bin/env python -+#!/usr/bin/env python3 - ########################################################################## - # - # Copyright 2014 VMware, Inc --- -2.17.1 - diff --git a/recipes-graphics/imx-gpu-apitrace/imx-gpu-apitrace/0003-scripts-Tie-Python-2-3-conversion-loose-ends.patch b/recipes-graphics/imx-gpu-apitrace/imx-gpu-apitrace/0003-scripts-Tie-Python-2-3-conversion-loose-ends.patch deleted file mode 100644 index e30273d5..00000000 --- a/recipes-graphics/imx-gpu-apitrace/imx-gpu-apitrace/0003-scripts-Tie-Python-2-3-conversion-loose-ends.patch +++ /dev/null @@ -1,276 +0,0 @@ -From 8ba82a1ef77e60bd614cca1e583e1a0c25b4f281 Mon Sep 17 00:00:00 2001 -From: Jose Fonseca <jfonseca@vmware.com> -Date: Sun, 28 Apr 2019 14:14:44 +0100 -Subject: [PATCH 3/4] scripts: Tie Python 2 -> 3 conversion loose ends. - -Upstream-Status: Backport [https://github.com/apitrace/apitrace/commit/247e1fa87f4e87b8914662e44a8ecef4d444cc90] - -(cherry picked from commit 247e1fa87f4e87b8914662e44a8ecef4d444cc90) -Signed-off-by: Andrey Zhizhikin <andrey.zhizhikin@leica-geosystems.com> ---- - retrace/glstate_params.py | 2 +- - scripts/convert.py | 2 +- - scripts/highlight.py | 3 ++- - scripts/jsondiff.py | 2 +- - scripts/jsonextractimages.py | 2 +- - scripts/leaks.py | 4 ++-- - scripts/profileshader.py | 2 +- - scripts/retracediff.py | 2 +- - scripts/snapdiff.py | 2 +- - scripts/tracecheck.py | 2 +- - scripts/tracediff.py | 10 +++++----- - scripts/unpickle.py | 19 ++++++++++--------- - 12 files changed, 27 insertions(+), 25 deletions(-) - -diff --git a/retrace/glstate_params.py b/retrace/glstate_params.py -index bc90f66b..55f2dbc9 100755 ---- a/retrace/glstate_params.py -+++ b/retrace/glstate_params.py -@@ -1,4 +1,4 @@ --#!/usr/bin/env python -+#!/usr/bin/env python3 - ########################################################################## - # - # Copyright 2011 Jose Fonseca -diff --git a/scripts/convert.py b/scripts/convert.py -index 83df70ce..1f285a8c 100755 ---- a/scripts/convert.py -+++ b/scripts/convert.py -@@ -1,4 +1,4 @@ --#!/usr/bin/env python -+#!/usr/bin/env python3 - ########################################################################## - # - # Copyright 2012 VMware Inc. -diff --git a/scripts/highlight.py b/scripts/highlight.py -index ed3b54d4..e494abf4 100644 ---- a/scripts/highlight.py -+++ b/scripts/highlight.py -@@ -221,7 +221,8 @@ def LessHighlighter(): - try: - less = subprocess.Popen( - args = ['less', '-FRXn'], -- stdin = subprocess.PIPE -+ stdin = subprocess.PIPE, -+ universal_newlines = True - ) - except OSError: - return ColorHighlighter() -diff --git a/scripts/jsondiff.py b/scripts/jsondiff.py -index 25c4840e..d7a18e21 100755 ---- a/scripts/jsondiff.py -+++ b/scripts/jsondiff.py -@@ -1,4 +1,4 @@ --#!/usr/bin/env python -+#!/usr/bin/env python3 - ########################################################################## - # - # Copyright 2015 VMware, Inc. -diff --git a/scripts/jsonextractimages.py b/scripts/jsonextractimages.py -index 917ee7e4..785e32db 100755 ---- a/scripts/jsonextractimages.py -+++ b/scripts/jsonextractimages.py -@@ -1,4 +1,4 @@ --#!/usr/bin/env python -+#!/usr/bin/env python3 - ########################################################################## - # - # Copyright 2012 Jose Fonseca -diff --git a/scripts/leaks.py b/scripts/leaks.py -index 325af1e2..706e60a9 100755 ---- a/scripts/leaks.py -+++ b/scripts/leaks.py -@@ -1,4 +1,4 @@ --#!/usr/bin/env python -+#!/usr/bin/env python3 - ########################################################################## - # - # Copyright 2014-2016 VMware, Inc. -@@ -39,7 +39,7 @@ class LeakDetector(unpickle.Unpickler): - def __init__(self, apitrace, trace): - - cmd = [apitrace, 'pickle', '--symbolic', trace] -- p = subprocess.Popen(args = cmd, stdout = subprocess.PIPE) -+ p = subprocess.Popen(args = cmd, stdout=subprocess.PIPE) - - unpickle.Unpickler.__init__(self, p.stdout) - -diff --git a/scripts/profileshader.py b/scripts/profileshader.py -index 5c2a58fb..c6c1c935 100755 ---- a/scripts/profileshader.py -+++ b/scripts/profileshader.py -@@ -1,4 +1,4 @@ --#!/usr/bin/env python -+#!/usr/bin/env python3 - ########################################################################## - # - # Copyright 2012-2013 VMware, Inc. -diff --git a/scripts/retracediff.py b/scripts/retracediff.py -index 8105f536..967f3a93 100755 ---- a/scripts/retracediff.py -+++ b/scripts/retracediff.py -@@ -1,4 +1,4 @@ --#!/usr/bin/env python -+#!/usr/bin/env python3 - ########################################################################## - # - # Copyright 2011 Jose Fonseca -diff --git a/scripts/snapdiff.py b/scripts/snapdiff.py -index b0d5f757..58fefe88 100755 ---- a/scripts/snapdiff.py -+++ b/scripts/snapdiff.py -@@ -1,4 +1,4 @@ --#!/usr/bin/env python -+#!/usr/bin/env python3 - ########################################################################## - # - # Copyright 2011 Jose Fonseca -diff --git a/scripts/tracecheck.py b/scripts/tracecheck.py -index 3a2ec452..38167e89 100755 ---- a/scripts/tracecheck.py -+++ b/scripts/tracecheck.py -@@ -1,4 +1,4 @@ --#!/usr/bin/env python -+#!/usr/bin/env python3 - ########################################################################## - # - # Copyright 2011 VMware, Inc. -diff --git a/scripts/tracediff.py b/scripts/tracediff.py -index 0cd9c8c6..88e389a3 100755 ---- a/scripts/tracediff.py -+++ b/scripts/tracediff.py -@@ -1,4 +1,4 @@ --#!/usr/bin/env python -+#!/usr/bin/env python3 - ########################################################################## - # - # Copyright 2011 Jose Fonseca -@@ -173,7 +173,7 @@ class ExternalDiffer(Differ): - try: - less = subprocess.Popen( - args = ['less', '-FRXn'], -- stdin = subprocess.PIPE -+ stdin = subprocess.PIPE, - ) - except OSError: - pass -@@ -214,7 +214,7 @@ ignoredFunctionNames = set([ - - - class Blob: -- '''Data-less proxy for bytearrays, to save memory.''' -+ '''Data-less proxy for bytes, to save memory.''' - - def __init__(self, size, hash): - self.size = size -@@ -233,7 +233,7 @@ class Blob: - class BlobReplacer(Rebuilder): - '''Replace blobs with proxys.''' - -- def visitByteArray(self, obj): -+ def visitBytes(self, obj): - return Blob(len(obj), hash(str(obj))) - - def visitCall(self, call): -@@ -287,7 +287,7 @@ class PythonDiffer(Differ): - '--calls=' + calls, - trace - ], -- stdout = subprocess.PIPE, -+ stdout=subprocess.PIPE, - ) - - parser = Loader(p.stdout) -diff --git a/scripts/unpickle.py b/scripts/unpickle.py -index 86891d29..822b8ea8 100755 ---- a/scripts/unpickle.py -+++ b/scripts/unpickle.py -@@ -1,4 +1,4 @@ --#!/usr/bin/env python -+#!/usr/bin/env python3 - ########################################################################## - # - # Copyright 2012 Jose Fonseca -@@ -34,6 +34,7 @@ Run as: - - - import itertools -+import operator - import optparse - import sys - import time -@@ -55,7 +56,7 @@ CALL_FLAG_MARKER_PUSH = (1 << 9) - CALL_FLAG_MARKER_POP = (1 << 10) - - --class Pointer(long): -+class Pointer(int): - - def __str__(self): - if self == 0: -@@ -79,7 +80,7 @@ class Visitor: - self.dispatch[tuple] = self.visitTuple - self.dispatch[list] = self.visitList - self.dispatch[dict] = self.visitDict -- self.dispatch[bytearray] = self.visitByteArray -+ self.dispatch[bytes] = self.visitBytes - self.dispatch[Pointer] = self.visitPointer - - def visit(self, obj): -@@ -119,7 +120,7 @@ class Visitor: - def visitDict(self, obj): - return self.visitIterable(obj) - -- def visitByteArray(self, obj): -+ def visitBytes(self, obj): - raise NotImplementedError - - def visitPointer(self, obj): -@@ -153,7 +154,7 @@ class Dumper(Visitor): - def visitDict(self, obj): - return '{' + self.visitItems(iter(obj.items())) + '}' - -- def visitByteArray(self, obj): -+ def visitBytes(self, obj): - return 'blob(%u)' % len(obj) - - -@@ -169,7 +170,7 @@ class Hasher(Visitor): - def visitIterable(self, obj): - return tuple(map(self.visit, obj)) - -- def visitByteArray(self, obj): -+ def visitBytes(self, obj): - return str(obj) - - -@@ -193,7 +194,7 @@ class Rebuilder(Visitor): - else: - return obj - -- def visitByteArray(self, obj): -+ def visitBytes(self, obj): - return obj - - -@@ -269,7 +270,7 @@ class Counter(Unpickler): - Unpickler.parse(self) - - functionFrequencies = list(self.functionFrequencies.items()) -- functionFrequencies.sort(lambda (name1, freq1), (name2, freq2): cmp(freq1, freq2)) -+ functionFrequencies.sort(key=operator.itemgetter(1)) - for name, frequency in functionFrequencies: - sys.stdout.write('%8u %s\n' % (frequency, name)) - -@@ -311,7 +312,7 @@ def main(): - msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY) - - startTime = time.time() -- parser = Counter(sys.stdin, options.verbose) -+ parser = Counter(sys.stdin.buffer, options.verbose) - parser.parse() - stopTime = time.time() - duration = stopTime - startTime --- -2.17.1 - diff --git a/recipes-graphics/imx-gpu-apitrace/imx-gpu-apitrace/0004-scripts-Tie-a-few-more-Python-2-to-3-conversion-loos.patch b/recipes-graphics/imx-gpu-apitrace/imx-gpu-apitrace/0004-scripts-Tie-a-few-more-Python-2-to-3-conversion-loos.patch deleted file mode 100644 index 8974e5db..00000000 --- a/recipes-graphics/imx-gpu-apitrace/imx-gpu-apitrace/0004-scripts-Tie-a-few-more-Python-2-to-3-conversion-loos.patch +++ /dev/null @@ -1,62 +0,0 @@ -From aa8e341e73c288b77a5187e3676a2bbb6588b705 Mon Sep 17 00:00:00 2001 -From: Jose Fonseca <jfonseca@vmware.com> -Date: Mon, 29 Apr 2019 06:41:49 +0100 -Subject: [PATCH 4/4] scripts: Tie a few more Python 2 to 3 conversion loose - ends. - -Upstream-Status: Backport [https://github.com/apitrace/apitrace/commit/f527924cca45591966139eae8c2fefb4a9a0f947] - -(cherry picked from commit f527924cca45591966139eae8c2fefb4a9a0f947) -Signed-off-by: Andrey Zhizhikin <andrey.zhizhikin@leica-geosystems.com> ---- - scripts/jsonextractimages.py | 10 +++++----- - scripts/profileshader.py | 2 +- - 2 files changed, 6 insertions(+), 6 deletions(-) - -diff --git a/scripts/jsonextractimages.py b/scripts/jsonextractimages.py -index 785e32db..ac20c23d 100755 ---- a/scripts/jsonextractimages.py -+++ b/scripts/jsonextractimages.py -@@ -34,7 +34,7 @@ import base64 - import sys - - --pngSignature = "\x89\x50\x4E\x47\x0D\x0A\x1A\x0A" -+pngSignature = b"\x89\x50\x4E\x47\x0D\x0A\x1A\x0A" - - - def dumpSurfaces(state, memberName): -@@ -46,13 +46,13 @@ def dumpSurfaces(state, memberName): - extName = 'png' - else: - magic = data[:2] -- if magic in ('P1', 'P4'): -+ if magic in (b'P1', b'P4'): - extName = 'pbm' -- elif magic in ('P2', 'P5'): -+ elif magic in (b'P2', b'P5'): - extName = 'pgm' -- elif magic in ('P3', 'P6'): -+ elif magic in (b'P3', b'P6'): - extName = 'ppm' -- elif magic in ('Pf', 'PF'): -+ elif magic in (b'Pf', b'PF'): - extName = 'pfm' - else: - sys.stderr.write('warning: unsupport Netpbm format %s\n' % magic) -diff --git a/scripts/profileshader.py b/scripts/profileshader.py -index c6c1c935..7e8637eb 100755 ---- a/scripts/profileshader.py -+++ b/scripts/profileshader.py -@@ -92,7 +92,7 @@ def process(stream, groupField): - id = str(group[0]).rjust(maxGroupLen) - draw = str(group[1]['draws']).rjust(12) - dura = str(group[1]['duration']).rjust(18) -- perCall = str(group[1]['duration'] / group[1]['draws']).rjust(12) -+ perCall = str(group[1]['duration'] // group[1]['draws']).rjust(12) - longest = str(group[1]['longest']).rjust(11) - print("| %s | %s | %s | %s | %s |" % (id, draw, dura, perCall, longest)) - --- -2.17.1 - diff --git a/recipes-graphics/imx-gpu-apitrace/imx-gpu-apitrace/0005-scripts-Tie-a-few-more-Python-2-to-3-conversion-loos.patch b/recipes-graphics/imx-gpu-apitrace/imx-gpu-apitrace/0005-scripts-Tie-a-few-more-Python-2-to-3-conversion-loos.patch deleted file mode 100644 index 6bff7e92..00000000 --- a/recipes-graphics/imx-gpu-apitrace/imx-gpu-apitrace/0005-scripts-Tie-a-few-more-Python-2-to-3-conversion-loos.patch +++ /dev/null @@ -1,60 +0,0 @@ -From 8b3afcaeebdd87962f2f3fef36973090621d116b Mon Sep 17 00:00:00 2001 -From: Max Krummenacher <max.krummenacher@toradex.com> -Date: Sun, 29 Mar 2020 15:38:31 +0000 -Subject: [PATCH 5/5] scripts: Tie a few more Python 2 to 3 conversion loose - ends. - -Upstream-Status: pending -Note: code exists in NXP's fork only. - -Signed-off-by: Max Krummenacher <max.krummenacher@toradex.com> ---- - wrappers/glxtrace.py | 14 +++++++------- - 1 file changed, 7 insertions(+), 7 deletions(-) - -diff --git a/wrappers/glxtrace.py b/wrappers/glxtrace.py -index b05028e2..2472560d 100644 ---- a/wrappers/glxtrace.py -+++ b/wrappers/glxtrace.py -@@ -67,9 +67,9 @@ class GlxTracer(GlTracer): - print(' gltrace::releaseContext((uintptr_t)ctx);') - - if function.name == 'glXGetCurrentDisplay': -- print ' if(_glXGetCurrentDisplay == &glXGetCurrentDisplay ){' -- print ' _glXGetCurrentDisplay = (PFN_GLXGETCURRENTDISPLAY)_getPublicProcAddress("glXGetCurrentDisplay");' -- print ' }' -+ print (' if(_glXGetCurrentDisplay == &glXGetCurrentDisplay ){') -+ print (' _glXGetCurrentDisplay = (PFN_GLXGETCURRENTDISPLAY)_getPublicProcAddress("glXGetCurrentDisplay");') -+ print (' }') - - GlTracer.traceFunctionImplBody(self, function) - -@@ -184,7 +184,7 @@ if __name__ == '__main__': - tracer = GlxTracer() - tracer.traceApi(api) - -- print r''' -+ print (r''' - - - /* -@@ -247,8 +247,8 @@ void * dlopen(const char *filename, int flag) - - - --''' -- print r''' -+''') -+ print (r''' - /* - * let the GPU driver know that we are in apitrace - */ -@@ -257,4 +257,4 @@ int APIENTRY ApiTraceEnabled(void) { - return 1; - } - --''' -+''') --- -2.20.1 - diff --git a/recipes-graphics/imx-gpu-apitrace/imx-gpu-apitrace_10.0.0.bb b/recipes-graphics/imx-gpu-apitrace/imx-gpu-apitrace_10.0.0.bb new file mode 100644 index 00000000..a2f049a8 --- /dev/null +++ b/recipes-graphics/imx-gpu-apitrace/imx-gpu-apitrace_10.0.0.bb @@ -0,0 +1,55 @@ +# Copyright 2018 (C) O.S. Systems Software LTDA. +SUMMARY = "Samples for OpenGL ES" +LICENSE = "MIT" +LIC_FILES_CHKSUM = "file://LICENSE;md5=aeb969185a143c3c25130bc2c3ef9a50" +DEPENDS = "imx-gpu-viv zlib libpng procps" + +SRC_URI = "git://github.com/nxp-imx/apitrace-imx.git;protocol=https;branch=imx_10.0 \ + file://0001-dlsym-workaround-glibc-2.34-build-failure.patch \ +" +SRCREV = "522cb2981289b7ba20d6dd4b4bf75097e079815b" + +S = "${WORKDIR}/git" + +inherit cmake pkgconfig perlnative python3native + +PACKAGECONFIG_BACKEND:mx6-nxp-bsp = " \ + ${@bb.utils.contains('DISTRO_FEATURES', 'wayland', 'waffle', \ + bb.utils.contains('DISTRO_FEATURES', 'x11', 'x11', \ + '', d), d)} \ +" +PACKAGECONFIG_BACKEND:mx7-nxp-bsp = "${PACKAGECONFIG_BACKEND:mx6-nxp-bsp}" +PACKAGECONFIG_BACKEND:mx8-nxp-bsp = "waffle" + +PACKAGECONFIG_GPU2D = "" +PACKAGECONFIG_GPU2D:imxgpu2d = "vivante" + +PACKAGECONFIG ??= " \ + egl \ + ${PACKAGECONFIG_BACKEND} \ + ${PACKAGECONFIG_GPU2D} \ +" + +PACKAGECONFIG[egl] = "-DENABLE_EGL=ON,-DENABLE_EGL=OFF,virtual/egl" +PACKAGECONFIG[gui] = "-DENABLE_GUI=ON,-DENABLE_GUI=OFF" +PACKAGECONFIG[multiarch] = "-DENABLE_MULTIARCH=ON,-DENABLE_MULTIARCH=OFF" +PACKAGECONFIG[waffle] = "-DENABLE_WAFFLE=ON,-DENABLE_WAFFLE=OFF,waffle" +PACKAGECONFIG[x11] = "-DENABLE_X11=ON,-DENABLE_X11=OFF" +PACKAGECONFIG[vivante] = "-DENABLE_VIVANTE=ON,-DENABLE_VIVANTE=OFF,virtual/libg2d" + +SOLIBS = ".so" +FILES_SOLIBSDEV = "" +FILES:${PN} += " \ + ${libdir}/apitrace/scripts/* \ + ${libdir}/apitrace/wrappers/* \ +" +EXTRA_OECMAKE += "\ + -DENABLE_GUI=OFF \ + -DENABLE_STATIC_LIBGCC=OFF \ + -DENABLE_STATIC_LIBSTDCXX=OFF \ + -DPython3_ROOT_DIR=/usr/bin/python3-native \ +" +PACKAGE_ARCH = "${MACHINE_SOCARCH}" +COMPATIBLE_MACHINE = "(imxgpu)" +SECURITY_CFLAGS:toolchain-clang = "" + diff --git a/recipes-graphics/imx-gpu-apitrace/imx-gpu-apitrace_9.0.0.bb b/recipes-graphics/imx-gpu-apitrace/imx-gpu-apitrace_9.0.0.bb deleted file mode 100644 index 9461a34d..00000000 --- a/recipes-graphics/imx-gpu-apitrace/imx-gpu-apitrace_9.0.0.bb +++ /dev/null @@ -1,36 +0,0 @@ -# Copyright 2018 (C) O.S. Systems Software LTDA. -SUMMARY = "Samples for OpenGL ES" -LICENSE = "MIT" -LIC_FILES_CHKSUM = "file://LICENSE;md5=aeb969185a143c3c25130bc2c3ef9a50" -DEPENDS = "imx-gpu-viv zlib libpng procps" - -SRC_URI = "git://source.codeaurora.org/external/imx/apitrace-imx.git;protocol=https;branch=imx_9.0" -SRCREV = "8636fa989d8e914a7986916b058878761a981a6f" - -S = "${WORKDIR}/git" - -inherit cmake pkgconfig perlnative python3native - -PACKAGECONFIG ??= "egl waffle" -PACKAGECONFIG_append = \ - "${@bb.utils.contains('DISTRO_FEATURES', 'wayland', '', \ - bb.utils.contains('DISTRO_FEATURES', 'x11', ' x11', \ - '', d), d)}" -PACKAGECONFIG_append_imxgpu2d = " vivante" - -PACKAGECONFIG[egl] = "-DENABLE_EGL=ON,-DENABLE_EGL=OFF,virtual/egl" -PACKAGECONFIG[gui] = "-DENABLE_GUI=ON,-DENABLE_GUI=OFF" -PACKAGECONFIG[multiarch] = "-DENABLE_MULTIARCH=ON,-DENABLE_MULTIARCH=OFF" -PACKAGECONFIG[waffle] = "-DENABLE_WAFFLE=ON,-DENABLE_WAFFLE=OFF,waffle" -PACKAGECONFIG[x11] = "-DENABLE_X11=ON,-DENABLE_X11=OFF" -PACKAGECONFIG[vivante] = "-DENABLE_VIVANTE=ON,-DENABLE_VIVANTE=OFF,virtual/libg2d" - -SOLIBS = ".so" -FILES_SOLIBSDEV = "" -FILES_${PN} += " \ - ${libdir}/apitrace/scripts/* \ - ${libdir}/apitrace/wrappers/* \ -" - -PACKAGE_ARCH = "${MACHINE_SOCARCH}" -COMPATIBLE_MACHINE = "(imxgpu)" diff --git a/recipes-graphics/imx-gpu-g2d/imx-gpu-g2d_6.4.0.p2.0.bb b/recipes-graphics/imx-gpu-g2d/imx-gpu-g2d_6.4.0.p2.0.bb deleted file mode 100644 index 8de2c35f..00000000 --- a/recipes-graphics/imx-gpu-g2d/imx-gpu-g2d_6.4.0.p2.0.bb +++ /dev/null @@ -1,39 +0,0 @@ -# Copyright (C) 2016 Freescale Semiconductor -# Copyright 2017-2018 NXP -# Copyright 2018 (C) O.S. Systems Software LTDA. -# Released under the MIT license (see COPYING.MIT for the terms) - -DESCRIPTION = "GPU G2D library and apps for i.MX with 2D GPU and no DPU" -LICENSE = "Proprietary" -LIC_FILES_CHKSUM = "file://COPYING;md5=fd4b227530cd88a82af6a5982cfb724d" - -DEPENDS += "libgal-imx" -PROVIDES += "virtual/libg2d" - -FSLBIN_NAME = "${PN}-${PV}-${TARGET_ARCH}" - -SRC_URI = "${FSL_MIRROR}/${FSLBIN_NAME}.bin;name=${TARGET_ARCH};fsl-eula=true" -SRC_URI[aarch64.md5sum] = "46a25ffb33312b36b4c1b8dea38c05f4" -SRC_URI[aarch64.sha256sum] = "3278d4e2bae91e86d148c7e142178d50d4d8eb476fc1ee4a2e265f7e66334741" -SRC_URI[arm.md5sum] = "69532382092c1a5e754be594d1a486b7" -SRC_URI[arm.sha256sum] = "c618c3ac6adc5f28439ceb88cb46889b78daaf36655ab82ea2ac6f50a88297f5" - -S = "${WORKDIR}/${FSLBIN_NAME}" - -inherit fsl-eula-unpack - -do_install () { - install -d ${D}${libdir} - install -d ${D}${includedir} - cp ${S}/g2d/usr/lib/*.so* ${D}${libdir} - cp -Pr ${S}/g2d/usr/include/* ${D}${includedir} - cp -r ${S}/gpu-demos/opt ${D} -} - -FILES_${PN} = "${libdir}/libg2d* /opt" -FILES_${PN}-dev = "${includedir}" -INSANE_SKIP_${PN} = "ldflags" - -RDEPENDS_${PN} = "libgal-imx" - -COMPATIBLE_MACHINE = "(imxgpu2d)" diff --git a/recipes-graphics/imx-gpu-viv/imx-gpu-viv-6.inc b/recipes-graphics/imx-gpu-viv/imx-gpu-viv-6.inc index 5c25eec6..56a9ec4d 100644 --- a/recipes-graphics/imx-gpu-viv/imx-gpu-viv-6.inc +++ b/recipes-graphics/imx-gpu-viv/imx-gpu-viv-6.inc @@ -1,12 +1,12 @@ # Copyright (C) 2012-2016 Freescale Semiconductor # Copyright (C) 2012-2018 O.S. Systems Software LTDA. -# Copyright 2017-2020 NXP +# Copyright 2017-2023 NXP # Released under the MIT license (see COPYING.MIT for the terms) DESCRIPTION = "GPU driver and apps for i.MX" SECTION = "libs" LICENSE = "Proprietary" -LIC_FILES_CHKSUM = "file://COPYING;md5=fd4b227530cd88a82af6a5982cfb724d" +LIC_FILES_CHKSUM = "file://COPYING;md5=ea25d099982d035af85d193c88a1b479" DEPENDS += " \ ${@bb.utils.contains('DISTRO_FEATURES', 'wayland', 'wayland', \ @@ -17,88 +17,123 @@ DEPENDS += " \ ${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'libxcb libxshmfence libxxf86vm', \ '', d)} \ " -DEPENDS_append_imxdrm = " libdrm wayland" -DEPENDS_append_mx8 = " patchelf-native" +DEPENDS:append:imxdrm = " libdrm wayland" +DEPENDS:append:mx8-nxp-bsp = " patchelf-native" # imx-gpu-viv does not provide everything it needs to for virtual/libgl # on x11 backend or on Wayland backend with XWayland support. # We depend on mesa to fill in what is missing. DEPENDS += "${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'mesa', '', d)}" -EXTRA_PROVIDES = "" -EXTRA_PROVIDES_append_imxgpu3d = " \ - ${@bb.utils.contains('DISTRO_FEATURES', 'wayland', 'virtual/libgl', \ - bb.utils.contains('DISTRO_FEATURES', 'x11', 'virtual/libgl', \ - '', d), d)} \ +DEPENDS:append:libc-musl = " gcompat" + +PROVIDES += " \ + imx-gpu-viv \ + libgal-imx \ + virtual/egl \ + virtual/libopenvg \ + ${EXTRA_PROVIDES} \ +" +EXTRA_PROVIDES = " \ + ${PROVIDES_OPENCL} \ + ${PROVIDES_OPENGLES3} \ + ${PROVIDES_OPENVX} \ +" +EXTRA_PROVIDES:append:imxgpu3d = " \ + virtual/libgl \ virtual/libgles1 \ virtual/libgles2 \ " -EXTRA_PROVIDES_append_mx8 = " \ +EXTRA_PROVIDES:append:mx8-nxp-bsp = " \ virtual/libgbm \ " -PROVIDES_OPENVX = "" -PROVIDES_OPENVX_mx8 = "virtual/libopenvx" -PROVIDES_OPENVX_mx8mm = "" -PROVIDES += " \ - imx-gpu-viv \ - libgal-imx \ + +PROVIDES_OPENCL = " \ opencl-headers \ - virtual/egl \ - virtual/libopenvg \ - virtual/opencl-headers \ + opencl-clhpp \ + opencl-icd-loader \ virtual/opencl-icd \ - ${PROVIDES_OPENVX} \ - ${EXTRA_PROVIDES} \ " +PROVIDES_OPENCL:mx7-nxp-bsp = "" +PROVIDES_OPENCL:mx8mm-nxp-bsp = "" + +PROVIDES_OPENGLES3 = "" +PROVIDES_OPENGLES3:mx8-nxp-bsp = "virtual/libgles3" + +# Note: OpenVX is fully supported on i.MX 8 QuadMax and 8 QuadPlus. +# However, only limited support is provided on other i.MX 8 machines +# as needed for i.MX machine learning packages. +PROVIDES_OPENVX = "" +PROVIDES_OPENVX:mx8-nxp-bsp = "virtual/libopenvx" +PROVIDES_OPENVX:mx8mm-nxp-bsp = "" -RPROVIDES_${PN}_imxgpu3d += "imx-gpu-viv" +RPROVIDES:${PN}:imxgpu3d += "imx-gpu-viv" PE = "1" -inherit fsl-eula-unpack features_check +inherit fsl-eula-unpack + +FILESEXTRAPATHS:append := "${THISDIR}/imx-gpu-viv:" +SRC_URI = "${FSL_MIRROR}/${BPN}-${PV}-${IMX_SRCREV_ABBREV}.bin;fsl-eula=true \ + file://imx_icd.json" + +S = "${WORKDIR}/${BPN}-${PV}-${IMX_SRCREV_ABBREV}" -REQUIRED_DISTRO_FEATURES_mx8 = "wayland" +PACKAGECONFIG ?= "" -SRC_URI = "${FSL_MIRROR}/${BPN}-${PV}.bin;fsl-eula=true" +# Enables valgrind annotations for libgal-imx +PACKAGECONFIG[valgrind] = "" # Note : If you add a package here, to prevent a naming conflict see the python_anonymous() futher below -IMX_PACKAGES_GBM = "" -IMX_PACKAGES_GBM_mx8 = "libgbm-imx libgbm-imx-dev" -PACKAGES =+ "libclc-imx libclc-imx-dev \ +PACKAGES =+ " \ libgl-imx libgl-imx-dev \ libgles1-imx libgles1-imx-dev \ libgles2-imx libgles2-imx-dev \ libgles3-imx-dev \ libglslc-imx libglslc-imx-dev \ - libopencl-imx libopencl-imx-dev \ + ${PACKAGES_OPENCL} \ libopenvg-imx libopenvg-imx-dev \ libvdk-imx libvdk-imx-dev \ libegl-imx libegl-imx-dev \ libgal-imx libgal-imx-dev \ - libvivante-dri-imx \ libvsc-imx \ - ${IMX_PACKAGES_GBM} \ - libwayland-viv-imx libwayland-viv-imx-dev \ - libgc-wayland-protocol-imx libgc-wayland-protocol-imx-dev \ + ${PACKAGES_GBM} \ imx-gpu-viv-tools \ imx-gpu-viv-demos \ - libvulkan-imx libvulkan-imx-dev \ - libopenvx-imx libopenvx-imx-dev \ - libnn-imx libnn-imx-dev \ + ${PACKAGES_VULKAN} \ + ${PACKAGES_OPENVX} \ + libnn-imx \ + libspirv-imx \ " + +PACKAGES_GBM = "" +PACKAGES_GBM:mx8-nxp-bsp = "libgbm-imx libgbm-imx-dev" + +PACKAGES_OPENCL = "libclc-imx libopencl-imx libopencl-imx-dev" +PACKAGES_OPENCL:mx7-nxp-bsp = "" +PACKAGES_OPENCL:mx8mm-nxp-bsp = "" + +PACKAGES_OPENVX = \ + "${@bb.utils.contains("PROVIDES_OPENVX", "virtual/libopenvx", \ + "libopenvx-imx libopenvx-imx-dev", "", d)}" + +PACKAGES_VULKAN = "" +PACKAGES_VULKAN:imxvulkan = "libvulkan-imx libvulkan-imx-dev" +PACKAGES_VULKAN:mx8mm-nxp-bsp = "libvulkan-imx libvulkan-imx-dev" + python __anonymous () { has_vivante_kernel_driver_support = (d.getVar('MACHINE_HAS_VIVANTE_KERNEL_DRIVER_SUPPORT') or '0') if has_vivante_kernel_driver_support != '1': raise bb.parse.SkipPackage('The kernel of machine needs to have Vivante kernel driver support for this recipe to be used.') } -USE_X11 = "${@bb.utils.contains("DISTRO_FEATURES", "x11", "yes", "no", d)}" -USE_WL = "${@bb.utils.contains("DISTRO_FEATURES", "wayland", "yes", "no", d)}" +BACKEND = "${@bb.utils.contains("DISTRO_FEATURES", "wayland", "wayland", "fb", d)}" -# Inhibit warnings about files being stripped. -INHIBIT_PACKAGE_STRIP = "1" +# The packaged binaries have been stripped of debug info, so disable +# operations accordingly. INHIBIT_PACKAGE_DEBUG_SPLIT = "1" -INSANE_SKIP_${BPN} += "already-stripped" +INHIBIT_PACKAGE_STRIP = "1" +INHIBIT_SYSROOT_STRIP = "1" # FIXME: The provided binary doesn't provide soname. If in future BSP # release the libraries are fixed, we can drop this hack. @@ -110,45 +145,50 @@ python __anonymous() { # the source we cannot fix it. Disable the insane check for now. packages = d.getVar('PACKAGES').split() for p in packages: - d.appendVar("INSANE_SKIP_%s" % p, " ldflags") + d.appendVar("INSANE_SKIP:%s" % p, " ldflags") # For the packages that make up the OpenGL interfaces, inject variables so that # they don't get Debian-renamed (which would remove the -imx suffix). for p in (("libegl", "libegl1"), ("libgl", "libgl1"), ("libgles1", "libglesv1-cm1"), ("libgles2", "libglesv2-2"), - ("libgles3",) , ("libvulkan",), ("libgbm",)): + ("libgles3",), ("libgbm",)): fullp = p[0] + "-imx" pkgs = "".join(' %s' % i for i in p) - d.setVar("DEBIAN_NOAUTONAME_" + fullp, "1") - d.appendVar("RREPLACES_" + fullp, pkgs) - d.appendVar("RPROVIDES_" + fullp, pkgs) - d.appendVar("RCONFLICTS_" + fullp, pkgs) + d.setVar("DEBIAN_NOAUTONAME:" + fullp, "1") + d.appendVar("RREPLACES:" + fullp, pkgs) + d.appendVar("RPROVIDES:" + fullp, pkgs) + d.appendVar("RCONFLICTS:" + fullp, pkgs) # For -dev, the first element is both the Debian and original name fullp += "-dev" pkgs = p[0] + "-dev" - d.setVar("DEBIAN_NOAUTONAME_" + fullp, "1") - d.appendVar("RREPLACES_" + fullp, pkgs) - d.appendVar("RPROVIDES_" + fullp, pkgs) - d.appendVar("RCONFLICTS_" + fullp, pkgs) + d.setVar("DEBIAN_NOAUTONAME:" + fullp, "1") + d.appendVar("RREPLACES:" + fullp, pkgs) + d.appendVar("RPROVIDES:" + fullp, pkgs) + d.appendVar("RCONFLICTS:" + fullp, pkgs) } IS_MX6SL = "0" -IS_MX6SL_mx6sl = "1" +IS_MX6SL:mx6sl-nxp-bsp = "1" IS_MX8 = "0" -IS_MX8_mx8 = "1" +IS_MX8:mx8-nxp-bsp = "1" PACKAGE_FP_TYPE = "hardfp" HAS_GBM = "false" -HAS_GBM_mx8 = "true" +HAS_GBM:mx8-nxp-bsp = "true" + +IMX_SOC = "IMX_SOC_NOT_SET" +IMX_SOC:mx8qm-nxp-bsp = "mx8qm" +IMX_SOC:mx8qxp-nxp-bsp = "mx8qxp" +IMX_SOC:mx8dx-nxp-bsp = "mx8qxp" +IMX_SOC:mx8mp-nxp-bsp = "mx8mp" +IMX_SOC:mx8mq-nxp-bsp = "mx8mq" +IMX_SOC:mx8mn-nxp-bsp = "mx8mn" +IMX_SOC:mx8ulp-nxp-bsp = "mx8ulp" -GLES3_HEADER_REMOVALS = "gl31.h gl32.h" -GLES3_HEADER_REMOVALS_mx8m = "gl32.h" -GLES3_HEADER_REMOVALS_mx8mm = "gl31.h gl32.h" -GLES3_HEADER_REMOVALS_mx8qxp = "" -GLES3_HEADER_REMOVALS_mx8qm = "" +LIBVULKAN_API_VERSION = "1.3.239" do_install () { install -d ${D}${libdir} @@ -163,104 +203,89 @@ do_install () { # Use vulkan header from vulkan-headers recipe to support vkmark rm -rf ${D}${includedir}/vulkan/ + # Install SOC-specific drivers + if [ -d ${S}/gpu-core/usr/lib/${IMX_SOC} ]; then + cp -r ${S}/gpu-core/usr/lib/${IMX_SOC}/* ${D}${libdir} + fi + install -d ${D}${libdir}/pkgconfig if ${HAS_GBM}; then install -m 0644 ${S}/gpu-core/usr/lib/pkgconfig/gbm.pc ${D}${libdir}/pkgconfig/gbm.pc fi - # The preference order, based in DISTRO_FEATURES, is Wayland (with or without X11), X11 and fb - if [ "${USE_WL}" = "yes" ]; then - - backend=wl + install -m 0644 ${S}/gpu-core/usr/lib/pkgconfig/glesv1_cm.pc ${D}${libdir}/pkgconfig/glesv1_cm.pc + install -m 0644 ${S}/gpu-core/usr/lib/pkgconfig/glesv2.pc ${D}${libdir}/pkgconfig/glesv2.pc + install -m 0644 ${S}/gpu-core/usr/lib/pkgconfig/vg.pc ${D}${libdir}/pkgconfig/vg.pc + # Install backend-specific drivers + if [ "${BACKEND}" = "wayland" ]; then + # Wayland backend + if ! ${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'true', 'false', d)}; then + install -m 0644 ${S}/gpu-core/usr/lib/pkgconfig/gl.pc ${D}${libdir}/pkgconfig/gl.pc + fi install -m 0644 ${S}/gpu-core/usr/lib/pkgconfig/egl_wayland.pc ${D}${libdir}/pkgconfig/egl.pc - install -m 0644 ${S}/gpu-core/usr/lib/pkgconfig/glesv1_cm.pc ${D}${libdir}/pkgconfig/glesv1_cm.pc - install -m 0644 ${S}/gpu-core/usr/lib/pkgconfig/glesv2.pc ${D}${libdir}/pkgconfig/glesv2.pc - install -m 0644 ${S}/gpu-core/usr/lib/pkgconfig/vg.pc ${D}${libdir}/pkgconfig/vg.pc - - if [ "${USE_X11}" = "yes" ]; then - - cp -r ${S}/gpu-core/usr/lib/dri ${D}${libdir} - - fi - - elif [ "${USE_X11}" = "yes" ]; then - - cp -r ${S}/gpu-core/usr/lib/dri ${D}${libdir} - - backend=x11 - - install -m 0644 ${S}/gpu-core/usr/lib/pkgconfig/gl_x11.pc ${D}${libdir}/pkgconfig/gl.pc - install -m 0644 ${S}/gpu-core/usr/lib/pkgconfig/egl_x11.pc ${D}${libdir}/pkgconfig/egl.pc - install -m 0644 ${S}/gpu-core/usr/lib/pkgconfig/glesv1_cm_x11.pc ${D}${libdir}/pkgconfig/glesv1_cm.pc - install -m 0644 ${S}/gpu-core/usr/lib/pkgconfig/glesv2_x11.pc ${D}${libdir}/pkgconfig/glesv2.pc - install -m 0644 ${S}/gpu-core/usr/lib/pkgconfig/vg_x11.pc ${D}${libdir}/pkgconfig/vg.pc - - else - install -m 0644 ${S}/gpu-core/usr/lib/pkgconfig/glesv1_cm.pc ${D}${libdir}/pkgconfig/glesv1_cm.pc - install -m 0644 ${S}/gpu-core/usr/lib/pkgconfig/glesv2.pc ${D}${libdir}/pkgconfig/glesv2.pc - install -m 0644 ${S}/gpu-core/usr/lib/pkgconfig/vg.pc ${D}${libdir}/pkgconfig/vg.pc - - # Regular framebuffer + cp -r ${S}/gpu-core/usr/lib/wayland/* ${D}${libdir} + elif [ "${IS_MX8}" != "1" ]; then + # Framebuffer backend for i.MX 6 and 7 install -m 0644 ${S}/gpu-core/usr/lib/pkgconfig/egl_linuxfb.pc ${D}${libdir}/pkgconfig/egl.pc - - backend=fb - - fi - - # Install Vendor ICDs for OpenCL's installable client driver loader (ICDs Loader) - install -d ${D}${sysconfdir}/OpenCL/vendors/ - install -m 0644 ${S}/gpu-core/etc/Vivante.icd ${D}${sysconfdir}/OpenCL/vendors/Vivante.icd - - # We'll only have one backend here so we rename it to generic name - # and avoid rework in other packages, when possible - if [ "${USE_WL}" = "yes" -o "${USE_X11}" = "yes" ]; then - cp ${S}/gpu-core/usr/lib/libGL-${backend}.so ${D}${libdir}/libGL.so.1.2.0 - ln -sf libGL.so.1.2.0 ${D}${libdir}/libGL.so.1.2 - ln -sf libGL.so.1.2.0 ${D}${libdir}/libGL.so.1 - ln -sf libGL.so.1.2.0 ${D}${libdir}/libGL.so + cp -r ${S}/gpu-core/usr/lib/fb/* ${D}${libdir} + else + # Framebuffer backend for i.MX 8 and beyond + install -m 0644 ${S}/gpu-core/usr/lib/pkgconfig/egl.pc ${D}${libdir}/pkgconfig/egl.pc + cp -r ${S}/gpu-core/usr/lib/wayland/* ${D}${libdir} + set -f + for f in ${FILES:libvdk-imx} ${FILES:libvdk-imx-dev}; do + set +f + rm -rf ${D}/$f + done + rm -rf \ + ${D}/opt/viv_samples/es20 \ + ${D}/opt/viv_samples/tiger \ + ${D}/opt/viv_samples/vdk fi - mv ${D}${libdir}/libEGL-${backend}.so ${D}${libdir}/libEGL.so.1.0 - ln -sf libEGL.so.1.0 ${D}${libdir}/libEGL.so.1 - ln -sf libEGL.so.1.0 ${D}${libdir}/libEGL.so - mv ${D}${libdir}/libGAL-${backend}.so ${D}${libdir}/libGAL.so - if [ "${USE_WL}" = "yes" ]; then + if [ "${BACKEND}" = "wayland" ] && [ "${IS_MX8}" != "1" ]; then # Special case for libVDK on Wayland backend, deliver fb library as well. - # Need to rename the libraries to avoid the code below that will remove - # *-fb.so and *-wl.so - mv ${D}${libdir}/libVDK-fb.so ${D}${libdir}/libVDK-framebuffer.so - mv ${D}${libdir}/libVDK-wl.so ${D}${libdir}/libVDK-wayland.so - ln -sf libVDK-wayland.so ${D}${libdir}/libVDK.so - else - mv ${D}${libdir}/libVDK-${backend}.so ${D}${libdir}/libVDK.so + cp ${S}/gpu-core/usr/lib/fb/libVDK.so.1.2.0 ${D}${libdir}/libVDK-fb.so.1.2.0 fi - # update libglesv2 as backend dependent - rm -rf ${D}${libdir}/libGLESv2* - cp ${S}/gpu-core/usr/lib/libGLESv2-${backend}.so ${D}${libdir}/libGLESv2.so.2.0.0 - ln -sf libGLESv2.so.2.0.0 ${D}${libdir}/libGLESv2.so.2 - ln -sf libGLESv2.so.2.0.0 ${D}${libdir}/libGLESv2.so + if [ -z "${PACKAGES_OPENCL}" ]; then + set -f + for f in ${FILES:libopencl-imx} ${FILES:libopencl-imx-dev} ${FILES:libclc-imx}; do + set +f + rm -rf ${D}$f + done + rm -rf ${D}/opt/viv_samples/cl11 + else + # Install Vendor ICDs for OpenCL's installable client driver loader (ICDs Loader) + install -d ${D}${sysconfdir}/OpenCL/vendors/ + install -m 0644 ${S}/gpu-core/etc/Vivante.icd ${D}${sysconfdir}/OpenCL/vendors/Vivante.icd - if [ "${IS_MX8}" = "1" ]; then - # Change libvulkon.so driver soname, so that it does not clash with the - # vulkan-loader libvulkan.so - patchelf --set-soname libvulkan_VSI.so.1 ${D}${libdir}/libvulkan-${backend}.so - mv ${D}${libdir}/libvulkan-${backend}.so ${D}${libdir}/libvulkan_VSI.so + if [ "${OPENCL_VX_INTRINSIC_EXTENSION_PACKAGES}" = "" ]; then + rm -f ${D}${includedir}/CL/cl_viv_vx_ext.h + fi fi - for header in ${GLES3_HEADER_REMOVALS}; do - rm -f ${D}${includedir}/GLES3/${header} - done - # skip packaging wayland libraries if no support is requested - if [ "${USE_WL}" = "no" ]; then - find ${D}${libdir} -name "libgc_wayland_protocol.*" -exec rm '{}' ';' - find ${D}${libdir} -name "libwayland-viv.*" -exec rm '{}' ';' + if [ -z "${PACKAGES_OPENVX}" ]; then + set -f + for f in ${FILES:libopenvx-imx} ${FILES:libopenvx-imx-dev}; do + set +f + rm -rf ${D}$f + done fi - for i in wl x11 fb dri; do - find ${D}${libdir} -name "*-$i.so" -exec rm '{}' ';' - find ${D}${libdir} -name "*.$i.so" -exec rm '{}' ';' - done + if [ "${IS_MX8}" = "1" ]; then + if [ -z "${PACKAGES_VULKAN}" ]; then + set -f + for f in ${FILES:libvulkan-imx} ${FILES:libvulkan-imx-dev}; do + set +f + rm -rf ${D}$f + done + else + install -Dm 0644 ${WORKDIR}/imx_icd.json ${D}${sysconfdir}/vulkan/icd.d/imx_icd.json + sed -i "s,%libdir%,${libdir}," ${D}${sysconfdir}/vulkan/icd.d/imx_icd.json + sed -i "s,%api_version%,${LIBVULKAN_API_VERSION}," ${D}${sysconfdir}/vulkan/icd.d/imx_icd.json + fi + fi # FIXME: MX6SL does not have 3D support; hack it for now if [ "${IS_MX6SL}" = "1" ]; then @@ -288,97 +313,122 @@ do_install () { chown -R root:root "${D}" } -ALLOW_EMPTY_${PN} = "1" +do_install:append:libc-musl() { + # libs + for f in `find ${D}${libdir} -name '*.so*' -type f` + do + patchelf --add-needed libgcompat.so.0 $f + done + # binaries + for f in `find ${D}/opt ${D}${bindir} -name '*' -type f -executable` + do + # prune scripts + if `patchelf --print-interpreter $f 2>&1 > /dev/null` + then + patchelf --set-interpreter ${root_prefix}`patchelf --print-interpreter $f` $f + patchelf --add-needed libgcompat.so.0 $f + fi + done +} + +ALLOW_EMPTY:${PN} = "1" -FILES_libclc-imx = "${libdir}/libCLC${SOLIBS}" -FILES_libclc-imx-dev = "${includedir}/CL ${libdir}/libCLC${SOLIBSDEV}" +FILES:libclc-imx = "${libdir}/libCLC${SOLIBS}" +FILES:libegl-imx = "${libdir}/libEGL${REALSOLIBS} ${libdir}/libEGL${SOLIBS} " +FILES:libegl-imx-dev = "${includedir}/EGL ${includedir}/KHR ${libdir}/pkgconfig/egl.pc" # libEGL.so is used by some demo apps from Freescale -INSANE_SKIP_libegl-imx += "dev-so" -FILES_libegl-imx = "${libdir}/libEGL${REALSOLIBS} ${libdir}/libEGL${SOLIBSDEV} " -FILES_libegl-imx-dev = "${includedir}/EGL ${includedir}/KHR ${libdir}/pkgconfig/egl.pc" - -FILES_libgal-imx = "${libdir}/libGAL${SOLIBS} ${libdir}/libGAL_egl${SOLIBS}" -FILES_libgal-imx-dev = "${libdir}/libGAL${SOLIBSDEV} ${includedir}/HAL" -RDEPENDS_libgal-imx += "kernel-module-imx-gpu-viv" -RSUGGESTS_libgal-imx += "valgrind" -RPROVIDES_libgal-imx += "libgal-imx" -INSANE_SKIP_libgal-imx += "build-deps" - -FILES_libvsc-imx = "${libdir}/libVSC${SOLIBS}" - -FILES_libgbm-imx_mx8 = "${libdir}/libgbm*${SOLIBS}" -FILES_libgbm-imx-dev_mx8 = "${libdir}/pkgconfig/gbm.pc ${includedir}/gbm.h ${libdir}/libgbm${SOLIBSDEV}" -RDEPENDS_libgbm-imx_append_mx8 = " libdrm" - -FILES_libvulkan-imx = "${libdir}/libvulkan_VSI${SOLIBS} ${libdir}/libSPIRV_viv${SOLIBS}" -FILES_libvulkan-imx-dev = "${includedir}/vulkan ${libdir}/libvulkan_VSI${SOLIBSDEV}" - -FILES_libopenvx-imx = " \ - ${libdir}/libOpenVX*${SOLIBS} \ - ${libdir}/libOvx*${SOLIBS} \ - ${libdir}/libovx*${SOLIBS} \ - " -FILES_libopenvx-imx-dev = "${includedir}/VX ${includedir}/OVXLIB" -RDEPENDS_libopenvx-imx = "libnn-imx" - -FILES_libgl-imx = "${libdir}/libGL${REALSOLIBS}" -FILES_libgl-imx-dev = "${libdir}/libGL${SOLIBSDEV} ${includedir}/GL" - -# libEGL needs to open libGLESv1.so -INSANE_SKIP_libgles1-imx += "dev-so" -FILES_libgles1-imx = "${libdir}/libGLESv1*${REALSOLIBS} ${libdir}/libGLESv1*${SOLIBS} ${libdir}/libGLES_*${REALSOLIBS} ${libdir}/libGLES_*${SOLIBS}" -FILES_libgles1-imx-dev = "${includedir}/GLES ${libdir}/libGLESv1*${SOLIBS} ${libdir}/libGLES_*${SOLIBSDEV} ${libdir}/pkgconfig/glesv1_cm.pc" -RPROVIDES_libgles1-imx = "libgles-imx" -RPROVIDES_libgles1-imx-dev = "libgles-imx-dev" - -# libEGL needs to open libGLESv2.so -INSANE_SKIP_libgles2-imx += "dev-so" -FILES_libgles2-imx = "${libdir}/libGLESv2${REALSOLIBS} ${libdir}/libGLESv2${SOLIBS}" -FILES_libgles2-imx-dev = "${includedir}/GLES2 ${libdir}/libGLESv2${SOLIBSDEV} ${libdir}/pkgconfig/glesv2.pc" -RDEPENDS_libgles2-imx = "libglslc-imx" - -FILES_libgles3-imx-dev = "${includedir}/GLES3" +INSANE_SKIP:libegl-imx += "dev-so" + +FILES:libgal-imx = "${libdir}/libGAL${SOLIBS} ${libdir}/libGAL_egl${SOLIBS}" +FILES:libgal-imx-dev = "${includedir}/HAL" +RDEPENDS:libgal-imx += "${@bb.utils.contains('PACKAGECONFIG', 'valgrind', 'valgrind', '', d)}" +RPROVIDES:libgal-imx += "libgal-imx" +RRECOMMENDS:libgal-imx += "kernel-module-imx-gpu-viv" +INSANE_SKIP:libgal-imx += "build-deps" + +FILES:libvsc-imx = "${libdir}/libVSC${SOLIBS}" + +FILES:libgbm-imx = "${libdir}/libgbm*${REALSOLIBS} ${libdir}/libgbm${SOLIBS} ${libdir}/libgbm_viv${SOLIBS}" +FILES:libgbm-imx-dev = "${libdir}/pkgconfig/gbm.pc ${includedir}/gbm.h" +RDEPENDS:libgbm-imx:append = " libdrm" +INSANE_SKIP:libgbm-imx += "dev-so" + +FILES:libvulkan-imx = "\ + ${libdir}/libvulkan_VSI${REALSOLIBS} \ + ${sysconfdir}/vulkan" +FILES:libvulkan-imx-dev = "${includedir}/vulkan ${libdir}/libvulkan_VSI${SOLIBSDEV}" + +FILES:libspirv-imx = " \ + ${libdir}/libSPIRV_viv${SOLIBS} \ +" + +FILES:libopenvx-imx = " \ + ${libdir}/libOpenVX${REALSOLIBS} \ + ${libdir}/libOpenVXC${SOLIBS} \ + ${libdir}/libOpenVXU${SOLIBS} \ + ${libdir}/libOvx*${SOLIBS} \ + ${libdir}/libArchModelSw${SOLIBS} \ +" +FILES:libopenvx-imx-dev = "${includedir}/VX ${libdir}/libOpenVX${SOLIBSDEV}" +RDEPENDS:libopenvx-imx = "libnn-imx ${OPENCL_VX_INTRINSIC_EXTENSION_PACKAGES}" +OPENCL_VX_INTRINSIC_EXTENSION_PACKAGES = "" +OPENCL_VX_INTRINSIC_EXTENSION_PACKAGES:mx8qm-nxp-bsp = "libclc-imx libopencl-imx-dev" +OPENCL_VX_INTRINSIC_EXTENSION_PACKAGES:mx8mp-nxp-bsp = "libclc-imx libopencl-imx-dev" +INSANE_SKIP:libopenvx-imx += "dev-deps" + +FILES:libgl-imx = "${libdir}/libGL${REALSOLIBS} ${libdir}/libGL${SOLIBS}" +FILES:libgl-imx-dev = "${includedir}/GL ${libdir}/pkgconfig/gl.pc" +# libGL is only targeting X11 backend, and in case if Wayland-only is used - +# package QA complains on missing RDEPENDS, which are only available for X11. +# Skip "file-rdeps" QA for this package. +INSANE_SKIP:libgl-imx += "file-rdeps" +# libEGL does dlopen of libGL.so +INSANE_SKIP:libgl-imx += "dev-so" + +FILES:libgles1-imx = "${libdir}/libGLESv1*${REALSOLIBS} ${libdir}/libGLESv1*${SOLIBS} ${libdir}/libGLES_*${REALSOLIBS} ${libdir}/libGLES_*${SOLIBS}" +FILES:libgles1-imx-dev = "${includedir}/GLES ${libdir}/pkgconfig/glesv1_cm.pc" +RPROVIDES:libgles1-imx = "libgles-imx" +RPROVIDES:libgles1-imx-dev = "libgles-imx-dev" +# libEGL does dlopen of libGLESv1.so +INSANE_SKIP:libgles1-imx += "dev-so" + +FILES:libgles2-imx = "${libdir}/libGLESv2${REALSOLIBS} ${libdir}/libGLESv2${SOLIBS}" +FILES:libgles2-imx-dev = "${includedir}/GLES2 ${libdir}/pkgconfig/glesv2.pc" +RDEPENDS:libgles2-imx = "libglslc-imx" +# libEGL does dlopen of libGLESv2.so +INSANE_SKIP:libgles2-imx += "dev-so" + +FILES:libgles3-imx-dev = "${includedir}/GLES3" # as long as there is no libgles3: ship libgles3-dev along with # libgles2-dev - otherwise GLES3 headers have to be added manually -RDEPENDS_libgles2-imx-dev += "libgles3-imx-dev" +RDEPENDS:libgles2-imx-dev += "libgles3-imx-dev" -FILES_libglslc-imx = "${libdir}/libGLSLC${SOLIBS}" -FILES_libglslc-imx-dev = "${includedir}/CL ${libdir}/libGLSLC${SOLIBSDEV}" +FILES:libglslc-imx = "${libdir}/libGLSLC${SOLIBS}" -FILES_libopencl-imx = "${libdir}/libOpenCL${SOLIBS} \ +FILES:libopencl-imx = "${libdir}/libOpenCL${REALSOLIBS} \ ${libdir}/libVivanteOpenCL${SOLIBS} \ ${libdir}/libLLVM_viv${SOLIBS} \ ${sysconfdir}/OpenCL/vendors/Vivante.icd" -FILES_libopencl-imx-dev = "${includedir}/CL ${libdir}/libOpenCL${SOLIBSDEV}" -RDEPENDS_libopencl-imx= "libclc-imx" - -INSANE_SKIP_libopenvg-imx += "dev-so" -FILES_libopenvg-imx = "${libdir}/libOpenVG*${SOLIBS}" -FILES_libopenvg-imx-dev = "${includedir}/VG ${libdir}/libOpenVG*${SOLIBSDEV} ${libdir}/pkgconfig/vg.pc" - -FILES_libvdk-imx = "${libdir}/libVDK*${SOLIBS}" -FILES_libvdk-imx-dev = "${includedir}/*vdk*.h ${libdir}/libVDK${SOLIBSDEV}" -INSANE_SKIP_libvdk-imx += "dev-so" +FILES:libopencl-imx-dev = "${includedir}/CL ${libdir}/libOpenCL${SOLIBSDEV}" +RDEPENDS:libopencl-imx= "libclc-imx" -FILES_libvivante-dri-imx = "${libdir}/dri/vivante_dri.so" -RDEPENDS_libvivante-dri-imx = "libdrm" +FILES:libopenvg-imx = "${libdir}/libOpenVG*${REALSOLIBS} ${libdir}/libOpenVG*${SOLIBS}" +FILES:libopenvg-imx-dev = "${includedir}/VG ${libdir}/pkgconfig/vg.pc" +# libEGL does dlopen of libOpenVG.so +INSANE_SKIP:libopenvg-imx += "dev-so" -INSANE_SKIP_libwayland-viv-imx += "dev-so" -FILES_libwayland-viv-imx = "${libdir}/libwayland-viv${REALSOLIBS} ${libdir}/libwayland-viv${SOLIBS}" -FILES_libwayland-viv-imx-dev = "${includedir}/wayland-viv ${libdir})/libwayland-viv${SOLIBSDEV} ${libdir}/pkgconfig/wayland-viv.pc" -RPROVIDES_libwayland-viv-imx += "${@bb.utils.contains('DISTRO_FEATURES', 'wayland', 'xf86-video-imx-vivante', '', d)}" +FILES:libvdk-imx = "${libdir}/libVDK*${REALSOLIBS}" +FILES:libvdk-imx-dev = "${includedir}/*vdk*.h ${libdir}/libVDK${SOLIBSDEV}" -INSANE_SKIP_libgc-wayland-protocol-imx += "dev-so" -FILES_libgc-wayland-protocol-imx = "${libdir}/libgc_wayland_protocol${REALSOLIBS} ${libdir}/libgc_wayland_protocol${SOLIBS}" -FILES_libgc-wayland-protocol-imx-dev = "${libdir}/libgc_wayland_protocol${SOLIBSDEV} ${libdir}/pkgconfig/gc_wayland_protocol.pc" +FILES:imx-gpu-viv-tools = "${bindir}/gmem_info" -FILES_imx-gpu-viv-tools = "${bindir}/gmem_info" +FILES:imx-gpu-viv-demos = "/opt" +INSANE_SKIP:imx-gpu-viv-demos += "rpaths dev-deps" -FILES_imx-gpu-viv-demos = "/opt" -INSANE_SKIP_imx-gpu-viv-demos += "rpaths dev-deps" +FILES:libnn-imx = "${libdir}/libNN*${SOLIBS}" -FILES_libnn-imx = "${libdir}/libNN*${SOLIBS} ${libdir}/libnn*${SOLIBS} ${libdir}/libneuralnetworks${SOLIBS}" -FILES_libnn-imx-dev = "${includedir}/nnrt" +# It will use gcompat at runtime therefore checking for these at compile time wont be useful as +# they dont match musl/gcompat but it should run fine +INSANE_SKIP:append:libc-musl = " file-rdeps" -# COMPATIBLE_MACHINE = "(mx6q|mx6dl|mx6sx|mx6sl|mx8)" diff --git a/recipes-graphics/imx-gpu-viv/imx-gpu-viv/imx_icd.json b/recipes-graphics/imx-gpu-viv/imx-gpu-viv/imx_icd.json new file mode 100644 index 00000000..21d83f94 --- /dev/null +++ b/recipes-graphics/imx-gpu-viv/imx-gpu-viv/imx_icd.json @@ -0,0 +1,7 @@ +{ + "file_format_version": "1.0.0", + "ICD": { + "library_path": "%libdir%/libvulkan_VSI.so.1", + "api_version": "%api_version%" + } +} diff --git a/recipes-graphics/imx-gpu-viv/imx-gpu-viv_6.4.0.p2.0-aarch32.bb b/recipes-graphics/imx-gpu-viv/imx-gpu-viv_6.4.0.p2.0-aarch32.bb deleted file mode 100644 index d1b82f6e..00000000 --- a/recipes-graphics/imx-gpu-viv/imx-gpu-viv_6.4.0.p2.0-aarch32.bb +++ /dev/null @@ -1,10 +0,0 @@ -# Copyright (C) 2013-2016 Freescale Semiconductor -# Copyright 2017-2020 NXP -# Released under the MIT license (see COPYING.MIT for the terms) - -require recipes-graphics/imx-gpu-viv/imx-gpu-viv-6.inc - -SRC_URI[md5sum] = "4544b0c874914dfbc47ec93855bd04a7" -SRC_URI[sha256sum] = "bae4099119259a303a265eb02d9f0d63348bbf3f8637de6cb892e209171b4c97" - -COMPATIBLE_MACHINE = "(mx6q|mx6dl|mx6sx|mx6sl|mx7ulp)" diff --git a/recipes-graphics/imx-gpu-viv/imx-gpu-viv_6.4.0.p2.0-aarch64.bb b/recipes-graphics/imx-gpu-viv/imx-gpu-viv_6.4.0.p2.0-aarch64.bb deleted file mode 100644 index b46c6115..00000000 --- a/recipes-graphics/imx-gpu-viv/imx-gpu-viv_6.4.0.p2.0-aarch64.bb +++ /dev/null @@ -1,6 +0,0 @@ -require imx-gpu-viv-6.inc - -SRC_URI[md5sum] = "f4005a4a2dba6a79d8f25547612aa3b9" -SRC_URI[sha256sum] = "148e1b1a9e382a8159d5763dd2b08caad008eb931f3d925ac901c2438440d508" - -COMPATIBLE_MACHINE = "(mx8)" diff --git a/recipes-graphics/imx-gpu-viv/imx-gpu-viv_6.4.11.p2.2-aarch32.bb b/recipes-graphics/imx-gpu-viv/imx-gpu-viv_6.4.11.p2.2-aarch32.bb new file mode 100644 index 00000000..07a92246 --- /dev/null +++ b/recipes-graphics/imx-gpu-viv/imx-gpu-viv_6.4.11.p2.2-aarch32.bb @@ -0,0 +1,10 @@ +require imx-gpu-viv-6.inc + +LIC_FILES_CHKSUM = "file://COPYING;md5=2827219e81f28aba7c6a569f7c437fa7" + +IMX_SRCREV_ABBREV = "fd0148d" + +SRC_URI[md5sum] = "267d3e2d580e264157b7de01df22fb66" +SRC_URI[sha256sum] = "15efe6da5d4bac2a6067c2a898190be8754df6f14128c3db4756cff59c6da049" + +COMPATIBLE_MACHINE = "(mx6q-nxp-bsp|mx6dl-nxp-bsp|mx6sx-nxp-bsp|mx6sl-nxp-bsp|mx7ulp-nxp-bsp)" diff --git a/recipes-graphics/imx-gpu-viv/imx-gpu-viv_6.4.11.p2.2-aarch64.bb b/recipes-graphics/imx-gpu-viv/imx-gpu-viv_6.4.11.p2.2-aarch64.bb new file mode 100644 index 00000000..cea83ddc --- /dev/null +++ b/recipes-graphics/imx-gpu-viv/imx-gpu-viv_6.4.11.p2.2-aarch64.bb @@ -0,0 +1,10 @@ +require imx-gpu-viv-6.inc + +LIC_FILES_CHKSUM = "file://COPYING;md5=2827219e81f28aba7c6a569f7c437fa7" + +IMX_SRCREV_ABBREV = "fd0148d" + +SRC_URI[md5sum] = "b76784e04f24ec9f2bedf2dd377ed5a8" +SRC_URI[sha256sum] = "6e34f3718925ba37c362cd09a3228cc56d03cfad323ebae0932f64449dbaeb2e" + +COMPATIBLE_MACHINE = "(mx8-nxp-bsp)" diff --git a/recipes-graphics/libepoxy/libepoxy_1.5.%.bbappend b/recipes-graphics/libepoxy/libepoxy_1.5.%.bbappend index 5b82b3f4..71baa53d 100644 --- a/recipes-graphics/libepoxy/libepoxy_1.5.%.bbappend +++ b/recipes-graphics/libepoxy/libepoxy_1.5.%.bbappend @@ -1,5 +1,5 @@ # Append EGL_CFLAGS to CFLAGS -CFLAGS_append_imxgpu = " \ +CFLAGS:append:imxgpu = " \ ${@bb.utils.contains('DISTRO_FEATURES', 'x11', '', '-DEGL_API_FB', d)} \ ${@bb.utils.contains('DISTRO_FEATURES', 'wayland', '-DWL_EGL_PLATFORM', '', d)} \ " diff --git a/recipes-graphics/libsdl2/libsdl2_%.bbappend b/recipes-graphics/libsdl2/libsdl2_%.bbappend index 303ea63a..3b2655ce 100644 --- a/recipes-graphics/libsdl2/libsdl2_%.bbappend +++ b/recipes-graphics/libsdl2/libsdl2_%.bbappend @@ -1,8 +1,8 @@ # what vivante driver does libsdl2 mean? Anyway it fails with missing functions as # VIVANTE_Create VIVANTE_GLES_GetProcAddress VIVANTE_GLES_UnloadLibrary ... -EXTRA_OECONF_append_imxgpu2d = " --disable-video-vivante" +EXTRA_OECMAKE:append:imxgpu = " -DSDL_VIVANTE=OFF" -CFLAGS_append_imxgpu = " -DLINUX \ +CFLAGS:append:imxgpu = " -DLINUX \ ${@bb.utils.contains('DISTRO_FEATURES', 'x11', '', '-DEGL_API_FB', d)} \ ${@bb.utils.contains('DISTRO_FEATURES', 'wayland', '-DWL_EGL_PLATFORM', '', d)} \ " diff --git a/recipes-graphics/libva/libva_%.bbappend b/recipes-graphics/libva/libva_%.bbappend new file mode 100644 index 00000000..080052f8 --- /dev/null +++ b/recipes-graphics/libva/libva_%.bbappend @@ -0,0 +1 @@ +PACKAGECONFIG:remove:imxgpu = "glx" diff --git a/recipes-graphics/mesa/libglu_%.bbappend b/recipes-graphics/mesa/libglu_%.bbappend new file mode 100644 index 00000000..96745dd8 --- /dev/null +++ b/recipes-graphics/mesa/libglu_%.bbappend @@ -0,0 +1 @@ +REQUIRED_DISTRO_FEATURES:remove:imxgpu = "x11" diff --git a/recipes-graphics/mesa/mesa-demos/Add-OpenVG-demos-to-support-wayland.patch b/recipes-graphics/mesa/mesa-demos/Add-OpenVG-demos-to-support-wayland.patch deleted file mode 100644 index 19bcca98..00000000 --- a/recipes-graphics/mesa/mesa-demos/Add-OpenVG-demos-to-support-wayland.patch +++ /dev/null @@ -1,84 +0,0 @@ -From 8aba54422d9a77383c150f9f70240b18b6e1918e Mon Sep 17 00:00:00 2001 -From: Prabhu Sundararaj <prabhu.sundararaj@freescale.com> -Date: Thu, 9 Apr 2015 15:47:21 -0500 -Subject: [PATCH] Add OpenVG demos to support wayland. - -Upstream-Status: Pending - -Signed-off-by: Prabhu Sundararaj <prabhu.sundararaj@freescale.com> ---- - src/egl/Makefile.am | 6 +++--- - src/egl/openvg/Makefile.am | 33 +++++++++++++++++++++++++++++---- - 2 files changed, 32 insertions(+), 7 deletions(-) - -Index: mesa-demos-8.2.0/src/egl/Makefile.am -=================================================================== ---- mesa-demos-8.2.0.orig/src/egl/Makefile.am 2016-05-09 11:45:51.479100180 -0500 -+++ mesa-demos-8.2.0/src/egl/Makefile.am 2016-05-09 11:45:51.475100160 -0500 -@@ -26,10 +26,10 @@ - eglut \ - opengles1 \ - opengles2 \ -- oes_vg -+ oes_vg \ -+ openvg - - if HAVE_GLU - SUBDIRS += \ -- opengl \ -- openvg -+ opengl - endif -Index: mesa-demos-8.2.0/src/egl/openvg/Makefile.am -=================================================================== ---- mesa-demos-8.2.0.orig/src/egl/openvg/Makefile.am 2016-05-09 11:45:51.479100180 -0500 -+++ mesa-demos-8.2.0/src/egl/openvg/Makefile.am 2016-05-09 12:39:30.000000000 -0500 -@@ -47,13 +47,26 @@ - endif - endif - -+if HAVE_WAYLAND -+EGL_WL_DEMOS = \ -+ lion_wayland \ -+ sp_wayland -+ -+if HAVE_FREETYPE2 -+EGL_WL_DEMOS += \ -+ vgtext_wayland -+endif -+endif -+ - if HAVE_EGL - if HAVE_VG - bin_PROGRAMS = \ -- $(EGL_X11_DEMOS) -+ $(EGL_X11_DEMOS) \ -+ $(EGL_WL_DEMOS) - endif - endif - -+if HAVE_X11 - lion_x11_SOURCES = lion.c lion-render.c lion-render.h - sp_x11_SOURCES = sp.c - -@@ -63,6 +76,20 @@ - text_SOURCES = text.c - text_CFLAGS = $(AM_CFLAGS) @FREETYPE2_CFLAGS@ - text_LDADD = @FREETYPE2_LIBS@ ../eglut/libeglut_x11.la -+endif -+ -+if HAVE_WAYLAND -+lion_wayland_SOURCES = lion.c lion-render.c lion-render.h -+lion_wayland_LDADD = ../eglut/libeglut_wayland.la -+ -+sp_wayland_SOURCES = sp.c -+sp_wayland_LDADD = ../eglut/libeglut_wayland.la -+ -+vgtext_wayland_SOURCES = text.c -+vgtext_wayland_CFLAGS = $(AM_CFLAGS) @FREETYPE2_CFLAGS@ -+vgtext_wayland_LDADD = @FREETYPE2_LIBS@ ../eglut/libeglut_wayland.la -+ -+endif - - SUBDIRS = \ - trivial diff --git a/recipes-graphics/mesa/mesa-demos/Replace-glWindowPos2iARB-calls-with-glWindowPos2i.patch b/recipes-graphics/mesa/mesa-demos/Replace-glWindowPos2iARB-calls-with-glWindowPos2i.patch index d899540f..8401793c 100644 --- a/recipes-graphics/mesa/mesa-demos/Replace-glWindowPos2iARB-calls-with-glWindowPos2i.patch +++ b/recipes-graphics/mesa/mesa-demos/Replace-glWindowPos2iARB-calls-with-glWindowPos2i.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Replace glWindowPos2iARB calls with glWindowPos2i Vivante libGL does not provide the glWindowPos2iARB symbol, but glWindowPos2i. Use this instead. -Upstream-Status: Inapropriate [embedded specific] +Upstream-Status: Inappropriate [embedded specific] Reported-by: Jeremy Stashluk <jstashluk@dekaresearch.com> Signed-off-by: Otavio Salvador <otavio@ossystems.com.br> diff --git a/recipes-graphics/mesa/mesa-demos/fix-clear-build-break.patch b/recipes-graphics/mesa/mesa-demos/fix-clear-build-break.patch index eb541d65..459a6ebd 100644 --- a/recipes-graphics/mesa/mesa-demos/fix-clear-build-break.patch +++ b/recipes-graphics/mesa/mesa-demos/fix-clear-build-break.patch @@ -1,7 +1,8 @@ mesa-demos: Add extension header to fix build break now that gl1 is removed -Upstream Status: Pending +Upstream-Status: Pending +Signed-off-by: Khem Raj <raj.khem@gmail.com> diff --git a/src/egl/opengles1/clear.c b/src/egl/opengles1/clear.c index 9fe1b5291e1905fd6fe572063ed707d59ce45a81..ca9954a21b5f475709dbdef07f90b900962fcbc7 100644 --- a/src/egl/opengles1/clear.c diff --git a/recipes-graphics/mesa/mesa-demos_%.bbappend b/recipes-graphics/mesa/mesa-demos_%.bbappend index 301f1b59..ff5d71ae 100644 --- a/recipes-graphics/mesa/mesa-demos_%.bbappend +++ b/recipes-graphics/mesa/mesa-demos_%.bbappend @@ -1,26 +1,23 @@ -FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" +FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:" -SRC_URI_append_imxgpu = " file://Replace-glWindowPos2iARB-calls-with-glWindowPos2i.patch \ - file://fix-clear-build-break.patch \ - file://Add-OpenVG-demos-to-support-wayland.patch" +SRC_URI:append:imxgpu = " \ + file://Replace-glWindowPos2iARB-calls-with-glWindowPos2i.patch \ + file://fix-clear-build-break.patch" +REQUIRED_DISTRO_FEATURES:remove:imxgpu = "x11" + +PACKAGECONFIG:remove = " \ + ${PACKAGECONFIG_REMOVE_IF_2D_ONLY} \ + ${PACKAGECONFIG_REMOVE_IF_GPU}" PACKAGECONFIG_REMOVE_IF_2D_ONLY = "" -PACKAGECONFIG_REMOVE_IF_2D_ONLY_imxgpu2d = "gles1 gles2" -PACKAGECONFIG_REMOVE_IF_2D_ONLY_imxgpu3d = "" +PACKAGECONFIG_REMOVE_IF_2D_ONLY:imxgpu2d = "gles1 gles2" +PACKAGECONFIG_REMOVE_IF_2D_ONLY:imxgpu3d = "" PACKAGECONFIG_REMOVE_IF_GPU = "" -PACKAGECONFIG_REMOVE_IF_GPU_imxgpu = " \ - ${@bb.utils.contains('DISTRO_FEATURES', 'wayland', 'glu x11', '', d)} \ -" -PACKAGECONFIG_remove = " \ - ${PACKAGECONFIG_REMOVE_IF_2D_ONLY} \ - ${PACKAGECONFIG_REMOVE_IF_GPU} \ -" +PACKAGECONFIG_REMOVE_IF_GPU:imxgpu = "x11" +PACKAGECONFIG:append = " \ + ${PACKAGECONFIG_APPEND_IF_GPU}" PACKAGECONFIG_APPEND_IF_GPU = "" -PACKAGECONFIG_APPEND_IF_GPU_imxgpu = " \ - ${@bb.utils.contains('DISTRO_FEATURES', 'wayland', 'wayland vg', '', d)} \ - ${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'glut', '', d)} \ -" -PACKAGECONFIG_append = " \ - ${PACKAGECONFIG_APPEND_IF_GPU} \ -" +PACKAGECONFIG_APPEND_IF_GPU:imxgpu = "glu" + +PACKAGECONFIG[glu] = ",,libglu" diff --git a/recipes-graphics/mesa/mesa-etnaviv-env/mesa-etnaviv.conf b/recipes-graphics/mesa/mesa-etnaviv-env/mesa-etnaviv.conf new file mode 100644 index 00000000..db4f8740 --- /dev/null +++ b/recipes-graphics/mesa/mesa-etnaviv-env/mesa-etnaviv.conf @@ -0,0 +1,3 @@ +[Manager] +DefaultEnvironment=MESA_GL_VERSION_OVERRIDE=2.1 ETNA_MESA_DEBUG=nir + diff --git a/recipes-graphics/mesa/mesa-etnaviv-env/mesa-etnaviv.sh b/recipes-graphics/mesa/mesa-etnaviv-env/mesa-etnaviv.sh new file mode 100644 index 00000000..8854a877 --- /dev/null +++ b/recipes-graphics/mesa/mesa-etnaviv-env/mesa-etnaviv.sh @@ -0,0 +1,2 @@ +export MESA_GL_VERSION_OVERRIDE=2.1 +export ETNA_MESA_DEBUG=nir diff --git a/recipes-graphics/mesa/mesa-etnaviv-env_0.1.bb b/recipes-graphics/mesa/mesa-etnaviv-env_0.1.bb new file mode 100644 index 00000000..87d05365 --- /dev/null +++ b/recipes-graphics/mesa/mesa-etnaviv-env_0.1.bb @@ -0,0 +1,31 @@ +SUMMARY = "Mesa environment variables for etnaviv on xserver" +LICENSE = "MIT" +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" + +PACKAGE_ARCH = "${MACHINE_ARCH}" + +SRC_URI = "\ + file://mesa-etnaviv.conf \ + file://mesa-etnaviv.sh \ +" + +do_configure[noexec] = "1" +do_compile[noexec] = "1" + +do_install:use-mainline-bsp() { + # MESA global envirronment variables + + # systemd + if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then + install -D -m 644 ${WORKDIR}/mesa-etnaviv.conf \ + ${D}${sysconfdir}/systemd/system.conf.d/mesa-etnaviv.conf + fi + + # sysvinit + if ${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', 'true', 'false', d)}; then + install -D -m 644 ${WORKDIR}/mesa-etnaviv.sh \ + ${D}${sysconfdir}/profile.d/mesa-etnaviv.sh + fi +} + +ALLOW_EMPTY:${PN} = "1" diff --git a/recipes-graphics/mesa/mesa-gl_%.bbappend b/recipes-graphics/mesa/mesa-gl_%.bbappend index ca1c8f46..dafd27f0 100644 --- a/recipes-graphics/mesa/mesa-gl_%.bbappend +++ b/recipes-graphics/mesa/mesa-gl_%.bbappend @@ -1 +1 @@ -COMPATIBLE_MACHINE_imxgpu = "(-)" +COMPATIBLE_MACHINE:imxgpu = "(-)" diff --git a/recipes-graphics/mesa/mesa_%.bbappend b/recipes-graphics/mesa/mesa_%.bbappend index 8d429abf..acddfbc6 100644 --- a/recipes-graphics/mesa/mesa_%.bbappend +++ b/recipes-graphics/mesa/mesa_%.bbappend @@ -1,8 +1,8 @@ -PROVIDES_remove_imxgpu = "virtual/egl" -PROVIDES_remove_imxgpu3d = "virtual/libgl virtual/libgles1 virtual/libgles2" +PROVIDES:remove:imxgpu = "virtual/egl" +PROVIDES:remove:imxgpu3d = "virtual/libgl virtual/libgles1 virtual/libgles2" -PACKAGECONFIG_remove_imxgpu = "egl gbm" -PACKAGECONFIG_remove_imxgpu3d = "gles" +PACKAGECONFIG:remove:imxgpu = "egl gbm" +PACKAGECONFIG:remove:imxgpu3d = "gles" # FIXME: mesa should support 'x11-no-tls' option python () { @@ -15,19 +15,13 @@ python () { } # Enable Etnaviv and Freedreno support -PACKAGECONFIG_append_use-mainline-bsp = " gallium etnaviv kmsro freedreno" +PACKAGECONFIG:append:use-mainline-bsp = " gallium etnaviv kmsro freedreno" -USE_OSMESA_ONLY ?= "no" +# For NXP BSP, GPU drivers don't support dri +PACKAGECONFIG:remove:imxgpu:use-nxp-bsp = "dri" -# Etnaviv support state for i.MX8 is unknown, therefore only enable OSMesa and -# disable Gallium for now. If you still want to enable Etnaviv, just set -# USE_OSMESA_ONLY_mx8 = "no" in your bbappend. -USE_OSMESA_ONLY_mx8 ?= "yes" - -# Enable OSMesa which also requires dri (classic) swrast -PACKAGECONFIG_append = " ${@oe.utils.conditional('USE_OSMESA_ONLY', 'yes', ' osmesa', '', d)}" -PACKAGECONFIG_remove = " ${@oe.utils.conditional('USE_OSMESA_ONLY', 'yes', 'gallium', '', d)}" -DRIDRIVERS_append = "${@oe.utils.conditional('USE_OSMESA_ONLY', 'yes', 'swrast', '', d)}" +# mainline/etnaviv: +RRECOMMENDS:${PN}-megadriver:append:use-mainline-bsp = " libdrm-etnaviv mesa-etnaviv-env" BACKEND = \ "${@bb.utils.contains('DISTRO_FEATURES', 'wayland', 'wayland', \ @@ -35,7 +29,7 @@ BACKEND = \ 'fb', d), d)}" # FIXME: Dirty hack to allow use of Vivante GPU libGL binary -do_install_append_imxgpu3d () { +do_install:append:imxgpu3d () { rm -f ${D}${libdir}/libGL.* \ ${D}${includedir}/GL/gl.h \ ${D}${includedir}/GL/glcorearb.h \ @@ -47,6 +41,6 @@ do_install_append_imxgpu3d () { fi } -do_install_append_imxgpu () { +do_install:append:imxgpu () { rm -rf ${D}${includedir}/KHR } diff --git a/recipes-graphics/pango/pango_%.bbappend b/recipes-graphics/pango/pango_%.bbappend new file mode 100644 index 00000000..bf8c38fc --- /dev/null +++ b/recipes-graphics/pango/pango_%.bbappend @@ -0,0 +1,5 @@ +# links with imx-gpu libs which are pre-built for glibc +# gcompat will address it during runtime +LDFLAGS:append:imxgpu:libc-musl = " -Wl,--allow-shlib-undefined" + +RDEPENDS:${PN}:append:imxgpu:libc-musl = " gcompat" diff --git a/recipes-graphics/piglit/piglit_%.bbappend b/recipes-graphics/piglit/piglit_%.bbappend new file mode 100644 index 00000000..fe2a0bc2 --- /dev/null +++ b/recipes-graphics/piglit/piglit_%.bbappend @@ -0,0 +1,6 @@ +PACKAGECONFIG:remove:imxgpu = "glx" + +PACKAGECONFIG:append:mx8-nxp-bsp = " opencl" +PACKAGECONFIG:append:mx9-nxp-bsp = " opencl" + +CFLAGS:append:imxgpu:toolchain-clang = " -Wno-error=int-conversion" diff --git a/recipes-graphics/vulkan/vulkan-loader_1.3.239.0.imx.bbappend b/recipes-graphics/vulkan/vulkan-loader_1.3.239.0.imx.bbappend new file mode 100644 index 00000000..05f566a8 --- /dev/null +++ b/recipes-graphics/vulkan/vulkan-loader_1.3.239.0.imx.bbappend @@ -0,0 +1,7 @@ +# libvulkan.so is loaded dynamically, so put it in the main package +SOLIBS = ".so*" +FILES_SOLIBSDEV = "" +INSANE_SKIP:${PN} += "dev-so" + +# Override default mesa drivers with i.MX GPU drivers +RRECOMMENDS:${PN}:imxvulkan = "libvulkan-imx" diff --git a/recipes-graphics/waffle/waffle/0001-meson-Add-missing-wayland-dependency-on-EGL.patch b/recipes-graphics/waffle/waffle/0001-meson-Add-missing-wayland-dependency-on-EGL.patch index b5225693..6f4be031 100644 --- a/recipes-graphics/waffle/waffle/0001-meson-Add-missing-wayland-dependency-on-EGL.patch +++ b/recipes-graphics/waffle/waffle/0001-meson-Add-missing-wayland-dependency-on-EGL.patch @@ -14,19 +14,19 @@ Signed-off-by: Tom Hochstein <tom.hochstein@nxp.com> meson.build | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) -diff --git a/meson.build b/meson.build -index ca8b127..efb51f4 100644 ---- a/meson.build -+++ b/meson.build +Index: git/meson.build +=================================================================== +--- git.orig/meson.build ++++ git/meson.build @@ -65,6 +65,7 @@ dep_gl = _dep_null dep_egl = _dep_null dep_wayland_client = _dep_null dep_wayland_egl = _dep_null +dep_wayland_wayland_egl = _dep_null + dep_wayland_scanner = _dep_null + dep_wayland_proto = _dep_null dep_x11_xcb = _dep_null - dep_gbm = _dep_null - dep_udev = _dep_null -@@ -90,7 +91,8 @@ else +@@ -106,7 +107,8 @@ else dep_wayland_client = dependency( 'wayland-client', version : '>= 1.10', required : get_option('wayland'), ) @@ -35,13 +35,13 @@ index ca8b127..efb51f4 100644 + dep_wayland_wayland_egl = dependency( 'wayland-egl', version : '>= 9.1', required : get_option('wayland'), ) - dep_x11_xcb = dependency('x11-xcb', required : get_option('glx')) -@@ -101,7 +103,7 @@ else - dep_udev = dependency('libudev', required : get_option('gbm')) + dep_wayland_scanner = dependency( +@@ -124,7 +126,7 @@ else + wayland_xdg_shell_xml = join_paths(dep_wayland_proto.get_variable(pkgconfig: 'pkgdatadir'), + 'stable/xdg-shell/xdg-shell.xml') + endif +- build_wayland = dep_egl.found() and dep_wayland_client.found() and dep_wayland_egl.found() and dep_wayland_scanner.found() and dep_wayland_proto.found() ++ build_wayland = dep_egl.found() and dep_wayland_client.found() and dep_wayland_egl.found() and dep_wayland_scanner.found() and dep_wayland_proto.found() and dep_wayland_wayland_egl.found() - build_x11_egl = dep_egl.found() -- build_wayland = dep_wayland_client.found() and dep_wayland_egl.found() -+ build_wayland = dep_wayland_client.found() and dep_wayland_egl.found() and dep_wayland_wayland_egl.found() - build_glx = dep_gl.found() - build_gbm = dep_gbm.found() and dep_udev.found() - build_surfaceless = dep_egl.found() + # We're interested only in the headers provided + # FINISHME: make x11_xcb and udev compile-only dependency diff --git a/recipes-graphics/waffle/waffle/0002-meson-Separate-surfaceless-option-from-x11.patch b/recipes-graphics/waffle/waffle/0002-meson-Separate-surfaceless-option-from-x11.patch index 9d5003e2..2a680cc6 100644 --- a/recipes-graphics/waffle/waffle/0002-meson-Separate-surfaceless-option-from-x11.patch +++ b/recipes-graphics/waffle/waffle/0002-meson-Separate-surfaceless-option-from-x11.patch @@ -14,8 +14,6 @@ Signed-off-by: Tom Hochstein <tom.hochstein@nxp.com> meson.build | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) -diff --git a/meson.build b/meson.build -index efb51f4..0ee3ee5 100644 --- a/meson.build +++ b/meson.build @@ -72,6 +72,7 @@ dep_udev = _dep_null @@ -26,19 +24,17 @@ index efb51f4..0ee3ee5 100644 # Get dependencies if build_wgl -@@ -101,12 +102,14 @@ else - endif +@@ -96,10 +97,11 @@ else + dep_egl = dependency('egl', required : get_option('gbm')) dep_gbm = dependency('gbm', required : get_option('gbm')) dep_udev = dependency('libudev', required : get_option('gbm')) + dep_surfaceless_egl = dependency('egl', required : get_option('surfaceless_egl')) + dep_surfaceless_gbm = dependency('gbm', required : get_option('surfaceless_egl')) + build_gbm = dep_egl.found() and dep_gbm.found() and dep_udev.found() - build_x11_egl = dep_egl.found() - build_wayland = dep_wayland_client.found() and dep_wayland_egl.found() and dep_wayland_wayland_egl.found() - build_glx = dep_gl.found() - build_gbm = dep_gbm.found() and dep_udev.found() +- dep_egl = dependency('egl', required : get_option('surfaceless_egl')) - build_surfaceless = dep_egl.found() + build_surfaceless = dep_surfaceless_egl.found() and dep_surfaceless_gbm.found() - endif - dep_bash = dependency('bash-completion', required : false) + dep_egl = dependency('egl', required : get_option('wayland')) + dep_wayland_client = dependency( diff --git a/recipes-graphics/waffle/waffle_%.bbappend b/recipes-graphics/waffle/waffle_%.bbappend index 9d090bcf..e88f558d 100644 --- a/recipes-graphics/waffle/waffle_%.bbappend +++ b/recipes-graphics/waffle/waffle_%.bbappend @@ -1,4 +1,4 @@ -FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" +FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:" SRC_URI += " \ file://0001-meson-Add-missing-wayland-dependency-on-EGL.patch \ @@ -6,11 +6,11 @@ SRC_URI += " \ " PACKAGECONFIG_IMXGPU_X11 = "" -PACKAGECONFIG_IMXGPU_X11_imxgpu3d = "x11-egl glx" +PACKAGECONFIG_IMXGPU_X11:imxgpu3d = "x11-egl glx" PACKAGECONFIG_IMXGPU_GBM = "gbm" -PACKAGECONFIG_IMXGPU_GBM_mx6 = "" -PACKAGECONFIG_IMXGPU_GBM_mx7 = "" -PACKAGECONFIG_imxgpu = " \ +PACKAGECONFIG_IMXGPU_GBM:mx6-nxp-bsp = "" +PACKAGECONFIG_IMXGPU_GBM:mx7-nxp-bsp = "" +PACKAGECONFIG:imxgpu = " \ ${@bb.utils.contains('DISTRO_FEATURES', 'wayland', 'wayland', \ bb.utils.contains('DISTRO_FEATURES', 'x11', '${PACKAGECONFIG_IMXGPU_X11}', \ '', d), d)} \ diff --git a/recipes-graphics/wayland/required-distro-features.inc b/recipes-graphics/wayland/required-distro-features.inc new file mode 100644 index 00000000..bb4a0e8e --- /dev/null +++ b/recipes-graphics/wayland/required-distro-features.inc @@ -0,0 +1,8 @@ +# distro features required by weston recipes + +inherit features_check + +# requires pam enabled if started via systemd +# +REQUIRED_DISTRO_FEATURES = "wayland opengl ${@oe.utils.conditional('VIRTUAL-RUNTIME_init_manager', 'systemd', 'pam', '', d)}" + diff --git a/recipes-graphics/wayland/wayland-protocols_1.18.imx.bb b/recipes-graphics/wayland/wayland-protocols_1.18.imx.bb deleted file mode 100644 index 7f15bdb3..00000000 --- a/recipes-graphics/wayland/wayland-protocols_1.18.imx.bb +++ /dev/null @@ -1,22 +0,0 @@ -SUMMARY = "Collection of additional Wayland protocols" -DESCRIPTION = "Wayland protocols that add functionality not \ -available in the Wayland core protocol. Such protocols either add \ -completely new functionality, or extend the functionality of some other \ -protocol either in Wayland core, or some other protocol in \ -wayland-protocols." -HOMEPAGE = "http://wayland.freedesktop.org" -LICENSE = "MIT" -LIC_FILES_CHKSUM = "file://COPYING;md5=c7b12b6702da38ca028ace54aae3d484 \ - file://stable/presentation-time/presentation-time.xml;endline=26;md5=4646cd7d9edc9fa55db941f2d3a7dc53" - -SRC_URI = "git://source.codeaurora.org/external/imx/wayland-protocols-imx.git;protocol=https;branch=wayland-protocols-imx-1.18" -SRCREV = "ee18c1f66877f7fb652467c349108395c20d4f9a" -S = "${WORKDIR}/git" - -inherit autotools pkgconfig - -PACKAGES = "${PN}" -FILES_${PN} += "${datadir}/pkgconfig/wayland-protocols.pc" - -PACKAGE_ARCH = "${MACHINE_SOCARCH}" -COMPATIBLE_MACHINE = "(imxfbdev|imxgpu)" diff --git a/recipes-graphics/wayland/wayland-protocols_1.32.imx.bb b/recipes-graphics/wayland/wayland-protocols_1.32.imx.bb new file mode 100644 index 00000000..6b2a7091 --- /dev/null +++ b/recipes-graphics/wayland/wayland-protocols_1.32.imx.bb @@ -0,0 +1,31 @@ +SUMMARY = "Collection of additional Wayland protocols" +DESCRIPTION = "Wayland protocols that add functionality not \ +available in the Wayland core protocol. Such protocols either add \ +completely new functionality, or extend the functionality of some other \ +protocol either in Wayland core, or some other protocol in \ +wayland-protocols." +HOMEPAGE = "http://wayland.freedesktop.org" +LICENSE = "MIT" +LIC_FILES_CHKSUM = "file://LICENSE;md5=c7b12b6702da38ca028ace54aae3d484 \ + file://stable/presentation-time/presentation-time.xml;endline=26;md5=4646cd7d9edc9fa55db941f2d3a7dc53" + +SRC_URI = "git://github.com/nxp-imx/wayland-protocols-imx.git;protocol=https;branch=wayland-protocols-imx-${@oe.utils.trim_version("${PV}", 2)}" +SRCREV = "7ece577d467f8afb2f5a2f7fff3761a1e0ee9dad" + +S = "${WORKDIR}/git" + +UPSTREAM_CHECK_URI = "https://wayland.freedesktop.org/releases.html" + +# NOTE: For i.MX drop allarch since the recipe is SOCARCH +#inherit meson pkgconfig allarch +inherit meson pkgconfig + +EXTRA_OEMESON += "-Dtests=false" + +PACKAGES = "${PN}" +FILES:${PN} += "${datadir}/pkgconfig/wayland-protocols.pc" + +BBCLASSEXTEND = "native nativesdk" + +PACKAGE_ARCH = "${MACHINE_SOCARCH}" +COMPATIBLE_MACHINE = "(mx6-nxp-bsp|mx7-nxp-bsp|mx8-nxp-bsp|mx9-nxp-bsp)" diff --git a/recipes-graphics/wayland/weston-10.0.4.imx/0001-Revert-protocol-no-found-wayland-scanner-with-Yocto-.patch b/recipes-graphics/wayland/weston-10.0.4.imx/0001-Revert-protocol-no-found-wayland-scanner-with-Yocto-.patch new file mode 100644 index 00000000..59f2a4b6 --- /dev/null +++ b/recipes-graphics/wayland/weston-10.0.4.imx/0001-Revert-protocol-no-found-wayland-scanner-with-Yocto-.patch @@ -0,0 +1,41 @@ +From 77eba6f6b04ff21b77c41500657495b4fd12a5f6 Mon Sep 17 00:00:00 2001 +From: Max Krummenacher <max.krummenacher@toradex.com> +Date: Mon, 11 Jul 2022 19:38:19 +0000 +Subject: [PATCH] Revert "protocol: no found wayland-scanner with Yocto + toolchain" + +This reverts commit 7859a762617682bd804e210ad3bda6bdcd3ea24a. + +With openembedded commit e525db4eb9 ("wayland: update 1.20.0 -> 1.21.0") +package config seems no longer to provide the path to the native +weston scanner. + +Thus the build fails with: + +| Run-time dependency wayland-scanner found: YES 1.21.0 +| Program /usr/bin/wayland-scanner found: NO +| +| ../git/protocol/meson.build:2:0: ERROR: Program '/usr/bin/wayland-scanner' not found or not executable + +Dropping weston 9.0.0-imx commit 7859a762 (protocol: no found +wayland-scanner with Yocto toolchain") fixes the issue. + +Upstream-Status: Inappropriate [Cross-compile Specific] +Signed-off-by: Max Krummenacher <max.krummenacher@toradex.com> +--- + protocol/meson.build | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/protocol/meson.build b/protocol/meson.build +index bdd322ac..e50b23bb 100644 +--- a/protocol/meson.build ++++ b/protocol/meson.build +@@ -1,4 +1,4 @@ +-dep_scanner = dependency('wayland-scanner', native: false) ++dep_scanner = dependency('wayland-scanner', native: true) + prog_scanner = find_program(dep_scanner.get_pkgconfig_variable('wayland_scanner')) + + dep_wp = dependency('wayland-protocols', version: '>= 1.24') +-- +2.17.1 + diff --git a/recipes-graphics/wayland/weston-10.0.4.imx/0001-g2d-renderer.c-Include-sys-stat.h.patch b/recipes-graphics/wayland/weston-10.0.4.imx/0001-g2d-renderer.c-Include-sys-stat.h.patch new file mode 100644 index 00000000..b9cb31fb --- /dev/null +++ b/recipes-graphics/wayland/weston-10.0.4.imx/0001-g2d-renderer.c-Include-sys-stat.h.patch @@ -0,0 +1,34 @@ +From 4afe9b2f9ef24ce0c9bf1cd41f94ca45afa4f445 Mon Sep 17 00:00:00 2001 +From: Khem Raj <raj.khem@gmail.com> +Date: Mon, 12 Sep 2022 20:58:14 -0700 +Subject: [PATCH] g2d-renderer.c: Include sys/stat.h + +This is needed for getting stat() prototype, its flagged with clang-15 +as error. + +| ../git/libweston/renderer-g2d/g2d-renderer.c:2057:6: error: call to undeclared function 'stat'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] +| if (stat(gr->drm_device, &dev_stat) != 0) { +| ^ +| 1 error generated. + +Upstream-Status: Pending +Signed-off-by: Khem Raj <raj.khem@gmail.com> +--- + libweston/renderer-g2d/g2d-renderer.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/libweston/renderer-g2d/g2d-renderer.c b/libweston/renderer-g2d/g2d-renderer.c +index f59fc4ee..36a458fc 100644 +--- a/libweston/renderer-g2d/g2d-renderer.c ++++ b/libweston/renderer-g2d/g2d-renderer.c +@@ -41,6 +41,7 @@ + #include <drm_fourcc.h> + #include <poll.h> + #include <errno.h> ++#include <sys/stat.h> /* stat() */ + + #include <libweston/libweston.h> + #include "g2d-renderer.h" +-- +2.37.3 + diff --git a/recipes-graphics/wayland/weston-init.bbappend b/recipes-graphics/wayland/weston-init.bbappend index 2cfae346..9d04df23 100644 --- a/recipes-graphics/wayland/weston-init.bbappend +++ b/recipes-graphics/wayland/weston-init.bbappend @@ -1,47 +1,93 @@ -FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" +FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:" # OpenGL is not required for parts with GPU support for 2D but not 3D IMX_REQUIRED_DISTRO_FEATURES_REMOVE = "" -IMX_REQUIRED_DISTRO_FEATURES_REMOVE_imxgpu2d = "opengl" -IMX_REQUIRED_DISTRO_FEATURES_REMOVE_imxgpu3d = "" -REQUIRED_DISTRO_FEATURES_remove = "${IMX_REQUIRED_DISTRO_FEATURES_REMOVE}" - -SRC_URI_append_mx6sl = " file://weston.config" - -# To customize weston.ini, start by setting the desired assignment in weston.ini, -# commented out. For example: -# #xwayland=true -# Then add the assignment to INI_UNCOMMENT_ASSIGNMENTS. -INI_UNCOMMENT_ASSIGNMENTS_append_imx = " \ - ${@bb.utils.contains('DISTRO_FEATURES', 'x11 wayland', 'xwayland=true', '', d)} \ -" -INI_UNCOMMENT_ASSIGNMENTS_append_mx7ulp = " \ - use-g2d=1 \ -" -INI_UNCOMMENT_ASSIGNMENTS_append_mx8mm = " \ - use-g2d=1 \ -" -INI_UNCOMMENT_ASSIGNMENTS_append_mx8mq = " \ - gbm-format=argb8888 \ - \\[shell\\] \ - size=1920x1080 \ -" -INI_UNCOMMENT_ASSIGNMENTS_append_mx8mn = " \ - use-g2d=1 \ +IMX_REQUIRED_DISTRO_FEATURES_REMOVE:imxgpu2d = "opengl" +IMX_REQUIRED_DISTRO_FEATURES_REMOVE:imxgpu3d = "" +REQUIRED_DISTRO_FEATURES:remove = "${IMX_REQUIRED_DISTRO_FEATURES_REMOVE}" + +SRC_URI:append:mx6sl-nxp-bsp = " file://weston.config" + +PACKAGECONFIG ??= " \ + no-idle-timeout \ + ${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'xwayland', '', d)} \ + ${PACKAGECONFIG_GBM_FORMAT} \ + ${PACKAGECONFIG_REPAINT_WINDOW} \ + ${PACKAGECONFIG_SIZE} \ + ${PACKAGECONFIG_USE_G2D} \ " -uncomment() { - if ! (grep "^#$1" $2); then - bbfatal "Commented setting '#$1' not found in file $2" - fi - sed -i -e 's,^#'"$1"','"$1"',g' $2 -} +# Mainline BSPs dont support xwayland +PACKAGECONFIG:remove:use-mainline-bsp = "xwayland" + +PACKAGECONFIG_GBM_FORMAT ?= "" +PACKAGECONFIG_GBM_FORMAT:mx8mq-nxp-bsp ?= "gbm-format" +PACKAGECONFIG_GBM_FORMAT:mx93-nxp-bsp ?= "gbm-format" + +GBM_FORMAT_VALUE:mx8mq-nxp-bsp = "argb8888" +GBM_FORMAT_VALUE:mx93-nxp-bsp = "argb8888" + +PACKAGECONFIG_REPAINT_WINDOW ?= "" +PACKAGECONFIG_REPAINT_WINDOW:mx8-nxp-bsp ?= "repaint-window" +PACKAGECONFIG_REPAINT_WINDOW:mx9-nxp-bsp ?= "repaint-window" + +PACKAGECONFIG_SIZE ?= "" +PACKAGECONFIG_SIZE:mx8mq-nxp-bsp ?= "size" + +SIZE_VALUE:mx8mq-nxp-bsp = "1920x1080" + +HAS_G2D = "false" +HAS_G2D:imxgpu2d = "true" + +PACKAGECONFIG_USE_G2D ?= "" +PACKAGECONFIG_USE_G2D:imxgpu2d ?= "use-g2d" +PACKAGECONFIG_USE_G2D:mx8qm-nxp-bsp ?= "" +PACKAGECONFIG_USE_G2D:mx8qxp-nxp-bsp ?= "" +PACKAGECONFIG_USE_G2D:mx8dx-nxp-bsp ?= "" +PACKAGECONFIG_USE_G2D:mx93-nxp-bsp ?= "use-g2d" -do_install_append() { +USE_G2D_VALUE = "true" +USE_G2D_VALUE:mx6-nxp-bsp = "1" +USE_G2D_VALUE:mx7-nxp-bsp = "1" + +PACKAGECONFIG[gbm-format] = ",," +PACKAGECONFIG[rdp] = ",," +PACKAGECONFIG[repaint-window] = ",," +PACKAGECONFIG[size] = ",," +PACKAGECONFIG[use-g2d] = ",," +PACKAGECONFIG[xwayland] = ",," + +do_install:append() { if [ -f "${WORKDIR}/weston.config" ]; then install -Dm0755 ${WORKDIR}/weston.config ${D}${sysconfdir}/default/weston fi - for assignment in ${INI_UNCOMMENT_ASSIGNMENTS}; do - uncomment "$assignment" ${D}${sysconfdir}/xdg/weston/weston.ini - done + + if [ "${@bb.utils.contains('PACKAGECONFIG', 'gbm-format', 'yes', 'no', d)}" = "yes" ]; then + sed -i -e "/^\[core\]/a gbm-format=${GBM_FORMAT_VALUE}" ${D}${sysconfdir}/xdg/weston/weston.ini + fi + + if [ "${@bb.utils.contains('PACKAGECONFIG', 'rdp', 'yes', 'no', d)}" = "yes" ]; then + sed -i -e "s|^command=${bindir}/weston .*|& --rdp-tls-cert=${sysconfdir}/freerdp/keys/server.crt --rdp-tls-key=${sysconfdir}/freerdp/keys/server.key|" ${D}${sysconfdir}/xdg/weston/weston.ini + sed -i -e "/^\[core\]/a modules=screen-share.so" ${D}${sysconfdir}/xdg/weston/weston.ini + fi + + if [ "${@bb.utils.contains('PACKAGECONFIG', 'repaint-window', 'yes', 'no', d)}" = "yes" ]; then + sed -i -e "/^\[core\]/a repaint-window=16" ${D}${sysconfdir}/xdg/weston/weston.ini + fi + + if [ "${@bb.utils.contains('PACKAGECONFIG', 'size', 'yes', 'no', d)}" = "yes" ]; then + sed -i -e "/^\[shell\]/a size=${SIZE_VALUE}" ${D}${sysconfdir}/xdg/weston/weston.ini + fi + + if [ "${@bb.utils.contains('PACKAGECONFIG', 'use-g2d', 'yes', 'no', d)}" = "yes" ]; then + sed -i -e "/^\[core\]/a use-g2d=${USE_G2D_VALUE}" ${D}${sysconfdir}/xdg/weston/weston.ini + elif ${HAS_G2D}; then + sed -i -e "/^\[core\]/a #use-g2d=${USE_G2D_VALUE}" ${D}${sysconfdir}/xdg/weston/weston.ini + fi + + if [ "${@bb.utils.contains('PACKAGECONFIG', 'xwayland', 'yes', 'no', d)}" = "no" ]; then + sed -i -e "s/^xwayland=true/#xwayland=true/g" ${D}${sysconfdir}/xdg/weston/weston.ini + fi + + sed -i -e 's,@bindir@,${bindir},g' ${D}${sysconfdir}/xdg/weston/weston.ini } diff --git a/recipes-graphics/wayland/weston-init/weston.ini b/recipes-graphics/wayland/weston-init/imx-nxp-bsp/weston.ini index d9094b1f..19e6ad24 100644 --- a/recipes-graphics/wayland/weston-init/weston.ini +++ b/recipes-graphics/wayland/weston-init/imx-nxp-bsp/weston.ini @@ -1,16 +1,15 @@ [core] -#gbm-format=argb8888 -idle-time=0 -#use-g2d=1 -#xwayland=true +#enable-overlay-view=1 -#[shell] -#size=1920x1080 +[shell] + +[libinput] +touchscreen_calibrator=true #[output] #name=HDMI-A-1 #mode=1920x1080@60 -#transform=90 +#transform=rotate-90 #[output] #name=HDMI-A-2 @@ -19,7 +18,8 @@ idle-time=0 # off Disables the output # preferred Uses the preferred mode # current Uses the current crt controller mode -#transform=90 +#transform=rotate-90 [screen-share] command=@bindir@/weston --backend=rdp-backend.so --shell=fullscreen-shell.so --no-clients-resize +#start-on-startup=true diff --git a/recipes-graphics/wayland/weston-init/mx6sl/weston.config b/recipes-graphics/wayland/weston-init/mx6sl-nxp-bsp/weston.config index 6456cd24..6456cd24 100755 --- a/recipes-graphics/wayland/weston-init/mx6sl/weston.config +++ b/recipes-graphics/wayland/weston-init/mx6sl-nxp-bsp/weston.config diff --git a/recipes-graphics/wayland/weston/0001-Revert-protocol-no-found-wayland-scanner-with-Yocto-.patch b/recipes-graphics/wayland/weston/0001-Revert-protocol-no-found-wayland-scanner-with-Yocto-.patch new file mode 100644 index 00000000..25a4770f --- /dev/null +++ b/recipes-graphics/wayland/weston/0001-Revert-protocol-no-found-wayland-scanner-with-Yocto-.patch @@ -0,0 +1,41 @@ +From 3aa4024ac4107e68552be4dfe5fce511900629c9 Mon Sep 17 00:00:00 2001 +From: Max Krummenacher <max.krummenacher@toradex.com> +Date: Mon, 11 Jul 2022 19:38:19 +0000 +Subject: [PATCH] Revert "protocol: no found wayland-scanner with Yocto + toolchain" + +This reverts commit 7859a762617682bd804e210ad3bda6bdcd3ea24a. + +With openembedded commit e525db4eb9 ("wayland: update 1.20.0 -> 1.21.0") +package config seems no longer to provide the path to the native +weston scanner. + +Thus the build fails with: + +| Run-time dependency wayland-scanner found: YES 1.21.0 +| Program /usr/bin/wayland-scanner found: NO +| +| ../git/protocol/meson.build:2:0: ERROR: Program '/usr/bin/wayland-scanner' not found or not executable + +Dropping weston 9.0.0-imx commit 7859a762 (protocol: no found +wayland-scanner with Yocto toolchain") fixes the issue. + +Upstream-Status: Inappropriate [Cross-compile specific] +Signed-off-by: Max Krummenacher <max.krummenacher@toradex.com> +--- + protocol/meson.build | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/protocol/meson.build b/protocol/meson.build +index e8698530..ba52089b 100644 +--- a/protocol/meson.build ++++ b/protocol/meson.build +@@ -1,4 +1,4 @@ +-dep_scanner = dependency('wayland-scanner', native: false) ++dep_scanner = dependency('wayland-scanner', native: true) + prog_scanner = find_program(dep_scanner.get_pkgconfig_variable('wayland_scanner')) + + dep_wp = dependency('wayland-protocols', version: '>= 1.26', +-- +2.25.1 + diff --git a/recipes-graphics/wayland/weston/0001-weston-launch-Provide-a-default-version-that-doesn-t.patch b/recipes-graphics/wayland/weston/0001-weston-launch-Provide-a-default-version-that-doesn-t.patch deleted file mode 100644 index 62b864c1..00000000 --- a/recipes-graphics/wayland/weston/0001-weston-launch-Provide-a-default-version-that-doesn-t.patch +++ /dev/null @@ -1,198 +0,0 @@ -From 5f2d71998eb77068cbaee2d468cbb296a42d5739 Mon Sep 17 00:00:00 2001 -From: Tom Hochstein <tom.hochstein@nxp.com> -Date: Wed, 22 Feb 2017 15:53:30 +0200 -Subject: [PATCH] weston-launch: Provide a default version that doesn't require - PAM - -weston-launch requires PAM for starting weston as a non-root user. - -Since starting weston as root is a valid use case by itself, if -PAM is not available, provide a default version of weston-launch -without non-root-user support. - -Upstream-Status: Pending - -Signed-off-by: Tom Hochstein <tom.hochstein@nxp.com> -Signed-off-by: Jussi Kukkonen <jussi.kukkonen@intel.com> -Signed-off-by: Denys Dmytriyenko <denys@ti.com> -Signed-off-by: Ming Liu <ming.liu@toradex.com> - ---- - libweston/meson.build | 16 ++++++++++++---- - libweston/weston-launch.c | 21 +++++++++++++++++++++ - meson_options.txt | 7 +++++++ - 3 files changed, 40 insertions(+), 4 deletions(-) - -diff --git a/libweston/meson.build b/libweston/meson.build -index 08d23ec..cb9fd3f 100644 ---- a/libweston/meson.build -+++ b/libweston/meson.build -@@ -216,16 +216,24 @@ dep_vertex_clipping = declare_dependency( - ) - - if get_option('weston-launch') -- dep_pam = cc.find_library('pam') -+ deps_weston_launch = [systemd_dep, dep_libdrm] - -- if not cc.has_function('pam_open_session', dependencies: dep_pam) -- error('pam_open_session not found for weston-launch') -+ if get_option('pam') -+ dep_pam = cc.find_library('pam') -+ if not cc.has_function('pam_open_session', dependencies: dep_pam) -+ error('pam_open_session not found for weston-launch') -+ endif -+ -+ if dep_pam.found() -+ deps_weston_launch += dep_pam -+ config_h.set('HAVE_PAM', '1') -+ endif - endif - - executable( - 'weston-launch', - 'weston-launch.c', -- dependencies: [dep_pam, systemd_dep, dep_libdrm], -+ dependencies: deps_weston_launch, - include_directories: common_inc, - install: true - ) -diff --git a/libweston/weston-launch.c b/libweston/weston-launch.c -index 8a711b4..54c567a 100644 ---- a/libweston/weston-launch.c -+++ b/libweston/weston-launch.c -@@ -51,7 +51,9 @@ - - #include <pwd.h> - #include <grp.h> -+#ifdef HAVE_PAM - #include <security/pam_appl.h> -+#endif - - #ifdef HAVE_SYSTEMD_LOGIN - #include <systemd/sd-login.h> -@@ -100,8 +102,10 @@ drmSetMaster(int drm_fd) - #endif - - struct weston_launch { -+#ifdef HAVE_PAM - struct pam_conv pc; - pam_handle_t *ph; -+#endif - int tty; - int ttynr; - int sock[2]; -@@ -192,6 +196,7 @@ weston_launch_allowed(struct weston_launch *wl) - return false; - } - -+#ifdef HAVE_PAM - static int - pam_conversation_fn(int msg_count, - const struct pam_message **messages, -@@ -232,6 +237,7 @@ setup_pam(struct weston_launch *wl) - - return 0; - } -+#endif - - static int - setup_launcher_socket(struct weston_launch *wl) -@@ -431,6 +437,7 @@ quit(struct weston_launch *wl, int status) - close(wl->signalfd); - close(wl->sock[0]); - -+#ifdef HAVE_PAM - if (wl->new_user) { - err = pam_close_session(wl->ph, 0); - if (err) -@@ -438,6 +445,7 @@ quit(struct weston_launch *wl, int status) - err, pam_strerror(wl->ph, err)); - pam_end(wl->ph, err); - } -+#endif - - if (ioctl(wl->tty, KDSKBMUTE, 0) && - ioctl(wl->tty, KDSKBMODE, wl->kb_mode)) -@@ -666,6 +674,7 @@ setup_session(struct weston_launch *wl, char **child_argv) - setenv("HOME", wl->pw->pw_dir, 1); - setenv("SHELL", wl->pw->pw_shell, 1); - -+#ifdef HAVE_PAM - env = pam_getenvlist(wl->ph); - if (env) { - for (i = 0; env[i]; ++i) { -@@ -674,6 +683,7 @@ setup_session(struct weston_launch *wl, char **child_argv) - } - free(env); - } -+#endif - - /* - * We open a new session, so it makes sense -@@ -745,8 +755,10 @@ static void - help(const char *name) - { - fprintf(stderr, "Usage: %s [args...] [-- [weston args..]]\n", name); -+#ifdef HAVE_PAM - fprintf(stderr, " -u, --user Start session as specified username,\n" - " e.g. -u joe, requires root.\n"); -+#endif - fprintf(stderr, " -t, --tty Start session on alternative tty,\n" - " e.g. -t /dev/tty4, requires -u option.\n"); - fprintf(stderr, " -v, --verbose Be verbose\n"); -@@ -760,7 +772,9 @@ main(int argc, char *argv[]) - int i, c; - char *tty = NULL; - struct option opts[] = { -+#ifdef HAVE_PAM - { "user", required_argument, NULL, 'u' }, -+#endif - { "tty", required_argument, NULL, 't' }, - { "verbose", no_argument, NULL, 'v' }, - { "help", no_argument, NULL, 'h' }, -@@ -772,11 +786,16 @@ main(int argc, char *argv[]) - while ((c = getopt_long(argc, argv, "u:t:vh", opts, &i)) != -1) { - switch (c) { - case 'u': -+#ifdef HAVE_PAM - wl.new_user = optarg; - if (getuid() != 0) { - fprintf(stderr, "weston: Permission denied. -u allowed for root only\n"); - exit(EXIT_FAILURE); - } -+#else -+ fprintf(stderr, "weston: -u is unsupported in this weston-launch build\n"); -+ exit(EXIT_FAILURE); -+#endif - break; - case 't': - tty = optarg; -@@ -828,8 +847,10 @@ main(int argc, char *argv[]) - if (setup_tty(&wl, tty) < 0) - exit(EXIT_FAILURE); - -+#ifdef HAVE_PAM - if (wl.new_user && setup_pam(&wl) < 0) - exit(EXIT_FAILURE); -+#endif - - if (setup_launcher_socket(&wl) < 0) - exit(EXIT_FAILURE); -diff --git a/meson_options.txt b/meson_options.txt -index c862ecc..73ef2c3 100644 ---- a/meson_options.txt -+++ b/meson_options.txt -@@ -73,6 +73,13 @@ option( - ) - - option( -+ 'pam', -+ type: 'boolean', -+ value: true, -+ description: 'Define if PAM is available' -+) -+ -+option( - 'xwayland', - type: 'boolean', - value: true, diff --git a/recipes-graphics/wayland/weston/systemd-notify.weston-start b/recipes-graphics/wayland/weston/systemd-notify.weston-start new file mode 100644 index 00000000..a97e7b38 --- /dev/null +++ b/recipes-graphics/wayland/weston/systemd-notify.weston-start @@ -0,0 +1,9 @@ +#!/bin/sh + +# SPDX-FileCopyrightText: Huawei Inc. +# SPDX-License-Identifier: Apache-2.0 + + +if [[ -x "/usr/lib/weston/systemd-notify.so" ]]; then + add_weston_module "systemd-notify.so" +fi diff --git a/recipes-graphics/wayland/weston/xwayland.weston-start b/recipes-graphics/wayland/weston/xwayland.weston-start index b483c97c..49204f21 100644 --- a/recipes-graphics/wayland/weston/xwayland.weston-start +++ b/recipes-graphics/wayland/weston/xwayland.weston-start @@ -1,7 +1,6 @@ #!/bin/sh if type Xwayland >/dev/null 2>/dev/null; then - mkdir -p /tmp/.X11-unix - - add_weston_argument "--modules=xwayland.so" + mkdir -m 775 -p /tmp/.X11-unix + chown root:video /tmp/.X11-unix fi diff --git a/recipes-graphics/wayland/weston_8.0.0.imx.bb b/recipes-graphics/wayland/weston_10.0.4.imx.bb index a021a54d..e31d2280 100644 --- a/recipes-graphics/wayland/weston_8.0.0.imx.bb +++ b/recipes-graphics/wayland/weston_10.0.4.imx.bb @@ -3,42 +3,57 @@ # recipe. The second section customizes the recipe for i.MX. ########### OE-core copy ################## -# Upstream hash: 9b1d30810eeecb46b977c8eed68be69aef891312 +# Upstream hash: 4b42fd87da290ddea098605aea3a5cce1fb432a7 SUMMARY = "Weston, a Wayland compositor" DESCRIPTION = "Weston is the reference implementation of a Wayland compositor" HOMEPAGE = "http://wayland.freedesktop.org" LICENSE = "MIT" LIC_FILES_CHKSUM = "file://COPYING;md5=d79ee9e66bb0f95d3386a7acae780b70 \ - file://libweston/compositor.c;endline=27;md5=6c53bbbd99273f4f7c4affa855c33c0a" + file://libweston/compositor.c;endline=27;md5=eb6d5297798cabe2ddc65e2af519bcf0 \ + " -SRC_URI = "https://wayland.freedesktop.org/releases/${BPN}-${PV}.tar.xz \ +SRC_URI = "https://gitlab.freedesktop.org/wayland/weston/-/releases/${PV}/downloads/${BPN}-${PV}.tar.xz \ file://weston.png \ file://weston.desktop \ file://xwayland.weston-start \ - file://0001-weston-launch-Provide-a-default-version-that-doesn-t.patch \ -" -SRC_URI[md5sum] = "53e4810d852df0601d01fd986a5b22b3" -SRC_URI[sha256sum] = "7518b49b2eaa1c3091f24671bdcc124fd49fc8f1af51161927afa4329c027848" + file://systemd-notify.weston-start \ + " + +SRC_URI[sha256sum] = "89646ca0d9f8d413c2767e5c3828eaa3fa149c2a105b3729a6894fa7cf1549e7" UPSTREAM_CHECK_URI = "https://wayland.freedesktop.org/releases.html" +UPSTREAM_CHECK_REGEX = "weston-(?P<pver>\d+\.\d+\.(?!9\d+)\d+)" + +inherit meson pkgconfig useradd -inherit meson pkgconfig useradd features_check # depends on virtual/egl -REQUIRED_DISTRO_FEATURES = "opengl" +# +require ${THISDIR}/required-distro-features.inc -DEPENDS = "libxkbcommon gdk-pixbuf pixman cairo glib-2.0 jpeg" +DEPENDS = "libxkbcommon gdk-pixbuf pixman cairo glib-2.0" DEPENDS += "wayland wayland-protocols libinput virtual/egl pango wayland-native" +LDFLAGS += "${@bb.utils.contains('DISTRO_FEATURES', 'lto', '-Wl,-z,undefs', '', d)}" + WESTON_MAJOR_VERSION = "${@'.'.join(d.getVar('PV').split('.')[0:1])}" -EXTRA_OEMESON += "-Dbackend-default=auto -Dbackend-rdp=false -Dpipewire=false" +EXTRA_OEMESON += "-Dpipewire=false" -PACKAGECONFIG ??= "${@bb.utils.contains('DISTRO_FEATURES', 'wayland', 'kms fbdev wayland egl clients', '', d)} \ +PACKAGECONFIG ??= "${@bb.utils.contains('DISTRO_FEATURES', 'wayland', 'kms wayland egl clients', '', d)} \ ${@bb.utils.contains('DISTRO_FEATURES', 'x11 wayland', 'xwayland', '', d)} \ - ${@bb.utils.filter('DISTRO_FEATURES', 'pam systemd x11', d)} \ + ${@bb.utils.filter('DISTRO_FEATURES', 'systemd x11', d)} \ ${@bb.utils.contains_any('DISTRO_FEATURES', 'wayland x11', '', 'headless', d)} \ - launch" + ${@oe.utils.conditional('VIRTUAL-RUNTIME_init_manager', 'sysvinit', 'launcher-libseat', '', d)} \ + image-jpeg \ + screenshare \ + shell-desktop \ + shell-fullscreen \ + shell-ivi" + +# Can be 'damage', 'im', 'egl', 'shm', 'touch', 'dmabuf-feedback', 'dmabuf-v4l', 'dmabuf-egl' or 'all' +SIMPLECLIENTS ?= "all" + # # Compositor choices # @@ -51,9 +66,11 @@ PACKAGECONFIG[x11] = "-Dbackend-x11=true,-Dbackend-x11=false,virtual/libx11 libx # Headless Weston PACKAGECONFIG[headless] = "-Dbackend-headless=true,-Dbackend-headless=false" # Weston on framebuffer -PACKAGECONFIG[fbdev] = "-Dbackend-fbdev=true,-Dbackend-fbdev=false,udev mtdev" +PACKAGECONFIG[fbdev] = "-Ddeprecated-backend-fbdev=true,-Ddeprecated-backend-fbdev=false,udev mtdev" +# Weston on RDP +PACKAGECONFIG[rdp] = "-Dbackend-rdp=true,-Dbackend-rdp=false,freerdp" # weston-launch -PACKAGECONFIG[launch] = "-Dweston-launch=true,-Dweston-launch=false,drm" +PACKAGECONFIG[launch] = "-Ddeprecated-weston-launch=true,-Ddeprecated-weston-launch=false,drm" # VA-API desktop recorder PACKAGECONFIG[vaapi] = "-Dbackend-drm-screencast-vaapi=true,-Dbackend-drm-screencast-vaapi=false,libva" # Weston with EGL support @@ -69,13 +86,23 @@ PACKAGECONFIG[xwayland] = "-Dxwayland=true,-Dxwayland=false" # colord CMS support PACKAGECONFIG[colord] = "-Dcolor-management-colord=true,-Dcolor-management-colord=false,colord" # Clients support -PACKAGECONFIG[clients] = "-Dsimple-clients=all -Ddemo-clients=true,-Dsimple-clients= -Ddemo-clients=false" +PACKAGECONFIG[clients] = "-Dsimple-clients=${SIMPLECLIENTS} -Ddemo-clients=true,-Dsimple-clients= -Ddemo-clients=false" # Virtual remote output with GStreamer on DRM backend -PACKAGECONFIG[remoting] = "-Dremoting=true,-Dremoting=false,gstreamer-1.0" -# Weston with PAM support -PACKAGECONFIG[pam] = "-Dpam=true,-Dpam=false,libpam" - -do_install_append() { +PACKAGECONFIG[remoting] = "-Dremoting=true,-Dremoting=false,gstreamer1.0 gstreamer1.0-plugins-base" +# Weston with screen-share support +PACKAGECONFIG[screenshare] = "-Dscreenshare=true,-Dscreenshare=false" +# Traditional desktop shell +PACKAGECONFIG[shell-desktop] = "-Dshell-desktop=true,-Dshell-desktop=false" +# Fullscreen shell +PACKAGECONFIG[shell-fullscreen] = "-Dshell-fullscreen=true,-Dshell-fullscreen=false" +# In-Vehicle Infotainment (IVI) shell +PACKAGECONFIG[shell-ivi] = "-Dshell-ivi=true,-Dshell-ivi=false" +# JPEG image loading support +PACKAGECONFIG[image-jpeg] = "-Dimage-jpeg=true,-Dimage-jpeg=false, jpeg" +# support libseat based launch +PACKAGECONFIG[launcher-libseat] = "-Dlauncher-libseat=true,-Dlauncher-libseat=false,seatd" + +do_install:append() { # Weston doesn't need the .la files to load modules, so wipe them rm -f ${D}/${libdir}/libweston-${WESTON_MAJOR_VERSION}/*.la @@ -92,6 +119,10 @@ do_install_append() { install -Dm 644 ${WORKDIR}/xwayland.weston-start ${D}${datadir}/weston-start/xwayland fi + if [ "${@bb.utils.contains('PACKAGECONFIG', 'systemd', 'yes', 'no', d)}" = "yes" ]; then + install -Dm 644 ${WORKDIR}/systemd-notify.weston-start ${D}${datadir}/weston-start/systemd-notify + fi + if [ "${@bb.utils.contains('PACKAGECONFIG', 'launch', 'yes', 'no', d)}" = "yes" ]; then chmod u+s ${D}${bindir}/weston-launch fi @@ -100,23 +131,23 @@ do_install_append() { PACKAGES += "${@bb.utils.contains('PACKAGECONFIG', 'xwayland', '${PN}-xwayland', '', d)} \ libweston-${WESTON_MAJOR_VERSION} ${PN}-examples" -FILES_${PN}-dev += "${libdir}/${BPN}/libexec_weston.so" -FILES_${PN} = "${bindir}/weston ${bindir}/weston-terminal ${bindir}/weston-info ${bindir}/weston-launch ${bindir}/wcap-decode ${libexecdir} ${libdir}/${BPN}/*.so* ${datadir}" +FILES:${PN}-dev += "${libdir}/${BPN}/libexec_weston.so" +FILES:${PN} = "${bindir}/weston ${bindir}/weston-terminal ${bindir}/weston-info ${bindir}/weston-launch ${bindir}/wcap-decode ${libexecdir} ${libdir}/${BPN}/*.so* ${datadir}" -FILES_libweston-${WESTON_MAJOR_VERSION} = "${libdir}/lib*${SOLIBS} ${libdir}/libweston-${WESTON_MAJOR_VERSION}/*.so" -SUMMARY_libweston-${WESTON_MAJOR_VERSION} = "Helper library for implementing 'wayland window managers'." +FILES:libweston-${WESTON_MAJOR_VERSION} = "${libdir}/lib*${SOLIBS} ${libdir}/libweston-${WESTON_MAJOR_VERSION}/*.so" +SUMMARY:libweston-${WESTON_MAJOR_VERSION} = "Helper library for implementing 'wayland window managers'." -FILES_${PN}-examples = "${bindir}/*" +FILES:${PN}-examples = "${bindir}/*" -FILES_${PN}-xwayland = "${libdir}/libweston-${WESTON_MAJOR_VERSION}/xwayland.so" -RDEPENDS_${PN}-xwayland += "xserver-xorg-xwayland" +FILES:${PN}-xwayland = "${libdir}/libweston-${WESTON_MAJOR_VERSION}/xwayland.so" +RDEPENDS:${PN}-xwayland += "xwayland" -RDEPENDS_${PN} += "xkeyboard-config" -RRECOMMENDS_${PN} = "weston-init liberation-fonts" -RRECOMMENDS_${PN}-dev += "wayland-protocols" +RDEPENDS:${PN} += "xkeyboard-config" +RRECOMMENDS:${PN} = "weston-init liberation-fonts" +RRECOMMENDS:${PN}-dev += "wayland-protocols" USERADD_PACKAGES = "${PN}" -GROUPADD_PARAM_${PN} = "--system weston-launch" +GROUPADD_PARAM:${PN} = "--system weston-launch" ########### End of OE-core copy ########### @@ -124,37 +155,40 @@ GROUPADD_PARAM_${PN} = "--system weston-launch" SUMMARY = "Weston, a Wayland compositor, i.MX fork" +LIC_FILES_CHKSUM:remove = "file://COPYING;md5=d79ee9e66bb0f95d3386a7acae780b70" +LIC_FILES_CHKSUM:append = "file://LICENSE;md5=d79ee9e66bb0f95d3386a7acae780b70" + DEFAULT_PREFERENCE = "-1" -SRCBRANCH = "weston-imx-8.0" -SRC_URI = "git://source.codeaurora.org/external/imx/weston-imx.git;protocol=https;branch=${SRCBRANCH} \ - file://weston.png \ - file://weston.desktop \ - file://xwayland.weston-start \ - file://0001-weston-launch-Provide-a-default-version-that-doesn-t.patch \ -" -SRCREV = "f6a7d35650121fbe7c20d4cbe0eaac730fab3b2a" +SRC_URI:remove = "https://gitlab.freedesktop.org/wayland/weston/-/releases/${PV}/downloads/${BPN}-${PV}.tar.xz" +SRC_URI:prepend = "git://github.com/nxp-imx/weston-imx.git;protocol=https;branch=${SRCBRANCH} " +SRC_URI += "file://0001-Revert-protocol-no-found-wayland-scanner-with-Yocto-.patch \ + file://0001-g2d-renderer.c-Include-sys-stat.h.patch" +SRCBRANCH = "weston-imx-10.0.4" +SRCREV = "6210a8f1302252273b50cc3c0ff55ec680dda479" S = "${WORKDIR}/git" # Disable OpenGL for parts with GPU support for 2D but not 3D REQUIRED_DISTRO_FEATURES = "opengl" -REQUIRED_DISTRO_FEATURES_imxgpu2d = "" -REQUIRED_DISTRO_FEATURES_imxgpu3d = "opengl" +REQUIRED_DISTRO_FEATURES:imxgpu2d = "" +REQUIRED_DISTRO_FEATURES:imxgpu3d = "opengl" PACKAGECONFIG_OPENGL = "opengl" -PACKAGECONFIG_OPENGL_imxgpu2d = "" -PACKAGECONFIG_OPENGL_imxgpu3d = "opengl" +PACKAGECONFIG_OPENGL:imxgpu2d = "" +PACKAGECONFIG_OPENGL:imxgpu3d = "opengl" -PACKAGECONFIG_append = " ${@bb.utils.filter('DISTRO_FEATURES', '${PACKAGECONFIG_OPENGL}', d)}" +PACKAGECONFIG_IMX_REMOVALS ?= "wayland x11" +PACKAGECONFIG:remove = "${PACKAGECONFIG_IMX_REMOVALS}" +PACKAGECONFIG:append = " ${@bb.utils.filter('DISTRO_FEATURES', '${PACKAGECONFIG_OPENGL}', d)}" -PACKAGECONFIG_remove_imxfbdev = "kms" -PACKAGECONFIG_append_imxfbdev = " fbdev clients" -PACKAGECONFIG_append_imxgpu = " imxgpu" -PACKAGECONFIG_append_imxgpu2d = " imxg2d" +PACKAGECONFIG:remove:imxfbdev = "kms" +PACKAGECONFIG:append:imxfbdev = " fbdev clients" +PACKAGECONFIG:append:imxgpu = " imxgpu" +PACKAGECONFIG:append:imxgpu2d = " imxg2d" -# Clients support -SIMPLE_CLIENTS = "all" -SIMPLE_CLIENTS_imxfbdev = "damage,im,egl,shm,touch,dmabuf-v4l" -PACKAGECONFIG[clients] = "-Dsimple-clients=${SIMPLE_CLIENTS} -Ddemo-clients=true,-Dsimple-clients= -Ddemo-clients=false" +SIMPLECLIENTS:imxfbdev = "damage,im,egl,shm,touch,dmabuf-v4l" + +# Override +PACKAGECONFIG[xwayland] = "-Dxwayland=true,-Dxwayland=false,libxcursor xwayland" # Weston with i.MX GPU support PACKAGECONFIG[imxgpu] = "-Dimxgpu=true,-Dimxgpu=false,virtual/egl" # Weston with i.MX G2D renderer @@ -162,6 +196,15 @@ PACKAGECONFIG[imxg2d] = "-Drenderer-g2d=true,-Drenderer-g2d=false,virtual/libg2d # Weston with OpenGL support PACKAGECONFIG[opengl] = "-Dopengl=true,-Dopengl=false" +PACKAGECONFIG[fbdev] = "-Dbackend-fbdev=true,-Dbackend-fbdev=false,udev mtdev libdrm" +EXTRA_OEMESON:append:imxfbdev = " -Dbackend-default=fbdev" + +EXTRA_OEMESON += "-Ddeprecated-wl-shell=true" + +# links with imx-gpu libs which are pre-built for glibc +# gcompat will address it during runtime +LDFLAGS:append:imxgpu:libc-musl = " -Wl,--allow-shlib-undefined" + PACKAGE_ARCH = "${MACHINE_SOCARCH}" COMPATIBLE_MACHINE = "(imxfbdev|imxgpu)" diff --git a/recipes-graphics/wayland/weston_11.0.3.imx.bb b/recipes-graphics/wayland/weston_11.0.3.imx.bb new file mode 100644 index 00000000..67eae268 --- /dev/null +++ b/recipes-graphics/wayland/weston_11.0.3.imx.bb @@ -0,0 +1,188 @@ +# This recipe is for the i.MX fork of weston. For ease of +# maintenance, the top section is a verbatim copy of an OE-core +# recipe. The second section customizes the recipe for i.MX. + +########### OE-core copy ################## +# Upstream hash: 7f1932cb5a408320a5b542e20ba2807718349e8f + +SUMMARY = "Weston, a Wayland compositor" +DESCRIPTION = "Weston is the reference implementation of a Wayland compositor" +HOMEPAGE = "http://wayland.freedesktop.org" +LICENSE = "MIT" +LIC_FILES_CHKSUM = "file://COPYING;md5=d79ee9e66bb0f95d3386a7acae780b70 \ + file://libweston/compositor.c;endline=27;md5=eb6d5297798cabe2ddc65e2af519bcf0 \ + " + +SRC_URI = "https://gitlab.freedesktop.org/wayland/weston/uploads/f5648c818fba5432edc3ea63c4db4813/${BPN}-${PV}.tar.xz \ + file://weston.png \ + file://weston.desktop \ + file://xwayland.weston-start \ + file://systemd-notify.weston-start \ + " + +SRC_URI[sha256sum] = "a413f68c252957fc3191c3650823ec356ae8c124ccc0cb440da5cdc4e2cb9e57" + +UPSTREAM_CHECK_URI = "https://wayland.freedesktop.org/releases.html" +UPSTREAM_CHECK_REGEX = "weston-(?P<pver>\d+\.\d+\.(?!9\d+)\d+)" + +inherit meson pkgconfig useradd + +# depends on virtual/egl +# +require ${THISDIR}/required-distro-features.inc + +DEPENDS = "libxkbcommon gdk-pixbuf pixman cairo glib-2.0" +DEPENDS += "wayland wayland-protocols libinput virtual/egl pango wayland-native" + +LDFLAGS += "${@bb.utils.contains('DISTRO_FEATURES', 'lto', '-Wl,-z,undefs', '', d)}" + +WESTON_MAJOR_VERSION = "${@'.'.join(d.getVar('PV').split('.')[0:1])}" + +EXTRA_OEMESON += "-Dpipewire=false" + +PACKAGECONFIG ??= "${@bb.utils.contains('DISTRO_FEATURES', 'wayland', 'kms wayland egl clients', '', d)} \ + ${@bb.utils.contains('DISTRO_FEATURES', 'x11 wayland', 'xwayland', '', d)} \ + ${@bb.utils.filter('DISTRO_FEATURES', 'systemd x11', d)} \ + ${@bb.utils.contains_any('DISTRO_FEATURES', 'wayland x11', '', 'headless', d)} \ + ${@oe.utils.conditional('VIRTUAL-RUNTIME_init_manager', 'sysvinit', 'launcher-libseat', '', d)} \ + image-jpeg \ + screenshare \ + shell-desktop \ + shell-fullscreen \ + shell-ivi \ + shell-kiosk \ + " + +# Can be 'damage', 'im', 'egl', 'shm', 'touch', 'dmabuf-feedback', 'dmabuf-v4l', 'dmabuf-egl' or 'all' +SIMPLECLIENTS ?= "all" + +# +# Compositor choices +# +# Weston on KMS +PACKAGECONFIG[kms] = "-Dbackend-drm=true,-Dbackend-drm=false,drm udev virtual/egl virtual/libgles2 virtual/libgbm mtdev" +# Weston on Wayland (nested Weston) +PACKAGECONFIG[wayland] = "-Dbackend-wayland=true,-Dbackend-wayland=false,virtual/egl virtual/libgles2" +# Weston on X11 +PACKAGECONFIG[x11] = "-Dbackend-x11=true,-Dbackend-x11=false,virtual/libx11 libxcb libxcb libxcursor cairo" +# Headless Weston +PACKAGECONFIG[headless] = "-Dbackend-headless=true,-Dbackend-headless=false" +# Weston on RDP +PACKAGECONFIG[rdp] = "-Dbackend-rdp=true,-Dbackend-rdp=false,freerdp" +# VA-API desktop recorder +PACKAGECONFIG[vaapi] = "-Dbackend-drm-screencast-vaapi=true,-Dbackend-drm-screencast-vaapi=false,libva" +# Weston with EGL support +PACKAGECONFIG[egl] = "-Drenderer-gl=true,-Drenderer-gl=false,virtual/egl" +# Weston with lcms support +PACKAGECONFIG[lcms] = "-Dcolor-management-lcms=true,-Dcolor-management-lcms=false,lcms" +# Weston with webp support +PACKAGECONFIG[webp] = "-Dimage-webp=true,-Dimage-webp=false,libwebp" +# Weston with systemd-login support +PACKAGECONFIG[systemd] = "-Dsystemd=true -Dlauncher-logind=true,-Dsystemd=false -Dlauncher-logind=false,systemd dbus" +# Weston with Xwayland support (requires X11 and Wayland) +PACKAGECONFIG[xwayland] = "-Dxwayland=true,-Dxwayland=false,xwayland" +# colord CMS support +PACKAGECONFIG[colord] = "-Ddeprecated-color-management-colord=true,-Ddeprecated-color-management-colord=false,colord" +# Clients support +PACKAGECONFIG[clients] = "-Dsimple-clients=${SIMPLECLIENTS} -Ddemo-clients=true,-Dsimple-clients= -Ddemo-clients=false" +# Virtual remote output with GStreamer on DRM backend +PACKAGECONFIG[remoting] = "-Dremoting=true,-Dremoting=false,gstreamer1.0 gstreamer1.0-plugins-base" +# Weston with screen-share support +PACKAGECONFIG[screenshare] = "-Dscreenshare=true,-Dscreenshare=false" +# Traditional desktop shell +PACKAGECONFIG[shell-desktop] = "-Dshell-desktop=true,-Dshell-desktop=false" +# Fullscreen shell +PACKAGECONFIG[shell-fullscreen] = "-Dshell-fullscreen=true,-Dshell-fullscreen=false" +# In-Vehicle Infotainment (IVI) shell +PACKAGECONFIG[shell-ivi] = "-Dshell-ivi=true,-Dshell-ivi=false" +# Kiosk shell +PACKAGECONFIG[shell-kiosk] = "-Dshell-kiosk=true,-Dshell-kiosk=false" +# JPEG image loading support +PACKAGECONFIG[image-jpeg] = "-Dimage-jpeg=true,-Dimage-jpeg=false, jpeg" +# support libseat based launch +PACKAGECONFIG[launcher-libseat] = "-Dlauncher-libseat=true,-Dlauncher-libseat=false,seatd" + +do_install:append() { + # Weston doesn't need the .la files to load modules, so wipe them + rm -f ${D}/${libdir}/libweston-${WESTON_MAJOR_VERSION}/*.la + + # If X11, ship a desktop file to launch it + if [ "${@bb.utils.filter('DISTRO_FEATURES', 'x11', d)}" ]; then + install -d ${D}${datadir}/applications + install ${WORKDIR}/weston.desktop ${D}${datadir}/applications + + install -d ${D}${datadir}/icons/hicolor/48x48/apps + install ${WORKDIR}/weston.png ${D}${datadir}/icons/hicolor/48x48/apps + fi + + if [ "${@bb.utils.contains('PACKAGECONFIG', 'xwayland', 'yes', 'no', d)}" = "yes" ]; then + install -Dm 644 ${WORKDIR}/xwayland.weston-start ${D}${datadir}/weston-start/xwayland + fi + + if [ "${@bb.utils.contains('PACKAGECONFIG', 'systemd', 'yes', 'no', d)}" = "yes" ]; then + install -Dm 644 ${WORKDIR}/systemd-notify.weston-start ${D}${datadir}/weston-start/systemd-notify + fi + + if [ "${@bb.utils.contains('PACKAGECONFIG', 'launch', 'yes', 'no', d)}" = "yes" ]; then + chmod u+s ${D}${bindir}/weston-launch + fi +} + +PACKAGES += "${@bb.utils.contains('PACKAGECONFIG', 'xwayland', '${PN}-xwayland', '', d)} \ + libweston-${WESTON_MAJOR_VERSION} ${PN}-examples" + +FILES:${PN}-dev += "${libdir}/${BPN}/libexec_weston.so" +FILES:${PN} = "${bindir}/weston ${bindir}/weston-terminal ${bindir}/weston-info ${bindir}/weston-launch ${bindir}/wcap-decode ${libexecdir} ${libdir}/${BPN}/*.so* ${datadir}" + +FILES:libweston-${WESTON_MAJOR_VERSION} = "${libdir}/lib*${SOLIBS} ${libdir}/libweston-${WESTON_MAJOR_VERSION}/*.so" +SUMMARY:libweston-${WESTON_MAJOR_VERSION} = "Helper library for implementing 'wayland window managers'." + +FILES:${PN}-examples = "${bindir}/*" + +FILES:${PN}-xwayland = "${libdir}/libweston-${WESTON_MAJOR_VERSION}/xwayland.so" +RDEPENDS:${PN}-xwayland += "xwayland" + +RDEPENDS:${PN} += "xkeyboard-config" +RRECOMMENDS:${PN} = "weston-init liberation-fonts" +RRECOMMENDS:${PN}-dev += "wayland-protocols" + +USERADD_PACKAGES = "${PN}" +GROUPADD_PARAM:${PN} = "--system weston-launch" + +########### End of OE-core copy ########### + +########### i.MX overrides ################ + +SUMMARY = "Weston, a Wayland compositor, i.MX fork" +LIC_FILES_CHKSUM:remove = "file://COPYING;md5=d79ee9e66bb0f95d3386a7acae780b70" +LIC_FILES_CHKSUM += "file://LICENSE;md5=d79ee9e66bb0f95d3386a7acae780b70" + +DEFAULT_PREFERENCE = "-1" + +SRC_URI:remove = "https://gitlab.freedesktop.org/wayland/weston/uploads/f5648c818fba5432edc3ea63c4db4813/${BPN}-${PV}.tar.xz" +SRC_URI:prepend = "git://github.com/nxp-imx/weston-imx.git;protocol=https;branch=${SRCBRANCH} " +SRC_URI += "file://0001-Revert-protocol-no-found-wayland-scanner-with-Yocto-.patch" +SRCBRANCH = "weston-imx-11.0.3" +SRCREV = "a509c319b7bfc72638c9b9d8f5e4b6259aba0ab7" +S = "${WORKDIR}/git" + +PACKAGECONFIG_IMX_REMOVALS ?= "wayland x11" +PACKAGECONFIG:remove = "${PACKAGECONFIG_IMX_REMOVALS}" + +PACKAGECONFIG:append:imxgpu2d = " imxg2d" +PACKAGECONFIG:append:mx93-nxp-bsp = " imxg2d" + +# Override +PACKAGECONFIG[xwayland] = "-Dxwayland=true,-Dxwayland=false,libxcursor xwayland" + +# Weston with i.MX G2D renderer +PACKAGECONFIG[imxg2d] = "-Drenderer-g2d=true,-Drenderer-g2d=false,virtual/libg2d" + +# links with imx-gpu libs which are pre-built for glibc +# gcompat will address it during runtime +LDFLAGS:append:imxgpu:libc-musl = " -Wl,--allow-shlib-undefined" + +PACKAGE_ARCH = "${MACHINE_SOCARCH}" +COMPATIBLE_MACHINE = "(imx-nxp-bsp)" + +########### End of i.MX overrides ######### diff --git a/recipes-graphics/xinput-calibrator/pointercal-xinput/mx6/pointercal.xinput b/recipes-graphics/xinput-calibrator/pointercal-xinput/mx6-nxp-bsp/pointercal.xinput index ba34b89f..ba34b89f 100644 --- a/recipes-graphics/xinput-calibrator/pointercal-xinput/mx6/pointercal.xinput +++ b/recipes-graphics/xinput-calibrator/pointercal-xinput/mx6-nxp-bsp/pointercal.xinput diff --git a/recipes-graphics/xinput-calibrator/pointercal-xinput_%.bbappend b/recipes-graphics/xinput-calibrator/pointercal-xinput_%.bbappend index a9c60f3e..d112b274 100644 --- a/recipes-graphics/xinput-calibrator/pointercal-xinput_%.bbappend +++ b/recipes-graphics/xinput-calibrator/pointercal-xinput_%.bbappend @@ -1,2 +1,2 @@ # Append path for freescale layer to include bsp pointercal.xinput -FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" +FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:" diff --git a/recipes-graphics/xorg-driver/xf86-video-armada_git.bb b/recipes-graphics/xorg-driver/xf86-video-armada_git.bb deleted file mode 100644 index 0aba8e5a..00000000 --- a/recipes-graphics/xorg-driver/xf86-video-armada_git.bb +++ /dev/null @@ -1,48 +0,0 @@ -SUMMARY = "X.org graphics driver for KMS based systems with pluggable GPU backend" -DESCRIPTION = "The xf86-video-armada module is a 2D graphics driver for the X Window \ -System as implemented by X.org, supporting these DRM KMS drivers: \ -\ - Freescale i.MX \ - Marvell Armada 510 (Dove) \ -\ -and GPU drivers: \ - Vivante libGAL (Armada only) \ - Etnaviv (Armada and i.MX) with galcore kernel driver \ - Etnaviv (Armada and i.MX) with etnaviv DRM kernel driver \ -" -LICENSE = "BSD" - -require recipes-graphics/xorg-driver/xorg-driver-video.inc - -DEPENDS += "libdrm-armada" - -LIC_FILES_CHKSUM = " \ - file://README;md5=d5271074fb6ad959b7b6cfa68b4adaf0 \ - file://../etna_viv/LICENSE;md5=9d4853905d85f044ed013e75def30a76 \ - " - -SRCREV_armada = "78e7116a5bc6cdd9f93cbf1552d342933623ab59" -SRCREV_etna = "8478eef32fd911ebb300c970071e22227afa1896" -SRCREV_FORMAT = "armada_etna" - -PV = "0.1+git${SRCPV}" - -SRC_URI = " \ - git://git.arm.linux.org.uk/cgit/xf86-video-armada.git;branch=unstable-devel;protocol=http;name=armada \ - git://github.com/etnaviv/etna_viv.git;protocol=https;name=etna;destsuffix=etna_viv \ - " - -S = "${WORKDIR}/git" - -RDEPENDS_${PN} = "xserver-xorg-module-exa \ - xserver-xorg-extension-dri \ - xserver-xorg-extension-dri2 \ - xserver-xorg-extension-glx \ - " - -EXTRA_OECONF = "--disable-etnaviv \ - --disable-vivante \ - --with-etnaviv-source=${WORKDIR}/etna_viv \ - " - -COMPATIBLE_MACHINE = "(imx|use-mainline-bsp)" diff --git a/recipes-graphics/xorg-driver/xf86-video-imx-vivante/rc.autohdmi b/recipes-graphics/xorg-driver/xf86-video-imx-vivante/rc.autohdmi deleted file mode 100644 index 8c16a1d7..00000000 --- a/recipes-graphics/xorg-driver/xf86-video-imx-vivante/rc.autohdmi +++ /dev/null @@ -1,42 +0,0 @@ -#! /bin/sh -### BEGIN INIT INFO -# Provides: rc.autohdmi -# Required-Start: $all -# Required-Stop: -# Default-Start: 2 3 4 5 -# Default-Stop: -### END INIT INFO - -PATH=/sbin:/usr/sbin:/bin:/usr/bin - -# Source function library. -. /etc/init.d/functions - -case "$1" in - start) - echo -n "Starting autohdmi: " - export DISPLAY=:0 - autohdmi & - echo - exit 0 - ;; - reload|force-reload) - echo "Error: argument '$1' not supported" >&2 - exit 3 - ;; - stop) - echo -n "Shutting down autohdmi: " - killproc autohdmi - echo - ;; - restart) - echo -n "Restarting autohdmi: " - $0 stop - $0 start - echo - ;; - *) - echo "Usage: $0 start|stop" >&2 - exit 3 - ;; -esac diff --git a/recipes-graphics/xorg-driver/xf86-video-imx-vivante_6.4.0.p0.0.bb b/recipes-graphics/xorg-driver/xf86-video-imx-vivante_6.4.0.p0.0.bb deleted file mode 100644 index 9268b11e..00000000 --- a/recipes-graphics/xorg-driver/xf86-video-imx-vivante_6.4.0.p0.0.bb +++ /dev/null @@ -1,65 +0,0 @@ -# Copyright (C) 2012-2016 Freescale Semiconductor -# Copyright (C) 2012-2018 O.S. Systems Software LTDA. -# Copyright 2017-2018 NXP -# Released under the MIT license (see COPYING.MIT for the terms) - -require recipes-graphics/xorg-driver/xorg-driver-video.inc - -PE = "3" - -inherit autotools-brokensep update-rc.d pkgconfig - -DEPENDS += "virtual/xserver virtual/libx11 libgal-imx imx-gpu-viv virtual/libg2d pixman" - -LIC_FILES_CHKSUM = "file://COPYING-MIT;md5=b5e9d9f5c02ea831ab3ecf802bb7c4f3" - -SRCREV = "c828e8a7c38743e960967e7bb78c134cec31c102" -SRCBRANCH = "imx_exa_viv6_g2d" -SRC_URI = "git://source.codeaurora.org/external/imx/xf86-video-imx-vivante.git;protocol=https;branch=${SRCBRANCH} \ - file://rc.autohdmi" - -S = "${WORKDIR}/git/" - -INITSCRIPT_PACKAGES = "xserver-xorg-extension-viv-autohdmi" -INITSCRIPT_NAME = "rc.autohdmi" -INITSCRIPT_PARAMS = "start 99 2 3 4 5 ." - -EXTRA_OEMAKE += "prefix=${exec_prefix} \ - sysroot=${STAGING_DIR_TARGET} \ - SDKTARGETSYSROOT=${STAGING_DIR_HOST} \ - BUSID_HAS_NUMBER=1 \ - BUILD_IN_YOCTO=1 \ - XSERVER_GREATER_THAN_13=1" -TARGET_CC_ARCH += "${LDFLAGS}" - -PACKAGES =+ "xserver-xorg-extension-viv-autohdmi" - -do_install_append () { - install -d ${D}${includedir} - cp -axr ${S}/EXA/src/vivante_gal/vivante_priv.h ${D}${includedir} - cp -axr ${S}/EXA/src/vivante_gal/vivante_gal.h ${D}${includedir} - - install -d ${D}/${sysconfdir}/init.d - install -m 755 ${WORKDIR}/rc.autohdmi ${D}/${sysconfdir}/init.d/rc.autohdmi - - find ${D}${includedir} -type f -exec chmod 660 {} \; -} - -RDEPENDS_${PN} += "libvivante-dri-imx \ - xserver-xorg-module-exa \ - mesa-driver-swrast \ - xserver-xorg-extension-dri \ - xserver-xorg-extension-dri2 \ - xserver-xorg-extension-glx" - -REALSOLIBS := "${SOLIBS}" -SOLIBS = "${SOLIBSDEV}" - -FILES_${PN} = "${libdir}/*/*/*/vivante_drv${SOLIBS}" -FILES_${PN}-dev = "${includedir} /usr/src ${libdir}/libfsl_x11_ext${SOLIBSDEV}" -FILES_${PN}-dbg = "${libdir}/*/*/*/.debug ${libdir}/.debug/libfsl_x11_ext${SOLIBS} ${exec_prefix}/bin/.debug/autohdmi" - -FILES_xserver-xorg-extension-viv-autohdmi = " ${libdir}/libfsl_x11_ext${SOLIBS} ${exec_prefix}/bin/autohdmi ${sysconfdir}/init.d/rc.autohdmi" - -PACKAGE_ARCH = "${MACHINE_SOCARCH}" -COMPATIBLE_MACHINE = "(mx6|mx7ulp)" diff --git a/recipes-graphics/xorg-xserver/xserver-xf86-config/mx5/xorg.conf b/recipes-graphics/xorg-xserver/xserver-xf86-config/mx5-generic-bsp/xorg.conf index a99e6f24..a99e6f24 100644 --- a/recipes-graphics/xorg-xserver/xserver-xf86-config/mx5/xorg.conf +++ b/recipes-graphics/xorg-xserver/xserver-xf86-config/mx5-generic-bsp/xorg.conf diff --git a/recipes-graphics/xorg-xserver/xserver-xf86-config/mx6sll/xorg.conf b/recipes-graphics/xorg-xserver/xserver-xf86-config/mx6-nxp-bsp/xorg.conf index 79b6c0fc..79b6c0fc 100755..100644 --- a/recipes-graphics/xorg-xserver/xserver-xf86-config/mx6sll/xorg.conf +++ b/recipes-graphics/xorg-xserver/xserver-xf86-config/mx6-nxp-bsp/xorg.conf diff --git a/recipes-graphics/xorg-xserver/xserver-xf86-config/mx6/xorg.conf b/recipes-graphics/xorg-xserver/xserver-xf86-config/mx6/xorg.conf deleted file mode 100644 index b89bed60..00000000 --- a/recipes-graphics/xorg-xserver/xserver-xf86-config/mx6/xorg.conf +++ /dev/null @@ -1,14 +0,0 @@ -Section "Device" - Identifier "i.MX Accelerated Framebuffer Device" - Driver "vivante" - Option "fbdev" "/dev/fb0" - Option "vivante_fbdev" "/dev/fb0" - Option "HWcursor" "false" -EndSection - -Section "ServerFlags" - Option "BlankTime" "0" - Option "StandbyTime" "0" - Option "SuspendTime" "0" - Option "OffTime" "0" -EndSection diff --git a/recipes-graphics/xorg-xserver/xserver-xf86-config/mx6sl/xorg.conf b/recipes-graphics/xorg-xserver/xserver-xf86-config/mx6sl-nxp-bsp/xorg.conf index de3905ab..de3905ab 100644 --- a/recipes-graphics/xorg-xserver/xserver-xf86-config/mx6sl/xorg.conf +++ b/recipes-graphics/xorg-xserver/xserver-xf86-config/mx6sl-nxp-bsp/xorg.conf diff --git a/recipes-graphics/xorg-xserver/xserver-xf86-config/mx6ul/xorg.conf b/recipes-graphics/xorg-xserver/xserver-xf86-config/mx6sll-nxp-bsp/xorg.conf index 79b6c0fc..79b6c0fc 100644..100755 --- a/recipes-graphics/xorg-xserver/xserver-xf86-config/mx6ul/xorg.conf +++ b/recipes-graphics/xorg-xserver/xserver-xf86-config/mx6sll-nxp-bsp/xorg.conf diff --git a/recipes-graphics/xorg-xserver/xserver-xf86-config/mx6sx/xorg.conf b/recipes-graphics/xorg-xserver/xserver-xf86-config/mx6sx-nxp-bsp/xorg.conf index de3905ab..de3905ab 100644 --- a/recipes-graphics/xorg-xserver/xserver-xf86-config/mx6sx/xorg.conf +++ b/recipes-graphics/xorg-xserver/xserver-xf86-config/mx6sx-nxp-bsp/xorg.conf diff --git a/recipes-graphics/xorg-xserver/xserver-xf86-config/mx6ull/xorg.conf b/recipes-graphics/xorg-xserver/xserver-xf86-config/mx6ul-nxp-bsp/xorg.conf index 79b6c0fc..79b6c0fc 100644 --- a/recipes-graphics/xorg-xserver/xserver-xf86-config/mx6ull/xorg.conf +++ b/recipes-graphics/xorg-xserver/xserver-xf86-config/mx6ul-nxp-bsp/xorg.conf diff --git a/recipes-graphics/xorg-xserver/xserver-xf86-config/mx7/xorg.conf b/recipes-graphics/xorg-xserver/xserver-xf86-config/mx6ull-nxp-bsp/xorg.conf index 79b6c0fc..79b6c0fc 100644 --- a/recipes-graphics/xorg-xserver/xserver-xf86-config/mx7/xorg.conf +++ b/recipes-graphics/xorg-xserver/xserver-xf86-config/mx6ull-nxp-bsp/xorg.conf diff --git a/recipes-graphics/xorg-xserver/xserver-xf86-config/mxs/xorg.conf b/recipes-graphics/xorg-xserver/xserver-xf86-config/mx7-nxp-bsp/xorg.conf index 79b6c0fc..79b6c0fc 100644 --- a/recipes-graphics/xorg-xserver/xserver-xf86-config/mxs/xorg.conf +++ b/recipes-graphics/xorg-xserver/xserver-xf86-config/mx7-nxp-bsp/xorg.conf diff --git a/recipes-graphics/xorg-xserver/xserver-xf86-config/mx7ulp/xorg.conf b/recipes-graphics/xorg-xserver/xserver-xf86-config/mx7ulp-nxp-bsp/xorg.conf index de6307a3..de6307a3 100755 --- a/recipes-graphics/xorg-xserver/xserver-xf86-config/mx7ulp/xorg.conf +++ b/recipes-graphics/xorg-xserver/xserver-xf86-config/mx7ulp-nxp-bsp/xorg.conf diff --git a/recipes-graphics/xorg-xserver/xserver-xf86-config/mxs-generic-bsp/xorg.conf b/recipes-graphics/xorg-xserver/xserver-xf86-config/mxs-generic-bsp/xorg.conf new file mode 100644 index 00000000..79b6c0fc --- /dev/null +++ b/recipes-graphics/xorg-xserver/xserver-xf86-config/mxs-generic-bsp/xorg.conf @@ -0,0 +1,12 @@ +Section "Device" + Identifier "Kernel Framebuffer Device" + Driver "fbdev" + Option "fbdev" "/dev/fb0" +EndSection + +Section "ServerFlags" + Option "BlankTime" "0" + Option "StandbyTime" "0" + Option "SuspendTime" "0" + Option "OffTime" "0" +EndSection diff --git a/recipes-graphics/xorg-xserver/xserver-xf86-config/use-mainline-bsp/xorg.conf b/recipes-graphics/xorg-xserver/xserver-xf86-config/use-mainline-bsp/xorg.conf index b6f83469..6fe64e11 100644 --- a/recipes-graphics/xorg-xserver/xserver-xf86-config/use-mainline-bsp/xorg.conf +++ b/recipes-graphics/xorg-xserver/xserver-xf86-config/use-mainline-bsp/xorg.conf @@ -1,28 +1,13 @@ Section "Device" - Identifier "Driver0" - Screen 0 - Driver "armada" - -# Support hotplugging displays? - Option "Hotplug" "TRUE" - -# Support hardware cursor if available? - Option "HWCursor" "TRUE" - -# Use GPU acceleration? - Option "UseGPU" "TRUE" - -# Provide Xv interfaces? - Option "XvAccel" "TRUE" - -# Prefer overlay for Xv (TRUE for armada-drm, FALSE for imx-drm) - Option "XvPreferOverlay" "TRUE" - -# Which accelerator module to load (automatically found if commented out) - Option "AccelModule" "etnadrm_gpu" - Option "AccelModule" "etnaviv_gpu" + Identifier "etnaviv" + Driver "modesetting" + Option "kmsdev" "/dev/dri/card1" + Option "AccelMethod" "glamor" + Option "Atomic" "On" +EndSection -# Support DRI2 interfaces? - Option "DRI" "TRUE" +Section "ServerFlags" + Option "AutoAddGPU" "false" + Option "DRI" "3" EndSection diff --git a/recipes-graphics/xorg-xserver/xserver-xf86-config/vf/xorg.conf b/recipes-graphics/xorg-xserver/xserver-xf86-config/vf-generic-bsp/xorg.conf index b4ee82a9..b4ee82a9 100644 --- a/recipes-graphics/xorg-xserver/xserver-xf86-config/vf/xorg.conf +++ b/recipes-graphics/xorg-xserver/xserver-xf86-config/vf-generic-bsp/xorg.conf diff --git a/recipes-graphics/xorg-xserver/xserver-xf86-config_%.bbappend b/recipes-graphics/xorg-xserver/xserver-xf86-config_%.bbappend index ceb438e3..3fe677b3 100644 --- a/recipes-graphics/xorg-xserver/xserver-xf86-config_%.bbappend +++ b/recipes-graphics/xorg-xserver/xserver-xf86-config_%.bbappend @@ -1,2 +1,2 @@ # Append path for freescale layer to include bsp xorg.conf -FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" +FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:" diff --git a/recipes-graphics/xorg-xserver/xserver-xorg/0001-Allow-to-enable-atomic-in-modesetting-DDX.patch b/recipes-graphics/xorg-xserver/xserver-xorg/0001-Allow-to-enable-atomic-in-modesetting-DDX.patch new file mode 100644 index 00000000..71e045b2 --- /dev/null +++ b/recipes-graphics/xorg-xserver/xserver-xorg/0001-Allow-to-enable-atomic-in-modesetting-DDX.patch @@ -0,0 +1,36 @@ +From 8f50f62cf9030d1839e23a7f1ff9688dec2063e4 Mon Sep 17 00:00:00 2001 +From: Daniel Abrecht <public@danielabrecht.ch> +Date: Wed, 21 Oct 2020 21:13:30 +0200 +Subject: [PATCH] Allow to enable atomic in modesetting DDX + +The linux kernel blacklisted atomic for the modesetting DDX to deal with +problems with old Xorg versions which didn't have it disabled by default. +Ever since, it wasn't possible to enable atomic in modesetting at all +anymore. + +This change doesn't enable atomic by default, but it allows a user to +enabled it again. + +Upstream-Status: Pending +Signed-off-by: Daniel Abrecht <public@danielabrecht.ch> + +--- + hw/xfree86/drivers/modesetting/driver.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/hw/xfree86/drivers/modesetting/driver.c b/hw/xfree86/drivers/modesetting/driver.c +index 535f49d..58a1c67 100644 +--- a/hw/xfree86/drivers/modesetting/driver.c ++++ b/hw/xfree86/drivers/modesetting/driver.c +@@ -1236,7 +1236,7 @@ PreInit(ScrnInfoPtr pScrn, int flags) + ms->atomic_modeset_capable = (ret == 0); + + if (xf86ReturnOptValBool(ms->drmmode.Options, OPTION_ATOMIC, FALSE)) { +- ret = drmSetClientCap(ms->fd, DRM_CLIENT_CAP_ATOMIC, 1); ++ ret = drmSetClientCap(ms->fd, DRM_CLIENT_CAP_ATOMIC, 2); + ms->atomic_modeset = (ret == 0); + } else { + ms->atomic_modeset = FALSE; +-- +GitLab + diff --git a/recipes-graphics/xorg-xserver/xserver-xorg/0001-glamor-Fix-fbo-pixmap-format-with-GL_BGRA_EXT.patch b/recipes-graphics/xorg-xserver/xserver-xorg/0001-glamor-Fix-fbo-pixmap-format-with-GL_BGRA_EXT.patch new file mode 100644 index 00000000..960bf3b5 --- /dev/null +++ b/recipes-graphics/xorg-xserver/xserver-xorg/0001-glamor-Fix-fbo-pixmap-format-with-GL_BGRA_EXT.patch @@ -0,0 +1,38 @@ +From c76f5d2c0a0dda534888025d7236465202884665 Mon Sep 17 00:00:00 2001 +From: Xianzhong <xianzhong.li@nxp.com> +Date: Thu, 5 Aug 2021 16:57:43 +0800 +Subject: [PATCH] glamor: Fix fbo pixmap format with GL_BGRA_EXT + +Red and Blue channels are swizzled in GLES path, +Fix color inverse problem with ximagesink command: +gst-launch-1.0 videotestsrc pattern=6 num-buffers=1 ! video/x-raw,format=BGRx ! videoconvert ! ximagesink display=:0 -v + +This fix requires GL_EXT_texture_format_BGRA8888 extention, not applicable for upstream. + +Upstream-Status: Inappropriate + +Signed-off-by: Xianzhong <xianzhong.li@nxp.com> +--- + glamor/glamor.c | 7 +++++++ + 1 file changed, 7 insertions(+) + +--- a/glamor/glamor.c ++++ b/glamor/glamor.c +@@ -586,10 +586,17 @@ glamor_setup_formats(ScreenPtr screen) + + if (glamor_priv->is_gles) { + assert(X_BYTE_ORDER == X_LITTLE_ENDIAN); ++#if GL_EXT_texture_format_BGRA8888 ++ glamor_add_format(screen, 24, PICT_x8r8g8b8, ++ GL_BGRA_EXT, GL_BGRA_EXT, GL_UNSIGNED_BYTE, TRUE); ++ glamor_add_format(screen, 32, PICT_a8r8g8b8, ++ GL_BGRA_EXT, GL_BGRA_EXT, GL_UNSIGNED_BYTE, TRUE); ++#else + glamor_add_format(screen, 24, PICT_x8b8g8r8, + GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, TRUE); + glamor_add_format(screen, 32, PICT_a8b8g8r8, + GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, TRUE); ++#endif + } else { + glamor_add_format(screen, 24, PICT_x8r8g8b8, + GL_RGBA, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, TRUE); diff --git a/recipes-graphics/xorg-xserver/xserver-xorg/0003-Remove-check-for-useSIGIO-option.patch b/recipes-graphics/xorg-xserver/xserver-xorg/0003-Remove-check-for-useSIGIO-option.patch deleted file mode 100644 index beed6cb4..00000000 --- a/recipes-graphics/xorg-xserver/xserver-xorg/0003-Remove-check-for-useSIGIO-option.patch +++ /dev/null @@ -1,47 +0,0 @@ -From cf407b16cd65ad6e26a9c8e5984e163409a5c0f7 Mon Sep 17 00:00:00 2001 -From: Prabhu Sundararaj <prabhu.sundararaj@nxp.com> -Date: Mon, 30 Jan 2017 16:32:06 -0600 -Subject: [PATCH] Remove check for useSIGIO option - -Commit 6a5a4e60373c1386b311b2a8bb666c32d68a9d99 removes the configure of useSIGIO -option. - -As the xfree86 SIGIO support is reworked to use internal versions of OsBlockSIGIO -and OsReleaseSIGIO. - -No longer the check for useSIGIO is needed - -Upstream-Status: Pending - -Signed-off-by: Prabhu Sundararaj <prabhu.sundararaj@nxp.com> ---- - hw/xfree86/os-support/shared/sigio.c | 6 ------ - 1 file changed, 6 deletions(-) - -diff --git a/hw/xfree86/os-support/shared/sigio.c b/hw/xfree86/os-support/shared/sigio.c -index 884a71c..be76498 100644 ---- a/hw/xfree86/os-support/shared/sigio.c -+++ b/hw/xfree86/os-support/shared/sigio.c -@@ -185,9 +185,6 @@ xf86InstallSIGIOHandler(int fd, void (*f) (int, void *), void *closure) - int i; - int installed = FALSE; - -- if (!xf86Info.useSIGIO) -- return 0; -- - for (i = 0; i < MAX_FUNCS; i++) { - if (!xf86SigIOFuncs[i].f) { - if (xf86IsPipe(fd)) -@@ -256,9 +253,6 @@ xf86RemoveSIGIOHandler(int fd) - int max; - int ret; - -- if (!xf86Info.useSIGIO) -- return 0; -- - max = 0; - ret = 0; - for (i = 0; i < MAX_FUNCS; i++) { --- -2.7.4 - diff --git a/recipes-graphics/xorg-xserver/xserver-xorg_%.bbappend b/recipes-graphics/xorg-xserver/xserver-xorg_%.bbappend index 84b69075..cf1c3a50 100644 --- a/recipes-graphics/xorg-xserver/xserver-xorg_%.bbappend +++ b/recipes-graphics/xorg-xserver/xserver-xorg_%.bbappend @@ -1,8 +1,11 @@ -IMX_OPENGL_PKGCONFIGS_REMOVE = "" -IMX_OPENGL_PKGCONFIGS_REMOVE_imxgpu = "glamor" -OPENGL_PKGCONFIGS_remove_mx6 = "${IMX_OPENGL_PKGCONFIGS_REMOVE}" -OPENGL_PKGCONFIGS_remove_mx7 = "${IMX_OPENGL_PKGCONFIGS_REMOVE}" -OPENGL_PKGCONFIGS_remove_mx8 = "${IMX_OPENGL_PKGCONFIGS_REMOVE}" +FILESEXTRAPATHS:prepend := "${THISDIR}/${BPN}:" + +SRC_URI:append:use-mainline-bsp = " file://0001-Allow-to-enable-atomic-in-modesetting-DDX.patch" -FILESEXTRAPATHS_prepend := "${THISDIR}/${BPN}:" -SRC_URI_append_imxgpu2d = " file://0003-Remove-check-for-useSIGIO-option.patch" +SRC_URI:append:imxgpu = " file://0001-glamor-Fix-fbo-pixmap-format-with-GL_BGRA_EXT.patch" + +IMX_OPENGL_PKGCONFIGS_REMOVE = "" +IMX_OPENGL_PKGCONFIGS_REMOVE:imxgpu = "glamor" +OPENGL_PKGCONFIGS:remove:mx6-nxp-bsp = "${IMX_OPENGL_PKGCONFIGS_REMOVE}" +OPENGL_PKGCONFIGS:remove:mx7-nxp-bsp = "${IMX_OPENGL_PKGCONFIGS_REMOVE}" +OPENGL_PKGCONFIGS:remove:imxdrm = "dri glx" diff --git a/recipes-graphics/xwayland/xwayland/0001-Prefer-to-create-GLES2-context-for-glamor-EGL.patch b/recipes-graphics/xwayland/xwayland/0001-Prefer-to-create-GLES2-context-for-glamor-EGL.patch new file mode 100644 index 00000000..c1e8ae11 --- /dev/null +++ b/recipes-graphics/xwayland/xwayland/0001-Prefer-to-create-GLES2-context-for-glamor-EGL.patch @@ -0,0 +1,31 @@ +From e75a4d7b4474529967490de6e75ae4f1b7128937 Mon Sep 17 00:00:00 2001 +From: Xianzhong <xianzhong.li@nxp.com> +Date: Sat, 22 Jan 2022 17:57:59 +0800 +Subject: [PATCH 1/3] Prefer to create GLES2 context for glamor EGL + +created the initial patch for xwayland-21.1.2 + +Upstream-Status: Inappropriate [embedded specific] +Signed-off-by: Xianzhong <xianzhong.li@nxp.com> +--- + hw/xwayland/xwayland-glamor-gbm.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/hw/xwayland/xwayland-glamor-gbm.c b/hw/xwayland/xwayland-glamor-gbm.c +index 12d820e44..8a89919be 100644 +--- a/hw/xwayland/xwayland-glamor-gbm.c ++++ b/hw/xwayland/xwayland-glamor-gbm.c +@@ -866,8 +866,8 @@ xwl_glamor_gbm_init_egl(struct xwl_screen *xwl_screen) + goto error; + } + +- if (!xwl_glamor_try_big_gl_api(xwl_screen) && +- !xwl_glamor_try_gles_api(xwl_screen)) { ++ if (!xwl_glamor_try_gles_api(xwl_screen) && ++ !xwl_glamor_try_big_gl_api(xwl_screen)) { + ErrorF("Cannot use neither GL nor GLES2\n"); + goto error; + } +-- +2.17.1 + diff --git a/recipes-graphics/xwayland/xwayland_23.1.1.imx.bb b/recipes-graphics/xwayland/xwayland_23.1.1.imx.bb new file mode 100644 index 00000000..a9705a23 --- /dev/null +++ b/recipes-graphics/xwayland/xwayland_23.1.1.imx.bb @@ -0,0 +1,53 @@ +# This recipe copy helps keep meta-freescale master branch compatible +# with Yocto langdale. +# (From OE-Core rev: 35fdbd0ea81650a0421d50fb53989d96c5956331) + +SUMMARY = "XWayland is an X Server that runs under Wayland." +DESCRIPTION = "XWayland is an X Server running as a Wayland client, \ +and thus is capable of displaying native X11 client applications in a \ +Wayland compositor environment. The goal of XWayland is to facilitate \ +the transition from X Window System to Wayland environments, providing \ +a way to run unported applications in the meantime." +HOMEPAGE = "https://fedoraproject.org/wiki/Changes/XwaylandStandalone" + +DEFAULT_PREFERENCE = "-1" + +LICENSE = "MIT" +LIC_FILES_CHKSUM = "file://COPYING;md5=5df87950af51ac2c5822094553ea1880" + +SRC_URI = "https://www.x.org/archive/individual/xserver/${BP_ORIGINAL}.tar.xz" +BP_ORIGINAL = "${BPN}-23.1.1" +SRC_URI[sha256sum] = "fb9461f5cb9fea5e07e91882311b0c88b43e8843b017ebac05eb5af69aa34c15" +S = "${WORKDIR}/${BP_ORIGINAL}" + +UPSTREAM_CHECK_REGEX = "xwayland-(?P<pver>\d+(\.(?!90\d)\d+)+)\.tar" + +inherit meson features_check pkgconfig +REQUIRED_DISTRO_FEATURES = "x11 opengl" + +DEPENDS += "xorgproto xtrans pixman libxkbfile libxfont2 wayland wayland-native wayland-protocols libdrm libepoxy libxcvt" + +OPENGL_PKGCONFIGS = "glx glamor dri3" +PACKAGECONFIG ??= "${XORG_CRYPTO} \ + ${@bb.utils.contains('DISTRO_FEATURES', 'opengl', '${OPENGL_PKGCONFIGS}', '', d)} \ +" +PACKAGECONFIG[dri3] = "-Ddri3=true,-Ddri3=false,libxshmfence" +PACKAGECONFIG[glx] = "-Dglx=true,-Dglx=false,virtual/libgl virtual/libx11" +PACKAGECONFIG[glamor] = "-Dglamor=true,-Dglamor=false,libepoxy virtual/libgbm,libegl" +PACKAGECONFIG[unwind] = "-Dlibunwind=true,-Dlibunwind=false,libunwind" +PACKAGECONFIG[xinerama] = "-Dxinerama=true,-Dxinerama=false" + +# Xorg requires a SHA1 implementation, pick one +XORG_CRYPTO ??= "openssl" +PACKAGECONFIG[openssl] = "-Dsha1=libcrypto,,openssl" +PACKAGECONFIG[nettle] = "-Dsha1=libnettle,,nettle" +PACKAGECONFIG[gcrypt] = "-Dsha1=libgcrypt,,libgcrypt" + +do_install:append() { + # remove files not needed and clashing with xserver-xorg + rm -rf ${D}/${libdir}/xorg/ +} + +FILES:${PN} += "${libdir}/xorg/protocol.txt" + +RDEPENDS:${PN} += "xkbcomp" diff --git a/recipes-graphics/xwayland/xwayland_23.1.1.imx.bbappend b/recipes-graphics/xwayland/xwayland_23.1.1.imx.bbappend new file mode 100644 index 00000000..e1708a96 --- /dev/null +++ b/recipes-graphics/xwayland/xwayland_23.1.1.imx.bbappend @@ -0,0 +1,20 @@ +FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:" + +SRC_URI:append:imxgpu = " \ + file://0001-Prefer-to-create-GLES2-context-for-glamor-EGL.patch \ +" + +OPENGL_PKGCONFIGS:remove:imxgpu = "${OPENGL_PKGCONFIGS_REMOVE_IMXGPU}" +OPENGL_PKGCONFIGS_REMOVE_IMXGPU = "" +OPENGL_PKGCONFIGS_REMOVE_IMXGPU:mx6-nxp-bsp = "glamor glx" +OPENGL_PKGCONFIGS_REMOVE_IMXGPU:mx7-nxp-bsp = "glamor glx" +OPENGL_PKGCONFIGS_REMOVE_IMXGPU:mx8-nxp-bsp = "glx" + + +# links with imx-gpu libs which are pre-built for glibc +# gcompat will address it during runtime +LDFLAGS:append:imxgpu:libc-musl = " -Wl,--allow-shlib-undefined" + +RDEPENDS:${PN}:append:imxgpu:libc-musl = " gcompat" + +PACKAGE_ARCH = "${MACHINE_SOCARCH}" |