是否可以通过编程方式查看游戏使用的图形API? [英] Is there a programmatic way to see what graphics API a game is using?

查看:401
本文介绍了是否可以通过编程方式查看游戏使用的图形API?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于DOTA 2之类的可以与DX9,DX11,Vulkan等不同图形API一起运行的游戏,我无法提出一种可行的解决方案来检查当前使用的是哪个API。我想这样做是为了正确注入一个dll以便在游戏上显示图像。

For games like DOTA 2 which can be run with different graphics API's such as DX9, DX11, Vulkan, I have not been able to come up with a viable solution to checking which of the API's its currently using. I want to do this to correctly inject a dll in order to display images over the game.

我研究了手动检查游戏加载了哪些dll

I have looked into manually checking what dll's the games have loaded,

此工具为例: https ://docs.microsoft.com/zh-cn/sysinternals/downloads/listdlls

但是,对于DOTA,它会同时加载d3d9 .dll和d3d11.dll库(如果未在Steam上的启动选项中指定)。有人对如何确定使用的正确图形API有其他想法吗?

however, in the case of DOTA, it loads in both d3d9.dll and d3d11.dll libraries if none is specified in launch options on steam. Anyone have any other ideas as to how to determine the correct graphics API used?

推荐答案

在Vulkan中,一种干净的方法是实现覆盖的Vulkan层。它比直接注入dll稍微干净。它可以在多个平台上工作。

In Vulkan, a clean way would be to implement a Vulkan Layer doing the overlay. It is slightly cleaner than outright injecting dlls. And it could work on multiple platforms.

在DirectX中,screencap软件通常可以做到这一点。某些软件会添加FPS计数器和此类覆盖图。似乎有类似目标的开源,例如此处: https://github.com/GPUOpen-Tools/OCAT 。我相信通常该方法是拦截(即在win32 api术语中为 hook)所有适当的API调用。

In DirectX, screencap software typically does this. Some software adds FPS counter and such overlays. There seems to be open source with similar goals e.g. here: https://github.com/GPUOpen-Tools/OCAT. I believe conventionally the method is to intercept (i.e. "hook" in win32 api terminology) all the appropriate API calls.

对于简单检测,如果调用 D3D12CreateDevice ,则可能是Direct3D12。但是同样,该应用也可以为所有API创建设备,并继续不使用它们。但是我认为,如果您只想进行覆盖,则API检测对您而言并不是特别重要;只要您拦截所有当前通话并在其上方绘制内容即可。

As for simple detection, if it calls D3D12CreateDevice then it likely is Direct3D 12. But then again the app could create devices for all the APIs too and proceed not to use them. But I think the API detection is not particularly important for you if you only want to make an overlay; as long as you just intercept all the present calls and draw your stuff on top of it.

这篇关于是否可以通过编程方式查看游戏使用的图形API?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆