Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The WGPU experiment #141

Closed
veeenu opened this issue Dec 29, 2023 · 7 comments
Closed

The WGPU experiment #141

veeenu opened this issue Dec 29, 2023 · 7 comments
Labels
breaking Fixing this would introduce a breaking change to the API. enhancement New feature or request
Milestone

Comments

@veeenu
Copy link
Owner

veeenu commented Dec 29, 2023

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

  • Improves maintainability by getting rid of all the engine-specific renderers and allowing to only focus on the hooking functionality
  • Improves the chance to maintain further hooks down the line
  • Avoids messing with the game renderers' state
  • Makes it easier to integrate new UI frameworks (looking at you, egui)
  • Potential positive side effects on performance: by running the UI frame renderer in parallel to the game engine's renderer, the game's frame time stays unaffected

Drawbacks

  • Potential negative side effects on performance: contention on GPU resources?

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 veeenu added enhancement New feature or request breaking Fixing this would introduce a breaking change to the API. labels Dec 29, 2023
@veeenu veeenu added this to the 0.6.0 milestone Dec 29, 2023
@veeenu
Copy link
Owner Author

veeenu commented Dec 29, 2023

Something is almost working in this branch.

@veeenu
Copy link
Owner Author

veeenu commented Dec 30, 2023

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
Copy link
Owner Author

veeenu commented Jan 4, 2024

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
Copy link
Owner Author

veeenu commented Jan 4, 2024

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
Copy link
Owner Author

veeenu commented Jan 4, 2024

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
Copy link
Owner Author

veeenu commented Jan 4, 2024

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

immagine

@veeenu
Copy link
Owner Author

veeenu commented Jan 26, 2024

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

@veeenu veeenu closed this as completed Jan 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking Fixing this would introduce a breaking change to the API. enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant