Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'extern/hipew/src/hipew.c')
-rw-r--r--extern/hipew/src/hipew.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/extern/hipew/src/hipew.c b/extern/hipew/src/hipew.c
index 02cec1ba28f..010c361fa46 100644
--- a/extern/hipew/src/hipew.c
+++ b/extern/hipew/src/hipew.c
@@ -71,6 +71,7 @@ thipDriverGetVersion *hipDriverGetVersion;
thipGetDevice *hipGetDevice;
thipGetDeviceCount *hipGetDeviceCount;
thipGetDeviceProperties *hipGetDeviceProperties;
+thipDeviceGet* hipDeviceGet;
thipDeviceGetName *hipDeviceGetName;
thipDeviceGetAttribute *hipDeviceGetAttribute;
thipDeviceComputeCapability *hipDeviceComputeCapability;
@@ -213,6 +214,36 @@ static void hipewHipExit(void) {
}
}
+#ifdef _WIN32
+static int hipewHasOldDriver(const char *hip_path) {
+ DWORD verHandle = 0;
+ DWORD verSize = GetFileVersionInfoSize(hip_path, &verHandle);
+ int old_driver = 0;
+ if (verSize != 0) {
+ LPSTR verData = (LPSTR)malloc(verSize);
+ if (GetFileVersionInfo(hip_path, verHandle, verSize, verData)) {
+ LPBYTE lpBuffer = NULL;
+ UINT size = 0;
+ if (VerQueryValue(verData, "\\", (VOID FAR * FAR *)&lpBuffer, &size)) {
+ if (size) {
+ VS_FIXEDFILEINFO *verInfo = (VS_FIXEDFILEINFO *)lpBuffer;
+ /* Magic value from
+ * https://docs.microsoft.com/en-us/windows/win32/api/verrsrc/ns-verrsrc-vs_fixedfileinfo */
+ if (verInfo->dwSignature == 0xfeef04bd) {
+ unsigned int fileVersionLS0 = (verInfo->dwFileVersionLS >> 16) & 0xffff;
+ unsigned int fileversionLS1 = (verInfo->dwFileVersionLS >> 0) & 0xffff;
+ /* Corresponds to versions older than AMD Radeon Pro 21.Q4. */
+ old_driver = ((fileVersionLS0 < 3354) || (fileVersionLS0 == 3354 && fileversionLS1 < 13));
+ }
+ }
+ }
+ }
+ free(verData);
+ }
+ return old_driver;
+}
+#endif
+
static int hipewHipInit(void) {
/* Library paths. */
#ifdef _WIN32
@@ -240,6 +271,14 @@ static int hipewHipInit(void) {
return result;
}
+#ifdef _WIN32
+ /* Test for driver version. */
+ if(hipewHasOldDriver(hip_paths[0])) {
+ result = HIPEW_ERROR_OLD_DRIVER;
+ return result;
+ }
+#endif
+
/* Load library. */
hip_lib = dynamic_library_open_find(hip_paths);
@@ -255,6 +294,7 @@ static int hipewHipInit(void) {
HIP_LIBRARY_FIND_CHECKED(hipGetDevice);
HIP_LIBRARY_FIND_CHECKED(hipGetDeviceCount);
HIP_LIBRARY_FIND_CHECKED(hipGetDeviceProperties);
+ HIP_LIBRARY_FIND_CHECKED(hipDeviceGet);
HIP_LIBRARY_FIND_CHECKED(hipDeviceGetName);
HIP_LIBRARY_FIND_CHECKED(hipDeviceGetAttribute);
HIP_LIBRARY_FIND_CHECKED(hipDeviceComputeCapability);