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:
Diffstat (limited to 'intern/cycles/device/device_memory.h')
-rw-r--r--intern/cycles/device/device_memory.h20
1 files changed, 17 insertions, 3 deletions
diff --git a/intern/cycles/device/device_memory.h b/intern/cycles/device/device_memory.h
index a2866ae3984..453dab9bfb3 100644
--- a/intern/cycles/device/device_memory.h
+++ b/intern/cycles/device/device_memory.h
@@ -243,15 +243,29 @@ public:
free();
}
- void alloc_to_device(size_t num)
+ void alloc_to_device(size_t num, bool shrink_to_fit = true)
{
- data_size = num*sizeof(T);
- device_alloc();
+ size_t new_size = num*sizeof(T);
+ bool reallocate;
+
+ if(shrink_to_fit) {
+ reallocate = (data_size != new_size);
+ }
+ else {
+ reallocate = (data_size < new_size);
+ }
+
+ if(reallocate) {
+ device_free();
+ data_size = new_size;
+ device_alloc();
+ }
}
void free()
{
device_free();
+ data_size = 0;
}
void zero_to_device()