[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43734] trunk/blender/intern/cycles: Cycles: render passes for CUDA cards with compute model >= 2.x.

Brecht Van Lommel brechtvanlommel at pandora.be
Thu Jan 26 20:07:11 CET 2012


Revision: 43734
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43734
Author:   blendix
Date:     2012-01-26 19:07:01 +0000 (Thu, 26 Jan 2012)
Log Message:
-----------
Cycles: render passes for CUDA cards with compute model >= 2.x.

Modified Paths:
--------------
    trunk/blender/intern/cycles/blender/blender_session.cpp
    trunk/blender/intern/cycles/device/device.cpp
    trunk/blender/intern/cycles/device/device.h
    trunk/blender/intern/cycles/device/device_cpu.cpp
    trunk/blender/intern/cycles/device/device_cuda.cpp
    trunk/blender/intern/cycles/device/device_multi.cpp
    trunk/blender/intern/cycles/device/device_network.cpp
    trunk/blender/intern/cycles/device/device_opencl.cpp
    trunk/blender/intern/cycles/kernel/kernel_passes.h
    trunk/blender/intern/cycles/kernel/kernel_types.h
    trunk/blender/intern/cycles/render/buffers.cpp
    trunk/blender/intern/cycles/render/svm.cpp

Modified: trunk/blender/intern/cycles/blender/blender_session.cpp
===================================================================
--- trunk/blender/intern/cycles/blender/blender_session.cpp	2012-01-26 17:11:43 UTC (rev 43733)
+++ trunk/blender/intern/cycles/blender/blender_session.cpp	2012-01-26 19:07:01 UTC (rev 43734)
@@ -206,7 +206,7 @@
 		vector<Pass> passes;
 		Pass::add(PASS_COMBINED, passes);
 
-		if(session_params.device.type == DEVICE_CPU) { /* todo */
+		if(session_params.device.advanced_shading) {
 			BL::RenderLayer::passes_iterator b_pass_iter;
 			
 			for(b_rlay.passes.begin(b_pass_iter); b_pass_iter != b_rlay.passes.end(); ++b_pass_iter) {

Modified: trunk/blender/intern/cycles/device/device.cpp
===================================================================
--- trunk/blender/intern/cycles/device/device.cpp	2012-01-26 17:11:43 UTC (rev 43733)
+++ trunk/blender/intern/cycles/device/device.cpp	2012-01-26 19:07:01 UTC (rev 43734)
@@ -183,6 +183,9 @@
 			return NULL;
 	}
 
+	if(device)
+		device->info = info;
+
 	return device;
 }
 

Modified: trunk/blender/intern/cycles/device/device.h
===================================================================
--- trunk/blender/intern/cycles/device/device.h	2012-01-26 17:11:43 UTC (rev 43733)
+++ trunk/blender/intern/cycles/device/device.h	2012-01-26 19:07:01 UTC (rev 43734)
@@ -51,6 +51,7 @@
 	string id;
 	int num;
 	bool display_device;
+	bool advanced_shading;
 	vector<DeviceInfo> multi_devices;
 
 	DeviceInfo()
@@ -59,6 +60,7 @@
 		id = "CPU";
 		num = 0;
 		display_device = false;
+		advanced_shading = true;
 	}
 };
 
@@ -101,10 +103,8 @@
 public:
 	virtual ~Device() {}
 
-	virtual bool support_full_kernel() = 0;
-
 	/* info */
-	virtual string description() = 0;
+	DeviceInfo info;
 	virtual const string& error_message() { return error_msg; }
 
 	/* regular memory */

Modified: trunk/blender/intern/cycles/device/device_cpu.cpp
===================================================================
--- trunk/blender/intern/cycles/device/device_cpu.cpp	2012-01-26 17:11:43 UTC (rev 43733)
+++ trunk/blender/intern/cycles/device/device_cpu.cpp	2012-01-26 19:07:01 UTC (rev 43734)
@@ -72,16 +72,11 @@
 		kernel_globals_free(kg);
 	}
 
-	bool support_full_kernel()
+	bool support_advanced_shading()
 	{
 		return true;
 	}
 
-	string description()
-	{
-		return system_cpu_brand_string();
-	}
-
 	void mem_alloc(device_memory& mem, MemoryType type)
 	{
 		mem.device_pointer = mem.data_pointer;
@@ -271,6 +266,7 @@
 	info.description = system_cpu_brand_string();
 	info.id = "CPU";
 	info.num = 0;
+	info.advanced_shading = true;
 
 	devices.insert(devices.begin(), info);
 }

Modified: trunk/blender/intern/cycles/device/device_cuda.cpp
===================================================================
--- trunk/blender/intern/cycles/device/device_cuda.cpp	2012-01-26 17:11:43 UTC (rev 43733)
+++ trunk/blender/intern/cycles/device/device_cuda.cpp	2012-01-26 19:07:01 UTC (rev 43734)
@@ -194,26 +194,6 @@
 		cuda_assert(cuCtxDetach(cuContext))
 	}
 
-	bool support_full_kernel()
-	{
-		int major, minor;
-		cuDeviceComputeCapability(&major, &minor, cuDevId);
-
-		return (major >= 2);
-	}
-
-	string description()
-	{
-		/* print device information */
-		char deviceName[256];
-
-		cuda_push_context();
-		cuDeviceGetName(deviceName, 256, cuDevId);
-		cuda_pop_context();
-
-		return string("CUDA ") + deviceName;
-	}
-
 	bool support_device(bool experimental)
 	{
 		if(!experimental) {
@@ -881,6 +861,10 @@
 		info.id = string_printf("CUDA_%d", num);
 		info.num = num;
 
+		int major, minor;
+		cuDeviceComputeCapability(&major, &minor, num);
+		info.advanced_shading = (major >= 2);
+
 		/* if device has a kernel timeout, assume it is used for display */
 		if(cuDeviceGetAttribute(&attr, CU_DEVICE_ATTRIBUTE_KERNEL_EXEC_TIMEOUT, num) == CUDA_SUCCESS && attr == 1) {
 			info.display_device = true;

Modified: trunk/blender/intern/cycles/device/device_multi.cpp
===================================================================
--- trunk/blender/intern/cycles/device/device_multi.cpp	2012-01-26 17:11:43 UTC (rev 43733)
+++ trunk/blender/intern/cycles/device/device_multi.cpp	2012-01-26 19:07:01 UTC (rev 43734)
@@ -76,16 +76,6 @@
 			delete sub.device;
 	}
 
-	bool support_full_kernel()
-	{
-		foreach(SubDevice& sub, devices) {
-			if(!sub.device->support_full_kernel())
-				return false;
-		}
-
-		return true;
-	}
-
 	const string& error_message()
 	{
 		foreach(SubDevice& sub, devices) {
@@ -99,38 +89,6 @@
 		return error_msg;
 	}
 
-	string description()
-	{
-		/* create map to find duplicate descriptions */
-		map<string, int> dupli_map;
-		map<string, int>::iterator dt;
-
-		foreach(SubDevice& sub, devices) {
-			string key = sub.device->description();
-
-			if(dupli_map.find(key) == dupli_map.end())
-				dupli_map[key] = 1;
-			else
-				dupli_map[key]++;
-		}
-
-		/* generate string */
-		stringstream desc;
-		bool first = true;
-
-		for(dt = dupli_map.begin(); dt != dupli_map.end(); dt++) {
-			if(!first) desc << ", ";
-			first = false;
-
-			if(dt->second > 1)
-				desc << dt->second << "x " << dt->first;
-			else
-				desc << dt->first;
-		}
-
-		return desc.str();
-	}
-
 	bool load_kernels(bool experimental)
 	{
 		foreach(SubDevice& sub, devices)
@@ -344,6 +302,8 @@
 	map<string, int>::iterator dt;
 	int num_added = 0, num_display = 0;
 
+	info.advanced_shading = true;
+
 	foreach(DeviceInfo& subinfo, devices) {
 		if(subinfo.type == type) {
 			if(subinfo.display_device) {
@@ -363,6 +323,8 @@
 			info.multi_devices.push_back(subinfo);
 			if(subinfo.display_device)
 				info.display_device = true;
+			if(!subinfo.advanced_shading)
+				info.advanced_shading = false;
 			num_added++;
 		}
 	}

Modified: trunk/blender/intern/cycles/device/device_network.cpp
===================================================================
--- trunk/blender/intern/cycles/device/device_network.cpp	2012-01-26 17:11:43 UTC (rev 43733)
+++ trunk/blender/intern/cycles/device/device_network.cpp	2012-01-26 19:07:01 UTC (rev 43734)
@@ -57,24 +57,6 @@
 	{
 	}
 
-	bool support_full_kernel()
-	{
-		return false;
-	}
-
-	string description()
-	{
-		RPCSend snd(socket, "description");
-		snd.write();
-
-		RPCReceive rcv(socket);
-		string desc_string;
-
-		*rcv.archive & desc_string;
-
-		return desc_string + " (remote)";
-	}
-
 	void mem_alloc(device_memory& mem, MemoryType type)
 	{
 #if 0

Modified: trunk/blender/intern/cycles/device/device_opencl.cpp
===================================================================
--- trunk/blender/intern/cycles/device/device_opencl.cpp	2012-01-26 17:11:43 UTC (rev 43733)
+++ trunk/blender/intern/cycles/device/device_opencl.cpp	2012-01-26 19:07:01 UTC (rev 43734)
@@ -453,20 +453,6 @@
 			clReleaseContext(cxContext);
 	}
 
-	bool support_full_kernel()
-	{
-		return false;
-	}
-
-	string description()
-	{
-		char name[1024];
-
-		clGetDeviceInfo(cdDevice, CL_DEVICE_NAME, sizeof(name), &name, NULL);
-
-		return string("OpenCL ") + name;
-	}
-
 	void mem_alloc(device_memory& mem, MemoryType type)
 	{
 		size_t size = mem.memory_size();
@@ -750,6 +736,7 @@
 		info.num = num;
 		/* we don't know if it's used for display, but assume it is */
 		info.display_device = true;
+		info.advanced_shading = false;
 
 		devices.push_back(info);
 	}

Modified: trunk/blender/intern/cycles/kernel/kernel_passes.h
===================================================================
--- trunk/blender/intern/cycles/kernel/kernel_passes.h	2012-01-26 17:11:43 UTC (rev 43733)
+++ trunk/blender/intern/cycles/kernel/kernel_passes.h	2012-01-26 19:07:01 UTC (rev 43734)
@@ -36,7 +36,7 @@
 	*buf = (sample == 0)? value: *buf + value;
 }
 
-__device void kernel_write_data_passes(KernelGlobals *kg, __global float *buffer, PathRadiance *L,
+__device_inline void kernel_write_data_passes(KernelGlobals *kg, __global float *buffer, PathRadiance *L,
 	ShaderData *sd, int sample, int path_flag, float3 throughput)
 {
 #ifdef __PASSES__
@@ -86,7 +86,7 @@
 #endif
 }
 
-__device void kernel_write_light_passes(KernelGlobals *kg, __global float *buffer, PathRadiance *L, int sample)
+__device_inline void kernel_write_light_passes(KernelGlobals *kg, __global float *buffer, PathRadiance *L, int sample)
 {
 #ifdef __PASSES__
 	int flag = kernel_data.film.pass_flag;

Modified: trunk/blender/intern/cycles/kernel/kernel_types.h
===================================================================
--- trunk/blender/intern/cycles/kernel/kernel_types.h	2012-01-26 17:11:43 UTC (rev 43733)
+++ trunk/blender/intern/cycles/kernel/kernel_types.h	2012-01-26 19:07:01 UTC (rev 43734)
@@ -185,6 +185,9 @@
 struct PathRadiance {
 	int use_light_pass;
 
+	float3 emission;
+	float3 background;
+
 	float3 indirect;
 	float3 direct_throughput;
 	float3 direct_emission;
@@ -200,9 +203,6 @@
 	float3 indirect_diffuse;
 	float3 indirect_glossy;
 	float3 indirect_transmission;
-
-	float3 emission;
-	float3 background;
 };
 
 struct BsdfEval {

Modified: trunk/blender/intern/cycles/render/buffers.cpp
===================================================================
--- trunk/blender/intern/cycles/render/buffers.cpp	2012-01-26 17:11:43 UTC (rev 43733)
+++ trunk/blender/intern/cycles/render/buffers.cpp	2012-01-26 19:07:01 UTC (rev 43734)
@@ -130,7 +130,7 @@
 	if(!buffer.device_pointer)
 		return false;
 
-	device->mem_copy_from(buffer, 0, params.width, params.height, sizeof(float4));
+	device->mem_copy_from(buffer, 0, params.width, params.height, params.get_passes_size()*sizeof(float));
 
 	return true;
 }

Modified: trunk/blender/intern/cycles/render/svm.cpp
===================================================================
--- trunk/blender/intern/cycles/render/svm.cpp	2012-01-26 17:11:43 UTC (rev 43733)
+++ trunk/blender/intern/cycles/render/svm.cpp	2012-01-26 19:07:01 UTC (rev 43734)
@@ -58,7 +58,7 @@
 	}
 	
 	bool sunsky_done = false;
-	bool use_multi_closure = device->support_full_kernel();
+	bool use_multi_closure = device->info.advanced_shading;
 
 	for(i = 0; i < scene->shaders.size(); i++) {
 		Shader *shader = scene->shaders[i];



More information about the Bf-blender-cvs mailing list