Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2016-01-14 10:24:09 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2016-01-14 10:27:22 +0300
commit2af7637f207c420af602f43e514b1b20e7cfc718 (patch)
tree10508ea78dd73df4625119d29d00d98a81d23030 /intern/cycles/device/device_cuda.cpp
parentd67535eea00b2d9f2b75e99d45f7f200bdc642d6 (diff)
Cycles: Add option to directly link against CUDA libraries
The main purpose of such linking is to make Blender compatible with NVidia's debuggers and profilers which are doing some LD_PRELOAD magic to intercept some function calls. Such magic conflicts with our CUDA wrangler magic and causes segmentation faults. The option is disabled by default, so there's no affect on any of artists. In order to make Blender linked directly against CUDA library use the WITH_CUDA_DYNLOAD CMake option (it's marked as advanced).
Diffstat (limited to 'intern/cycles/device/device_cuda.cpp')
-rw-r--r--intern/cycles/device/device_cuda.cpp46
1 files changed, 45 insertions, 1 deletions
diff --git a/intern/cycles/device/device_cuda.cpp b/intern/cycles/device/device_cuda.cpp
index 5c9ca3454c6..88f1a86d6ac 100644
--- a/intern/cycles/device/device_cuda.cpp
+++ b/intern/cycles/device/device_cuda.cpp
@@ -23,7 +23,13 @@
#include "buffers.h"
-#include "cuew.h"
+#ifdef WITH_CUDA_DYNLOAD
+# include "cuew.h"
+#else
+# include "util_opengl.h"
+# include <cuda.h>
+# include <cudaGL.h>
+#endif
#include "util_debug.h"
#include "util_logging.h"
#include "util_map.h"
@@ -42,6 +48,40 @@
CCL_NAMESPACE_BEGIN
+#ifndef WITH_CUDA_DYNLOAD
+
+/* Transparently implement some functions, so majority of the file does not need
+ * to worry about difference between dynamically loaded and linked CUDA at all.
+ */
+
+namespace {
+
+const char *cuewErrorString(CUresult result)
+{
+ /* We can only give error code here without major code duplication, that
+ * should be enough since dynamic loading is only being disabled by folks
+ * who knows what they're doing anyway.
+ *
+ * NOTE: Avoid call from several threads.
+ */
+ static string error;
+ error = string_printf("%d", result);
+ return error.c_str();
+}
+
+const char *cuewCompilerPath(void)
+{
+ return CYCLES_CUDA_NVCC_EXECUTABLE;
+}
+
+int cuewCompilerVersion(void)
+{
+ return (CUDA_VERSION / 100) + (CUDA_VERSION % 100 / 10);
+}
+
+} /* namespace */
+#endif /* WITH_CUDA_DYNLOAD */
+
class CUDADevice : public Device
{
public:
@@ -1100,6 +1140,7 @@ public:
bool device_cuda_init(void)
{
+#ifdef WITH_CUDA_DYNLOAD
static bool initialized = false;
static bool result = false;
@@ -1133,6 +1174,9 @@ bool device_cuda_init(void)
}
return result;
+#else /* WITH_CUDA_DYNLOAD */
+ return true;
+#endif /* WITH_CUDA_DYNLOAD */
}
Device *device_cuda_create(DeviceInfo& info, Stats &stats, bool background)