[Bf-blender-cvs] [06e64058dd6] master: Removing OMP: BKE's mask_rasterize.c

Bastien Montagne noreply at git.blender.org
Sun Nov 26 20:28:13 CET 2017


Commit: 06e64058dd687634b6bf873dbf21c6d3563ed6c9
Author: Bastien Montagne
Date:   Sun Nov 26 19:06:26 2017 +0100
Branches: master
https://developer.blender.org/rB06e64058dd687634b6bf873dbf21c6d3563ed6c9

Removing OMP: BKE's mask_rasterize.c

Once again nothing much to say here, except that whole mask rendering
process from VSE is about 25% quicker now. ;)

===================================================================

M	source/blender/blenkernel/intern/mask_rasterize.c

===================================================================

diff --git a/source/blender/blenkernel/intern/mask_rasterize.c b/source/blender/blenkernel/intern/mask_rasterize.c
index 13ec970c65c..4c0cc131440 100644
--- a/source/blender/blenkernel/intern/mask_rasterize.c
+++ b/source/blender/blenkernel/intern/mask_rasterize.c
@@ -80,6 +80,7 @@
 
 #include "BLI_math.h"
 #include "BLI_rect.h"
+#include "BLI_task.h"
 #include "BLI_listbase.h"
 #include "BLI_linklist.h"
 
@@ -1423,6 +1424,37 @@ float BKE_maskrasterize_handle_sample(MaskRasterHandle *mr_handle, const float x
 	return value;
 }
 
+
+typedef struct MaskRasterizeBufferData {
+	MaskRasterHandle *mr_handle;
+	float x_inv, y_inv;
+	float x_px_ofs, y_px_ofs;
+	uint width;
+
+	float *buffer;
+} MaskRasterizeBufferData;
+
+static void maskrasterize_buffer_cb(void *userdata, int y)
+{
+	MaskRasterizeBufferData *data = userdata;
+
+	MaskRasterHandle *mr_handle = data->mr_handle;
+	float *buffer = data->buffer;
+
+	const uint width = data->width;
+	const float x_inv = data->x_inv;
+	const float x_px_ofs = data->x_px_ofs;
+
+	uint i = (uint)y * width;
+	float xy[2];
+	xy[1] = ((float)y * data->y_inv) + data->y_px_ofs;
+	for (uint x = 0; x < width; x++, i++) {
+		xy[0] = ((float)x * x_inv) + x_px_ofs;
+
+		buffer[i] = BKE_maskrasterize_handle_sample(mr_handle, xy);
+	}
+}
+
 /**
  * \brief Rasterize a buffer from a single mask
  *
@@ -1439,33 +1471,15 @@ void BKE_maskrasterize_buffer(MaskRasterHandle *mr_handle,
 {
 	const float x_inv = 1.0f / (float)width;
 	const float y_inv = 1.0f / (float)height;
-	const float x_px_ofs = x_inv * 0.5f;
-	const float y_px_ofs = y_inv * 0.5f;
-#ifdef _MSC_VER
-	int y;  /* msvc requires signed for some reason */
-
-	/* ignore sign mismatch */
-#  pragma warning(push)
-#  pragma warning(disable:4018)
-#else
-	unsigned int y;
-#endif
-
-#pragma omp parallel for private(y)
-	for (y = 0; y < height; y++) {
-		unsigned int i = y * width;
-		unsigned int x;
-		float xy[2];
-		xy[1] = ((float)y * y_inv) + y_px_ofs;
-		for (x = 0; x < width; x++, i++) {
-			xy[0] = ((float)x * x_inv) + x_px_ofs;
-
-			buffer[i] = BKE_maskrasterize_handle_sample(mr_handle, xy);
-		}
-	}
-
-#ifdef _MSC_VER
-#  pragma warning(pop)
-#endif
 
+	MaskRasterizeBufferData data = {
+	    .mr_handle = mr_handle,
+	    .x_inv = x_inv,
+	    .y_inv = y_inv,
+	    .x_px_ofs = x_inv * 0.5f,
+	    .y_px_ofs = y_inv * 0.5f,
+	    .width = width,
+	    .buffer = buffer
+	};
+	BLI_task_parallel_range(0, (int)height, &data, maskrasterize_buffer_cb, height * width > 10000);
 }



More information about the Bf-blender-cvs mailing list