commit:     0ef4aa73c14bdf1caa82a1befdac214cb6542729
Author:     Paul Zander <negril.nx+gentoo <AT> gmail <DOT> com>
AuthorDate: Tue May 20 15:32:25 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Thu May 22 16:07:14 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=0ef4aa73

media-libs/opencv: fix build with cuda-12.9

Signed-off-by: Paul Zander <negril.nx+gentoo <AT> gmail.com>
Part-of: https://github.com/gentoo/gentoo/pull/42202
Signed-off-by: Sam James <sam <AT> gentoo.org>

 .../opencv/files/opencv-4.11.0-cuda-12.9.patch     | 65 ++++++++++++++++++++++
 media-libs/opencv/opencv-4.11.0.ebuild             |  2 +
 2 files changed, 67 insertions(+)

diff --git a/media-libs/opencv/files/opencv-4.11.0-cuda-12.9.patch 
b/media-libs/opencv/files/opencv-4.11.0-cuda-12.9.patch
new file mode 100644
index 000000000000..006d88295195
--- /dev/null
+++ b/media-libs/opencv/files/opencv-4.11.0-cuda-12.9.patch
@@ -0,0 +1,65 @@
+From 8a2903c190fd41b2ac4255c436fddf1dd58dacde Mon Sep 17 00:00:00 2001
+From: ruisv <[email protected]>
+Date: Tue, 6 May 2025 23:47:12 +0800
+Subject: [PATCH 1/2] =?UTF-8?q?CUDA=E2=80=AF12.9=20support:=20build?=
+ =?UTF-8?q?=E2=80=AFNppStreamContext=E2=80=AFmanually?=
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+---
+ .../core/include/opencv2/core/private.cuda.hpp | 18 +++++++++++++++++-
+ 1 file changed, 17 insertions(+), 1 deletion(-)
+
+diff --git a/modules/core/include/opencv2/core/private.cuda.hpp 
b/modules/core/include/opencv2/core/private.cuda.hpp
+index 39f2ddcdeb3d..a9029131fbfa 100644
+--- a/modules/core/include/opencv2/core/private.cuda.hpp
++++ b/modules/core/include/opencv2/core/private.cuda.hpp
+@@ -147,7 +147,23 @@ namespace cv { namespace cuda
+         inline explicit NppStreamHandler(cudaStream_t newStream)
+         {
+             nppStreamContext = {};
+-            nppSafeCall(nppGetStreamContext(&nppStreamContext));
++            #if CUDA_VERSION < 12090
++                nppSafeCall(nppGetStreamContext(&nppStreamContext));
++            #else
++                int device = 0;
++                cudaSafeCall(cudaGetDevice(&device));
++
++                cudaDeviceProp prop{};
++                cudaSafeCall(cudaGetDeviceProperties(&prop, device));
++                
++                nppStreamContext.nCudaDeviceId = device;
++                nppStreamContext.nMultiProcessorCount = 
prop.multiProcessorCount;
++                nppStreamContext.nMaxThreadsPerMultiProcessor = 
prop.maxThreadsPerMultiProcessor;
++                nppStreamContext.nMaxThreadsPerBlock = 
prop.maxThreadsPerBlock;
++                nppStreamContext.nSharedMemPerBlock = prop.sharedMemPerBlock;
++                nppStreamContext.nCudaDevAttrComputeCapabilityMajor = 
prop.major;
++                nppStreamContext.nCudaDevAttrComputeCapabilityMinor = 
prop.minor;
++            #endif
+             nppStreamContext.hStream = newStream;
+             cudaSafeCall(cudaStreamGetFlags(nppStreamContext.hStream, 
&nppStreamContext.nStreamFlags));
+         }
+
+From 9ab3a249c2509e969ae12190400b22ded775108d Mon Sep 17 00:00:00 2001
+From: ruisv <[email protected]>
+Date: Wed, 7 May 2025 11:46:43 +0800
+Subject: [PATCH 2/2] remove private.cuda.hpp:158 space
+
+---
+ modules/core/include/opencv2/core/private.cuda.hpp | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/modules/core/include/opencv2/core/private.cuda.hpp 
b/modules/core/include/opencv2/core/private.cuda.hpp
+index a9029131fbfa..4250f6103302 100644
+--- a/modules/core/include/opencv2/core/private.cuda.hpp
++++ b/modules/core/include/opencv2/core/private.cuda.hpp
+@@ -155,7 +155,7 @@ namespace cv { namespace cuda
+ 
+                 cudaDeviceProp prop{};
+                 cudaSafeCall(cudaGetDeviceProperties(&prop, device));
+-                
++
+                 nppStreamContext.nCudaDeviceId = device;
+                 nppStreamContext.nMultiProcessorCount = 
prop.multiProcessorCount;
+                 nppStreamContext.nMaxThreadsPerMultiProcessor = 
prop.maxThreadsPerMultiProcessor;

diff --git a/media-libs/opencv/opencv-4.11.0.ebuild 
b/media-libs/opencv/opencv-4.11.0.ebuild
index b8cdff13f89d..9830992ab4f8 100644
--- a/media-libs/opencv/opencv-4.11.0.ebuild
+++ b/media-libs/opencv/opencv-4.11.0.ebuild
@@ -383,6 +383,8 @@ PATCHES=(
 
        "${FILESDIR}"/${PN}-4.11.0-fix-libspng-link.patch #  PR pending #27314
 
+       "${FILESDIR}/${PN}-4.11.0-cuda-12.9.patch" # PR 27288
+
        # TODO applied in src_prepare
        # "${FILESDIR}/${PN}_contrib-4.8.1-rgbd.patch"
 

Reply via email to