调整IDXGISWAPCHAIN2 :: SETMAXIMEM FRAMELATINCY中设置的值

发布于 2025-01-30 18:50:18 字数 1238 浏览 4 评论 0原文

我使用dxgi_swap_chain_flag_frame_frame_latency_waitable_objectgetframelatencyWaitableObject()setMaximumframelatency(uint maxlatency) getframelatencyWaitableBignt(uint maxlatency)。 1值1给出最低的输入滞后,但有时我需要更高的值来减少由CPU和GPU引起的抖动/口吃/放缓,而GPU在值为1时实际上无法并行工作。

我希望能够动态地更改此值基于所需的输入滞后与平滑度权衡。

我注意到的问题是,虽然在框架之间可以通过调用setMaximumframelatency的值,但值的值比以前更高通过先前调用相同函数的呼叫,比该互换链设置的最大值低。因此,如果我将其设置为2,则不可能将其设置为1。这是一个错误还是无证件的“功能”?还是我做错了什么?

API本身不会返回任何错误或类似的错误;从API的角度来看,它似乎正确应用了新的较低值。

为了测试这一点,我的BufferCount = 16,然后将最大延迟值从1个调整到16,这使当前的延迟显而易见。因此,显然DXGI不应用新的较低值。

我试图以不同的订单调用功能,关闭可钉对象的句柄,并在修改延迟时重新创建新的函数,但没有任何作用。到目前为止,我知道唯一的解决方法是完全重新创建交换链,这很烦人,这是由于需要解开所有上下文对象等的要求

,因此我创建掉期链,并使用setMaximumframelatency 。

然后,游戏循环基本上是这样的:

  1. call waitforsingleobject在可钉对象句柄上。
  2. 过程输入。
  3. 渲染并提出框架。
  4. 如果确定延迟应在这一点上发生变化,请使用新值调用setMaximumframelatency

其他信息:

  • 渲染器:Direct3d 11
  • OS:Windows 11 21H2版本22000.675
  • 图形卡:Intel UHD Graphics 620 / nvidia GeForce MX150(使用这两张卡进行了尝试),使用最新驱动程序,支持WDDM 3.0
  • App类型:Win32台式应用程序:Win32 Desktop应用程序

I use the combination of DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT, GetFrameLatencyWaitableObject() and SetMaximumFrameLatency(UINT MaxLatency) to control the input lag vs. smoothness of my application as explained at https://learn.microsoft.com/en-us/windows/uwp/gaming/reduce-latency-with-dxgi-1-3-swap-chains. A value of 1 gives the lowest input lag, but sometimes I need a higher value to reduce jitter/stutter/slowdown caused by cpu and gpu cannot really work in parallel when the value is 1.

I want to be able to dynamically change this value based on the required input lag vs smoothness trade-off.

The problem I have noticed is that while it's possible to, between frames, increase this value by calling SetMaximumFrameLatency with a higher value than set before, I see no effect when decreasing this value by calling the function again with a lower value than the maximum value ever set for this swap chain by a previous call to the same function. So if I ever set it to 2, it is not possible to set it to 1 later. Is this a bug or undocumented "feature"? Or did I do something wrong?

The API itself does not return any error or similar; from the API point of view it appears to apply the new lower value correctly.

To test this, I have BufferCount = 16 and then adjust the max latency value from 1 to 16 which makes the current latency obvious to the eye. It's therefore apparent that dxgi does not apply new lower values.

I've tried to call functions in different orders, close the handle for the waitable object and recreate a new one when modifying the latency, but nothing works. The only workaround so far I'm aware of is to fully recreate the swap chain, which is annoying due to the requirement to unbind all context objects etc.

When initializing the game, I create the swap chain and set an initial latency using SetMaximumFrameLatency.

The game loop is then basically this:

  1. Call WaitForSingleObject on the waitable object handle.
  2. Process inputs.
  3. Render and present a frame.
  4. If it's decided that the latency should change at this point, call SetMaximumFrameLatency with the new value.

Other info:

  • Renderer: Direct3D 11
  • OS: Windows 11 21H2 version 22000.675
  • Graphics card: Intel UHD Graphics 620 / Nvidia GeForce MX150 (tried with both cards) with latest drivers, supporting WDDM 3.0
  • App type: Win32 desktop application

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文