[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [57169] trunk/blender/intern/cycles/device /device_opencl.cpp: Fix another windows / msvc build error.

Brecht Van Lommel brechtvanlommel at pandora.be
Sat Jun 1 04:39:36 CEST 2013


Revision: 57169
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=57169
Author:   blendix
Date:     2013-06-01 02:39:34 +0000 (Sat, 01 Jun 2013)
Log Message:
-----------
Fix another windows / msvc build error.

Modified Paths:
--------------
    trunk/blender/intern/cycles/device/device_opencl.cpp

Modified: trunk/blender/intern/cycles/device/device_opencl.cpp
===================================================================
--- trunk/blender/intern/cycles/device/device_opencl.cpp	2013-06-01 02:28:57 UTC (rev 57168)
+++ trunk/blender/intern/cycles/device/device_opencl.cpp	2013-06-01 02:39:34 UTC (rev 57169)
@@ -172,7 +172,7 @@
 	 * default constructed thread_scoped_lock */
 	template<typename T>
 	static T get_something(cl_platform_id platform, cl_device_id device,
-		T Slot::*member, cl_int (*retain_func)(T), thread_scoped_lock &slot_locker)
+		T Slot::*member, thread_scoped_lock &slot_locker)
 	{
 		assert(platform != NULL);
 
@@ -204,18 +204,13 @@
 		/* the item was already cached, release the slot lock */
 		slot_locker.unlock();
 
-		/* caller is going to release it when done with it, so retain it */
-		cl_int ciErr = retain_func(slot.*member);
-		assert(ciErr == CL_SUCCESS);
-		(void)ciErr;
-
 		return slot.*member;
 	}
 
 	/* store something in the cache. you MUST have tried to get the item before storing to it */
 	template<typename T>
 	static void store_something(cl_platform_id platform, cl_device_id device, T thing,
-		T Slot::*member, cl_int (*retain_func)(T), thread_scoped_lock &slot_locker)
+		T Slot::*member, thread_scoped_lock &slot_locker)
 	{
 		assert(platform != NULL);
 		assert(device != NULL);
@@ -237,12 +232,6 @@
 
 		/* unlock the slot */
 		slot_locker.unlock();
-
-		/* increment reference count in OpenCL.
-		 * The caller is going to release the object when done with it. */
-		cl_int ciErr = retain_func(thing);
-		assert(ciErr == CL_SUCCESS);
-		(void)ciErr;
 	}
 
 public:
@@ -250,28 +239,54 @@
 	static cl_context get_context(cl_platform_id platform, cl_device_id device,
 		thread_scoped_lock &slot_locker)
 	{
-		return get_something<cl_context>(platform, device, &Slot::context, clRetainContext, slot_locker);
+		cl_context context = get_something<cl_context>(platform, device, &Slot::context, slot_locker);
+
+		/* caller is going to release it when done with it, so retain it */
+		cl_int ciErr = clRetainContext(context);
+		assert(ciErr == CL_SUCCESS);
+		(void)ciErr;
+
+		return context;
 	}
 
 	/* see get_something comment */
 	static cl_program get_program(cl_platform_id platform, cl_device_id device,
 		thread_scoped_lock &slot_locker)
 	{
-		return get_something<cl_program>(platform, device, &Slot::program, clRetainProgram, slot_locker);
+		cl_program program = get_something<cl_program>(platform, device, &Slot::program, slot_locker);
+
+		/* caller is going to release it when done with it, so retain it */
+		cl_int ciErr = clRetainProgram(program);
+		assert(ciErr == CL_SUCCESS);
+		(void)ciErr;
+
+		return program;
 	}
 
 	/* see store_something comment */
 	static void store_context(cl_platform_id platform, cl_device_id device, cl_context context,
 		thread_scoped_lock &slot_locker)
 	{
-		store_something<cl_context>(platform, device, context, &Slot::context, clRetainContext, slot_locker);
+		store_something<cl_context>(platform, device, context, &Slot::context, slot_locker);
+
+		/* increment reference count in OpenCL.
+		 * The caller is going to release the object when done with it. */
+		cl_int ciErr = clRetainContext(context);
+		assert(ciErr == CL_SUCCESS);
+		(void)ciErr;
 	}
 
 	/* see store_something comment */
 	static void store_program(cl_platform_id platform, cl_device_id device, cl_program program,
 		thread_scoped_lock &slot_locker)
 	{
-		store_something<cl_program>(platform, device, program, &Slot::program, clRetainProgram, slot_locker);
+		store_something<cl_program>(platform, device, program, &Slot::program, slot_locker);
+
+		/* increment reference count in OpenCL.
+		 * The caller is going to release the object when done with it. */
+		cl_int ciErr = clRetainProgram(program);
+		assert(ciErr == CL_SUCCESS);
+		(void)ciErr;
 	}
 
 	/* discard all cached contexts and programs




More information about the Bf-blender-cvs mailing list