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-05-05 23:44:33 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2012-05-05 23:44:33 +0400
commit8103381ded923a097eae5a0ba012ae41847a83ad (patch)
treeb2d224fac3262dea4eca154480f26bdd10662c81 /intern/cycles/render/image.cpp
parentc53fe94bb4973362278b488ef26384a029d3cc69 (diff)
Cycles: threading optimizations
* Multithreaded image loading, each thread can load a separate image. * Better multithreading for multiple instanced meshes, different threads can now build BVH's for different meshes, rather than all cooperating on the same mesh. Especially noticeable for dynamic BVH building for the viewport, gave about 2x faster build on 8 core in fairly complex scene with many objects. * The main thread waiting for worker threads can now also work itself, so (num_cores + 1) threads will be working, this supposedly gives better performance on some operating systems, but did not measure performance for this very detailed yet.
Diffstat (limited to 'intern/cycles/render/image.cpp')
-rw-r--r--intern/cycles/render/image.cpp54
1 files changed, 31 insertions, 23 deletions
diff --git a/intern/cycles/render/image.cpp b/intern/cycles/render/image.cpp
index 78b8f06c7b4..3e6052338c0 100644
--- a/intern/cycles/render/image.cpp
+++ b/intern/cycles/render/image.cpp
@@ -324,8 +324,10 @@ bool ImageManager::file_load_float_image(Image *img, device_vector<float4>& tex_
return true;
}
-void ImageManager::device_load_image(Device *device, DeviceScene *dscene, int slot)
+void ImageManager::device_load_image(Device *device, DeviceScene *dscene, int slot, Progress *progress)
{
+ if(progress->get_cancel())
+ return;
if(osl_texture_system)
return;
@@ -342,6 +344,9 @@ void ImageManager::device_load_image(Device *device, DeviceScene *dscene, int sl
}
if(is_float) {
+ string filename = path_filename(float_images[slot]->filename);
+ progress->set_status("Updating Images", "Loading " + filename);
+
device_vector<float4>& tex_img = dscene->tex_float_image[slot - TEX_IMAGE_FLOAT_START];
if(tex_img.device_pointer)
@@ -365,6 +370,9 @@ void ImageManager::device_load_image(Device *device, DeviceScene *dscene, int sl
device->tex_alloc(name.c_str(), tex_img, true, true);
}
else {
+ string filename = path_filename(images[slot]->filename);
+ progress->set_status("Updating Images", "Loading " + filename);
+
device_vector<uchar4>& tex_img = dscene->tex_image[slot];
if(tex_img.device_pointer)
@@ -387,6 +395,8 @@ void ImageManager::device_load_image(Device *device, DeviceScene *dscene, int sl
device->tex_alloc(name.c_str(), tex_img, true, true);
}
+
+ img->need_load = false;
}
void ImageManager::device_free_image(Device *device, DeviceScene *dscene, int slot)
@@ -431,39 +441,37 @@ void ImageManager::device_update(Device *device, DeviceScene *dscene, Progress&
{
if(!need_update)
return;
+
+ TaskPool pool;
for(size_t slot = 0; slot < images.size(); slot++) {
- if(images[slot]) {
- if(images[slot]->users == 0) {
- device_free_image(device, dscene, slot);
- }
- else if(images[slot]->need_load) {
- string name = path_filename(images[slot]->filename);
- progress.set_status("Updating Images", "Loading " + name);
- device_load_image(device, dscene, slot);
- images[slot]->need_load = false;
- }
+ if(!images[slot])
+ continue;
- if(progress.get_cancel()) return;
+ if(images[slot]->users == 0) {
+ device_free_image(device, dscene, slot);
+ }
+ else if(images[slot]->need_load) {
+ if(!osl_texture_system)
+ pool.push(function_bind(&ImageManager::device_load_image, this, device, dscene, slot, &progress));
}
}
for(size_t slot = 0; slot < float_images.size(); slot++) {
- if(float_images[slot]) {
- if(float_images[slot]->users == 0) {
- device_free_image(device, dscene, slot + TEX_IMAGE_FLOAT_START);
- }
- else if(float_images[slot]->need_load) {
- string name = path_filename(float_images[slot]->filename);
- progress.set_status("Updating Images", "Loading " + name);
- device_load_image(device, dscene, slot + TEX_IMAGE_FLOAT_START);
- float_images[slot]->need_load = false;
- }
+ if(!float_images[slot])
+ continue;
- if(progress.get_cancel()) return;
+ if(float_images[slot]->users == 0) {
+ device_free_image(device, dscene, slot + TEX_IMAGE_FLOAT_START);
+ }
+ else if(float_images[slot]->need_load) {
+ if(!osl_texture_system)
+ pool.push(function_bind(&ImageManager::device_load_image, this, device, dscene, slot + TEX_IMAGE_FLOAT_START, &progress));
}
}
+ pool.wait_work();
+
need_update = false;
}