Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mesa: acceleration (experiment) #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions build-package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ source "$TERMUX_SCRIPTDIR/scripts/build/setup/termux_setup_cmake.sh"
# shellcheck source=scripts/build/setup/termux_setup_protobuf.sh
source "$TERMUX_SCRIPTDIR/scripts/build/setup/termux_setup_protobuf.sh"

source "$TERMUX_SCRIPTDIR/scripts/build/setup/termux_setup_glslang.sh"

# Setup variables used by the build. Not to be overridden by packages.
# shellcheck source=scripts/build/termux_step_setup_variables.sh
source "$TERMUX_SCRIPTDIR/scripts/build/termux_step_setup_variables.sh"
Expand Down
11 changes: 11 additions & 0 deletions packages/libclc/CMakeLists.txt.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- libclc-16.0.1.src/CMakeLists.txt 2023-04-05 06:36:38.000000000 +0300
+++ libclc-16.0.1.src/CMakeLists.txt.patch 2023-04-13 13:43:55.134228201 +0300
@@ -326,7 +326,7 @@

# Add prepare target
add_custom_command( OUTPUT "${obj_suffix}"
- COMMAND prepare_builtins -o
+ COMMAND "./prepare_builtins_hb" -o
"${obj_suffix}"
"builtins.opt.${obj_suffix}"
DEPENDS "opt.${obj_suffix}"
59 changes: 59 additions & 0 deletions packages/libclc/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
TERMUX_PKG_HOMEPAGE=https://libclc.llvm.org/
TERMUX_PKG_DESCRIPTION="Library requirements of the OpenCL C programming language"
TERMUX_PKG_LICENSE="MIT"
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=16.0.1
TERMUX_PKG_SRCURL=https://github.com/llvm/llvm-project/releases/download/llvmorg-$TERMUX_PKG_VERSION/libclc-$TERMUX_PKG_VERSION.src.tar.xz
TERMUX_PKG_SHA256=23e4c684d50200ab6ec2b0120b4da2531ce8144b131a558ba0d42ab4efe0d996
TERMUX_PKG_BUILD_DEPENDS="libllvm-static, spirv-llvm-translator"
TERMUX_PKG_PLATFORM_INDEPENDENT=true
TERMUX_PKG_BUILD_IN_SRC=true
TERMUX_PKG_HOSTBUILD=true

termux_step_host_build() {
termux_setup_cmake
termux_setup_ninja
mkdir -p $TERMUX_PKG_SRCDIR/build
termux_download https://github.com/llvm/llvm-project/releases/download/llvmorg-$TERMUX_PKG_VERSION/libclc-$TERMUX_PKG_VERSION.src.tar.xz \
libclc.src.tar.xz \
$TERMUX_PKG_SHA256
tar xJf libclc.src.tar.xz
cd libclc-$TERMUX_PKG_VERSION.src
mkdir build
cd build
cmake .. -G Ninja \
-DLLVM_SPIRV=/usr/bin/llvm-spirv \
-DCMAKE_MODULE_PATH=$TERMUX_PREFIX/lib/cmake/llvm
ninja prepare_builtins
mkdir -p $TERMUX_PKG_SRCDIR/build
mv prepare_builtins $TERMUX_PKG_SRCDIR/build/prepare_builtins_hb
}

termux_step_pre_configure() {
CXXFLAGS+=" -I$TERMUX_PREFIX/include"
LDFLAGS+=" -lz -lzstd -ltinfo"
}

termux_step_configure() {
cd build
cmake .. -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=$TERMUX_PREFIX \
-DLLVM_SPIRV=/usr/bin/llvm-spirv \
-DLLVM_CLANG=$(command -v $CC) \
-DLLVM_AS=$(command -v llvm-as) \
-DLLVM_LINK=$(command -v llvm-link) \
-DLLVM_OPT=/usr/lib/llvm-13/bin/opt \
-DLLVM_CMAKE_DIR=$TERMUX_PREFIX/lib/cmake/llvm \
-DCMAKE_MODULE_PATH=$TERMUX_PREFIX/lib/cmake/llvm
}

termux_step_make() {
cd build
ninja
}

termux_step_make_install() {
cd build
ninja install
}
10 changes: 4 additions & 6 deletions packages/libdrm/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@ TERMUX_PKG_DESCRIPTION="Userspace interface to kernel DRM services"
TERMUX_PKG_LICENSE="MIT"
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=2.4.115
TERMUX_PKG_REVISION=1
TERMUX_PKG_SRCURL=https://dri.freedesktop.org/libdrm/libdrm-${TERMUX_PKG_VERSION}.tar.xz
TERMUX_PKG_SHA256=554cfbfe0542bddb391b4e3e05bfbbfc3e282b955bd56218d21c0616481f65eb

TERMUX_PKG_EXTRA_CONFIGURE_ARGS="
-Dintel=disabled
-Dradeon=disabled
-Damdgpu=disabled
-Dnouveau=disabled
-Dvmwgfx=disabled
-Dtests=false
-Dvalgrind=disabled
-Dudev=false
-Dinstall-test-programs=true
"

termux_step_pre_configure() {
Expand Down
38 changes: 38 additions & 0 deletions packages/libdrm/threaded.c.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
--- src/tests/nouveau/threaded.c 2023-03-13 10:01:32.898802503 +0300
+++ src/tests/nouveau/threaded.c.patch 2023-03-13 10:02:05.108802491 +0300
@@ -31,15 +31,14 @@
#include "xf86drm.h"
#include "nouveau.h"

-static __typeof__(ioctl) *old_ioctl;
static int failed;

static int import_fd;

#if defined(__GLIBC__) || defined(__FreeBSD__)
-int ioctl(int fd, unsigned long request, ...)
+int ioctl_new(int fd, unsigned long request, ...)
#else
-int ioctl(int fd, int request, ...)
+int ioctl_new(int fd, int request, ...)
#endif
{
va_list va;
@@ -48,7 +47,7 @@

va_start(va, request);
arg = va_arg(va, void *);
- ret = old_ioctl(fd, request, arg);
+ ret = ioctl(fd, request, arg);
va_end(va);

if (ret < 0 && request == DRM_IOCTL_GEM_CLOSE && errno == EINVAL)
@@ -80,8 +79,6 @@
struct nouveau_bo *bo;
pthread_t t1, t2;

- old_ioctl = dlsym(RTLD_NEXT, "ioctl");
-
if (argc < 2) {
fd = drmOpenWithType("nouveau", NULL, DRM_NODE_RENDER);
if (fd >= 0)
17 changes: 17 additions & 0 deletions packages/libomxil-bellagio/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
TERMUX_PKG_HOMEPAGE=http://omxil.sourceforge.net
TERMUX_PKG_DESCRIPTION="An opensource implementation of the OpenMAX Integration Layer API"
TERMUX_PKG_LICENSE="LGPL-2.0"
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=0.9.3
TERMUX_PKG_SRCURL=https://downloads.sourceforge.net/project/omxil/omxil/Bellagio%200.9.3/libomxil-bellagio-$TERMUX_PKG_VERSION.tar.gz
TERMUX_PKG_SHA256=593c0729c8ef8c1467b3bfefcf355ec19a46dd92e31bfc280e17d96b0934d74c
TERMUX_PKG_DEPENDS="libc++"
TERMUX_PKG_EXTRA_CONFIGURE_ARGS="
--disable-static
"

termux_step_pre_configure() {
sed -e 's/-Werror//' -i configure.ac
sed -e 's/-lomxil-bellagio//' -i src/Makefile.*
CFLAGS+=' -fcommon'
}
10 changes: 10 additions & 0 deletions packages/libomxil-bellagio/configure.ac.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
--- libomxil-bellagio-0.9.3/configure.ac 2023-03-12 22:17:09.598818625 +0300
+++ libomxil-bellagio-0.9.3/configure.ac.patch 2023-03-12 22:35:17.768818210 +0300
@@ -231,7 +231,6 @@
# Check for library functions #
################################################################################

-AC_FUNC_MALLOC
AC_FUNC_REALLOC
AC_CHECK_FUNCS([gethostbyname gettimeofday memset mkdir socket strdup strerror strndup strrchr])

16 changes: 16 additions & 0 deletions packages/libva/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
TERMUX_PKG_HOMEPAGE=https://01.org/linuxmedia/vaapi
TERMUX_PKG_DESCRIPTION="Video Acceleration (VA) API for Linux"
TERMUX_PKG_LICENSE="MIT"
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=2.17.0
TERMUX_PKG_SRCURL=https://github.com/intel/libva/releases/download/$TERMUX_PKG_VERSION/libva-$TERMUX_PKG_VERSION.tar.bz2
TERMUX_PKG_SHA256=f3e5eb27c305e05a9bb62703d1915a127301cc0c4f9f209025767432230c4eac
TERMUX_PKG_DEPENDS="libdrm, libglvnd, libx11, libxext, libxfixes, libwayland"
TERMUX_PKG_BUILD_DEPENDS="libglvnd"
TERMUX_PKG_EXTRA_CONFIGURE_ARGS="
--disable-static
"

termux_step_pre_configure() {
CFLAGS+=" -DENABLE_VA_MESSAGING"
}
17 changes: 17 additions & 0 deletions packages/libvdpau/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
TERMUX_PKG_HOMEPAGE=libvdpau
TERMUX_PKG_DESCRIPTION="Nvidia VDPAU library"
TERMUX_PKG_LICENSE="MIT"
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=1.5
TERMUX_PKG_SRCURL=https://gitlab.freedesktop.org/vdpau/libvdpau/-/archive/$TERMUX_PKG_VERSION/libvdpau-$TERMUX_PKG_VERSION.tar.gz
TERMUX_PKG_SHA256=66490802f30426d30ff9e8af35263bbbbaa23b52d0a2d797d06959c3d19638fd
TERMUX_PKG_DEPENDS="libxext"
TERMUX_PKG_BUILD_DEPENDS="xorgproto"
TERMUX_PKG_EXTRA_CONFIGURE_ARGS="
--prefix=$TERMUX_PREFIX
"

termux_step_pre_configure() {
termux_setup_meson
termux_setup_ninja
}
File renamed without changes.
10 changes: 10 additions & 0 deletions packages/mesa/2-meson.build.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
--- mesa-23.0.0/meson.build 2023-02-23 05:36:49.000000000 +0300
+++ mesa-23.0.0/meson.build.patch 2023-03-11 18:38:50.288856581 +0300
@@ -1178,7 +1178,6 @@
'-Werror=missing-prototypes',
'-Werror=return-type',
'-Werror=empty-body',
- '-Werror=incompatible-pointer-types',
'-Werror=int-conversion',
'-Wimplicit-fallthrough',
'-Wmisleading-indentation',
33 changes: 27 additions & 6 deletions packages/mesa/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ TERMUX_PKG_LICENSE="MIT"
TERMUX_PKG_LICENSE_FILE="docs/license.rst"
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=23.0.2
TERMUX_PKG_REVISION=1
TERMUX_PKG_SRCURL=https://archive.mesa3d.org/mesa-${TERMUX_PKG_VERSION}.tar.xz
TERMUX_PKG_SHA256=1b7d3399fc6f16f030361f925d33ebc7600cbf98094582f54775b6a1180529e7
TERMUX_PKG_DEPENDS="libandroid-shmem, libc++, libdrm, libexpat, libglvnd, libwayland, libx11, libxext, libxfixes, libxshmfence, libxxf86vm, ncurses, zlib, zstd"
TERMUX_PKG_DEPENDS="libandroid-shmem, libc++, libdrm, libexpat, libglvnd, libwayland, libx11, libxext, libxfixes, libxshmfence, libxxf86vm, ncurses, zlib, zstd, glslang, libvdpau, valgrind, libva, libomxil-bellagio, libelf, vulkan-loader-generic"
TERMUX_PKG_SUGGESTS="mesa-dev"
TERMUX_PKG_BUILD_DEPENDS="libllvm-static, libwayland-protocols, libxrandr, llvm, llvm-tools, mlir, xorgproto"
TERMUX_PKG_BUILD_DEPENDS="libllvm-static, libwayland-protocols, libxrandr, llvm, llvm-tools, mlir, xorgproto, rust"
TERMUX_PKG_CONFLICTS="libmesa, ndk-sysroot (<= 25b)"
TERMUX_PKG_REPLACES="libmesa"
TERMUX_PKG_PYTHON_COMMON_DEPS="mako"

TERMUX_PKG_EXTRA_CONFIGURE_ARGS="
--cmake-prefix-path $TERMUX_PREFIX
Expand All @@ -26,18 +28,37 @@ TERMUX_PKG_EXTRA_CONFIGURE_ARGS="
-Dllvm=enabled
-Dshared-llvm=disabled
-Dplatforms=x11,wayland
-Dgallium-drivers=swrast,virgl
-Dvulkan-drivers=swrast
-Dgallium-drivers=r300,r600,radeonsi,freedreno,nouveau,swrast,virgl,zink,d3d12,etnaviv,kmsro,lima,panfrost,v3d,vc4,asahi,svga,tegra
-Dgallium-extra-hud=true
-Dgallium-nine=true
-Dgallium-omx=bellagio
-Dgallium-va=enabled
-Dgallium-vdpau=enabled
-Dgallium-xa=enabled
-Dvulkan-drivers=amd,swrast,broadcom,panfrost,virtio-experimental
-Dvulkan-layers=overlay
-Dosmesa=true
-Dglvnd=true
-Dxmlconfig=disabled
-Dvalgrind=enabled
-Dshared-glapi=enabled
-Dmicrosoft-clc=disabled
-Db_ndebug=true
-Dgallium-rusticl=true
-Drust_std=2021
"

termux_step_pre_configure() {
termux_setup_cmake
termux_setup_rust
termux_setup_cargo_c
termux_setup_glslang

CPPFLAGS+=" -D__USE_GNU"
LDFLAGS+=" -landroid-shmem"
CFLAGS+=' -g1'
CXXFLAGS+=' -g1'

CPPFLAGS+=" -D__USE_GNU -fno-rtti"
LDFLAGS+=" -landroid-shmem -lexpat"

_WRAPPER_BIN=$TERMUX_PKG_BUILDDIR/_wrapper/bin
mkdir -p $_WRAPPER_BIN
Expand Down
81 changes: 81 additions & 0 deletions packages/mesa/draw_llvm.c.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
--- mesa-23.0.0/src/gallium/auxiliary/draw/draw_llvm.c 2023-02-23 05:36:49.000000000 +0300
+++ mesa-23.0.0/src/gallium/auxiliary/draw/draw_llvm.c.patch 2023-03-18 11:33:37.928635601 +0300
@@ -872,12 +872,15 @@
variant = MALLOC(sizeof *variant +
shader->variant_key_size -
sizeof variant->key);
+ printf("ok1\n");
if (!variant)
return NULL;
+ printf("ok2\n");

variant->llvm = llvm;
variant->shader = shader;
memcpy(&variant->key, key, shader->variant_key_size);
+ printf("ok3\n");

snprintf(module_name, sizeof(module_name), "draw_llvm_vs_variant%u",
variant->shader->variants_cached);
@@ -888,40 +891,59 @@
shader->variant_key_size,
num_inputs,
ir_sha1_cache_key);
+ printf("ok3.1\n");

llvm->draw->disk_cache_find_shader(llvm->draw->disk_cache_cookie,
&cached,
ir_sha1_cache_key);
+ printf("ok3.2\n");
if (!cached.data_size)
needs_caching = true;
}
+ printf("ok4\n");
variant->gallivm = gallivm_create(module_name, llvm->context, &cached);
+ printf("ok5\n");

create_jit_types(variant);
+ printf("ok6\n");

if (gallivm_debug & (GALLIVM_DEBUG_TGSI | GALLIVM_DEBUG_IR)) {
- if (llvm->draw->vs.vertex_shader->state.type == PIPE_SHADER_IR_TGSI)
+ if (llvm->draw->vs.vertex_shader->state.type == PIPE_SHADER_IR_TGSI) {
tgsi_dump(llvm->draw->vs.vertex_shader->state.tokens, 0);
- else
+ printf("ok6.1\n");
+ } else {
nir_print_shader(llvm->draw->vs.vertex_shader->state.ir.nir, stderr);
+ printf("ok6.2\n");
+ }
draw_llvm_dump_variant_key(&variant->key);
+ printf("ok6.3\n");
}
+ printf("ok7\n");

variant->vertex_header_type = create_jit_vertex_header(variant->gallivm, num_inputs);
+ printf("ok8\n");
variant->vertex_header_ptr_type = LLVMPointerType(variant->vertex_header_type, 0);
+ printf("ok9\n");

draw_llvm_generate(llvm, variant);
+ printf("ok10\n");

gallivm_compile_module(variant->gallivm);
+ printf("ok11\n");

variant->jit_func = (draw_jit_vert_func)
gallivm_jit_function(variant->gallivm, variant->function);
+ printf("ok12\n");

- if (needs_caching)
+ if (needs_caching) {
llvm->draw->disk_cache_insert_shader(llvm->draw->disk_cache_cookie,
&cached,
ir_sha1_cache_key);
+ printf("ok12.1\n");
+ }
+ printf("ok13\n");
gallivm_free_ir(variant->gallivm);
+ printf("ok14\n");

variant->list_item_global.base = variant;
variant->list_item_local.base = variant;
10 changes: 10 additions & 0 deletions packages/mesa/nine_memory_helper.c.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
--- mesa-23.0.0/src/gallium/frontends/nine/nine_memory_helper.c 2023-02-23 05:36:49.000000000 +0300
+++ mesa-23.0.0/src/gallium/frontends/nine/nine_memory_helper.c.patch 2023-03-11 20:15:13.458854375 +0300
@@ -90,7 +90,6 @@
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
-#include <ulimit.h>
#include <unistd.h>

#include "util/list.h"
Loading