Squirrelies / RE2REmakeSRT

An SRT (SpeedRun Tool) for Resident Evil 2 (2019).
MIT License
48 stars 11 forks source link

[BUG] DirectX Overlay does not render in DX11 Fullscreen mode. #21

Open Squirrelies opened 4 years ago

Squirrelies commented 4 years ago

Computer Information:

Describe the bug Overlay does not draw when DX11 Fullscreen mode is selected. All other modes work. Originally reported by Failmore (via Twitch stream).

Steps to Reproduce Steps to reproduce the behavior:

  1. Set renderer to DirectX 11.
  2. Set window mode to Fullscreen.
  3. Restart game.
  4. Run SRT with DirectX Overlay enabled.

Expected behavior Overlay to draw.

Screenshots N/A

Additional context DX11 Fullscreen: Broken DX11 Borderless Windowed: Works DX12 Fullscreen: Works DX12 Borderless Windowed: Works

Squirrelies commented 4 years ago

We are currently drawing to an invisible, click-through, always-on-top WinForm. We need to hook the game's d3d11.dll EndScene/Present methods and write there instead.

hntd187 commented 4 years ago

When I created my overlay I started by attempting to fix your overlay, but I found the winforms window to just be insanely difficult to get reasonably working.

From this point I went and looked into how you could do the dll and function hooking from C# and again found very little resources concerning how to do this. Strangely enough the REEngine is a mix of C# and C++ so the interop with C# should be better but for the most part the answer I got when I asked about doing graphics like this in C# was "Do it in C++ instead" I know I haven't said anything helpful yet, but unless you want to go through a good bit of effort I ended up writing mine in C++ and leveraging the RE2 Framework to make the hooking and memory scanning a lot easier. You'll also find the memory scanning from a hooked function inside D3D11 is different than how you are currently doing it which again may make things harder. Either way mine might provide a good basis for what you want to do if you decide to go down that route.

Squirrelies commented 4 years ago

Yeah I think I have the hooking of the Present function working but I am having difficulties getting the drawing working. I'll check out your code and see how you're doing it in C++. Maybe it can be transplanted. Thanks!

hntd187 commented 4 years ago

It's just DirectX was built to be used in C++ so doing things easily in C# is just from what I tried to do terrible. I guess if this was unity it'd be much easier, but alas not so. You could offload some of the memory reading you have to an FFI in C# and use the C++ hooking purely for drawing on the screen.

Squirrelies commented 4 years ago

SharpDX handles the native calls but most of my knowledge was around Direct2D and further wrappers for that. Not too knowledgeable on vertex shaders and so on, so looking at /src/re2-imgui/imgui_impl_dx11.cpp from your project has given me a starting point to see what I was missing in my test project.

hntd187 commented 4 years ago

That is the actual code that helps draw the gui in imgui, I did not write it so I don't know if you want to try and replicate it as it's made for imgui. You're better off in my opinion just using that impl directly and using something like imgui to assist in the interface drawing. It will be a lot of work to create your own there.