DirectX Resize在Edges中显示Win32背景 [英] DirectX Resize shows win32 background at Edges

查看:113
本文介绍了DirectX Resize在Edges中显示Win32背景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在DirectX中缩小尺寸时,我注意到底部/右侧边缘闪烁。

When resizing down in DirectX I noticed a flicker along the bottom/right edges.

如果您固定交换链的大小(以红色表示),并将win32背景设置为绿色,则在调整大小时将得到以下内容:

If you fix the size of the swapchain (in red), and set the win32 background to green you will get the following on a resize down:

似乎窗口大小落后于鼠标位置(拖动矩形),但是DirectX填充的区域(红色和黑色)与拖动矩形,其余部分用窗口背景色(绿色)绘制。

It appears that the window size lags behind the mouse position ("Drag Rectangle") but the area DirectX fills (in red and black) matches the Drag Rectangle, with the remainder to be painted with the window background color (green).

DirectX实用工具包(DXUT)没有此问题。通过试验他们的设置,我发现设置 DXGI_SWAP_CHAIN_DESC :: SwapEffect = DXGI_SWAP_EFFECT_DISCARD 只会在sizemove期间将屏幕涂成绿色(窗口背景色)。我假设DXUT对于win32输入模态sizemove循环,以便在sizemove期间显示DirectX内容。

The DirectX Utility Toolkit (DXUT) didn't have this problem. Experimenting with their settings I found that setting DXGI_SWAP_CHAIN_DESC::SwapEffect = DXGI_SWAP_EFFECT_DISCARD would just paint the screen green (the window background color) during a sizemove. I assume that DXUT has their own special handling for when win32 enters a modal sizemove loop in order to display DirectX content during a sizemove.

DXGI_SWAP_EFFECT_DISCARD 旧的位模式显示模型。值得注意的是,它不能具有 DXGI_SWAP_CHAIN_DESC1 :: Scaling = DXGI_SCALING_NONE 缩放比例必须扩展到窗口大小。因此,我最好的猜测是这种行为是由于翻转表示模型的实现(它翻转的矩形太小(黑色),然后将其余的部分涂成绿色)。

DXGI_SWAP_EFFECT_DISCARD is part of the old blit mode presentation model. Notably it cant have DXGI_SWAP_CHAIN_DESC1::Scaling = DXGI_SCALING_NONE the scaling must be stretched to the window size. So my best guess is this behavior is due to the implementation of the flip presentation model (it flips a rectangle too small (black) and then covers by painting the rest green).

有人吗?知道如何阻止显示win32背景吗?

Does anyone know how to stop the win32 background from showing?

编辑:

感谢IInspectable!我可以确认 WS_EX_NOREDIRECTIONBITMAP 扩展样式是有效的:它从win32背景中停止工件,显示

Thanks to IInspectable! I can confirm the WS_EX_NOREDIRECTIONBITMAP extended style works: it stops the artifact from the win32 background showing

推荐答案

当我将 CreateSwapChainForComposition()与DirectComposition一起使用时,我再现了完全相同的行为,就像我使用 CreateSwapChainForHwnd()

I reproduced the exact same behavior when using CreateSwapChainForComposition() with DirectComposition as I got using CreateSwapChainForHwnd().

这意味着像素有两种到达屏幕的路径。绿色像素穿过重定向表面。因此,显式请求 WS_EX_NOREDIRECTIONBITMAP 可以防止通过重定向曲面进行的任何绘制停止显示win32背景。

This means that there are two path for pixels to get to the screen. The green pixels are going through the Redirection Surface. Hence, explicitly requesting WS_EX_NOREDIRECTIONBITMAP prevents any drawing through a Redirection Surface stopping the win32 background from showing.

另一条路径是翻转展示行为,即红色和黑色像素的显示方式。因此,在调整大小时不使用翻转演示文稿也将阻止显示Win32背景。

The other path is the flip presentation behavior which is how the red and black pixels are get displayed. Hence, not using flip presentation when resizing also stops the win32 background from being shown.

DWM必须存在一个错误:当存在重定向曲面时,为了防止交换链内容的剪切延伸超过窗口的宽度小于重定向表面,因此可以沿着底部/右侧边缘看到它。

There must be a bug with DWM: when there is a Redirection Surface, the clipping to prevent the swapchain's contents extending past the window is smaller than the redirection surface allowing it to be seen along the bottom/right edges.

有两个有趣的观察结果:

There are two observations of interest:


  1. 当使用 WS_EX_LAYOUTRTL 或将 IDCompositionVisual 手动定位到屏幕的右边缘时 GetClientRect(),交换链的内容正确定位,但仍被剪切。

  2. 使用 WS_EX_NOREDIRECTIONBITMAP 窗口的非客户区域与交换链的内容对齐,而不是与被剪切的交换链的内容对齐

  1. when using WS_EX_LAYOUTRTL or manually positioning a IDCompositionVisual to the right edge of the screen with GetClientRect(), the swapchains contents are correctly position, but still clipped.
  2. when using WS_EX_NOREDIRECTIONBITMAP the window`s nonclient area lines up with the contents of the swapchain rather than the swapchains contents being clipped

这些观察结果将与暗示问题的原因是DWM有时使用首选大小作为窗口大小以及重定向表面的大小。

These observations would seam to imply that the cause of the issue is that DWM is using it's prefered size for the window size sometimes and the size of the redirection surface othertimes.

这篇关于DirectX Resize在Edges中显示Win32背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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