Fixed ERROR: IDXGIFactory::CreateSwapChain: The flag DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING is only allowed for FLIP swapchains

This commit is contained in:
Sam Lantinga
2025-09-07 16:53:25 -07:00
parent a7ee54f9a3
commit 174d411b50

View File

@@ -614,14 +614,16 @@ static HRESULT D3D11_CreateDeviceResources(SDL_Renderer *renderer)
#ifdef HAVE_DXGI1_5_H #ifdef HAVE_DXGI1_5_H
// Check for tearing support, which requires the IDXGIFactory5 interface. // Check for tearing support, which requires the IDXGIFactory5 interface.
data->swapChainFlags = 0; data->swapChainFlags = 0;
result = IDXGIFactory2_QueryInterface(data->dxgiFactory, &SDL_IID_IDXGIFactory5, (void **)&dxgiFactory5); if (!(SDL_GetWindowFlags(renderer->window) & SDL_WINDOW_TRANSPARENT)) {
if (SUCCEEDED(result)) { result = IDXGIFactory2_QueryInterface(data->dxgiFactory, &SDL_IID_IDXGIFactory5, (void **)&dxgiFactory5);
BOOL allowTearing = FALSE; if (SUCCEEDED(result)) {
result = IDXGIFactory5_CheckFeatureSupport(dxgiFactory5, DXGI_FEATURE_PRESENT_ALLOW_TEARING, &allowTearing, sizeof(allowTearing)); BOOL allowTearing = FALSE;
if (SUCCEEDED(result) && allowTearing) { result = IDXGIFactory5_CheckFeatureSupport(dxgiFactory5, DXGI_FEATURE_PRESENT_ALLOW_TEARING, &allowTearing, sizeof(allowTearing));
data->swapChainFlags = DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING; if (SUCCEEDED(result) && allowTearing) {
data->swapChainFlags = DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING;
}
IDXGIFactory5_Release(dxgiFactory5);
} }
IDXGIFactory5_Release(dxgiFactory5);
} }
#endif // HAVE_DXGI1_5_H #endif // HAVE_DXGI1_5_H