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@gmail.com>2017-11-08 22:15:38 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2017-11-09 22:28:00 +0300
commitbd4bea3e98a436521f9a7effcfed19cdf46eadfb (patch)
treee3dea019f996d610fc5bb14281930213f648497a /intern/cycles/device/device_memory.h
parentdf886b178c9c176eefb73617c997f85e9d750c2d (diff)
Cycles: avoid reallocating tile denoising memory many times during render.
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()