elishacloud / dxwrapper

Fixes compatibility issues with older games running on Windows 10/11 by wrapping DirectX dlls. Also allows loading custom libraries with the file extension .asi into game processes.
zlib License
1.16k stars 83 forks source link

[Chrome] Open in "Exclusive Fullscreen" instead of "Maximized Borderless Window" #130

Open carstenschwede opened 3 years ago

carstenschwede commented 3 years ago

Sorry in advance if this is the wrong place to ask. I am looking for an option to force Chrome on Windows 10 to open in "exclusive fullscreen" to circumvent DWM in order to avoid triple buffering.

I also tried and failed with DXWnd although I am not sure about the overlap in functionalities with this project.

Can DxWrapper be used to help me get tearlines in Chrome and Win10? :)

Thanks in advance.

carstenschwede commented 3 years ago

I think https://github.com/elishacloud/dxwrapper/issues/53 discusses similar issues in relation to input lag and DWM, in particular the comments by @UCyborg.

mirh commented 3 years ago

While investigating windows/drivers godawful shenanigans behind fullscreen is certainly an enterprise worth pursuing, chrome has nothing to do with this. It uses dx11, and a lot of other non-gaming apis.

carstenschwede commented 3 years ago

Don't know if this is relevant, but on Windows you can choose different rendering backend for Chrome (e.g. OpenGL/Direct3D9/11,...) Is DxWrapper something that can help me avoid DWM while using Chrome or am I on the wrong track?

elishacloud commented 3 years ago

@carstenschwede, as far as I know, the only way to avoid DWM is to run the program in exclusive fullscreen mode (as you mention). I don't have options in dxwrapper at this time to force a program into exclusive fullscreen mode.

I should be able to add a mode to force exclusive fullscreen mode when using Direct3D9. But, can you give more details on why you want to disable triple buffering?

Note: dxwrapper does not yet support OpenGL or Direct3D11. At this point I don't plan to add support for these renderers.

carstenschwede commented 3 years ago

@elishacloud Thanks for your response.

Chrome under Windows suffers from excessive input lag (https://bugs.chromium.org/p/chromium/issues/detail?id=460919). Disabling VSYNC on the GPU and in Chrome (--disable-gpu-vsync) in comparsion with higher app framerate helps, but without exclusive fullscreen, you apparently can't truly disable VSYNC when DWM is still enabled.

The Triple Buffering forced by DWM causes worst-case latencies of at least one frame (16ms on 60Hz) which I would like to avoid.

On my 60 Hz display, Chrome has median input lag of >50ms. Disabling DWM via Exclusive Fullscreen (and running my app at 240fps in VSYNC OFF) could reduce worst case lag to <8ms.

elishacloud commented 2 years ago

@carstenschwede, I added a feature to force exclusive fullscreen mode. The new option is ForceExclusiveFullscreen. This requires using Direct3D9. Also, it will only set exclusive fullscreen mode when running the program in a resolution supported by exclusive fullscreen mode.

I don't have a good way to test this so I added some extra logging in case there is any issues.

Here is the update: dxwrapper.zip

carstenschwede commented 2 years ago

@elishacloud Thanks a lot!

I extracted the files in the directory with the chrome.exe binary and created two shortcuts:

Fullscreen: chrome.exe --use-angle=d3d9 --disable-gpu-watchdog --disable-gpu-program-cache --start-fullscreen --disable-frame-rate-limit --disable-gpu-vsync "http://vsynctester.com"

Opens in fullscreen, but not exclusive.


Window with fullscreen resolution: chrome.exe --use-angle=d3d9 --disable-gpu-watchdog --disable-gpu-program-cache --disable-frame-rate-limit --disable-gpu-vsync --chrome-frame --window-size=1920,1080 --app="http://vsynctester.com"

Does not open in fullscreen, just regular window of fullscreen size.


Looking at chrome://gpu, I can see the Direct3D9 backend being used, however, I do not see a dxwrapper-chrome.log being created. I thus assume that dxwrapper is not active in this case or the d3d9.dll is not used by Chrome?


I took a look at Chrome in the Process Explorer and it is using System32\d3d9.dll instead of the local one. Replacing it with the one including in your zip-file results in Chrome not using d3d9.dll at all with the following log messages:

[6644:10628:0717/155704.338:ERROR:gl_surface_egl.cc(780)] : EGL Driver message (Critical) eglInitialize: No available renderers.
[6644:10628:0717/155704.338:ERROR:gl_surface_egl.cc(1373)] : eglInitialize D3D9 failed with error EGL_NOT_INITIALIZED
[6644:10628:0717/155704.338:ERROR:gl_initializer_win.cc(143)] : GLSurfaceEGL::InitializeOneOff failed.
[6644:10628:0717/155704.341:ERROR:viz_main_impl.cc(160)] : Exiting GPU process due to errors during initialization
GpuProcessHost: The GPU process exited normally. Everything is okay.
[12508:12984:0717/155704.661:ERROR:gpu_init.cc(440)] : Passthrough is not supported, GL is swiftshader
GpuProcessHost: The info collection GPU process exited normally. Everything is okay.
elishacloud commented 2 years ago

I took a look at Chrome in the Process Explorer and it is using System32\d3d9.dll instead of the local one.

I just realized that you are probably running the 64bit version of Chrome. If that is the case then this wrapper will not work as it is only 32bit version. I don't know what it would take to build a 64bit version of this wrapper, but it is far outside of what I plan to do at this point.

carstenschwede commented 2 years ago

Ah, ok the 32bit version of Chrome indeed uses the correct d3d9.dll ("Stub for DxWrapper"). I however still don't see an effect in windowed or fullscreen mode and also no log file is being created in the same directory.

Chrome is installed in a user owned directory (~/Downloads/...); running Chrome with Administrator privileges doesn't change anything (i.e. still no log being created).

Any ideas?

elishacloud commented 2 years ago

Can you post your log file? There may be something in the log file that will give a clue on what is happening.

Edit: make sure that you have dxwrapper.dll in the same folder as the stub and that dxwrapper.dll is being loaded also.

carstenschwede commented 2 years ago

I managed to get a log file by adding --disable-gpu-sandbox to Chrome's arguments, still no executive fullscreen:

15032 13:31:59.567 Starting DxWrapper v1.0.6544.21
15032 13:31:59.567 Running from: C:\Users\MyUser\Downloads\Chrome\App\Chrome-bin\dxwrapper.dll
15032 13:31:59.567 Reading config file: C:\Users\MyUser\Downloads\Chrome\App\Chrome-bin\dxwrapper.ini
15032 13:31:59.567 Gigabyte Technology Co., Ltd. Z87MX-D3H To be filled by O.E.M. (Desktop)
15032 13:31:59.567 Gigabyte Technology Co., Ltd. Z87MX-D3H-CF To be filled by O.E.M. (Desktop)
15032 13:31:59.568 NVIDIA GeForce GTX 1080
15032 13:31:59.568 Windows 10 Enterprise 64-bit (10.0.19041)
15032 13:31:59.568 "chrome.exe" (PID:15028)
15032 13:31:59.574 Environment variable __COMPAT_LAYER = ""
15032 13:31:59.574 Disabling High DPI Scaling...
15032 13:31:59.574 Loaded library: user32.dll
15032 13:31:59.574 Loaded library: shcore.dll
15032 13:31:59.574 Enabling d3d9 wrapper
15032 13:31:59.574 Loading 'd3d9.dll'...
15032 13:31:59.574 Hooking d3d9.dll APIs...
15032 13:31:59.574 DxWrapper loaded!
15032 13:31:59.577 d9_Direct3DCreate9Ex
15032 13:31:59.577 Redirecting 'Direct3DCreate9Ex' ...
15032 13:31:59.633 Creating interface m_IDirect3D9Ex::m_IDirect3D9Ex (04AD3240)
carstenschwede commented 2 years ago

Polite ping @elishacloud, is the log helpful?

carstenschwede commented 2 years ago

@elishacloud Would be great if you could take a look at this if you find the time. Thanks!