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:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2012-12-23 16:53:58 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2012-12-23 16:53:58 +0400
commit35c0b821a5b8d13079cbdf8258391c59d7043082 (patch)
treeb9030d29a8b19aae22121c411783e2be511889b7
parent779662aff7e815962b43eacff46c9a5710c48e3f (diff)
Cycles: deal a bit better with errors when CUDA runs out of memory, try to avoid crashes.
-rw-r--r--intern/cycles/device/device.h1
-rw-r--r--intern/cycles/device/device_cuda.cpp40
2 files changed, 34 insertions, 7 deletions
diff --git a/intern/cycles/device/device.h b/intern/cycles/device/device.h
index 9840687b76a..7b31b9ba157 100644
--- a/intern/cycles/device/device.h
+++ b/intern/cycles/device/device.h
@@ -84,6 +84,7 @@ public:
/* info */
DeviceInfo info;
virtual const string& error_message() { return error_msg; }
+ bool have_error() { return !error_message().empty(); }
/* statistics */
Stats &stats;
diff --git a/intern/cycles/device/device_cuda.cpp b/intern/cycles/device/device_cuda.cpp
index 14f8cfa8767..040f3044457 100644
--- a/intern/cycles/device/device_cuda.cpp
+++ b/intern/cycles/device/device_cuda.cpp
@@ -124,7 +124,7 @@ public:
if(error_msg == "") \
error_msg = message; \
fprintf(stderr, "%s\n", message.c_str()); \
- cuda_abort(); \
+ /*cuda_abort();*/ \
} \
}
@@ -326,7 +326,8 @@ public:
void mem_copy_to(device_memory& mem)
{
cuda_push_context();
- cuda_assert(cuMemcpyHtoD(cuda_device_ptr(mem.device_pointer), (void*)mem.data_pointer, mem.memory_size()))
+ if(mem.device_pointer)
+ cuda_assert(cuMemcpyHtoD(cuda_device_ptr(mem.device_pointer), (void*)mem.data_pointer, mem.memory_size()))
cuda_pop_context();
}
@@ -336,8 +337,13 @@ public:
size_t size = elem*w*h;
cuda_push_context();
- cuda_assert(cuMemcpyDtoH((uchar*)mem.data_pointer + offset,
- (CUdeviceptr)((uchar*)mem.device_pointer + offset), size))
+ if(mem.device_pointer) {
+ cuda_assert(cuMemcpyDtoH((uchar*)mem.data_pointer + offset,
+ (CUdeviceptr)((uchar*)mem.device_pointer + offset), size))
+ }
+ else {
+ memset((char*)mem.data_pointer + offset, 0, size);
+ }
cuda_pop_context();
}
@@ -346,7 +352,8 @@ public:
memset((void*)mem.data_pointer, 0, mem.memory_size());
cuda_push_context();
- cuda_assert(cuMemsetD8(cuda_device_ptr(mem.device_pointer), 0, mem.memory_size()))
+ if(mem.device_pointer)
+ cuda_assert(cuMemsetD8(cuda_device_ptr(mem.device_pointer), 0, mem.memory_size()))
cuda_pop_context();
}
@@ -390,13 +397,18 @@ public:
default: assert(0); return;
}
- CUtexref texref;
+ CUtexref texref = NULL;
cuda_push_context();
cuda_assert(cuModuleGetTexRef(&texref, cuModule, name))
+ if(!texref) {
+ cuda_pop_context();
+ return;
+ }
+
if(interpolation) {
- CUarray handle;
+ CUarray handle = NULL;
CUDA_ARRAY_DESCRIPTOR desc;
desc.Width = mem.data_width;
@@ -406,6 +418,11 @@ public:
cuda_assert(cuArrayCreate(&handle, &desc))
+ if(!handle) {
+ cuda_pop_context();
+ return;
+ }
+
if(mem.data_height > 1) {
CUDA_MEMCPY2D param;
memset(&param, 0, sizeof(param));
@@ -481,6 +498,9 @@ public:
void path_trace(RenderTile& rtile, int sample)
{
+ if(have_error())
+ return;
+
cuda_push_context();
CUfunction cuPathTrace;
@@ -546,6 +566,9 @@ public:
void tonemap(DeviceTask& task, device_ptr buffer, device_ptr rgba)
{
+ if(have_error())
+ return;
+
cuda_push_context();
CUfunction cuFilmConvert;
@@ -615,6 +638,9 @@ public:
void shader(DeviceTask& task)
{
+ if(have_error())
+ return;
+
cuda_push_context();
CUfunction cuDisplace;