diff options
Diffstat (limited to 'intern/cycles/render')
-rw-r--r-- | intern/cycles/render/image.cpp | 59 | ||||
-rw-r--r-- | intern/cycles/render/image.h | 5 |
2 files changed, 41 insertions, 23 deletions
diff --git a/intern/cycles/render/image.cpp b/intern/cycles/render/image.cpp index cfdf26c6787..80ec77f8b4a 100644 --- a/intern/cycles/render/image.cpp +++ b/intern/cycles/render/image.cpp @@ -716,7 +716,12 @@ void ImageManager::device_load_image(Device *device, if(dscene->tex_float4_image[slot] == NULL) dscene->tex_float4_image[slot] = new device_vector<float4>(); device_vector<float4>& tex_img = *dscene->tex_float4_image[slot]; - device_tex_free_safe(device, tex_img); + + if(tex_img.device_pointer) { + thread_scoped_lock device_lock(device_mutex); + device->tex_free(tex_img); + } + if(!file_load_image<TypeDesc::FLOAT, float>(img, type, texture_limit, @@ -743,7 +748,12 @@ void ImageManager::device_load_image(Device *device, if(dscene->tex_float_image[slot] == NULL) dscene->tex_float_image[slot] = new device_vector<float>(); device_vector<float>& tex_img = *dscene->tex_float_image[slot]; - device_tex_free_safe(device, tex_img); + + if(tex_img.device_pointer) { + thread_scoped_lock device_lock(device_mutex); + device->tex_free(tex_img); + } + if(!file_load_image<TypeDesc::FLOAT, float>(img, type, texture_limit, @@ -767,7 +777,12 @@ void ImageManager::device_load_image(Device *device, if(dscene->tex_byte4_image[slot] == NULL) dscene->tex_byte4_image[slot] = new device_vector<uchar4>(); device_vector<uchar4>& tex_img = *dscene->tex_byte4_image[slot]; - device_tex_free_safe(device, tex_img); + + if(tex_img.device_pointer) { + thread_scoped_lock device_lock(device_mutex); + device->tex_free(tex_img); + } + if(!file_load_image<TypeDesc::UINT8, uchar>(img, type, texture_limit, @@ -794,7 +809,12 @@ void ImageManager::device_load_image(Device *device, if(dscene->tex_byte_image[slot] == NULL) dscene->tex_byte_image[slot] = new device_vector<uchar>(); device_vector<uchar>& tex_img = *dscene->tex_byte_image[slot]; - device_tex_free_safe(device, tex_img); + + if(tex_img.device_pointer) { + thread_scoped_lock device_lock(device_mutex); + device->tex_free(tex_img); + } + if(!file_load_image<TypeDesc::UINT8, uchar>(img, type, texture_limit, @@ -817,7 +837,12 @@ void ImageManager::device_load_image(Device *device, if(dscene->tex_half4_image[slot] == NULL) dscene->tex_half4_image[slot] = new device_vector<half4>(); device_vector<half4>& tex_img = *dscene->tex_half4_image[slot]; - device_tex_free_safe(device, tex_img); + + if(tex_img.device_pointer) { + thread_scoped_lock device_lock(device_mutex); + device->tex_free(tex_img); + } + if(!file_load_image<TypeDesc::HALF, half>(img, type, texture_limit, @@ -843,7 +868,12 @@ void ImageManager::device_load_image(Device *device, if(dscene->tex_half_image[slot] == NULL) dscene->tex_half_image[slot] = new device_vector<half>(); device_vector<half>& tex_img = *dscene->tex_half_image[slot]; - device_tex_free_safe(device, tex_img); + + if(tex_img.device_pointer) { + thread_scoped_lock device_lock(device_mutex); + device->tex_free(tex_img); + } + if(!file_load_image<TypeDesc::HALF, half>(img, type, texture_limit, @@ -927,7 +957,11 @@ void ImageManager::device_free_image(Device *device, DeviceScene *dscene, ImageD tex_img = NULL; } if(tex_img) { - device_tex_free_safe(device, *tex_img); + if(tex_img->device_pointer) { + thread_scoped_lock device_lock(device_mutex); + device->tex_free(*tex_img); + } + delete tex_img; } } @@ -1063,16 +1097,5 @@ void ImageManager::device_free(Device *device, DeviceScene *dscene) dscene->tex_half_image.clear(); } -void ImageManager::device_tex_free_safe(Device *device, device_memory& mem) -{ - if(mem.device_pointer) { - thread_scoped_lock device_lock(device_mutex); - device->tex_free(mem); - } - else { - device->tex_free(mem); - } -} - CCL_NAMESPACE_END diff --git a/intern/cycles/render/image.h b/intern/cycles/render/image.h index abd1abbd729..c86d1cbedbf 100644 --- a/intern/cycles/render/image.h +++ b/intern/cycles/render/image.h @@ -160,11 +160,6 @@ private: DeviceScene *dscene, ImageDataType type, int slot); - - /* Will do locking when needed and make sure possible memory manager from - * the device implementation is aware of freed texture. - */ - void device_tex_free_safe(Device *device, device_memory& mem); }; CCL_NAMESPACE_END |