[Bf-blender-cvs] [960d7df] master: Cycles: Pass device compute capabilities to kernel via build options

Sergey Sharybin noreply at git.blender.org
Fri May 15 10:23:53 CEST 2015


Commit: 960d7df56f11cd8161bc7ba4478d5c6988c8232f
Author: Sergey Sharybin
Date:   Fri May 15 12:12:10 2015 +0500
Branches: master
https://developer.blender.org/rB960d7df56f11cd8161bc7ba4478d5c6988c8232f

Cycles: Pass device compute capabilities to kernel via build options

This way it's possible to do device-selective feature disabling/enabling.
Currently only supported for NVidia devices via OpenCL extension.

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

M	intern/cycles/device/device_opencl.cpp

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

diff --git a/intern/cycles/device/device_opencl.cpp b/intern/cycles/device/device_opencl.cpp
index 76821e8..05c8530 100644
--- a/intern/cycles/device/device_opencl.cpp
+++ b/intern/cycles/device/device_opencl.cpp
@@ -1097,6 +1097,16 @@ protected:
 			build_options += "-D__KERNEL_OPENCL_NVIDIA__ "
 			                 "-cl-nv-maxrregcount=32 "
 			                 "-cl-nv-verbose ";
+
+			uint compute_capability_major, compute_capability_minor;
+			clGetDeviceInfo(cdDevice, CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV,
+			                sizeof(cl_uint), &compute_capability_major, NULL);
+			clGetDeviceInfo(cdDevice, CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV,
+			                sizeof(cl_uint), &compute_capability_minor, NULL);
+
+			build_options += string_printf("-D__COMPUTE_CAPABILITY__=%d ",
+			                               compute_capability_major * 100 +
+			                               compute_capability_minor * 10);
 		}
 
 		else if(platform_name == "Apple")




More information about the Bf-blender-cvs mailing list