Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- v3: Properly clean up on driver info initialization failure, use bool instead of BOOL. v4: Don't call adapter_no3d_destroy() from wined3d_adapter_no3d_create().
dlls/wined3d/adapter_gl.c | 8 ++++++-- dlls/wined3d/adapter_vk.c | 13 +++++++------ dlls/wined3d/directx.c | 23 +++++++++++++---------- dlls/wined3d/wined3d_private.h | 2 +- 4 files changed, 27 insertions(+), 19 deletions(-)
diff --git a/dlls/wined3d/adapter_gl.c b/dlls/wined3d/adapter_gl.c index cc78c9046b6c..5bf9d179e4da 100644 --- a/dlls/wined3d/adapter_gl.c +++ b/dlls/wined3d/adapter_gl.c @@ -5214,8 +5214,12 @@ static BOOL wined3d_adapter_gl_init(struct wined3d_adapter_gl *adapter_gl, gl_info->supported[ARB_TEXTURE_STORAGE] = FALSE; }
- wined3d_driver_info_init(driver_info, caps_gl_ctx.gpu_description, adapter_gl->a.d3d_info.feature_level, - caps_gl_ctx.vram_bytes, 0); + if (!wined3d_driver_info_init(driver_info, caps_gl_ctx.gpu_description, adapter_gl->a.d3d_info.feature_level, + caps_gl_ctx.vram_bytes, 0)) + { + wined3d_caps_gl_ctx_destroy(&caps_gl_ctx); + return FALSE; + } TRACE("Reporting (fake) driver version 0x%08x-0x%08x.\n", driver_info->version_high, driver_info->version_low);
diff --git a/dlls/wined3d/adapter_vk.c b/dlls/wined3d/adapter_vk.c index cbfb29cdd43b..fd7b29fc8afe 100644 --- a/dlls/wined3d/adapter_vk.c +++ b/dlls/wined3d/adapter_vk.c @@ -2037,7 +2037,7 @@ static enum wined3d_display_driver guess_display_driver(enum wined3d_pci_vendor } }
-static void adapter_vk_init_driver_info(struct wined3d_adapter_vk *adapter_vk, +static bool adapter_vk_init_driver_info(struct wined3d_adapter_vk *adapter_vk, const VkPhysicalDeviceProperties *properties) { const VkPhysicalDeviceMemoryProperties *memory_properties = &adapter_vk->memory_properties; @@ -2082,10 +2082,8 @@ static void adapter_vk_init_driver_info(struct wined3d_adapter_vk *adapter_vk, gpu_description = &description; }
- wined3d_driver_info_init(&adapter_vk->a.driver_info, gpu_description, adapter_vk->a.d3d_info.feature_level, - vram_bytes, sysmem_bytes); - TRACE("Reporting (fake) driver version 0x%08x-0x%08x.\n", - adapter_vk->a.driver_info.version_high, adapter_vk->a.driver_info.version_low); + return wined3d_driver_info_init(&adapter_vk->a.driver_info, gpu_description, + adapter_vk->a.d3d_info.feature_level, vram_bytes, sysmem_bytes); }
static enum wined3d_feature_level feature_level_from_caps(const struct shader_caps *shader_caps) @@ -2209,7 +2207,10 @@ static BOOL wined3d_adapter_vk_init(struct wined3d_adapter_vk *adapter_vk,
wined3d_adapter_vk_init_d3d_info(adapter_vk, wined3d_creation_flags);
- adapter_vk_init_driver_info(adapter_vk, &properties2.properties); + if (!adapter_vk_init_driver_info(adapter_vk, &properties2.properties)) + goto fail; + TRACE("Reporting (fake) driver version 0x%08x-0x%08x.\n", + adapter_vk->a.driver_info.version_high, adapter_vk->a.driver_info.version_low); adapter->vram_bytes_used = 0; TRACE("Emulating 0x%s bytes of video ram.\n", wine_dbgstr_longlong(adapter->driver_info.vram_bytes));
diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c index e797f2188810..67e96d1249c1 100644 --- a/dlls/wined3d/directx.c +++ b/dlls/wined3d/directx.c @@ -672,7 +672,7 @@ static void wined3d_copy_name(char *dst, const char *src, unsigned int dst_size) } }
-void wined3d_driver_info_init(struct wined3d_driver_info *driver_info, +bool wined3d_driver_info_init(struct wined3d_driver_info *driver_info, const struct wined3d_gpu_description *gpu_desc, enum wined3d_feature_level feature_level, UINT64 vram_bytes, UINT64 sysmem_bytes) { @@ -849,15 +849,13 @@ void wined3d_driver_info_init(struct wined3d_driver_info *driver_info, driver_info->name = version_info->driver_name; driver_info->version_high = MAKEDWORD_VERSION(driver_os_version, driver_feature_level); driver_info->version_low = MAKEDWORD_VERSION(version_info->subversion, version_info->build); + + return true; } - else - { - ERR("No driver version info found for device %04x:%04x, driver model %#x.\n", - driver_info->vendor, driver_info->device, driver_model); - driver_info->name = "Display"; - driver_info->version_high = MAKEDWORD_VERSION(driver_os_version, driver_feature_level); - driver_info->version_low = MAKEDWORD_VERSION(8, 6); /* NVIDIA RIVA TNT, arbitrary */ - } + + ERR("No driver version info found for device %04x:%04x, driver model %#x.\n", + driver_info->vendor, driver_info->device, driver_model); + return false; }
enum wined3d_pci_device wined3d_gpu_from_feature_level(enum wined3d_pci_vendor *vendor, @@ -2996,7 +2994,12 @@ static struct wined3d_adapter *wined3d_adapter_no3d_create(unsigned int ordinal, return NULL; }
- wined3d_driver_info_init(&adapter->driver_info, &gpu_description, WINED3D_FEATURE_LEVEL_NONE, 0, 0); + if (!wined3d_driver_info_init(&adapter->driver_info, &gpu_description, WINED3D_FEATURE_LEVEL_NONE, 0, 0)) + { + wined3d_adapter_cleanup(adapter); + heap_free(adapter); + return NULL; + } adapter->vram_bytes_used = 0; TRACE("Emulating 0x%s bytes of video ram.\n", wine_dbgstr_longlong(adapter->driver_info.vram_bytes));
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 82dfd507754a..83d790936f74 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -3199,7 +3199,7 @@ struct wined3d_driver_info DWORD version_low; };
-void wined3d_driver_info_init(struct wined3d_driver_info *driver_info, +bool wined3d_driver_info_init(struct wined3d_driver_info *driver_info, const struct wined3d_gpu_description *gpu_description, enum wined3d_feature_level feature_level, UINT64 vram_bytes, UINT64 sysmem_bytes) DECLSPEC_HIDDEN;