[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [59180] trunk/blender: Make byte-float conversion threaded in compositor

Sergey Sharybin sergey.vfx at gmail.com
Fri Aug 16 12:01:09 CEST 2013


Revision: 59180
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=59180
Author:   nazgul
Date:     2013-08-16 10:01:09 +0000 (Fri, 16 Aug 2013)
Log Message:
-----------
Make byte-float conversion threaded in compositor

In fact, there's no need to get float buffer at all,
conversion could be done in pixel processor level
after interpolation.

It might give slightly worse interpolation results
(which i'm not sure would be visible by eye) but
it gives more than 2x speedup on my laptop on node
setups used for warping image.

--
svn merge -r58988:58989 ^/branches/soc-2011-tomato

Revision Links:
--------------
    http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=58988

Modified Paths:
--------------
    trunk/blender/source/blender/compositor/operations/COM_ImageOperation.cpp
    trunk/blender/source/blender/compositor/operations/COM_ImageOperation.h
    trunk/blender/source/blender/compositor/operations/COM_MultilayerImageOperation.cpp

Property Changed:
----------------
    trunk/blender/
    trunk/blender/source/blender/editors/interface/interface.c
    trunk/blender/source/blender/editors/space_outliner/


Property changes on: trunk/blender
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/ge_dev:58091-58422
/branches/ge_harmony:42255,42279-42282,42286,42302,42338,42349,42616,42620,42698-42699,42739,42753,42773-42774,42832,44568,44597-44598,44793-44794
/branches/soc-2011-cucumber:37517,38166-38167,38177,38179-38180,38187,38242,38384,38387,38403-38404,38407,38968,38970,38973,39045,40845,42997-42998,43439
/branches/soc-2011-tomato:42376,42378-42379,42383,42385,42395,42397-42400,42407,42411,42418,42443-42444,42446,42467,42472,42486,42650-42652,42654-42655,42709-42710,42733-42734,42801,43872,44130,44141,44147-44149,44151-44152,44229-44230,45623-45625,46037,48089,48092,48551-48552,48679,48790,48792-48793,49076,49087,49292,49294,49466,49894,50052,50126,52854-52856,54573,58822
/branches/soc-2013-depsgraph_mt:57516
/branches/soc-2013-dingto:57424,57487,57507,57525,57599,57670,57918-57919,57981,58091,58245,58253,58587,58772,58774-58775,58828,58835,59032
/tags/blender-2.67b-release/blender:57122
   + /branches/ge_dev:58091-58422
/branches/ge_harmony:42255,42279-42282,42286,42302,42338,42349,42616,42620,42698-42699,42739,42753,42773-42774,42832,44568,44597-44598,44793-44794
/branches/soc-2011-cucumber:37517,38166-38167,38177,38179-38180,38187,38242,38384,38387,38403-38404,38407,38968,38970,38973,39045,40845,42997-42998,43439
/branches/soc-2011-tomato:42376,42378-42379,42383,42385,42395,42397-42400,42407,42411,42418,42443-42444,42446,42467,42472,42486,42650-42652,42654-42655,42709-42710,42733-42734,42801,43872,44130,44141,44147-44149,44151-44152,44229-44230,45623-45625,46037,48089,48092,48551-48552,48679,48790,48792-48793,49076,49087,49292,49294,49466,49894,50052,50126,52854-52856,54573,58822,58989
/branches/soc-2013-depsgraph_mt:57516
/branches/soc-2013-dingto:57424,57487,57507,57525,57599,57670,57918-57919,57981,58091,58245,58253,58587,58772,58774-58775,58828,58835,59032
/tags/blender-2.67b-release/blender:57122

Modified: trunk/blender/source/blender/compositor/operations/COM_ImageOperation.cpp
===================================================================
--- trunk/blender/source/blender/compositor/operations/COM_ImageOperation.cpp	2013-08-16 09:58:00 UTC (rev 59179)
+++ trunk/blender/source/blender/compositor/operations/COM_ImageOperation.cpp	2013-08-16 10:01:09 UTC (rev 59180)
@@ -40,7 +40,8 @@
 {
 	this->m_image = NULL;
 	this->m_buffer = NULL;
-	this->m_imageBuffer = NULL;
+	this->m_imageFloatBuffer = NULL;
+	this->m_imageByteBuffer = NULL;
 	this->m_imageUser = NULL;
 	this->m_imagewidth = 0;
 	this->m_imageheight = 0;
@@ -70,10 +71,6 @@
 		BKE_image_release_ibuf(this->m_image, ibuf, NULL);
 		return NULL;
 	}
-	
-	if (ibuf->rect_float == NULL) {
-		IMB_float_from_rect(ibuf);
-	}
 	return ibuf;
 }
 
@@ -83,7 +80,8 @@
 	ImBuf *stackbuf = getImBuf();
 	this->m_buffer = stackbuf;
 	if (stackbuf) {
-		this->m_imageBuffer = stackbuf->rect_float;
+		this->m_imageFloatBuffer = stackbuf->rect_float;
+		this->m_imageByteBuffer = stackbuf->rect;
 		this->m_depthBuffer = stackbuf->zbuf_float;
 		this->m_imagewidth = stackbuf->x;
 		this->m_imageheight = stackbuf->y;
@@ -93,7 +91,8 @@
 
 void BaseImageOperation::deinitExecution()
 {
-	this->m_imageBuffer = NULL;
+	this->m_imageFloatBuffer = NULL;
+	this->m_imageByteBuffer = NULL;
 	BKE_image_release_ibuf(this->m_image, this->m_buffer, NULL);
 }
 
@@ -112,46 +111,61 @@
 	BKE_image_release_ibuf(this->m_image, stackbuf, NULL);
 }
 
-void ImageOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+static void sampleImageAtLocation(ImBuf *ibuf, float x, float y, PixelSampler sampler, bool make_linear_rgb, float color[4])
 {
-	if (this->m_imageBuffer == NULL || x < 0 || y < 0 || x >= this->getWidth() || y >= this->getHeight() ) {
-		zero_v4(output);
+	if (ibuf->rect_float) {
+		switch (sampler) {
+			case COM_PS_NEAREST:
+				nearest_interpolation_color(ibuf, NULL, color, x, y);
+				break;
+			case COM_PS_BILINEAR:
+				bilinear_interpolation_color(ibuf, NULL, color, x, y);
+				break;
+			case COM_PS_BICUBIC:
+				bicubic_interpolation_color(ibuf, NULL, color, x, y);
+				break;
+		}
 	}
 	else {
+		unsigned char byte_color[4];
 		switch (sampler) {
 			case COM_PS_NEAREST:
-				nearest_interpolation_color(this->m_buffer, NULL, output, x, y);
+				nearest_interpolation_color(ibuf, byte_color, NULL, x, y);
 				break;
 			case COM_PS_BILINEAR:
-				bilinear_interpolation_color(this->m_buffer, NULL, output, x, y);
+				bilinear_interpolation_color(ibuf, byte_color, NULL, x, y);
 				break;
 			case COM_PS_BICUBIC:
-				bicubic_interpolation_color(this->m_buffer, NULL, output, x, y);
+				bicubic_interpolation_color(ibuf, byte_color, NULL, x, y);
 				break;
 		}
+		rgba_uchar_to_float(color, byte_color);
+		if (make_linear_rgb) {
+			IMB_colormanagement_colorspace_to_scene_linear_v4(color, FALSE, ibuf->rect_colorspace);
+		}
 	}
 }
 
+void ImageOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+{
+	if ((this->m_imageFloatBuffer == NULL && this->m_imageByteBuffer == NULL) || x < 0 || y < 0 || x >= this->getWidth() || y >= this->getHeight() ) {
+		zero_v4(output);
+	}
+	else {
+		sampleImageAtLocation(this->m_buffer, x, y, sampler, true, output);
+	}
+}
+
 void ImageAlphaOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
 {
 	float tempcolor[4];
 
-	if (this->m_imageBuffer == NULL || x < 0 || y < 0 || x >= this->getWidth() || y >= this->getHeight() ) {
+	if ((this->m_imageFloatBuffer == NULL && this->m_imageByteBuffer == NULL) || x < 0 || y < 0 || x >= this->getWidth() || y >= this->getHeight() ) {
 		output[0] = 0.0f;
 	}
 	else {
 		tempcolor[3] = 1.0f;
-		switch (sampler) {
-			case COM_PS_NEAREST:
-				nearest_interpolation_color(this->m_buffer, NULL, tempcolor, x, y);
-				break;
-			case COM_PS_BILINEAR:
-				bilinear_interpolation_color(this->m_buffer, NULL, tempcolor, x, y);
-				break;
-			case COM_PS_BICUBIC:
-				bicubic_interpolation_color(this->m_buffer, NULL, tempcolor, x, y);
-				break;
-		}
+		sampleImageAtLocation(this->m_buffer, x, y, sampler, false, tempcolor);
 		output[0] = tempcolor[3];
 	}
 }

Modified: trunk/blender/source/blender/compositor/operations/COM_ImageOperation.h
===================================================================
--- trunk/blender/source/blender/compositor/operations/COM_ImageOperation.h	2013-08-16 09:58:00 UTC (rev 59179)
+++ trunk/blender/source/blender/compositor/operations/COM_ImageOperation.h	2013-08-16 10:01:09 UTC (rev 59180)
@@ -42,7 +42,8 @@
 	ImBuf *m_buffer;
 	Image *m_image;
 	ImageUser *m_imageUser;
-	float *m_imageBuffer;
+	float *m_imageFloatBuffer;
+	unsigned int *m_imageByteBuffer;
 	float *m_depthBuffer;
 	int m_imageheight;
 	int m_imagewidth;

Modified: trunk/blender/source/blender/compositor/operations/COM_MultilayerImageOperation.cpp
===================================================================
--- trunk/blender/source/blender/compositor/operations/COM_MultilayerImageOperation.cpp	2013-08-16 09:58:00 UTC (rev 59179)
+++ trunk/blender/source/blender/compositor/operations/COM_MultilayerImageOperation.cpp	2013-08-16 10:01:09 UTC (rev 59180)
@@ -47,7 +47,7 @@
 {
 	int yi = y;
 	int xi = x;
-	if (this->m_imageBuffer == NULL || xi < 0 || yi < 0 || (unsigned int)xi >= this->getWidth() || (unsigned int)yi >= this->getHeight() ) {
+	if (this->m_imageFloatBuffer == NULL || xi < 0 || yi < 0 || (unsigned int)xi >= this->getWidth() || (unsigned int)yi >= this->getHeight() ) {
 		zero_v4(output);
 	}
 	else {
@@ -66,7 +66,7 @@
 		}
 		else {
 			int offset = (yi * this->getWidth() + xi) * 3;
-			copy_v3_v3(output, &this->m_imageBuffer[offset]);
+			copy_v3_v3(output, &this->m_imageFloatBuffer[offset]);
 		}
 	}
 }
@@ -75,11 +75,11 @@
 {
 	int yi = y;
 	int xi = x;
-	if (this->m_imageBuffer == NULL || xi < 0 || yi < 0 || (unsigned int)xi >= this->getWidth() || (unsigned int)yi >= this->getHeight() ) {
+	if (this->m_imageFloatBuffer == NULL || xi < 0 || yi < 0 || (unsigned int)xi >= this->getWidth() || (unsigned int)yi >= this->getHeight() ) {
 		output[0] = 0.0f;
 	}
 	else {
-		float result = this->m_imageBuffer[yi * this->getWidth() + xi];
+		float result = this->m_imageFloatBuffer[yi * this->getWidth() + xi];
 		output[0] = result;
 	}
 }
@@ -88,11 +88,11 @@
 {
 	int yi = y;
 	int xi = x;
-	if (this->m_imageBuffer == NULL || xi < 0 || yi < 0 || (unsigned int)xi >= this->getWidth() || (unsigned int)yi >= this->getHeight() ) {
+	if (this->m_imageFloatBuffer == NULL || xi < 0 || yi < 0 || (unsigned int)xi >= this->getWidth() || (unsigned int)yi >= this->getHeight() ) {
 		output[0] = 0.0f;
 	}
 	else {
 		int offset = (yi * this->getWidth() + xi) * 3;
-		copy_v3_v3(output, &this->m_imageBuffer[offset]);
+		copy_v3_v3(output, &this->m_imageFloatBuffer[offset]);
 	}
 }


Property changes on: trunk/blender/source/blender/editors/interface/interface.c
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/ge_candy/source/blender/editors/interface/interface.c:45070-46163
/branches/ge_harmony/source/blender/editors/interface/interface.c:42255,42279-42282,42286,42302,42338,42349,42616,42620,42698-42699,42739,42753,42773-42774,42832,44568,44597-44598,44793-44794
/branches/soc-2011-cucumber/source/blender/editors/interface/interface.c:37517,38166-38167,38177,38179-38180,38187,38242,38384,38387,38403-38404,38407,38968,38970,38973,39045,40845,42997-42998,43439
/branches/soc-2011-tomato/source/blender/editors/interface/interface.c:42376,42378-42379,42383,42385,42395,42397-42400,42407,42411,42418,42443-42444,42446,42467,42472,42486,42650-42652,42654-42655,42709-42710,42733-42734,42801,43872,44130,44141,44147-44149,44151-44152,44229-44230,45623-45625,46037,48089,48092,48551-48552,48679,48790,48792-48793,49076,49087,49292,49294,49466,49894,50052,50126,52854-52856,54573,58822
/branches/soc-2013-depsgraph_mt/source/blender/editors/interface/interface.c:57516
   + /branches/ge_candy/source/blender/editors/interface/interface.c:45070-46163
/branches/ge_harmony/source/blender/editors/interface/interface.c:42255,42279-42282,42286,42302,42338,42349,42616,42620,42698-42699,42739,42753,42773-42774,42832,44568,44597-44598,44793-44794

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list