summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'media-libs')
-rw-r--r--media-libs/opensubdiv/files/opensubdiv-3.4.4-tbb-2021.patch65
-rw-r--r--media-libs/opensubdiv/opensubdiv-3.4.4-r3.ebuild94
2 files changed, 159 insertions, 0 deletions
diff --git a/media-libs/opensubdiv/files/opensubdiv-3.4.4-tbb-2021.patch b/media-libs/opensubdiv/files/opensubdiv-3.4.4-tbb-2021.patch
new file mode 100644
index 000000000000..bae9c4a9d1f1
--- /dev/null
+++ b/media-libs/opensubdiv/files/opensubdiv-3.4.4-tbb-2021.patch
@@ -0,0 +1,65 @@
+https://github.com/PixarAnimationStudios/OpenSubdiv/pull/1234
+https://bugs.gentoo.org/820824
+
+From 7375c99a4d1337f9b79775fb2c753e7865968642 Mon Sep 17 00:00:00 2001
+From: Artur Sinila <freesoftware@logarithmus.dev>
+Date: Sun, 25 Jul 2021 20:34:48 +0300
+Subject: [PATCH 1/2] Fix typo: schedular -> scheduler
+
+---
+ opensubdiv/osd/tbbEvaluator.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/opensubdiv/osd/tbbEvaluator.h b/opensubdiv/osd/tbbEvaluator.h
+index 6bd365bc5..886a94837 100644
+--- a/opensubdiv/osd/tbbEvaluator.h
++++ b/opensubdiv/osd/tbbEvaluator.h
+@@ -1226,7 +1226,7 @@ class TbbEvaluator {
+ /// \brief synchronize all asynchronous computation invoked on this device.
+ static void Synchronize(void *deviceContext = NULL);
+
+- /// \brief initialize tbb task schedular
++ /// \brief initialize tbb task scheduler
+ /// (optional: client may use tbb::task_scheduler_init)
+ ///
+ /// @param numThreads how many threads
+
+From 9079a517f406afba9ea50657b0a0786ad7a7bdcb Mon Sep 17 00:00:00 2001
+From: Artur Sinila <freesoftware@logarithmus.dev>
+Date: Sun, 25 Jul 2021 20:58:27 +0300
+Subject: [PATCH 2/2] Support oneTBB 2021
+
+---
+ opensubdiv/osd/tbbEvaluator.cpp | 12 +++++++-----
+ 1 file changed, 7 insertions(+), 5 deletions(-)
+
+diff --git a/opensubdiv/osd/tbbEvaluator.cpp b/opensubdiv/osd/tbbEvaluator.cpp
+index c98db9f6d..66c2ed58f 100644
+--- a/opensubdiv/osd/tbbEvaluator.cpp
++++ b/opensubdiv/osd/tbbEvaluator.cpp
+@@ -25,7 +25,8 @@
+ #include "../osd/tbbEvaluator.h"
+ #include "../osd/tbbKernel.h"
+
+-#include <tbb/task_scheduler_init.h>
++#define TBB_PREVIEW_GLOBAL_CONTROL true
++#include <tbb/global_control.h>
+
+ namespace OpenSubdiv {
+ namespace OPENSUBDIV_VERSION {
+@@ -215,10 +216,11 @@ TbbEvaluator::Synchronize(void *) {
+ /* static */
+ void
+ TbbEvaluator::SetNumThreads(int numThreads) {
+- if (numThreads == -1) {
+- tbb::task_scheduler_init init;
+- } else {
+- tbb::task_scheduler_init init(numThreads);
++ if (numThreads != -1) {
++ tbb::global_control tbb_global_control(
++ tbb::global_control::max_allowed_parallelism,
++ numThreads
++ );
+ }
+ }
+
diff --git a/media-libs/opensubdiv/opensubdiv-3.4.4-r3.ebuild b/media-libs/opensubdiv/opensubdiv-3.4.4-r3.ebuild
new file mode 100644
index 000000000000..524b64930836
--- /dev/null
+++ b/media-libs/opensubdiv/opensubdiv-3.4.4-r3.ebuild
@@ -0,0 +1,94 @@
+# Copyright 1999-2022 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+CMAKE_MAKEFILE_GENERATOR=emake
+
+inherit cmake cuda toolchain-funcs
+
+MY_PV="$(ver_rs "1-3" '_')"
+DESCRIPTION="An Open-Source subdivision surface library"
+HOMEPAGE="https://graphics.pixar.com/opensubdiv/docs/intro.html"
+SRC_URI="https://github.com/PixarAnimationStudios/OpenSubdiv/archive/v${MY_PV}.tar.gz -> ${P}.tar.gz"
+S="${WORKDIR}/OpenSubdiv-${MY_PV}"
+
+# Modfied Apache-2.0 license, where section 6 has been replaced.
+# See for example CMakeLists.txt for details.
+LICENSE="Apache-2.0"
+SLOT="0"
+KEYWORDS="~amd64 ~arm ~arm64 ~x86"
+IUSE="cuda examples opencl openmp ptex tbb test tutorials"
+RESTRICT="!test? ( test )"
+
+RDEPEND="
+ media-libs/glew:=
+ media-libs/glfw:=
+ x11-libs/libXinerama
+ cuda? ( dev-util/nvidia-cuda-toolkit:* )
+ opencl? ( virtual/opencl )
+ ptex? ( media-libs/ptex )
+"
+DEPEND="
+ ${RDEPEND}
+ tbb? ( dev-cpp/tbb:= )
+"
+
+PATCHES=(
+ "${FILESDIR}/${PN}-3.3.0-use-gnuinstalldirs.patch"
+ "${FILESDIR}/${PN}-3.4.3-install-tutorials-into-bin.patch"
+ "${FILESDIR}/${P}-add-CUDA11-compatibility.patch"
+ "${FILESDIR}/${PN}-3.4.4-tbb-2021.patch"
+)
+
+pkg_pretend() {
+ [[ ${MERGE_TYPE} != binary ]] && use openmp && tc-check-openmp
+}
+
+pkg_setup() {
+ [[ ${MERGE_TYPE} != binary ]] && use openmp && tc-check-openmp
+}
+
+src_prepare() {
+ cmake_src_prepare
+
+ use cuda && cuda_src_prepare
+}
+
+src_configure() {
+ # GLTESTS are disabled as portage is unable to open a display during test phase
+ # TODO: virtx work?
+ local mycmakeargs=(
+ -DGLEW_LOCATION="${ESYSROOT}/usr/$(get_libdir)"
+ -DGLFW_LOCATION="${ESYSROOT}/usr/$(get_libdir)"
+ -DNO_CLEW=ON
+ -DNO_CUDA=$(usex !cuda)
+ # Docs needed Python 2 so disabled
+ # bug #815172
+ -DNO_DOC=ON
+ -DNO_EXAMPLES=$(usex !examples)
+ -DNO_GLTESTS=ON
+ -DNO_OMP=$(usex !openmp)
+ -DNO_OPENCL=$(usex !opencl)
+ -DNO_PTEX=$(usex !ptex)
+ -DNO_REGRESSION=$(usex !test)
+ -DNO_TBB=$(usex !tbb)
+ -DNO_TESTS=$(usex !test)
+ -DNO_TUTORIALS=$(usex !tutorials)
+ )
+
+ if use cuda; then
+ # old cmake CUDA module doesn't use environment variable to initialize flags
+ mycmakeargs+=( -DCUDA_NVCC_FLAGS="${NVCCFLAGS}" )
+
+ # check if user provided --gpu-architecture/-arch flag and prevent cmake from overriding it if so
+ for f in ${NVCCFLAGS}; do
+ if [[ ${f} == -arch* || ${f} == --gpu-architecture* ]]; then
+ mycmakeargs+=( -DOSD_CUDA_NVCC_FLAGS="" )
+ break
+ fi
+ done
+ fi
+
+ cmake_src_configure
+}