diff --git a/intern/cycles/device/device_cuda.cpp b/intern/cycles/device/device_cuda.cpp index cac1edb188e..7ab823423b5 100644 --- a/intern/cycles/device/device_cuda.cpp +++ b/intern/cycles/device/device_cuda.cpp @@ -47,6 +47,7 @@ #include "util/util_system.h" #include "util/util_types.h" #include "util/util_time.h" +#include "util/util_windows.h" #include "kernel/split/kernel_split_data_types.h" @@ -2659,6 +2660,14 @@ void device_cuda_info(vector &devices) cuDeviceGetAttribute(&timeout_attr, CU_DEVICE_ATTRIBUTE_KERNEL_EXEC_TIMEOUT, num); cuDeviceGetAttribute(&preempt_attr, CU_DEVICE_ATTRIBUTE_COMPUTE_PREEMPTION_SUPPORTED, num); + /* The CUDA driver reports compute preemption as not being available on + * Windows 10 even when it is, due to an issue in application profiles. + * Detect case where we expect it to be available and override. */ + if (preempt_attr == 0 && (major >= 6) && system_windows_version_at_least(10, 17134)) { + VLOG(1) << "Assuming device has compute preemption on Windows 10."; + preempt_attr = 1; + } + if (timeout_attr && !preempt_attr) { VLOG(1) << "Device is recognized as display."; info.description += " (Display)"; @@ -2666,6 +2675,7 @@ void device_cuda_info(vector &devices) display_devices.push_back(info); } else { + VLOG(1) << "Device has compute preemption or is not used for display."; devices.push_back(info); } VLOG(1) << "Added device \"" << name << "\" with id \"" << info.id << "\"."; diff --git a/intern/cycles/util/CMakeLists.txt b/intern/cycles/util/CMakeLists.txt index 1c7a6549253..f0157b1be7b 100644 --- a/intern/cycles/util/CMakeLists.txt +++ b/intern/cycles/util/CMakeLists.txt @@ -25,6 +25,7 @@ set(SRC util_thread.cpp util_time.cpp util_transform.cpp + util_windows.cpp ) set(LIB diff --git a/intern/cycles/util/util_windows.cpp b/intern/cycles/util/util_windows.cpp new file mode 100644 index 00000000000..b8de9c418fe --- /dev/null +++ b/intern/cycles/util/util_windows.cpp @@ -0,0 +1,54 @@ +/* + * Copyright 2019-2019 Blender Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifdef _WIN32 +#include +#endif + +#include "util_windows.h" + +CCL_NAMESPACE_BEGIN + +bool system_windows_version_at_least(int major, int build) +{ +#ifdef _WIN32 + HMODULE hMod = ::GetModuleHandleW(L"ntdll.dll"); + if (hMod == 0) { + return false; + } + + typedef NTSTATUS(WINAPI * RtlGetVersionPtr)(PRTL_OSVERSIONINFOW); + RtlGetVersionPtr rtl_get_version = (RtlGetVersionPtr)::GetProcAddress(hMod, "RtlGetVersion"); + if (rtl_get_version == NULL) { + return false; + } + + RTL_OSVERSIONINFOW rovi = {0}; + rovi.dwOSVersionInfoSize = sizeof(rovi); + if (rtl_get_version(&rovi) != 0) { + return false; + } + + return (rovi.dwMajorVersion > major || + (rovi.dwMajorVersion == major && rovi.dwBuildNumber >= build)); +#else + (void)major; + (void)build; + return false; +#endif +} + +CCL_NAMESPACE_END diff --git a/intern/cycles/util/util_windows.h b/intern/cycles/util/util_windows.h index 0d85c5437f6..9cbf91a23a7 100644 --- a/intern/cycles/util/util_windows.h +++ b/intern/cycles/util/util_windows.h @@ -33,4 +33,10 @@ #endif /* _WIN32 */ +CCL_NAMESPACE_BEGIN + +bool system_windows_version_at_least(int major, int build); + +CCL_NAMESPACE_END + #endif /* __UTIL_WINDOWS_H__ */