summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/gfx/cuda/cuda-device.cpp3
-rw-r--r--tools/gfx/cuda/cuda-helper-functions.h13
2 files changed, 15 insertions, 1 deletions
diff --git a/tools/gfx/cuda/cuda-device.cpp b/tools/gfx/cuda/cuda-device.cpp
index 129ea793f..be190babf 100644
--- a/tools/gfx/cuda/cuda-device.cpp
+++ b/tools/gfx/cuda/cuda-device.cpp
@@ -180,8 +180,9 @@ SLANG_NO_THROW SlangResult SLANG_MCALL DeviceImpl::initialize(const Desc& desc)
SLANG_CUDA_RETURN_ON_FAIL(cuDeviceGet(&m_device, m_deviceIndex));
+ // Use version-aware context creation that works with both CUDA 12 and CUDA 13
SLANG_CUDA_RETURN_WITH_REPORT_ON_FAIL(
- cuCtxCreate(&m_context->m_context, 0, m_device),
+ createCudaContext(&m_context->m_context, 0, m_device),
reportType);
{
diff --git a/tools/gfx/cuda/cuda-helper-functions.h b/tools/gfx/cuda/cuda-helper-functions.h
index 8474e830d..2b2614bb0 100644
--- a/tools/gfx/cuda/cuda-helper-functions.h
+++ b/tools/gfx/cuda/cuda-helper-functions.h
@@ -99,6 +99,19 @@ void _optixLogCallback(unsigned int level, const char* tag, const char* message,
AdapterLUID getAdapterLUID(int deviceIndex);
+// Version-aware cuCtxCreate wrapper that works with both CUDA 12 and CUDA 13
+inline CUresult createCudaContext(CUcontext* pctx, unsigned int flags, CUdevice dev)
+{
+#if CUDA_VERSION >= 13000
+ // CUDA 13+ requires CUctxCreateParams
+ CUctxCreateParams ctxCreateParams = {};
+ return cuCtxCreate(pctx, &ctxCreateParams, flags, dev);
+#else
+ // CUDA 12 and earlier use the old signature
+ return cuCtxCreate(pctx, flags, dev);
+#endif
+}
+
} // namespace cuda
#endif