[PATCH v17 0/1] MR11398: wined3d: Support WINE_D3D_CONFIG=no_create_flags=0x800 (bug #50277)
Fix for UnityPlayer.dll calls to D3D11_CREATE_DEVICE_VIDEO_SUPPORT until supported. Forces UnityPlayer.dll software video decoding which skips all the cross-device multi-thread calls involving dxgi_resource_GetSharedHandle and d3d11_device_OpenSharedResource. https://bugs.winehq.org/show_bug.cgi?id=50277#c46 -- v17: wined3d: Support WINE_D3D_CONFIG=no_create_flags=0x800 https://gitlab.winehq.org/wine/wine/-/merge_requests/11398
From: Stian Low <wineryyyyy@gmail.com> --- dlls/dxgi/device.c | 8 ++++++-- dlls/dxgi/dxgi_main.c | 2 +- dlls/dxgi/dxgi_private.h | 3 ++- dlls/wined3d/directx.c | 13 +++++++++++++ dlls/wined3d/wined3d_main.c | 2 ++ dlls/wined3d/wined3d_private.h | 1 + include/wine/wined3d.h | 1 + 7 files changed, 26 insertions(+), 4 deletions(-) diff --git a/dlls/dxgi/device.c b/dlls/dxgi/device.c index eedcc81d845..40ab6deae6d 100644 --- a/dlls/dxgi/device.c +++ b/dlls/dxgi/device.c @@ -485,7 +485,7 @@ static const struct IWineDXGISwapChainFactoryVtbl dxgi_swapchain_factory_vtbl = }; HRESULT dxgi_device_init(struct dxgi_device *device, struct dxgi_device_layer *layer, - IDXGIFactory *factory, IDXGIAdapter *adapter, + IDXGIFactory *factory, IDXGIAdapter *adapter, unsigned int flags, const D3D_FEATURE_LEVEL *feature_levels, unsigned int level_count) { struct wined3d_device_parent *wined3d_device_parent; @@ -494,6 +494,7 @@ HRESULT dxgi_device_init(struct dxgi_device *device, struct dxgi_device_layer *l struct dxgi_adapter *dxgi_adapter; struct dxgi_factory *dxgi_factory; struct dxgi_output *dxgi_output; + unsigned int wined3d_flags = 0; struct IDXGIOutput *output; void *layer_base; HWND window; @@ -540,8 +541,11 @@ HRESULT dxgi_device_init(struct dxgi_device *device, struct dxgi_device_layer *l wined3d_device_parent = IWineDXGIDeviceParent_get_wined3d_device_parent(dxgi_device_parent); IWineDXGIDeviceParent_Release(dxgi_device_parent); + if (flags & D3D11_CREATE_DEVICE_VIDEO_SUPPORT) + wined3d_flags |= WINED3DCREATE_VIDEO_SUPPORT; + if (FAILED(hr = wined3d_device_create(dxgi_factory->wined3d, - dxgi_adapter->wined3d_adapter, WINED3D_DEVICE_TYPE_HAL, NULL, 0, 4, + dxgi_adapter->wined3d_adapter, WINED3D_DEVICE_TYPE_HAL, NULL, wined3d_flags, 4, (const enum wined3d_feature_level *)feature_levels, level_count, wined3d_device_parent, &device->wined3d_device))) { diff --git a/dlls/dxgi/dxgi_main.c b/dlls/dxgi/dxgi_main.c index ca1fb525535..36ce309db37 100644 --- a/dlls/dxgi/dxgi_main.c +++ b/dlls/dxgi/dxgi_main.c @@ -191,7 +191,7 @@ HRESULT WINAPI DXGID3D10CreateDevice(HMODULE d3d10core, IDXGIFactory *factory, I return E_OUTOFMEMORY; } - hr = dxgi_device_init(dxgi_device, &d3d10_layer, factory, adapter, feature_levels, level_count); + hr = dxgi_device_init(dxgi_device, &d3d10_layer, factory, adapter, flags, feature_levels, level_count); if (FAILED(hr)) { WARN("Failed to initialize device, hr %#lx.\n", hr); diff --git a/dlls/dxgi/dxgi_private.h b/dlls/dxgi/dxgi_private.h index ed82d366799..6ecd5751243 100644 --- a/dlls/dxgi/dxgi_private.h +++ b/dlls/dxgi/dxgi_private.h @@ -32,6 +32,7 @@ #include "dxgi1_6.h" #include "d3d10_1.h" +#include "d3d11.h" #include "d3d12.h" #ifdef DXGI_INIT_GUID #include "initguid.h" @@ -138,7 +139,7 @@ struct dxgi_device }; HRESULT dxgi_device_init(struct dxgi_device *device, struct dxgi_device_layer *layer, - IDXGIFactory *factory, IDXGIAdapter *adapter, + IDXGIFactory *factory, IDXGIAdapter *adapter, unsigned int flags, const D3D_FEATURE_LEVEL *feature_levels, unsigned int level_count); /* IDXGIOutput */ diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c index e75c3cf625e..f580e129836 100644 --- a/dlls/wined3d/directx.c +++ b/dlls/wined3d/directx.c @@ -25,6 +25,7 @@ #include "wined3d_gl.h" #include "winternl.h" #include "wine/list.h" +#include "d3d11.h" WINE_DEFAULT_DEBUG_CHANNEL(d3d); WINE_DECLARE_DEBUG_CHANNEL(winediag); @@ -2788,6 +2789,7 @@ HRESULT CDECL wined3d_device_create(struct wined3d *wined3d, struct wined3d_adap struct wined3d_device_parent *device_parent, struct wined3d_device **device) { struct wined3d_device *object; + uint32_t wined3d_flags = 0; HRESULT hr; TRACE("wined3d %p, adapter %p, device_type %#x, focus_window %p, flags %#x, " @@ -2795,6 +2797,17 @@ HRESULT CDECL wined3d_device_create(struct wined3d *wined3d, struct wined3d_adap wined3d, adapter, device_type, focus_window, flags, surface_alignment, feature_levels, feature_level_count, device_parent, device); + /* Unity uses shared resources if D3D11_CREATE_DEVICE_VIDEO_SUPPORT succeeds, + * so allow failing for now */ + if (wined3d_settings.no_create_flags & D3D11_CREATE_DEVICE_VIDEO_SUPPORT) + wined3d_flags |= WINED3DCREATE_VIDEO_SUPPORT; + + if (flags != (flags & ~wined3d_flags)) + { + FIXME("Failing for device create flags 0x%x forced unsupported by WINE_D3D_CONFIG override.\n", wined3d_settings.no_create_flags); + return E_FAIL; + } + if (FAILED(hr = adapter->adapter_ops->adapter_create_device(wined3d, adapter, device_type, focus_window, flags, surface_alignment, feature_levels, feature_level_count, device_parent, &object))) diff --git a/dlls/wined3d/wined3d_main.c b/dlls/wined3d/wined3d_main.c index 91d8dd567ff..2deefb127b7 100644 --- a/dlls/wined3d/wined3d_main.c +++ b/dlls/wined3d/wined3d_main.c @@ -344,6 +344,8 @@ static BOOL wined3d_dll_init(HINSTANCE hInstDLL) { if (!get_config_key_dword(hkey, appkey, env, "csmt", &wined3d_settings.cs_multithreaded)) ERR_(winediag)("Setting multithreaded command stream to %#x.\n", wined3d_settings.cs_multithreaded); + if (!get_config_key_dword(hkey, appkey, env, "no_create_flags", &wined3d_settings.no_create_flags)) + ERR_(winediag)("Force D3D device creation without support for flags %#x.\n", wined3d_settings.no_create_flags); if (!get_config_key_dword(hkey, appkey, env, "MaxVersionGL", &tmpvalue)) { ERR_(winediag)("Setting maximum allowed wined3d GL version to %u.%u.\n", diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 9537670f7c5..8f6d777168c 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -466,6 +466,7 @@ struct wined3d_settings { unsigned int cs_multithreaded; unsigned int max_gl_version; + unsigned int no_create_flags; unsigned short pci_vendor_id; unsigned short pci_device_id; /* Memory tracking and object counting. */ diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index 49c6672fa3f..2a6b6a59243 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -1054,6 +1054,7 @@ enum wined3d_memory_segment_group #define WINED3DCREATE_ENABLE_PRESENTSTATS 0x00004000 #define WINED3DCREATE_DISABLE_PRINTSCREEN 0x00008000 #define WINED3DCREATE_SCREENSAVER 0x10000000 +#define WINED3DCREATE_VIDEO_SUPPORT 0x20000000 /* VTF defines */ #define WINED3DDMAPSAMPLER 0x100 -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11398
Latest push has been refactored to satisfy consensus favorability to minimize support for overriding d3d create flags by limiting to only D3D11_CREATE_DEVICE_VIDEO_SUPPORT in order to expedite quickest available fixes for users. Elderborn test results for latest minimized/limited patch: - https://bugs.winehq.org/show_bug.cgi?id=50277#c81 ``` 0024:fixme:dxgi:DXGID3D10CreateDevice Ignoring flags 0x20. 0024:fixme:dxgi:DXGID3D10CreateDevice Ignoring flags 0x820. ``` 1. `WINE_D3D_CONFIG=no_create_flags=0x20` Neither primary nor secondary d3d device creations are skipped thus reproducing video bug. Previous patch failed for primary device creation now ignored for 0x20. 2. `WINE_D3D_CONFIG=no_create_flags=0x800` and `WINE_D3D_CONFIG=no_create_flags=0x820` Only secondary d3d device creation is skipped thus fixing video bug via software video processing fallback for UnityPlayer.dll. Previous patch failed only for secondary device for 0x800 and both devices for 0x820 but 0x20 is now ignored for primary device fail. Please let me know if anything else should be changed. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/11398#note_148277
On Fri Aug 7 12:26:46 2026 +0000, Stian Low wrote: > Latest push has been refactored to satisfy consensus favorability to > minimize support for overriding d3d create flags by limiting to only > D3D11_CREATE_DEVICE_VIDEO_SUPPORT in order to expedite quickest > available fixes for users. > Elderborn test results for latest minimized/limited patch: > - https://bugs.winehq.org/show_bug.cgi?id=50277#c81 > ``` > 0024:fixme:dxgi:DXGID3D10CreateDevice Ignoring flags 0x20. > 0024:fixme:dxgi:DXGID3D10CreateDevice Ignoring flags 0x820. > ``` > 1. `WINE_D3D_CONFIG=no_create_flags=0x20` > Neither primary nor secondary d3d device creations are skipped thus > reproducing video bug. > Previous patch failed for primary device creation now ignored for 0x20. > 2. `WINE_D3D_CONFIG=no_create_flags=0x800` and `WINE_D3D_CONFIG=no_create_flags=0x820` > Only secondary d3d device creation is skipped thus fixing video bug via > software video processing fallback for UnityPlayer.dll. > Previous patch failed only for secondary device for 0x800 and both > devices for 0x820 but 0x20 is now ignored for primary device fail. > Please let me know if anything else should be changed. MR-11612 captures/continues more expansive overrides patch to support all d3d/ddraw create flags instead of only D3D11_CREATE_DEVICE_VIDEO_SUPPORT if ever needed: - https://gitlab.winehq.org/wine/wine/-/merge_requests/11612 Maybe its appropriate enough for wine-staging without additional requirements that may block it for non-staging in the meantime. Otherwise it may need to fulfill additional requirements to be considered safe enough for merge anywhere. Further discussion regarding wider scope beyond just D3D11_CREATE_DEVICE_VIDEO_SUPPORT should be redirected to MR-11612. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/11398#note_148286
MR-11612 has been closed for support of more expanded form of this solution per wined3d reviewer feedback so this is an update regarding it. - https://gitlab.winehq.org/wine/wine/-/merge_requests/11612#note_149079 MR-11612 was referred to as a "dead end" which wined3d maintainers also seem to consider this patch despite expressing that it may be merged if narrowed to its current form so it may still be at risk of rejection. However MR-11404 as share resources alternative has been recommended to be pulled from DXVK implementation which wined3d maintainers have also called a "dead end." Therefore both solutions seem at risk of rejection for similar sentiments with the latter due to affiliation with DXVK as a source of contention for wined3d maintainers. It is unfortunate but it seems supporting user freedom is not top priority for wined3d team but rather secondary to other priorities which seems imbalanced and misaligned with what should be core values. DXVK seems so successful because users are more top priority. If wined3d team were to prioritize supporting user freedom more then these video bugs probably would have been fixed sometime over the past 8 years. Since providing this trivial solution to fix these video bugs, wined3d maintainers have indicated that these bugs are deliberately not fixed either to not "cover up" other bugs or to not break 1 unknown app that still cannot be named nor explained in any detail. Deliberately undermining user freedom over priority to not "cover up" other bugs seems to have proven ineffective and instead led to a different "cover up" of the underlying problem that lead to 8 years of unnecessary confusion and frustration also. If the strategy not to "cover up" were effective then at very least bugs would have been marked duplicate and clarified by those who chose to deliberately limited users freedom to have their apps work. Because `D3D11_CREATE_DEVICE_VIDEO_SUPPORT` was believed to be supported until proven false during this merge request, it seems these bugs may not have actually been left deliberately broken but rather by some accident which introduced bugs that unnecessarily limit users freedom. Bottom line, UnityPlayer is meant to support fallback video playback so users should have the freedom to use it. It's possible there may be performance differences that further justify it but regardless users should have the freedom to choose which this merge and MR-11612 promoted over any other priorities like unclear maintenance concerns or one mysterious app which would not be broken by this merge. Therefore my advice to any users who wanted this merged is to choose to align with the team that cares most about your freedom which at this moment is DXVK and proton teams rallied around it. Solutions that prioritize user freedom referred to by wined3d team as "dead end" seem to come from a place of misaligned priorities. Some paths are still wide open and free flowing with solutions despite wined3d wishing they were closed as dead ends as soon as possible. If user freedom is not eventually better prioritized by wind3d then perhaps a new d3d1ring to rule them all may be appropriate to be trusted in the hands of those who always put user freedom first. Part of my focus on wine d3d was to better understand how to most universally support indie game endeavors. My hope was to add more universality but some dependencies seem too immovable and gate kept from the most trivial progress in a most counterintuitive way. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/11398#note_149268
It seems !11720 and other related merges will handle fulfilling user freedom to force UntiyPlayer to fallback video playback via `decoder_backend=none` vs `no_create_flags=0x800` That small change would have been included with this merge upon request which seems favorable to maintainers because it does not introduce a new flag but rather just a new value for existing flag `decoder_backend` I have no further objections other than what was advocated for !11612 which will remain closed for now since the highest priority to fixed users videos will be fulfilled one way or another without it. This merge request will likely be closed as overridden by !11720 and related which will also include shared resources with support likely limited to only vulkan for now. Therefore users who were interested in this merge will either need to use `decoder_backend=none` to skip shared_resources or `renderer=vulkan` for shared_resources compatibility. Maybe it's best to to have renderer=gl default to `decoder_backend=none` until gl also supports shared resources and renderer=vulkan to default to supporting shared_resources. Either way users will have the freedom to override to fix whatever bugs may arise from less compatible combinations that may be encountered. All of this effort is very encouraging and appreciate and worthy of renewed enthusiasm for any that may have been lost for wined3d. I will shift focus to getting !10567 over the finish line since this merge is partially dependent upon it because UnityPlayer videos and gameplay render too dark for win10 until merged so that `winecfg /v win8` is not also required as another workaround in the meantime. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/11398#note_149513
participants (2)
-
Stian Low -
Stian Low (@stianlow)