From 7b30a3e98def6f9f158da0e315b7077655acfd20 Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Fri, 11 Jun 2021 15:55:09 +0200 Subject: Performance: Use parallel range for ImBuf scanline processor. Scanline processor did its own heurestic what didn't scale well when having a multiple cores. In stead of using our own code this patch will leave it to TBB to determine how to split the scanlines over the available threads. Performance of the IMB_transform before this change was 0.002123s, with this change 0.001601s. This change increases performance in other areas as well including color management conversions. Reviewed By: zeddb Differential Revision: https://developer.blender.org/D11578 --- source/blender/blenkernel/intern/image_gen.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'source/blender/blenkernel/intern/image_gen.c') diff --git a/source/blender/blenkernel/intern/image_gen.c b/source/blender/blenkernel/intern/image_gen.c index ceb13c4955e..1a0cc8c2924 100644 --- a/source/blender/blenkernel/intern/image_gen.c +++ b/source/blender/blenkernel/intern/image_gen.c @@ -69,10 +69,11 @@ static void image_buf_fill_color_slice( } } -static void image_buf_fill_color_thread_do(void *data_v, int start_scanline, int num_scanlines) +static void image_buf_fill_color_thread_do(void *data_v, int scanline) { FillColorThreadData *data = (FillColorThreadData *)data_v; - size_t offset = ((size_t)start_scanline) * data->width * 4; + const int num_scanlines = 1; + size_t offset = ((size_t)scanline) * data->width * 4; unsigned char *rect = (data->rect != NULL) ? (data->rect + offset) : NULL; float *rect_float = (data->rect_float != NULL) ? (data->rect_float + offset) : NULL; image_buf_fill_color_slice(rect, rect_float, data->width, num_scanlines, data->color); @@ -197,13 +198,14 @@ typedef struct FillCheckerThreadData { int width; } FillCheckerThreadData; -static void image_buf_fill_checker_thread_do(void *data_v, int start_scanline, int num_scanlines) +static void image_buf_fill_checker_thread_do(void *data_v, int scanline) { FillCheckerThreadData *data = (FillCheckerThreadData *)data_v; - size_t offset = ((size_t)start_scanline) * data->width * 4; + size_t offset = ((size_t)scanline) * data->width * 4; + const int num_scanlines = 1; unsigned char *rect = (data->rect != NULL) ? (data->rect + offset) : NULL; float *rect_float = (data->rect_float != NULL) ? (data->rect_float + offset) : NULL; - image_buf_fill_checker_slice(rect, rect_float, data->width, num_scanlines, start_scanline); + image_buf_fill_checker_slice(rect, rect_float, data->width, num_scanlines, scanline); } void BKE_image_buf_fill_checker(unsigned char *rect, float *rect_float, int width, int height) @@ -444,16 +446,15 @@ typedef struct FillCheckerColorThreadData { int width, height; } FillCheckerColorThreadData; -static void checker_board_color_prepare_thread_do(void *data_v, - int start_scanline, - int num_scanlines) +static void checker_board_color_prepare_thread_do(void *data_v, int scanline) { FillCheckerColorThreadData *data = (FillCheckerColorThreadData *)data_v; - size_t offset = ((size_t)data->width) * start_scanline * 4; + const int num_scanlines = 1; + size_t offset = ((size_t)data->width) * scanline * 4; unsigned char *rect = (data->rect != NULL) ? (data->rect + offset) : NULL; float *rect_float = (data->rect_float != NULL) ? (data->rect_float + offset) : NULL; checker_board_color_prepare_slice( - rect, rect_float, data->width, num_scanlines, start_scanline, data->height); + rect, rect_float, data->width, num_scanlines, scanline, data->height); } void BKE_image_buf_fill_checker_color(unsigned char *rect, -- cgit v1.2.3