IASetInputLayout 是否检查是否传递了已设置的输入布局?

发布于 2024-12-27 06:05:32 字数 504 浏览 1 评论 0原文

我正在 DirectX 11 中设计游戏引擎,并且对 ID3D11DeviceContext::IASetInputLayout 函数有疑问。从我在文档中找到的内容来看,没有提及如果您为之前设置的设备设置输入布局,该函数将执行什么操作。在上下文中,如果我要执行以下操作:

//this assumes dc is a valid ID3D11DeviceContex interface and that
//ia is a valid ID3D11InputLayout interface.
dc->IASetInputLayout(&ia);

//other program lines: drawing, setting vertex shaders/pixel shaders, etc.

dc->IASetInputLayout(&ia);

//continue execution

这是否会因设备状态切换而导致性能损失,或者运行时是否会将输入布局识别为与已设置并返回的布局等效?

I am designing a game engine in DirectX 11 and I had a question about the ID3D11DeviceContext::IASetInputLayout function. From what i can find in the documentation there is no mention of what the function will do if you set an input layout to the device that has been previously set. In context, if i were to do the following:

//this assumes dc is a valid ID3D11DeviceContex interface and that
//ia is a valid ID3D11InputLayout interface.
dc->IASetInputLayout(&ia);

//other program lines: drawing, setting vertex shaders/pixel shaders, etc.

dc->IASetInputLayout(&ia);

//continue execution

would this incur a performance penalty through device state switching, or would the runtime recognize the input layout as being equivalent to the one already set and return?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

維他命╮ 2025-01-03 06:05:32

虽然我也找不到与 InputLayout 是否已设置相关的任何内容,但您可以通过调用 ID3D11DeviceContext::IAGetInputLayout 或通过保留自己的引用进行内部检查来获取指向已绑定的输入布局的指针,这样您就不会调用您的 ID3D11DeviceContext 对象。

While I also can not find anything related to if the InputLayout is already set, you could get a pointer to the input layout already bound by calling ID3D11DeviceContext::IAGetInputLayout or by doing an internal check by keeping your own reference, that way you do not have a call to your ID3D11DeviceContext object.

山川志 2025-01-03 06:05:32

据我所知,它应该检测到没有任何变化,因此调用将被忽略。但它可以轻松测试 - 只需每次渲染调用此方法 10000 次,看看 FPS 下降有多严重:)

As far as I know, it should detect that there are no changes and so the call is to be ignored. But it can be easily tested - just call this method 10000 times each render and see how bad FPS drop is :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文