diff options
author | Sayak Biswas <sayakAMD> | 2021-11-23 16:16:24 +0300 |
---|---|---|
committer | Brecht Van Lommel <brecht@blender.org> | 2021-11-23 17:45:37 +0300 |
commit | 3bb8d173e70c1ec80612733c63efedc5e1d854e5 (patch) | |
tree | 291b748046fddf0a68ddb1920787f59fc6672a54 /extern/hipew/src/hipew.c | |
parent | 1a7c32a0aba5219a97ff96c5269e075b1d3a3fed (diff) |
Fix T93109: Cycles HIP missing check for correct driver version
21.Q4 is required, older version should not show devices in the preferences.
This adds a check for the file version of amdhip64.dll file during hipew
initialization.
Differential Revision: https://developer.blender.org/D13324
Diffstat (limited to 'extern/hipew/src/hipew.c')
-rw-r--r-- | extern/hipew/src/hipew.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/extern/hipew/src/hipew.c b/extern/hipew/src/hipew.c index 92022778dfc..593901aad9c 100644 --- a/extern/hipew/src/hipew.c +++ b/extern/hipew/src/hipew.c @@ -214,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 @@ -241,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); |