Refactors existing handling of the Quirks regkey to allow for easier addition of future keys.
Signed-off-by: Liam Middlebrook lmiddlebrook@nvidia.com Signed-off-by: Daniel Koch dkoch@nvidia.com --- dlls/winevulkan/vulkan.c | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-)
diff --git a/dlls/winevulkan/vulkan.c b/dlls/winevulkan/vulkan.c index 57b0e65152a..a9a341209f8 100644 --- a/dlls/winevulkan/vulkan.c +++ b/dlls/winevulkan/vulkan.c @@ -658,22 +658,46 @@ fail:
static void wine_vk_process_quirks(const VkApplicationInfo *pApplicationInfo, struct VkInstance_T *object) { - HKEY globalKey; + uint8_t validKeysMask = 0; + int keyIndex = 0; + HKEY keys[1]; + int i;
- /* Load Global Quirks - * @@ Wine registry key: HKCU\Software\Wine\Vulkan + memset(&keys, 0, sizeof(keys)); + + /* Match regkey settings in the following order, breaking early if settings + * are found: + * global defaults + * @@ Wine registry key: HKCU\Software\Wine\Vulkan */ - if (RegOpenKeyA(HKEY_CURRENT_USER, "Software\Wine\Vulkan", &globalKey) == 0) + if (RegOpenKeyA(HKEY_CURRENT_USER, "Software\Wine\Vulkan", keys + keyIndex++) == 0) + validKeysMask |= (1 << (keyIndex - 1)); + + /* Load Global Quirks */ + for (i = 0; i < ARRAY_SIZE(keys); i++) { DWORD type, value, size; size = sizeof(value); - if (RegQueryValueExA(globalKey, "Quirks", NULL, &type, (LPBYTE)&value, &size) == 0 + + if ((validKeysMask & (1 << i)) == 0) + continue; + + if (RegQueryValueExA(keys[i], "Quirks", NULL, &type, (LPBYTE)&value, &size) == 0 && type == REG_DWORD) { object->quirks = value; TRACE("Loaded Quirks value %x\n", value); + break; } - RegCloseKey(globalKey); + } + + for (i = 0; i < ARRAY_SIZE(keys); i++) + { + if ((validKeysMask & (1 << i)) == 0) + continue; + + validKeysMask &= ~(1 << i); + RegCloseKey(keys[i]); } }