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:
authorSergey Sharybin <sergey.vfx@gmail.com>2016-05-06 00:33:40 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2016-05-06 00:47:22 +0300
commit9b89071c9cdd2a341ba16db44cd4625303fb6e2f (patch)
treed7cc4e415a8df68f080705051b9cb64b72b46399 /source/blender/imbuf
parent3064270e132693d1dce1f273381a3120b3953d90 (diff)
Multi-thread generated image creation
Gives about 2x speedup on laptop when creating new hires generated image, regardless of it's type (color, color grid, uv grid).
Diffstat (limited to 'source/blender/imbuf')
-rw-r--r--source/blender/imbuf/IMB_imbuf.h3
-rw-r--r--source/blender/imbuf/intern/divers.c70
2 files changed, 73 insertions, 0 deletions
diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h
index 2c97d9bc21f..383a5f19c4a 100644
--- a/source/blender/imbuf/IMB_imbuf.h
+++ b/source/blender/imbuf/IMB_imbuf.h
@@ -439,6 +439,9 @@ void IMB_buffer_float_from_byte(float *rect_to, const unsigned char *rect_from,
void IMB_buffer_float_from_float(float *rect_to, const float *rect_from,
int channels_from, int profile_to, int profile_from, bool predivide,
int width, int height, int stride_to, int stride_from);
+void IMB_buffer_float_from_float_threaded(float *rect_to, const float *rect_from,
+ int channels_from, int profile_to, int profile_from, bool predivide,
+ int width, int height, int stride_to, int stride_from);
void IMB_buffer_float_from_float_mask(float *rect_to, const float *rect_from,
int channels_from, int width, int height, int stride_to, int stride_from, char *mask);
void IMB_buffer_byte_from_byte(unsigned char *rect_to, const unsigned char *rect_from,
diff --git a/source/blender/imbuf/intern/divers.c b/source/blender/imbuf/intern/divers.c
index 3aabf7e18cc..62fd623ecfa 100644
--- a/source/blender/imbuf/intern/divers.c
+++ b/source/blender/imbuf/intern/divers.c
@@ -532,6 +532,76 @@ void IMB_buffer_float_from_float(float *rect_to, const float *rect_from,
}
}
+typedef struct FloatToFloatThreadData {
+ float *rect_to;
+ const float *rect_from;
+ int channels_from;
+ int profile_to;
+ int profile_from;
+ bool predivide;
+ int width;
+ int stride_to;
+ int stride_from;
+} FloatToFloatThreadData;
+
+static void imb_buffer_float_from_float_thread_do(void *data_v,
+ int start_scanline,
+ int num_scanlines)
+{
+ FloatToFloatThreadData *data = (FloatToFloatThreadData *)data_v;
+ size_t offset_from = ((size_t)start_scanline) * data->stride_from * data->channels_from;
+ size_t offset_to = ((size_t)start_scanline) * data->stride_to * data->channels_from;
+ IMB_buffer_float_from_float(data->rect_to + offset_to,
+ data->rect_from + offset_from,
+ data->channels_from,
+ data->profile_to,
+ data->profile_from,
+ data->predivide,
+ data->width,
+ num_scanlines,
+ data->stride_to,
+ data->stride_from);
+}
+
+void IMB_buffer_float_from_float_threaded(float *rect_to,
+ const float *rect_from,
+ int channels_from,
+ int profile_to,
+ int profile_from,
+ bool predivide,
+ int width,
+ int height,
+ int stride_to,
+ int stride_from)
+{
+ if (((size_t)width) * height < 64 * 64) {
+ IMB_buffer_float_from_float(rect_to,
+ rect_from,
+ channels_from,
+ profile_to,
+ profile_from,
+ predivide,
+ width,
+ height,
+ stride_to,
+ stride_from);
+ }
+ else {
+ FloatToFloatThreadData data;
+ data.rect_to = rect_to;
+ data.rect_from = rect_from;
+ data.channels_from = channels_from;
+ data.profile_to = profile_to;
+ data.profile_from = profile_from;
+ data.predivide = predivide;
+ data.width = width;
+ data.stride_to = stride_to;
+ data.stride_from = stride_from;
+ IMB_processor_apply_threaded_scanlines(
+ height, imb_buffer_float_from_float_thread_do, &data);
+ }
+}
+
/* float to float pixels, output 4-channel RGBA */
void IMB_buffer_float_from_float_mask(float *rect_to, const float *rect_from, int channels_from,
int width, int height, int stride_to, int stride_from, char *mask)