winevulkan: Use __wine_unix_call interface for Unix lib initialization.
Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
feb0b73a3c
commit
a34e8c2bc3
|
@ -1,4 +1,5 @@
|
|||
MODULE = winevulkan.dll
|
||||
UNIXLIB = winevulkan.so
|
||||
IMPORTLIB = winevulkan
|
||||
IMPORTS = user32 gdi32 advapi32 setupapi win32u
|
||||
EXTRALIBS = $(PTHREAD_LIBS)
|
||||
|
|
|
@ -17,19 +17,13 @@
|
|||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "winternl.h"
|
||||
#include "vulkan_loader.h"
|
||||
#include "winreg.h"
|
||||
#include "winuser.h"
|
||||
#include "initguid.h"
|
||||
#include "devguid.h"
|
||||
#include "setupapi.h"
|
||||
|
||||
#include "vulkan_loader.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(vulkan);
|
||||
|
||||
/* For now default to 4 as it felt like a reasonable version feature wise to support.
|
||||
|
@ -41,6 +35,7 @@ DEFINE_DEVPROPKEY(DEVPROPKEY_GPU_LUID, 0x60b193cb, 0x5276, 0x4d0f, 0x96, 0xfc, 0
|
|||
DEFINE_DEVPROPKEY(WINE_DEVPROPKEY_GPU_VULKAN_UUID, 0x233a9ef3, 0xafc4, 0x4abd, 0xb5, 0x64, 0xc3, 0x2f, 0x21, 0xf1, 0x53, 0x5c, 2);
|
||||
|
||||
const struct unix_funcs *unix_funcs;
|
||||
unixlib_handle_t unix_handle;
|
||||
|
||||
static HINSTANCE hinstance;
|
||||
|
||||
|
@ -220,13 +215,24 @@ VkResult WINAPI vk_icdNegotiateLoaderICDInterfaceVersion(uint32_t *supported_ver
|
|||
|
||||
static BOOL WINAPI wine_vk_init(INIT_ONCE *once, void *param, void **context)
|
||||
{
|
||||
const struct vulkan_funcs *driver;
|
||||
const void *driver;
|
||||
|
||||
driver = __wine_get_vulkan_driver(WINE_VULKAN_DRIVER_VERSION);
|
||||
if (!driver)
|
||||
{
|
||||
ERR("Failed to load Wine graphics driver supporting Vulkan.\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return driver && !__wine_init_unix_lib(hinstance, DLL_PROCESS_ATTACH, driver, &unix_funcs);
|
||||
if (NtQueryVirtualMemory(GetCurrentProcess(), hinstance, MemoryWineUnixFuncs,
|
||||
&unix_handle, sizeof(unix_handle), NULL))
|
||||
return FALSE;
|
||||
|
||||
if (vk_unix_call(unix_init, &driver) || !driver)
|
||||
return FALSE;
|
||||
|
||||
unix_funcs = driver;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static BOOL wine_vk_init_once(void)
|
||||
|
|
|
@ -431,4 +431,10 @@ struct unix_funcs
|
|||
BOOL (WINAPI *p_is_available_device_function)(VkDevice, const char *);
|
||||
};
|
||||
|
||||
enum unix_call
|
||||
{
|
||||
unix_init,
|
||||
unix_count,
|
||||
};
|
||||
|
||||
#endif /* __WINE_VULKAN_LOADER_THUNKS_H */
|
||||
|
|
|
@ -2792,7 +2792,13 @@ class VkGenerator(object):
|
|||
f.write(" &{1}{0},\n".format(vk_func.name, prefix))
|
||||
f.write(" &wine_vk_is_available_instance_function,\n")
|
||||
f.write(" &wine_vk_is_available_device_function,\n")
|
||||
f.write("};\n\n")
|
||||
|
||||
f.write("const unixlib_entry_t __wine_unix_call_funcs[] =\n")
|
||||
f.write("{\n")
|
||||
f.write(" init_vulkan,\n")
|
||||
f.write("};\n")
|
||||
f.write("C_ASSERT(ARRAYSIZE(__wine_unix_call_funcs) == unix_count);\n")
|
||||
|
||||
def generate_thunks_h(self, f, prefix):
|
||||
self._generate_copyright(f)
|
||||
|
@ -2998,6 +3004,12 @@ class VkGenerator(object):
|
|||
f.write(" BOOL (WINAPI *p_is_available_device_function)(VkDevice, const char *);\n")
|
||||
f.write("};\n\n")
|
||||
|
||||
f.write("enum unix_call\n")
|
||||
f.write("{\n")
|
||||
f.write(" unix_init,\n")
|
||||
f.write(" unix_count,\n")
|
||||
f.write("};\n\n")
|
||||
|
||||
f.write("#endif /* __WINE_VULKAN_LOADER_THUNKS_H */\n")
|
||||
|
||||
def generate_vulkan_h(self, f):
|
||||
|
|
|
@ -23,19 +23,13 @@
|
|||
|
||||
#include "config.h"
|
||||
#include <time.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "ntstatus.h"
|
||||
#define WIN32_NO_STATUS
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "vulkan_private.h"
|
||||
#include "winreg.h"
|
||||
#include "winuser.h"
|
||||
#include "winternl.h"
|
||||
|
||||
#include "vulkan_private.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(vulkan);
|
||||
|
||||
#define wine_vk_find_struct(s, t) wine_vk_find_struct_((void *)s, VK_STRUCTURE_TYPE_##t)
|
||||
|
@ -68,7 +62,6 @@ static uint32_t wine_vk_count_struct_(void *s, VkStructureType t)
|
|||
}
|
||||
|
||||
static const struct vulkan_funcs *vk_funcs;
|
||||
static VkResult (*p_vkEnumerateInstanceVersion)(uint32_t *version);
|
||||
|
||||
#define WINE_VK_ADD_DISPATCHABLE_MAPPING(instance, object, native_handle) \
|
||||
wine_vk_add_handle_mapping((instance), (uint64_t) (uintptr_t) (object), (uint64_t) (uintptr_t) (native_handle), &(object)->mapping)
|
||||
|
@ -140,8 +133,7 @@ static VkBool32 debug_utils_callback_conversion(VkDebugUtilsMessageSeverityFlagB
|
|||
|
||||
wine_callback_data = *((VkDebugUtilsMessengerCallbackDataEXT *) callback_data);
|
||||
|
||||
object_name_infos = RtlAllocateHeap(GetProcessHeap(), HEAP_ZERO_MEMORY,
|
||||
wine_callback_data.objectCount * sizeof(*object_name_infos));
|
||||
object_name_infos = calloc(wine_callback_data.objectCount, sizeof(*object_name_infos));
|
||||
|
||||
for (i = 0; i < wine_callback_data.objectCount; i++)
|
||||
{
|
||||
|
@ -156,7 +148,7 @@ static VkBool32 debug_utils_callback_conversion(VkDebugUtilsMessageSeverityFlagB
|
|||
if (!object_name_infos[i].objectHandle)
|
||||
{
|
||||
WARN("handle conversion failed 0x%s\n", wine_dbgstr_longlong(callback_data->pObjects[i].objectHandle));
|
||||
RtlFreeHeap(GetProcessHeap(), 0, object_name_infos);
|
||||
free(object_name_infos);
|
||||
return VK_FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -171,7 +163,7 @@ static VkBool32 debug_utils_callback_conversion(VkDebugUtilsMessageSeverityFlagB
|
|||
/* applications should always return VK_FALSE */
|
||||
result = object->user_callback(severity, message_types, &wine_callback_data, object->user_data);
|
||||
|
||||
RtlFreeHeap(GetProcessHeap(), 0, object_name_infos);
|
||||
free(object_name_infos);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -422,13 +414,10 @@ static void wine_vk_device_free(struct VkDevice_T *device)
|
|||
free(device);
|
||||
}
|
||||
|
||||
NTSTATUS CDECL __wine_init_unix_lib(HMODULE module, DWORD reason, const void *driver, void *ptr_out)
|
||||
NTSTATUS init_vulkan(void *args)
|
||||
{
|
||||
if (reason != DLL_PROCESS_ATTACH) return STATUS_SUCCESS;
|
||||
|
||||
vk_funcs = driver;
|
||||
p_vkEnumerateInstanceVersion = vk_funcs->p_vkGetInstanceProcAddr(NULL, "vkEnumerateInstanceVersion");
|
||||
*(const struct unix_funcs **)ptr_out = &loader_funcs;
|
||||
vk_funcs = *(const struct vulkan_funcs **)args;
|
||||
*(const struct unix_funcs **)args = &loader_funcs;
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -962,6 +951,10 @@ VkResult WINAPI wine_vkEnumerateInstanceVersion(uint32_t *version)
|
|||
{
|
||||
VkResult res;
|
||||
|
||||
static VkResult (*p_vkEnumerateInstanceVersion)(uint32_t *version);
|
||||
if (!p_vkEnumerateInstanceVersion)
|
||||
p_vkEnumerateInstanceVersion = vk_funcs->p_vkGetInstanceProcAddr(NULL, "vkEnumerateInstanceVersion");
|
||||
|
||||
if (p_vkEnumerateInstanceVersion)
|
||||
{
|
||||
res = p_vkEnumerateInstanceVersion(version);
|
||||
|
|
|
@ -20,9 +20,16 @@
|
|||
#ifndef __WINE_VULKAN_LOADER_H
|
||||
#define __WINE_VULKAN_LOADER_H
|
||||
|
||||
#include "ntstatus.h"
|
||||
#define WIN32_NO_STATUS
|
||||
#include <stdarg.h>
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "winternl.h"
|
||||
#include "wine/debug.h"
|
||||
#include "wine/vulkan.h"
|
||||
#include "wine/vulkan_driver.h"
|
||||
#include "wine/unixlib.h"
|
||||
|
||||
#include "loader_thunks.h"
|
||||
|
||||
|
@ -63,5 +70,11 @@ void *wine_vk_get_phys_dev_proc_addr(const char *name) DECLSPEC_HIDDEN;
|
|||
void *wine_vk_get_instance_proc_addr(const char *name) DECLSPEC_HIDDEN;
|
||||
|
||||
extern const struct unix_funcs *unix_funcs;
|
||||
extern unixlib_handle_t unix_handle DECLSPEC_HIDDEN;
|
||||
|
||||
static inline NTSTATUS vk_unix_call(enum unix_call code, void *params)
|
||||
{
|
||||
return __wine_unix_call(unix_handle, code, params);
|
||||
}
|
||||
|
||||
#endif /* __WINE_VULKAN_LOADER_H */
|
||||
|
|
|
@ -210,6 +210,8 @@ BOOL wine_vk_instance_extension_supported(const char *name) DECLSPEC_HIDDEN;
|
|||
BOOL wine_vk_is_type_wrapped(VkObjectType type) DECLSPEC_HIDDEN;
|
||||
uint64_t wine_vk_unwrap_handle(VkObjectType type, uint64_t handle) DECLSPEC_HIDDEN;
|
||||
|
||||
NTSTATUS init_vulkan(void *args) DECLSPEC_HIDDEN;
|
||||
|
||||
extern const struct unix_funcs loader_funcs;
|
||||
|
||||
BOOL WINAPI wine_vk_is_available_instance_function(VkInstance instance, const char *name) DECLSPEC_HIDDEN;
|
||||
|
|
|
@ -9088,3 +9088,9 @@ const struct unix_funcs loader_funcs =
|
|||
&wine_vk_is_available_instance_function,
|
||||
&wine_vk_is_available_device_function,
|
||||
};
|
||||
|
||||
const unixlib_entry_t __wine_unix_call_funcs[] =
|
||||
{
|
||||
init_vulkan,
|
||||
};
|
||||
C_ASSERT(ARRAYSIZE(__wine_unix_call_funcs) == unix_count);
|
||||
|
|
Loading…
Reference in New Issue