wined3d_adapter_init() will allocate random LUIDs for adapters if no valid LUID is found in wined3d_adapter_gl/vk_init(). To avoid overriding valid LUIDs, the function has to be moved. Also when assigning outputs to their corresponding adapters for multiple adapters support, LUIDs should be valid before calling wined3d_adapter_init().
Signed-off-by: Zhiyi Zhang zzhang@codeweavers.com --- dlls/wined3d/adapter_gl.c | 10 +++++++--- dlls/wined3d/adapter_vk.c | 16 ++++++---------- dlls/wined3d/directx.c | 4 ---- 3 files changed, 13 insertions(+), 17 deletions(-)
diff --git a/dlls/wined3d/adapter_gl.c b/dlls/wined3d/adapter_gl.c index a97e7bd7a41..680019c1189 100644 --- a/dlls/wined3d/adapter_gl.c +++ b/dlls/wined3d/adapter_gl.c @@ -5141,9 +5141,6 @@ static BOOL wined3d_adapter_gl_init(struct wined3d_adapter_gl *adapter_gl, TRACE("adapter_gl %p, ordinal %u, wined3d_creation_flags %#x.\n", adapter_gl, ordinal, wined3d_creation_flags);
- if (!wined3d_adapter_init(&adapter_gl->a, ordinal, &wined3d_adapter_gl_ops)) - return FALSE; - /* Dynamically load all GL core functions */ #ifdef USE_WIN32_OPENGL { @@ -5241,6 +5238,13 @@ static BOOL wined3d_adapter_gl_init(struct wined3d_adapter_gl *adapter_gl,
wined3d_adapter_init_ffp_attrib_ops(&adapter_gl->a);
+ if (!wined3d_adapter_init(&adapter_gl->a, ordinal, &wined3d_adapter_gl_ops)) + { + ERR("Failed to initialise adapter.\n"); + heap_free(adapter_gl->pixel_formats); + return FALSE; + } + return TRUE; }
diff --git a/dlls/wined3d/adapter_vk.c b/dlls/wined3d/adapter_vk.c index 1e4d663dcb4..f648dd196f7 100644 --- a/dlls/wined3d/adapter_vk.c +++ b/dlls/wined3d/adapter_vk.c @@ -2170,17 +2170,14 @@ static BOOL wined3d_adapter_vk_init(struct wined3d_adapter_vk *adapter_vk, TRACE("adapter_vk %p, ordinal %u, wined3d_creation_flags %#x.\n", adapter_vk, ordinal, wined3d_creation_flags);
- if (!wined3d_adapter_init(adapter, ordinal, &wined3d_adapter_vk_ops)) - return FALSE; - if (!wined3d_init_vulkan(vk_info)) { WARN("Failed to initialize Vulkan.\n"); - goto fail; + return FALSE; }
if (!(adapter_vk->physical_device = get_vulkan_physical_device(vk_info))) - goto fail_vulkan; + goto fail;
memset(&id_properties, 0, sizeof(id_properties)); id_properties.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ID_PROPERTIES; @@ -2203,7 +2200,7 @@ static BOOL wined3d_adapter_vk_init(struct wined3d_adapter_vk *adapter_vk, memcpy(&adapter->device_uuid, id_properties.deviceUUID, sizeof(adapter->device_uuid));
if (!wined3d_adapter_vk_init_format_info(adapter_vk, vk_info)) - goto fail_vulkan; + goto fail;
adapter->vertex_pipe = wined3d_spirv_vertex_pipe_init_vk(); adapter->fragment_pipe = wined3d_spirv_fragment_pipe_init_vk(); @@ -2212,13 +2209,12 @@ static BOOL wined3d_adapter_vk_init(struct wined3d_adapter_vk *adapter_vk,
wined3d_adapter_vk_init_d3d_info(adapter_vk, wined3d_creation_flags);
- return TRUE; + if (wined3d_adapter_init(adapter, ordinal, &wined3d_adapter_vk_ops)) + return TRUE;
-fail_vulkan: +fail: VK_CALL(vkDestroyInstance(vk_info->instance, NULL)); wined3d_unload_vulkan(vk_info); -fail: - wined3d_adapter_cleanup(adapter); return FALSE; }
diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c index e77283832ca..a9a5a3aac36 100644 --- a/dlls/wined3d/directx.c +++ b/dlls/wined3d/directx.c @@ -3018,10 +3018,6 @@ BOOL wined3d_adapter_init(struct wined3d_adapter *adapter, unsigned int ordinal, } adapter->output_count = 1;
- memset(&adapter->driver_uuid, 0, sizeof(adapter->driver_uuid)); - memset(&adapter->device_uuid, 0, sizeof(adapter->device_uuid)); - - adapter->formats = NULL; adapter->adapter_ops = adapter_ops; ret = TRUE; done: