veeenu / hudhook

A videogame overlay framework written in Rust, supporting DirectX and OpenGL
MIT License
207 stars 30 forks source link

The WGPU experiment #141

Closed veeenu closed 9 months ago

veeenu commented 10 months ago

I want to run a small, isolated experiment: build a wgpu renderer, check if it can be run in parallel to a game's renderer, and use BitBlt or similar to overlay the surface.

This would change the approach of hudhook to further reduce coupling, complexity, and maintainability effort: we could easily get rid of all the per-framework renderers, and get access to those for free when instantiating a hook.

Benefits

Drawbacks


If the experiment proves successful, I will keep the current "legacy" renderers as-is for 0.6.0, and then remove them in 0.7.0 once enough people have had the chance to test it.

veeenu commented 10 months ago

Something is almost working in this branch.

veeenu commented 10 months ago

Progress report: here's a small demo of a DirectX 12 renderer overlaid on top of Dark Souls III's DirectX 11 surface.

out.webm

Next attempt is trying this against different renderers -- DX9, OpenGL, Vulkan. WGPU has proven a bit difficult to work with in regards to handling transparency, but I'll give it another shot.

veeenu commented 10 months ago

With no changes at all, the same library hooks successfully against a DirectX 12 game:

immagine

This suggests a method for detecting hook type could be feasible -- just using simple heuristics like check if a given DLL is loaded or not.

I am going to test against DX9 and OpenGL by replicating their hooks, and once I can confirm they work as well I will start a massive refactor.

veeenu commented 10 months ago

Dark Souls (DX9) is a go. Had to change the Dx12 device to use D3D_FEATURE_LEVEL_11_1 at creation, but with that value Dark Souls III and Elden Ring still work.

immagine

veeenu commented 10 months ago

A note: it is possible to block the game window from receiving messages by overlaying a transparent HWND on top of it, and selectively altering its WS_EX_TRANSPARENT state. This could solve #79 finally

veeenu commented 10 months ago

OpenGL confirmed! We can now support all existing renderers, and adding new ones is going to be almost trivial.

immagine

veeenu commented 9 months ago

143 implements this (though a DirectX12 renderer and not a WGPU renderer).