Commit: a0f16e12a03c686e05f9315634e4d081a0aa6a80
Author: Sergey Sharybin
Date:   Mon Mar 20 19:05:04 2017 +0100
Branches: master
https://developer.blender.org/rBa0f16e12a03c686e05f9315634e4d081a0aa6a80

Cycles: Use more friendly GPU device name for AMD cards

For example, for RX480 you'll no longer see "Ellesmere" but will see
"AMD Radeon RX 480 Graphics" which makes more sense and allows to easily
distinguish which exact card it is when having multiple different cards
of Ellesmere codenames (i.e. RX480 and WX7100) in the same machine.

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

M       intern/cycles/device/opencl/opencl.h
M       intern/cycles/device/opencl/opencl_util.cpp

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

diff --git a/intern/cycles/device/opencl/opencl.h 
b/intern/cycles/device/opencl/opencl.h
index 6b3bbf91f2..59e61aad25 100644
--- a/intern/cycles/device/opencl/opencl.h
+++ b/intern/cycles/device/opencl/opencl.h
@@ -131,6 +131,13 @@ public:
                                    cl_device_type *device_type,
                                    cl_int* error = NULL);
        static cl_device_type get_device_type(cl_device_id device_id);
+
+       /* Get somewhat more readable device name.
+        * Main difference is AMD OpenCL here which only gives code name
+        * for the regular device name. This will give more sane device
+        * name using some extensions.
+        */
+       static string get_readable_device_name(cl_device_id device_id);
 };
 
 /* Thread safe cache for contexts and programs.
diff --git a/intern/cycles/device/opencl/opencl_util.cpp 
b/intern/cycles/device/opencl/opencl_util.cpp
index 6b0d4e14f2..1f5b9ee089 100644
--- a/intern/cycles/device/opencl/opencl_util.cpp
+++ b/intern/cycles/device/opencl/opencl_util.cpp
@@ -797,14 +797,22 @@ void 
OpenCLInfo::get_usable_devices(vector<OpenCLPlatformDevice> *usable_devices
                                                      << 
string(clewErrorString(error));
                                        continue;
                                }
-                               FIRST_VLOG(2) << "Adding new device " << 
device_name << ".";
+                               string readable_device_name =
+                                       get_readable_device_name(device_id);
+                               if(readable_device_name != device_name) {
+                                       FIRST_VLOG(2) << "Using more readable 
device name: "
+                                                     << readable_device_name;
+                               }
+                               FIRST_VLOG(2) << "Adding new device "
+                                             << readable_device_name << ".";
                                string hardware_id = 
get_hardware_id(platform_name, device_id);
-                               
usable_devices->push_back(OpenCLPlatformDevice(platform_id,
-                                                                              
platform_name,
-                                                                              
device_id,
-                                                                              
device_type,
-                                                                              
device_name,
-                                                                              
hardware_id));
+                               usable_devices->push_back(OpenCLPlatformDevice(
+                                       platform_id,
+                                       platform_name,
+                                       device_id,
+                                       device_type,
+                                       readable_device_name,
+                                       hardware_id));
                        }
                        else {
                                FIRST_VLOG(2) << "Ignoring device " << 
device_name
@@ -1046,6 +1054,21 @@ cl_device_type OpenCLInfo::get_device_type(cl_device_id 
device_id)
        return device_type;
 }
 
+string OpenCLInfo::get_readable_device_name(cl_device_id device_id)
+{
+       char board_name[1024];
+       if(clGetDeviceInfo(device_id,
+                          CL_DEVICE_BOARD_NAME_AMD,
+                          sizeof(board_name),
+                          &board_name,
+                          NULL) == CL_SUCCESS)
+       {
+               return board_name;
+       }
+       /* Fallback to standard device name API. */
+       return get_device_name(device_id);
+}
+
 CCL_NAMESPACE_END
 
 #endif

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to