简体   繁体   English

在DirectX11游戏上叠加

[英]Overlay on DirectX11 game

I'm working on a project to show an overlay on any DirectX11 games. 我正在开展一个项目,以显示任何DirectX11游戏的叠加层。 Now the overaly can show in some DX11 games but cannot in some others. 现在,在一些DX11游戏中可以显示但是在其他一些游戏中却无法显示。

I hooked the DX11 API IDXGISwapChain::Present() using the MS Detour. 我使用MS Detour连接了DX11 API IDXGISwapChain :: Present()。 In the function Present(), I setup each pipeline, call the DrawIndex and ResourceCopy update my overlay texture to GPU's memory, then call the original Present to bring the back buffer to front buffer. 在函数Present()中,我设置每个管道,调用DrawIndex和ResourceCopy将我的覆盖纹理更新到GPU的内存,然后调用原始Present将后缓冲区带到前缓冲区。 It works fine in some games like Unigene and DIRT2 but it doesn't work on some others like LostPlanet2 and DragonAge2. 它在Unigene和DIRT2等游戏中运行良好,但它不适用于LostPlanet2和DragonAge2等其他游戏。

Doing some logging with hooking all DX11 functions, I found an interesting things - those not working games call ResourceCopy and ResourceCopyRegion before calling Present. 通过挂钩所有DX11功能进行一些日志记录,我发现了一些有趣的事情 - 那些不工作的游戏在调用Present之前调用ResourceCopy和ResourceCopyRegion。

Like I said previously, I also called the ResourceCopy in my Present(). 就像我之前说的那样,我也在我的Present()中调用了ResourceCopy。 Is it the reason why it doesn't work? 这是它不起作用的原因吗? How can I workarround it? 我该怎么办呢?

Thanks, Marshall 谢谢,马歇尔

I am also developing a similar D3D11 proxy hook. 我也在开发类似的D3D11代理钩子。 However, I begin from the entrypoints D3D11CreateDevice and D3D11CreateDeviceAndSwapChain. 但是,我从入口点D3D11CreateDevice和D3D11CreateDeviceAndSwapChain开始。 Then use replacement classes as hooks to my own. 然后使用替换类作为我自己的钩子。 I found that some cases Detours cannot actually perform the detour properly: Error detouring EntryPoint(): 6 I worked around this by actually modifying the Detours 3.0 source code to trampoline the function correctly. 我发现有些案例Detours实际上无法正确执行绕行:错误绕道入口Point():6我通过实际修改Detours 3.0源代码来正确地蹦蹦跳来解决这个问题。

I am working with 64 bit Windows 7 but compiled for x86 Detours 3.0. 我正在使用64位Windows 7,但编译为x86 Detours 3.0。 I can try out those binaries to work. 我可以尝试使用这些二进制文件。 It's quite hard to explain where ResourceCopy can influence the call path other than rendering style used by the programmer. 除了程序员使用的渲染样式之外,很难解释ResourceCopy可以影响调用路径的位置。 If you like, you can send me your project code and I might be able to help. 如果您愿意,可以将项目代码发送给我,我也许可以提供帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM