Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47109 Signed-off-by: Brendan Shanks bshanks@codeweavers.com --- v4: Rebase on latest Vulkan 1.2.134 commits, and use the new VK_HEADER_VERSION_COMPLETE #define rather than adding our own.
dlls/winevulkan/Makefile.in | 2 +- dlls/winevulkan/make_vulkan | 3 ++ dlls/winevulkan/vulkan.c | 83 +++++++++++++++++++++++++++++++++ dlls/winevulkan/winevulkan.spec | 2 + loader/wine.inf.in | 1 + 5 files changed, 90 insertions(+), 1 deletion(-)
diff --git a/dlls/winevulkan/Makefile.in b/dlls/winevulkan/Makefile.in index e0bca6fad7..2ffff40c3a 100644 --- a/dlls/winevulkan/Makefile.in +++ b/dlls/winevulkan/Makefile.in @@ -1,6 +1,6 @@ MODULE = winevulkan.dll IMPORTLIB = winevulkan -IMPORTS = user32 gdi32 +IMPORTS = user32 gdi32 advapi32
C_SRCS = \ vulkan.c \ diff --git a/dlls/winevulkan/make_vulkan b/dlls/winevulkan/make_vulkan index e0b94a06cb..bccfa6a6d6 100755 --- a/dlls/winevulkan/make_vulkan +++ b/dlls/winevulkan/make_vulkan @@ -2509,6 +2509,9 @@ class VkGenerator(object): else: f.write("@ stub {0}\n".format(func.name))
+ f.write("@ stdcall -private DllRegisterServer()\n") + f.write("@ stdcall -private DllUnregisterServer()\n") + def generate_vulkan_loader_spec(self, f): self._generate_copyright(f, spec_file=True)
diff --git a/dlls/winevulkan/vulkan.c b/dlls/winevulkan/vulkan.c index 59472bcef8..5c5cde3649 100644 --- a/dlls/winevulkan/vulkan.c +++ b/dlls/winevulkan/vulkan.c @@ -21,6 +21,7 @@
#include "windef.h" #include "winbase.h" +#include "winreg.h" #include "winuser.h"
#include "vulkan_private.h" @@ -1307,3 +1308,85 @@ void *native_vkGetInstanceProcAddrWINE(VkInstance instance, const char *name) { return vk_funcs->p_vkGetInstanceProcAddr(instance, name); } + + +static const WCHAR winevulkan_jsonW[] = {'\','w','i','n','e','v','u','l','k','a','n','.','j','s','o','n',0}; +static const WCHAR vulkan_driversW[] = {'S','o','f','t','w','a','r','e','\','K','h','r','o','n','o','s','\', + 'V','u','l','k','a','n','\','D','r','i','v','e','r','s',0}; +static BOOL writestr(HANDLE handle, const char *str) +{ + DWORD written; + return WriteFile(handle, str, strlen(str), &written, NULL); +} + +HRESULT WINAPI DllRegisterServer(void) +{ + WCHAR path[MAX_PATH]; + char vk_version[20]; + HANDLE file; + LRESULT result; + HKEY key; + DWORD zero = 0; + + /* Create the JSON manifest and registry key to register this ICD with the official Vulkan loader. */ + TRACE("\n"); + GetSystemDirectoryW(path, ARRAY_SIZE(path)); + lstrcatW(path, winevulkan_jsonW); + file = CreateFileW(path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + if (file == INVALID_HANDLE_VALUE) + { ERR("Unable to create JSON manifest.\n"); return E_UNEXPECTED; } + + snprintf(vk_version, sizeof(vk_version), "%u.%u.%u", + VK_VERSION_MAJOR(VK_HEADER_VERSION_COMPLETE), + VK_VERSION_MINOR(VK_HEADER_VERSION_COMPLETE), + VK_VERSION_PATCH(VK_HEADER_VERSION_COMPLETE)); + + writestr(file, "{\r\n"); + writestr(file, " "file_format_version": "1.0.0",\r\n"); + writestr(file, " "ICD": {\r\n"); + writestr(file, " "library_path": "winevulkan.dll",\r\n"); + writestr(file, " "api_version": ""); + writestr(file, vk_version); + writestr(file, ""\r\n"); + writestr(file, " }\r\n"); + writestr(file, "}\r\n"); + CloseHandle(file); + + result = RegCreateKeyExW(HKEY_LOCAL_MACHINE, vulkan_driversW, + 0, NULL, 0, KEY_SET_VALUE, NULL, &key, NULL); + if (result != ERROR_SUCCESS) + { ERR("Unable to create registry key.\n"); return E_UNEXPECTED; } + + result = RegSetValueExW(key, path, 0, REG_DWORD, (const BYTE *)&zero, sizeof(zero)); + if (result != ERROR_SUCCESS) + { ERR("Unable to set registry value.\n"); return E_UNEXPECTED; } + + RegCloseKey(key); + return S_OK; +} + +HRESULT WINAPI DllUnregisterServer(void) +{ + WCHAR path[MAX_PATH]; + LRESULT result; + HKEY key; + + /* Remove the JSON manifest and registry key */ + TRACE("\n"); + GetSystemDirectoryW(path, ARRAY_SIZE(path)); + lstrcatW(path, winevulkan_jsonW); + if (!DeleteFileW(path)) + ERR("Unable to delete JSON file.\n"); + + result = RegOpenKeyExW(HKEY_LOCAL_MACHINE, vulkan_driversW, + 0, KEY_SET_VALUE, &key); + if (result != ERROR_SUCCESS) + { ERR("Unable to open registry key.\n"); return E_UNEXPECTED; } + + result = RegDeleteValueW(key, path); + if (result != ERROR_SUCCESS) + ERR("Unable to delete registry key.\n"); + + RegCloseKey(key); + return S_OK; +} diff --git a/dlls/winevulkan/winevulkan.spec b/dlls/winevulkan/winevulkan.spec index c02af5aeaa..e024a43586 100644 --- a/dlls/winevulkan/winevulkan.spec +++ b/dlls/winevulkan/winevulkan.spec @@ -239,3 +239,5 @@ @ stdcall -private wine_vkUpdateDescriptorSets(ptr long ptr long ptr) @ stdcall -private wine_vkWaitForFences(ptr long ptr long int64) @ stdcall -private wine_vkWaitSemaphores(ptr ptr int64) +@ stdcall -private DllRegisterServer() +@ stdcall -private DllUnregisterServer() diff --git a/loader/wine.inf.in b/loader/wine.inf.in index 6e0cb21253..d0b156eb77 100644 --- a/loader/wine.inf.in +++ b/loader/wine.inf.in @@ -2569,6 +2569,7 @@ HKLM,%CurrentVersion%\Telephony\Country List\998,"SameAreaRule",,"G" 11,,windowscodecs.dll,1 11,,winegstreamer.dll,1 11,,wineqtdecoder.dll,1 +11,,winevulkan.dll,1 11,,wintrust.dll,1 11,,iexplore.exe,1