From: Rafael Sadowski Subject: www/chromium vaapi support To: ports@openbsd.org, robert@openbsd.org Date: Tue, 7 Oct 2025 21:01:46 +0200 Hi Robert@, hey ports@ I've been playing around with Chromium a bit. The following diff enables VA-API support by default. multimedia/aom and multimedia/libvpx from the ports tree are sacrificed by the bundled version because internal headers are needed for building and libvpxrc or libaomrc stuff is required: ‘//third_party/libaom:libaomrc’, "// third_party/libvpx:libvpxrc", I took the liberty of merging everything from the ports tree into chromium. The results are solid. I measure with radeontop and the GPU goes towards 10-20%. With the current version, however, I don't see any GPU stuttering. I'm not saying we should use it that way, I don't have a strong opinion either way. In any case, I see VAAPI as a benefit from my perspective. Cheers, Rafael diff --git a/www/chromium/Makefile b/www/chromium/Makefile index ae67f128536..7074c7b3149 100644 --- a/www/chromium/Makefile +++ b/www/chromium/Makefile @@ -15,6 +15,7 @@ COMMENT= Chromium browser V= 141.0.7390.54 DISTNAME= chromium-${V} +REVISION= 0 DISTFILES+= ${CHROMIUM_DISTFILES} \ ${REGRESS_DISTFILES} @@ -54,14 +55,15 @@ MODPY_RUNDEP= No COMPILER= ports-clang # uses pledge() -WANTLIB+= GL X11 Xcomposite Xdamage Xext Xfixes Xi Xrandr Xrender Xtst -WANTLIB+= aom atk-1.0 atk-bridge-2.0 atspi c cairo cbor crypto cups -WANTLIB+= dav1d dbus-1 drm epoll-shim execinfo expat fido2 fontconfig -WANTLIB+= gbm gio-2.0 glib-2.0 gmodule-2.0 gobject-2.0 gthread-2.0 -WANTLIB+= harfbuzz harfbuzz-subset icudata icui18n icuuc intl jpeg kvm -WANTLIB+= m nspr4 nss3 nssutil3 openh264 opus pango-1.0 pangocairo-1.0 -WANTLIB+= plc4 plds4 png pthread pthread smime3 sndio udev usbhid util -WANTLIB+= vpx xcb xkbcommon xml2 xshmfence xslt z +WANTLIB += GL X11 Xcomposite Xdamage Xext Xfixes Xi Xrandr Xrender +WANTLIB += Xtst atk-1.0 atk-bridge-2.0 atspi c cairo cbor crypto +WANTLIB += cups dav1d dbus-1 drm epoll-shim execinfo expat fido2 +WANTLIB += fontconfig gbm gio-2.0 glib-2.0 gmodule-2.0 gobject-2.0 +WANTLIB += gthread-2.0 harfbuzz harfbuzz-subset icudata icui18n +WANTLIB += icuuc intl jpeg kvm m nspr4 nss3 nssutil3 openh264 +WANTLIB += opus pango-1.0 pangocairo-1.0 plc4 plds4 png pthread +WANTLIB += smime3 sndio udev usbhid util xcb xkbcommon xml2 xshmfence +WANTLIB += xslt z RUN_DEPENDS= devel/xdg-utils \ devel/desktop-file-utils \ @@ -90,9 +92,7 @@ BUILD_DEPENDS= archivers/bzip2 \ LIB_DEPENDS= audio/opus \ devel/pango \ graphics/jpeg \ - multimedia/aom \ multimedia/dav1d \ - multimedia/libvpx \ multimedia/openh264 \ security/nss \ textproc/icu4c \ @@ -144,10 +144,8 @@ BUILDDIR= ${WRKSRC}/out/${BUILDTYPE} GN_SYSTEM_LIBS= dav1d \ fontconfig \ icu \ - libaom \ libjpeg \ libpng \ - libvpx \ libxml \ libxslt \ openh264 \ @@ -185,6 +183,7 @@ GN_ARGS= is_official_build=true \ v8_enable_cet_ibt=true \ use_qt5=true \ use_qt6=true \ + use_vaapi=true \ moc_qt5_path=\"${MODQT5_MOC}\" \ moc_qt6_path=\"${MODQT6_MOC}\" @@ -195,9 +194,6 @@ GN_ARGS+= enable_rust=true \ rust_sysroot_absolute=\"${LOCALBASE}\" \ rustc_version=\"${RUSTC_VERSION}\" -# notyet -GN_ARGS+= use_vaapi=false - .if ${MACHINE_ARCH} == "aarch64" GN_ARGS+= extra_ldflags=\"-L${LOCALBASE}/lib -L${X11BASE}/lib\" PKG_ARGS+= -Dswiftshader=0 diff --git a/www/chromium/patches/patch-third_party_libaom_source_libaom_aom_ports_aarch32_cpudetect_c b/www/chromium/patches/patch-third_party_libaom_source_libaom_aom_ports_aarch32_cpudetect_c new file mode 100644 index 00000000000..5d400a604d7 --- /dev/null +++ b/www/chromium/patches/patch-third_party_libaom_source_libaom_aom_ports_aarch32_cpudetect_c @@ -0,0 +1,25 @@ +Index: third_party/libaom/source/libaom/aom_ports/aarch32_cpudetect.c +--- third_party/libaom/source/libaom/aom_ports/aarch32_cpudetect.c.orig ++++ third_party/libaom/source/libaom/aom_ports/aarch32_cpudetect.c +@@ -55,7 +55,7 @@ static int arm_get_cpu_caps(void) { + return flags; + } + +-#elif defined(__linux__) // end defined(AOM_USE_ANDROID_CPU_FEATURES) ++#elif defined(__linux__) || defined(__OpenBSD__) // end defined(AOM_USE_ANDROID_CPU_FEATURES) + + #include + +@@ -65,7 +65,12 @@ static int arm_get_cpu_caps(void) { + + static int arm_get_cpu_caps(void) { + int flags = 0; ++#ifdef __OpenBSD__ ++ unsigned long hwcap = 0; ++ elf_aux_info(AT_HWCAP, &hwcap, sizeof(hwcap)); ++#else + unsigned long hwcap = getauxval(AT_HWCAP); ++#endif + #if HAVE_NEON + if (hwcap & AOM_AARCH32_HWCAP_NEON) flags |= HAS_NEON; + #endif // HAVE_NEON diff --git a/www/chromium/patches/patch-third_party_libaom_source_libaom_aom_ports_aarch64_cpudetect_c b/www/chromium/patches/patch-third_party_libaom_source_libaom_aom_ports_aarch64_cpudetect_c index 8ae0677878f..3d26a4793ee 100644 --- a/www/chromium/patches/patch-third_party_libaom_source_libaom_aom_ports_aarch64_cpudetect_c +++ b/www/chromium/patches/patch-third_party_libaom_source_libaom_aom_ports_aarch64_cpudetect_c @@ -1,50 +1,24 @@ Index: third_party/libaom/source/libaom/aom_ports/aarch64_cpudetect.c --- third_party/libaom/source/libaom/aom_ports/aarch64_cpudetect.c.orig +++ third_party/libaom/source/libaom/aom_ports/aarch64_cpudetect.c -@@ -127,9 +127,45 @@ static int arm_get_cpu_caps(void) { - return flags; - } - --#elif defined(__linux__) // end defined(AOM_USE_ANDROID_CPU_FEATURES) -+#elif defined(__OpenBSD__) -+#include -+#include -+#include - -+static int arm_get_cpu_caps(void) { -+ int flags = 0; -+ int isar0_mib[] = { CTL_MACHDEP, CPU_ID_AA64ISAR0 }; -+ uint64_t cpu_id = 0; -+ size_t len = sizeof(cpu_id); -+ -+ flags |= HAS_NEON; // Neon is mandatory in Armv8.0-A. -+ -+ if (sysctl(isar0_mib, 2, &cpu_id, &len, NULL, 0) < 0) -+ return flags; -+ -+ if (ID_AA64ISAR0_CRC32(cpu_id) >= ID_AA64ISAR0_CRC32_BASE) -+ flags |= HAS_ARM_CRC32; -+ -+ return flags; -+} -+ -+#elif defined(__linux__) || defined(__FreeBSD__) // end defined(AOM_USE_ANDROID_CPU_FEATURES) -+ - #include -+ -+#if defined(__FreeBSD__) -+static unsigned long getauxval(unsigned long type) -+{ -+ /* Only AT_HWCAP* return unsigned long */ -+ if (type != AT_HWCAP && type != AT_HWCAP2) { -+ return 0; -+ } -+ -+ unsigned long ret = 0; -+ elf_aux_info(type, &ret, sizeof(ret)); -+ return ret; -+} +@@ -178,10 +178,20 @@ static unsigned long getauxval(unsigned long type) + static int arm_get_cpu_caps(void) { + int flags = 0; + #if HAVE_ARM_CRC32 || HAVE_NEON_DOTPROD || HAVE_SVE ++#ifdef __OpenBSD__ ++ unsigned long hwcap = 0; ++ elf_aux_info(AT_HWCAP, &hwcap, sizeof(hwcap)); ++#else + unsigned long hwcap = getauxval(AT_HWCAP); + #endif ++#endif + #if HAVE_NEON_I8MM || HAVE_SVE2 ++#ifdef __OpenBSD__ ++ unsigned long hwcap2 = 0; ++ elf_aux_info(AT_HWCAP2, &hwcap2, sizeof(hwcap2)); ++#else + unsigned long hwcap2 = getauxval(AT_HWCAP2); +#endif + #endif - // Define hwcap values ourselves: building with an old auxv header where these - // hwcap values are not defined should not prevent features from being enabled. + #if HAVE_NEON diff --git a/www/chromium/patches/patch-third_party_libaom_source_libaom_aom_ports_ppc_cpudetect_c b/www/chromium/patches/patch-third_party_libaom_source_libaom_aom_ports_ppc_cpudetect_c new file mode 100644 index 00000000000..8cd9367e3cb --- /dev/null +++ b/www/chromium/patches/patch-third_party_libaom_source_libaom_aom_ports_ppc_cpudetect_c @@ -0,0 +1,57 @@ +Index: third_party/libaom/source/libaom/aom_ports/ppc_cpudetect.c +--- third_party/libaom/source/libaom/aom_ports/ppc_cpudetect.c.orig ++++ third_party/libaom/source/libaom/aom_ports/ppc_cpudetect.c +@@ -38,6 +38,12 @@ static int cpu_env_mask(void) { + return env && *env ? (int)strtol(env, NULL, 0) : ~0; + } + ++#if defined(__linux__) ++ ++#include ++#include ++#include ++ + int ppc_simd_caps(void) { + int flags; + int mask; +@@ -76,7 +82,40 @@ out_close: + close(fd); + return flags & mask; + } ++ ++#elif defined(__OpenBSD__) ++ ++#include ++ ++// Define hwcap values ourselves: building with an old auxv header where these ++// hwcap values are not defined should not prevent features from being enabled. ++#define AOM_PPC_HWCAP_VSX (1 << 7) ++ ++int ppc_simd_caps(void) { ++ int flags; ++ int mask; ++ ++ // If AOM_SIMD_CAPS_MASK is set then allow only those capabilities. ++ if (!cpu_env_flags(&flags)) { ++ return flags; ++ } ++ ++ mask = cpu_env_mask(); ++ ++#ifdef __OpenBSD__ ++ unsigned long hwcap = 0; ++ elf_aux_info(AT_HWCAP, &hwcap, sizeof(hwcap)); + #else ++ unsigned long hwcap = getauxval(AT_HWCAP); ++#endif ++#if HAVE_VSX ++ if (hwcap & AOM_PPC_HWCAP_VSX) { ++ flags |= HAS_VSX; ++ } ++#endif // HAVE_VSX ++ return flags & mask; ++} ++else + // If there is no RTCD the function pointers are not used and can not be + // changed. + int ppc_simd_caps(void) { return 0; } diff --git a/www/chromium/patches/patch-third_party_libaom_source_libaom_aom_ports_riscv_cpudetect_c b/www/chromium/patches/patch-third_party_libaom_source_libaom_aom_ports_riscv_cpudetect_c new file mode 100644 index 00000000000..e4e73175ba4 --- /dev/null +++ b/www/chromium/patches/patch-third_party_libaom_source_libaom_aom_ports_riscv_cpudetect_c @@ -0,0 +1,16 @@ +Index: third_party/libaom/source/libaom/aom_ports/riscv_cpudetect.c +--- third_party/libaom/source/libaom/aom_ports/riscv_cpudetect.c.orig ++++ third_party/libaom/source/libaom/aom_ports/riscv_cpudetect.c +@@ -26,7 +26,12 @@ + int riscv_simd_caps(void) { + int flags = 0; + #if HAVE_RVV ++#ifdef __OpenBSD__ ++ unsigned long hwcap = 0; ++ elf_aux_info(AT_HWCAP, &hwcap, sizeof(hwcap)); ++#else + unsigned long hwcap = getauxval(AT_HWCAP); ++#endif + if (hwcap & HWCAP_RVV) flags |= HAS_RVV; + #endif + return flags; diff --git a/www/chromium/patches/patch-third_party_libaom_source_libaom_third_party_x86inc_x86inc_asm b/www/chromium/patches/patch-third_party_libaom_source_libaom_third_party_x86inc_x86inc_asm new file mode 100644 index 00000000000..c40f85e8aff --- /dev/null +++ b/www/chromium/patches/patch-third_party_libaom_source_libaom_third_party_x86inc_x86inc_asm @@ -0,0 +1,28 @@ +Index: third_party/libaom/source/libaom/third_party/x86inc/x86inc.asm +--- third_party/libaom/source/libaom/third_party/x86inc/x86inc.asm.orig ++++ third_party/libaom/source/libaom/third_party/x86inc/x86inc.asm +@@ -52,6 +52,16 @@ + %endif + %endif + ++%if AOM_ARCH_X86_64 ++%imacro _endbr64 0 ++ dd 0xfa1e0ff3 ++%endmacro ++%else ++%imacro _endbr64 0 ++; empty ++%endmacro ++%endif ++ + %define WIN64 0 + %define UNIX64 0 + %if AOM_ARCH_X86_64 +@@ -860,6 +870,7 @@ BRANCH_INSTR jz, je, jnz, jne, jl, jle, jnl, jnle, jg, + %endif + align function_align + %2: ++ _endbr64 + RESET_MM_PERMUTATION ; needed for x86-64, also makes disassembly somewhat nicer + %xdefine rstk rsp ; copy of the original stack pointer, used when greater alignment than the known stack alignment is required + %assign stack_offset 0 ; stack pointer offset relative to the return address diff --git a/www/chromium/patches/patch-third_party_libvpx_source_libvpx_third_party_x86inc_x86inc_asm b/www/chromium/patches/patch-third_party_libvpx_source_libvpx_third_party_x86inc_x86inc_asm new file mode 100644 index 00000000000..a35298697d8 --- /dev/null +++ b/www/chromium/patches/patch-third_party_libvpx_source_libvpx_third_party_x86inc_x86inc_asm @@ -0,0 +1,13 @@ +Index: third_party/libvpx/source/libvpx/third_party/x86inc/x86inc.asm +--- third_party/libvpx/source/libvpx/third_party/x86inc/x86inc.asm.orig ++++ third_party/libvpx/source/libvpx/third_party/x86inc/x86inc.asm +@@ -860,6 +860,9 @@ BRANCH_INSTR jz, je, jnz, jne, jl, jle, jnl, jnle, jg, + %endif + align function_align + %2: ++ %if VPX_ARCH_X86_64 ++ dd 0xfa1e0ff3 ++ %endif + RESET_MM_PERMUTATION ; needed for x86-64, also makes disassembly somewhat nicer + %xdefine rstk rsp ; copy of the original stack pointer, used when greater alignment than the known stack alignment is required + %assign stack_offset 0 ; stack pointer offset relative to the return address diff --git a/www/chromium/patches/patch-third_party_libvpx_source_libvpx_vp8_common_x86_subpixel_ssse3_asm b/www/chromium/patches/patch-third_party_libvpx_source_libvpx_vp8_common_x86_subpixel_ssse3_asm new file mode 100644 index 00000000000..251b2e2667a --- /dev/null +++ b/www/chromium/patches/patch-third_party_libvpx_source_libvpx_vp8_common_x86_subpixel_ssse3_asm @@ -0,0 +1,67 @@ +Index: third_party/libvpx/source/libvpx/vp8/common/x86/subpixel_ssse3.asm +--- third_party/libvpx/source/libvpx/vp8/common/x86/subpixel_ssse3.asm.orig ++++ third_party/libvpx/source/libvpx/vp8/common/x86/subpixel_ssse3.asm +@@ -37,6 +37,7 @@ SECTION .text + ;) + globalsym(vp8_filter_block1d8_h6_ssse3) + sym(vp8_filter_block1d8_h6_ssse3): ++ _endbr64 + push rbp + mov rbp, rsp + SHADOW_ARGS_TO_STACK 6 +@@ -180,6 +181,7 @@ vp8_filter_block1d8_h4_ssse3: + ;) + globalsym(vp8_filter_block1d16_h6_ssse3) + sym(vp8_filter_block1d16_h6_ssse3): ++ _endbr64 + push rbp + mov rbp, rsp + SHADOW_ARGS_TO_STACK 6 +@@ -287,6 +289,7 @@ sym(vp8_filter_block1d16_h6_ssse3): + ;) + globalsym(vp8_filter_block1d4_h6_ssse3) + sym(vp8_filter_block1d4_h6_ssse3): ++ _endbr64 + push rbp + mov rbp, rsp + SHADOW_ARGS_TO_STACK 6 +@@ -417,6 +420,7 @@ sym(vp8_filter_block1d4_h6_ssse3): + ;) + globalsym(vp8_filter_block1d16_v6_ssse3) + sym(vp8_filter_block1d16_v6_ssse3): ++ _endbr64 + push rbp + mov rbp, rsp + SHADOW_ARGS_TO_STACK 6 +@@ -605,6 +609,7 @@ sym(vp8_filter_block1d16_v6_ssse3): + ;) + globalsym(vp8_filter_block1d8_v6_ssse3) + sym(vp8_filter_block1d8_v6_ssse3): ++ _endbr64 + push rbp + mov rbp, rsp + SHADOW_ARGS_TO_STACK 6 +@@ -745,6 +750,7 @@ sym(vp8_filter_block1d8_v6_ssse3): + ;) + globalsym(vp8_filter_block1d4_v6_ssse3) + sym(vp8_filter_block1d4_v6_ssse3): ++ _endbr64 + push rbp + mov rbp, rsp + SHADOW_ARGS_TO_STACK 6 +@@ -884,6 +890,7 @@ sym(vp8_filter_block1d4_v6_ssse3): + ;) + globalsym(vp8_bilinear_predict16x16_ssse3) + sym(vp8_bilinear_predict16x16_ssse3): ++ _endbr64 + push rbp + mov rbp, rsp + SHADOW_ARGS_TO_STACK 6 +@@ -1147,6 +1154,7 @@ sym(vp8_bilinear_predict16x16_ssse3): + ;) + globalsym(vp8_bilinear_predict8x8_ssse3) + sym(vp8_bilinear_predict8x8_ssse3): ++ _endbr64 + push rbp + mov rbp, rsp + SHADOW_ARGS_TO_STACK 6 diff --git a/www/chromium/patches/patch-third_party_libvpx_source_libvpx_vp8_encoder_x86_copy_sse3_asm b/www/chromium/patches/patch-third_party_libvpx_source_libvpx_vp8_encoder_x86_copy_sse3_asm new file mode 100644 index 00000000000..bf724c3e694 --- /dev/null +++ b/www/chromium/patches/patch-third_party_libvpx_source_libvpx_vp8_encoder_x86_copy_sse3_asm @@ -0,0 +1,12 @@ +Index: third_party/libvpx/source/libvpx/vp8/encoder/x86/copy_sse3.asm +--- third_party/libvpx/source/libvpx/vp8/encoder/x86/copy_sse3.asm.orig ++++ third_party/libvpx/source/libvpx/vp8/encoder/x86/copy_sse3.asm +@@ -94,6 +94,8 @@ SECTION .text + globalsym(vp8_copy32xn_sse3) + sym(vp8_copy32xn_sse3): + ++ _endbr64 ++ + STACK_FRAME_CREATE_X3 + + .block_copy_sse3_loopx4: diff --git a/www/chromium/patches/patch-third_party_libvpx_source_libvpx_vp8_encoder_x86_dct_sse2_asm b/www/chromium/patches/patch-third_party_libvpx_source_libvpx_vp8_encoder_x86_dct_sse2_asm new file mode 100644 index 00000000000..7ee0f9fa7af --- /dev/null +++ b/www/chromium/patches/patch-third_party_libvpx_source_libvpx_vp8_encoder_x86_dct_sse2_asm @@ -0,0 +1,21 @@ +Index: third_party/libvpx/source/libvpx/vp8/encoder/x86/dct_sse2.asm +--- third_party/libvpx/source/libvpx/vp8/encoder/x86/dct_sse2.asm.orig ++++ third_party/libvpx/source/libvpx/vp8/encoder/x86/dct_sse2.asm +@@ -66,6 +66,8 @@ SECTION .text + globalsym(vp8_short_fdct4x4_sse2) + sym(vp8_short_fdct4x4_sse2): + ++ _endbr64 ++ + STACK_FRAME_CREATE + + movq xmm0, MMWORD PTR[input ] ;03 02 01 00 +@@ -170,6 +172,8 @@ sym(vp8_short_fdct4x4_sse2): + ;void vp8_short_fdct8x4_sse2(short *input, short *output, int pitch) + globalsym(vp8_short_fdct8x4_sse2) + sym(vp8_short_fdct8x4_sse2): ++ ++ _endbr64 + + STACK_FRAME_CREATE + diff --git a/www/chromium/patches/patch-third_party_libvpx_source_libvpx_vp8_encoder_x86_fwalsh_sse2_asm b/www/chromium/patches/patch-third_party_libvpx_source_libvpx_vp8_encoder_x86_fwalsh_sse2_asm new file mode 100644 index 00000000000..28d693e6078 --- /dev/null +++ b/www/chromium/patches/patch-third_party_libvpx_source_libvpx_vp8_encoder_x86_fwalsh_sse2_asm @@ -0,0 +1,11 @@ +Index: third_party/libvpx/source/libvpx/vp8/encoder/x86/fwalsh_sse2.asm +--- third_party/libvpx/source/libvpx/vp8/encoder/x86/fwalsh_sse2.asm.orig ++++ third_party/libvpx/source/libvpx/vp8/encoder/x86/fwalsh_sse2.asm +@@ -16,6 +16,7 @@ SECTION .text + ;void vp8_short_walsh4x4_sse2(short *input, short *output, int pitch) + globalsym(vp8_short_walsh4x4_sse2) + sym(vp8_short_walsh4x4_sse2): ++ _endbr64 + push rbp + mov rbp, rsp + SHADOW_ARGS_TO_STACK 3 diff --git a/www/chromium/patches/patch-third_party_libvpx_source_libvpx_vpx_ports_aarch32_cpudetect_c b/www/chromium/patches/patch-third_party_libvpx_source_libvpx_vpx_ports_aarch32_cpudetect_c new file mode 100644 index 00000000000..56a8b681df7 --- /dev/null +++ b/www/chromium/patches/patch-third_party_libvpx_source_libvpx_vpx_ports_aarch32_cpudetect_c @@ -0,0 +1,25 @@ +Index: third_party/libvpx/source/libvpx/vpx_ports/aarch32_cpudetect.c +--- third_party/libvpx/source/libvpx/vpx_ports/aarch32_cpudetect.c.orig ++++ third_party/libvpx/source/libvpx/vpx_ports/aarch32_cpudetect.c +@@ -57,7 +57,7 @@ static int arm_get_cpu_caps(void) { + return flags; + } + +-#elif defined(__linux__) // end defined(VPX_USE_ANDROID_CPU_FEATURES) ++#elif defined(__linux__) || defined(__OpenBSD__) // end defined(VPX_USE_ANDROID_CPU_FEATURES) + + #include + +@@ -67,7 +67,12 @@ static int arm_get_cpu_caps(void) { + + static int arm_get_cpu_caps(void) { + int flags = 0; ++#ifdef __OpenBSD__ ++ unsigned long hwcap = 0; ++ elf_aux_info(AT_HWCAP, &hwcap, sizeof(hwcap)); ++#else + unsigned long hwcap = getauxval(AT_HWCAP); ++#endif + #if HAVE_NEON || HAVE_NEON_ASM + if (hwcap & VPX_AARCH32_HWCAP_NEON) { + flags |= HAS_NEON; diff --git a/www/chromium/patches/patch-third_party_libvpx_source_libvpx_vpx_ports_aarch64_cpudetect_c b/www/chromium/patches/patch-third_party_libvpx_source_libvpx_vpx_ports_aarch64_cpudetect_c index 2c68c8c3118..b52e351208d 100644 --- a/www/chromium/patches/patch-third_party_libvpx_source_libvpx_vpx_ports_aarch64_cpudetect_c +++ b/www/chromium/patches/patch-third_party_libvpx_source_libvpx_vpx_ports_aarch64_cpudetect_c @@ -1,28 +1,24 @@ Index: third_party/libvpx/source/libvpx/vpx_ports/aarch64_cpudetect.c --- third_party/libvpx/source/libvpx/vpx_ports/aarch64_cpudetect.c.orig +++ third_party/libvpx/source/libvpx/vpx_ports/aarch64_cpudetect.c -@@ -120,9 +120,23 @@ static int arm_get_cpu_caps(void) { - return flags; - } - --#elif defined(__linux__) // end defined(VPX_USE_ANDROID_CPU_FEATURES) -+#elif defined(__linux__) || defined(__FreeBSD__) // end defined(VPX_USE_ANDROID_CPU_FEATURES) - - #include -+ -+#if defined(__FreeBSD__) -+static unsigned long getauxval(unsigned long type) -+{ -+ /* Only AT_HWCAP* return unsigned long */ -+ if (type != AT_HWCAP && type != AT_HWCAP2) { -+ return 0; -+ } -+ -+ unsigned long ret = 0; -+ elf_aux_info(type, &ret, sizeof(ret)); -+ return ret; -+} +@@ -148,10 +148,20 @@ static unsigned long getauxval(unsigned long type) + static int arm_get_cpu_caps(void) { + int flags = 0; + #if HAVE_NEON_DOTPROD || HAVE_SVE ++#ifdef __OpenBSD__ ++ unsigned long hwcap = 0; ++ elf_aux_info(AT_HWCAP, &hwcap, sizeof(hwcap)); ++#else + unsigned long hwcap = getauxval(AT_HWCAP); +#endif - - // Define hwcap values ourselves: building with an old auxv header where these - // hwcap values are not defined should not prevent features from being enabled. + #endif // HAVE_NEON_DOTPROD || HAVE_SVE + #if HAVE_NEON_I8MM || HAVE_SVE2 ++#ifdef __OpenBSD__ ++ unsigned long hwcap2 = 0; ++ elf_aux_info(AT_HWCAP2, &hwcap2, sizeof(hwcap2)); ++#else + unsigned long hwcap2 = getauxval(AT_HWCAP2); ++#endif + #endif // HAVE_NEON_I8MM || HAVE_SVE2 + #if HAVE_NEON + flags |= HAS_NEON; // Neon is mandatory in Armv8.0-A. diff --git a/www/chromium/patches/patch-third_party_libvpx_source_libvpx_vpx_ports_ppc_cpudetect_c b/www/chromium/patches/patch-third_party_libvpx_source_libvpx_vpx_ports_ppc_cpudetect_c new file mode 100644 index 00000000000..d940286e545 --- /dev/null +++ b/www/chromium/patches/patch-third_party_libvpx_source_libvpx_vpx_ports_ppc_cpudetect_c @@ -0,0 +1,68 @@ +Index: third_party/libvpx/source/libvpx/vpx_ports/ppc_cpudetect.c +--- third_party/libvpx/source/libvpx/vpx_ports/ppc_cpudetect.c.orig ++++ third_party/libvpx/source/libvpx/vpx_ports/ppc_cpudetect.c +@@ -8,11 +8,8 @@ + * be found in the AUTHORS file in the root of the source tree. + */ + +-#include + #include + #include +-#include +-#include + + #include "./vpx_config.h" + #include "vpx_ports/ppc.h" +@@ -35,6 +32,12 @@ static int cpu_env_mask(void) { + return env && *env ? (int)strtol(env, NULL, 0) : ~0; + } + ++#if defined(__linux__) ++ ++#include ++#include ++#include ++ + int ppc_simd_caps(void) { + int flags; + int mask; +@@ -71,6 +74,39 @@ int ppc_simd_caps(void) { + } + out_close: + close(fd); ++ return flags & mask; ++} ++ ++#elif defined(__OpenBSD__) ++ ++#include ++ ++// Define hwcap values ourselves: building with an old auxv header where these ++// hwcap values are not defined should not prevent features from being enabled. ++#define VPX_PPC_HWCAP_VSX (1 << 7) ++ ++int ppc_simd_caps(void) { ++ int flags; ++ int mask; ++ ++ // If VPX_SIMD_CAPS is set then allow only those capabilities. ++ if (!cpu_env_flags(&flags)) { ++ return flags; ++ } ++ ++ mask = cpu_env_mask(); ++ ++#ifdef __OpenBSD__ ++ unsigned long hwcap = 0; ++ elf_aux_info(AT_HWCAP, &hwcap, sizeof(hwcap)); ++#else ++ unsigned long hwcap = getauxval(AT_HWCAP); ++#endif ++#if HAVE_VSX ++ if (hwcap & VPX_PPC_HWCAP_VSX) { ++ flags |= HAS_VSX; ++ } ++#endif // HAVE_VSX + return flags & mask; + } + #else diff --git a/www/chromium/patches/patch-third_party_libvpx_source_libvpx_vpx_ports_x86_abi_support_asm b/www/chromium/patches/patch-third_party_libvpx_source_libvpx_vpx_ports_x86_abi_support_asm new file mode 100644 index 00000000000..1678eadc130 --- /dev/null +++ b/www/chromium/patches/patch-third_party_libvpx_source_libvpx_vpx_ports_x86_abi_support_asm @@ -0,0 +1,17 @@ +Index: third_party/libvpx/source/libvpx/vpx_ports/x86_abi_support.asm +--- third_party/libvpx/source/libvpx/vpx_ports/x86_abi_support.asm.orig ++++ third_party/libvpx/source/libvpx/vpx_ports/x86_abi_support.asm +@@ -423,3 +423,13 @@ extern sym(rand) + %define LIBVPX_RAND rand + %endif + %endif ; CONFIG_POSTPROC || CONFIG_VP9_POSTPROC ++ ++%if VPX_ARCH_X86_64=1 ++%imacro _endbr64 0 ++ dd 0xfa1e0ff3 ++%endmacro ++%else ++%imacro _endbr64 0 ++; empty ++%endmacro ++%endif