我认为我的 DirectX 11 应用程序在以前的系统上运行良好(我有 70% 的把握)。但现在,在 Windows 10(笔记本电脑)中,我仅在全屏模式下出现撕裂问题(窗口模式工作时没有任何撕裂)。
场景非常“沉重”(它应该为我的应用程序进行性能测试)。当 DirectX 渲染“较重”的部分时,它会在短时间内下降到大约 50fps(我的测量可能有点不准确),然后又回到 60-61fps。奇怪的是,我没有看到“较重”部分(约 50fps)出现撕裂。
我听说它可能与 DWM 有关,它为窗口应用程序提供自己的同步(这就是为什么我的程序在窗口模式下工作正常?)。
我能做些什么呢?
交换链:
DXGI_SWAP_CHAIN_DESC sd;
ZeroMemory(&sd, sizeof(sd));
sd.BufferCount = 1;
sd.BufferDesc.Width = width;
sd.BufferDesc.Height = height;
sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
sd.BufferDesc.RefreshRate.Numerator = numerator;
sd.BufferDesc.RefreshRate.Denominator = denominator;
sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
sd.OutputWindow = *hwnd;
sd.SampleDesc.Count = sampleCount; //1 (and 0 for quality) to turn off multisampling
sd.SampleDesc.Quality = maxQualityLevel;
sd.Windowed = fullScreen ? FALSE : TRUE;
sd.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH; //allow full-screen switchin
// Set the scan line ordering and scaling to unspecified.
sd.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
sd.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;
// Discard the back buffer contents after presenting.
sd.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
根据本教程计算的位置numerator
和位置:denominator
...
numerator = displayModeList[i].RefreshRate.Numerator;
denominator = displayModeList[i].RefreshRate.Denominator;
它返回两个非常高的值,它们60
在彼此相除时给出(我是否可以通过将它们设置为60
and来获得相同的效果1
?):
我还渲染:
if(VSYNC){
swapChain->Present(1, 0); //lock to screen refresh rate
}else{
swapChain->Present(0, 0); //present as fast as possible
}
我错过了什么?还是我做错了什么?