[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43743] trunk/blender/intern/cycles: Cycles: another fix for CUDA render passes, needed to align float4 passes.

Brecht Van Lommel brechtvanlommel at pandora.be
Fri Jan 27 14:58:41 CET 2012


Revision: 43743
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43743
Author:   blendix
Date:     2012-01-27 13:58:32 +0000 (Fri, 27 Jan 2012)
Log Message:
-----------
Cycles: another fix for CUDA render passes, needed to align float4 passes.

Modified Paths:
--------------
    trunk/blender/intern/cycles/device/device_cuda.cpp
    trunk/blender/intern/cycles/render/buffers.cpp
    trunk/blender/intern/cycles/render/film.cpp
    trunk/blender/intern/cycles/util/util_types.h

Modified: trunk/blender/intern/cycles/device/device_cuda.cpp
===================================================================
--- trunk/blender/intern/cycles/device/device_cuda.cpp	2012-01-27 09:03:47 UTC (rev 43742)
+++ trunk/blender/intern/cycles/device/device_cuda.cpp	2012-01-27 13:58:32 UTC (rev 43743)
@@ -106,11 +106,6 @@
 		}
 	}
 
-	static int cuda_align_up(int& offset, int alignment)
-	{
-		return (offset + alignment - 1) & ~(alignment - 1);
-	}
-
 #ifdef NDEBUG
 #define cuda_abort()
 #else
@@ -485,7 +480,7 @@
 		offset += sizeof(d_rng_state);
 
 		int sample = task.sample;
-		offset = cuda_align_up(offset, __alignof(sample));
+		offset = align_up(offset, __alignof(sample));
 
 		cuda_assert(cuParamSeti(cuPathTrace, offset, task.sample))
 		offset += sizeof(task.sample);
@@ -549,7 +544,7 @@
 		offset += sizeof(d_buffer);
 
 		int sample = task.sample;
-		offset = cuda_align_up(offset, __alignof(sample));
+		offset = align_up(offset, __alignof(sample));
 
 		cuda_assert(cuParamSeti(cuFilmConvert, offset, task.sample))
 		offset += sizeof(task.sample);
@@ -618,7 +613,7 @@
 		offset += sizeof(d_offset);
 
 		int shader_eval_type = task.shader_eval_type;
-		offset = cuda_align_up(offset, __alignof(shader_eval_type));
+		offset = align_up(offset, __alignof(shader_eval_type));
 
 		cuda_assert(cuParamSeti(cuDisplace, offset, task.shader_eval_type))
 		offset += sizeof(task.shader_eval_type);

Modified: trunk/blender/intern/cycles/render/buffers.cpp
===================================================================
--- trunk/blender/intern/cycles/render/buffers.cpp	2012-01-27 09:03:47 UTC (rev 43742)
+++ trunk/blender/intern/cycles/render/buffers.cpp	2012-01-27 13:58:32 UTC (rev 43743)
@@ -71,7 +71,7 @@
 	foreach(Pass& pass, passes)
 		size += pass.components;
 	
-	return size;
+	return align_up(size, 4);
 }
 
 /* Render Buffers */

Modified: trunk/blender/intern/cycles/render/film.cpp
===================================================================
--- trunk/blender/intern/cycles/render/film.cpp	2012-01-27 09:03:47 UTC (rev 43742)
+++ trunk/blender/intern/cycles/render/film.cpp	2012-01-27 13:58:32 UTC (rev 43743)
@@ -21,12 +21,20 @@
 #include "film.h"
 #include "scene.h"
 
+#include "util_algorithm.h"
 #include "util_foreach.h"
 
 CCL_NAMESPACE_BEGIN
 
 /* Pass */
 
+static bool compare_pass_order(const Pass& a, const Pass& b)
+{
+	if(a.components == b.components)
+		return (a.type < b.type);
+	return (a.components > b.components);
+}
+
 void Pass::add(PassType type, vector<Pass>& passes)
 {
 	Pass pass;
@@ -106,6 +114,10 @@
 	}
 
 	passes.push_back(pass);
+
+	/* order from by components, to ensure alignment so passes with size 4
+	   come first and then passes with size 1 */
+	sort(passes.begin(), passes.end(), compare_pass_order);
 }
 
 bool Pass::equals(const vector<Pass>& A, const vector<Pass>& B)
@@ -219,6 +231,8 @@
 		kfilm->pass_stride += pass.components;
 	}
 
+	kfilm->pass_stride = align_up(kfilm->pass_stride, 4);
+
 	need_update = false;
 }
 

Modified: trunk/blender/intern/cycles/util/util_types.h
===================================================================
--- trunk/blender/intern/cycles/util/util_types.h	2012-01-27 09:03:47 UTC (rev 43742)
+++ trunk/blender/intern/cycles/util/util_types.h	2012-01-27 13:58:32 UTC (rev 43743)
@@ -277,6 +277,11 @@
 	return a;
 }
 
+__device int align_up(int offset, int alignment)
+{
+	return (offset + alignment - 1) & ~(alignment - 1);
+}
+
 #endif
 
 CCL_NAMESPACE_END



More information about the Bf-blender-cvs mailing list