diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-10-11 11:14:16 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-10-11 11:14:16 +0300 |
commit | dc95c79971d48dae9418e0047f14c01e6dcab13c (patch) | |
tree | f6da183a7e7b3d0adf691c5b270ccab4f8801e35 /intern/cycles/device | |
parent | ef1918d3128b1f56d69c189a838b648dc88de4c9 (diff) | |
parent | 4782000fd5b2a1ae3041884f64ab192dbcb853c0 (diff) |
Merge branch 'master' into blender2.8
Diffstat (limited to 'intern/cycles/device')
-rw-r--r-- | intern/cycles/device/device.cpp | 48 | ||||
-rw-r--r-- | intern/cycles/device/device.h | 5 | ||||
-rw-r--r-- | intern/cycles/device/device_cpu.cpp | 2 | ||||
-rw-r--r-- | intern/cycles/device/device_cuda.cpp | 23 | ||||
-rw-r--r-- | intern/cycles/device/device_network.cpp | 6 | ||||
-rw-r--r-- | intern/cycles/device/device_opencl.cpp | 2 |
6 files changed, 57 insertions, 29 deletions
diff --git a/intern/cycles/device/device.cpp b/intern/cycles/device/device.cpp index 5ae83b56fcd..19c4bec55a8 100644 --- a/intern/cycles/device/device.cpp +++ b/intern/cycles/device/device.cpp @@ -35,6 +35,7 @@ CCL_NAMESPACE_BEGIN bool Device::need_types_update = true; bool Device::need_devices_update = true; +thread_mutex Device::device_mutex; vector<DeviceType> Device::types; vector<DeviceInfo> Device::devices; @@ -443,53 +444,49 @@ string Device::string_from_type(DeviceType type) vector<DeviceType>& Device::available_types() { + thread_scoped_lock lock(device_mutex); if(need_types_update) { types.clear(); types.push_back(DEVICE_CPU); - #ifdef WITH_CUDA - if(device_cuda_init()) + if(device_cuda_init()) { types.push_back(DEVICE_CUDA); + } #endif - #ifdef WITH_OPENCL - if(device_opencl_init()) + if(device_opencl_init()) { types.push_back(DEVICE_OPENCL); + } #endif - #ifdef WITH_NETWORK types.push_back(DEVICE_NETWORK); #endif - need_types_update = false; } - return types; } vector<DeviceInfo>& Device::available_devices() { + thread_scoped_lock lock(device_mutex); if(need_devices_update) { devices.clear(); -#ifdef WITH_CUDA - if(device_cuda_init()) - device_cuda_info(devices); -#endif - #ifdef WITH_OPENCL - if(device_opencl_init()) + if(device_opencl_init()) { device_opencl_info(devices); + } +#endif +#ifdef WITH_CUDA + if(device_cuda_init()) { + device_cuda_info(devices); + } #endif - device_cpu_info(devices); - #ifdef WITH_NETWORK device_network_info(devices); #endif - need_devices_update = false; } - return devices; } @@ -497,12 +494,6 @@ string Device::device_capabilities() { string capabilities = "CPU device capabilities: "; capabilities += device_cpu_capabilities() + "\n"; -#ifdef WITH_CUDA - if(device_cuda_init()) { - capabilities += "\nCUDA device capabilities:\n"; - capabilities += device_cuda_capabilities(); - } -#endif #ifdef WITH_OPENCL if(device_opencl_init()) { @@ -511,6 +502,13 @@ string Device::device_capabilities() } #endif +#ifdef WITH_CUDA + if(device_cuda_init()) { + capabilities += "\nCUDA device capabilities:\n"; + capabilities += device_cuda_capabilities(); + } +#endif + return capabilities; } @@ -526,10 +524,14 @@ DeviceInfo Device::get_multi_device(vector<DeviceInfo> subdevices) info.num = 0; info.has_bindless_textures = true; + info.has_volume_decoupled = true; + info.has_qbvh = true; foreach(DeviceInfo &device, subdevices) { assert(device.type == info.multi_devices[0].type); info.has_bindless_textures &= device.has_bindless_textures; + info.has_volume_decoupled &= device.has_volume_decoupled; + info.has_qbvh &= device.has_qbvh; } return info; diff --git a/intern/cycles/device/device.h b/intern/cycles/device/device.h index fe0bcc5b91f..29803abd153 100644 --- a/intern/cycles/device/device.h +++ b/intern/cycles/device/device.h @@ -55,6 +55,8 @@ public: bool display_device; bool advanced_shading; bool has_bindless_textures; /* flag for GPU and Multi device */ + bool has_volume_decoupled; + bool has_qbvh; bool use_split_kernel; /* Denotes if the device is going to run cycles using split-kernel */ vector<DeviceInfo> multi_devices; @@ -66,6 +68,8 @@ public: display_device = false; advanced_shading = true; has_bindless_textures = false; + has_volume_decoupled = false; + has_qbvh = false; use_split_kernel = false; } @@ -364,6 +368,7 @@ public: private: /* Indicted whether device types and devices lists were initialized. */ static bool need_types_update, need_devices_update; + static thread_mutex device_mutex; static vector<DeviceType> types; static vector<DeviceInfo> devices; }; diff --git a/intern/cycles/device/device_cpu.cpp b/intern/cycles/device/device_cpu.cpp index ac6d3246d38..a17caabc850 100644 --- a/intern/cycles/device/device_cpu.cpp +++ b/intern/cycles/device/device_cpu.cpp @@ -1024,6 +1024,8 @@ void device_cpu_info(vector<DeviceInfo>& devices) info.id = "CPU"; info.num = 0; info.advanced_shading = true; + info.has_qbvh = system_cpu_support_sse2(); + info.has_volume_decoupled = true; devices.insert(devices.begin(), info); } diff --git a/intern/cycles/device/device_cuda.cpp b/intern/cycles/device/device_cuda.cpp index 3d209e5560c..066be82d55b 100644 --- a/intern/cycles/device/device_cuda.cpp +++ b/intern/cycles/device/device_cuda.cpp @@ -1313,9 +1313,14 @@ public: CUdeviceptr d_work_tiles = cuda_device_ptr(work_tiles.device_pointer); /* Prepare work size. More step samples render faster, but for now we - * remain conservative to avoid driver timeouts. */ + * remain conservative for GPUs connected to a display to avoid driver + * timeouts and display freezing. */ int min_blocks, num_threads_per_block; cuda_assert(cuOccupancyMaxPotentialBlockSize(&min_blocks, &num_threads_per_block, cuPathTrace, NULL, 0, 0)); + if(!info.display_device) { + min_blocks *= 8; + } + uint step_samples = divide_up(min_blocks * num_threads_per_block, wtile->w * wtile->h);; /* Render all samples. */ @@ -2130,7 +2135,6 @@ void device_cuda_info(vector<DeviceInfo>& devices) for(int num = 0; num < count; num++) { char name[256]; - int attr; if(cuDeviceGetName(name, 256, num) != CUDA_SUCCESS) continue; @@ -2149,6 +2153,8 @@ void device_cuda_info(vector<DeviceInfo>& devices) info.advanced_shading = (major >= 2); info.has_bindless_textures = (major >= 3); + info.has_volume_decoupled = false; + info.has_qbvh = false; int pci_location[3] = {0, 0, 0}; cuDeviceGetAttribute(&pci_location[0], CU_DEVICE_ATTRIBUTE_PCI_DOMAIN_ID, num); @@ -2160,14 +2166,21 @@ void device_cuda_info(vector<DeviceInfo>& devices) (unsigned int)pci_location[1], (unsigned int)pci_location[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) { + /* If device has a kernel timeout and no compute preemption, we assume + * it is connected to a display and will freeze the display while doing + * computations. */ + int timeout_attr = 0, preempt_attr = 0; + cuDeviceGetAttribute(&timeout_attr, CU_DEVICE_ATTRIBUTE_KERNEL_EXEC_TIMEOUT, num); + cuDeviceGetAttribute(&preempt_attr, CU_DEVICE_ATTRIBUTE_COMPUTE_PREEMPTION_SUPPORTED, num); + + if(timeout_attr && !preempt_attr) { info.description += " (Display)"; info.display_device = true; display_devices.push_back(info); } - else + else { devices.push_back(info); + } } if(!display_devices.empty()) diff --git a/intern/cycles/device/device_network.cpp b/intern/cycles/device/device_network.cpp index deea59f1d23..ced10c98dc9 100644 --- a/intern/cycles/device/device_network.cpp +++ b/intern/cycles/device/device_network.cpp @@ -343,7 +343,11 @@ void device_network_info(vector<DeviceInfo>& devices) info.description = "Network Device"; info.id = "NETWORK"; info.num = 0; - info.advanced_shading = true; /* todo: get this info from device */ + + /* todo: get this info from device */ + info.advanced_shading = true; + info.has_volume_decoupled = false; + info.has_qbvh = false; devices.push_back(info); } diff --git a/intern/cycles/device/device_opencl.cpp b/intern/cycles/device/device_opencl.cpp index 9d89decaaaf..5808a31e605 100644 --- a/intern/cycles/device/device_opencl.cpp +++ b/intern/cycles/device/device_opencl.cpp @@ -123,6 +123,8 @@ void device_opencl_info(vector<DeviceInfo>& devices) info.advanced_shading = OpenCLInfo::kernel_use_advanced_shading(platform_name); info.use_split_kernel = OpenCLInfo::kernel_use_split(platform_name, device_type); + info.has_volume_decoupled = false; + info.has_qbvh = false; info.id = string("OPENCL_") + platform_name + "_" + device_name + "_" + hardware_id; devices.push_back(info); num_devices++; |