diff --git a/src/d3d8/d3d8_d3d9_util.h b/src/d3d8/d3d8_d3d9_util.h index ab0aa4d9b..d3ec7f7dd 100644 --- a/src/d3d8/d3d8_d3d9_util.h +++ b/src/d3d8/d3d8_d3d9_util.h @@ -78,33 +78,25 @@ namespace dxvk { // MultiSampleQuality is only used with D3DMULTISAMPLE_NONMASKABLE, which is not available in D3D8 params.MultiSampleQuality = 0; + // If an application passes multiple D3DPRESENT_INTERVAL flags, this will be + // validated appropriately by D3D9. Simply copy the values here. UINT PresentationInterval = pParams->FullScreen_PresentationInterval; if (pParams->Windowed) { - - if (unlikely(PresentationInterval != D3DPRESENT_INTERVAL_DEFAULT)) { - // TODO: what does dx8 do if windowed app sets FullScreen_PresentationInterval? - Logger::warn(str::format( - "D3D8: Application is windowed yet requested FullScreen_PresentationInterval ", PresentationInterval, - " (should be D3DPRESENT_INTERVAL_DEFAULT). This will be ignored.")); - } - // D3D8: For windowed swap chain, the back buffer is copied to the window immediately. PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; } D3DSWAPEFFECT SwapEffect = pParams->SwapEffect; - // D3DSWAPEFFECT_COPY_VSYNC has been removed if (SwapEffect == D3DSWAPEFFECT_COPY_VSYNC) { - + // D3DSWAPEFFECT_COPY_VSYNC has been removed from D3D9, use D3DSWAPEFFECT_COPY SwapEffect = D3DSWAPEFFECT_COPY; // D3D8: In windowed mode, D3DSWAPEFFECT_COPY_VSYNC enables VSYNC. // In fullscreen, D3DPRESENT_INTERVAL_IMMEDIATE is meaningless. - if (pParams->Windowed || (PresentationInterval & D3DPRESENT_INTERVAL_IMMEDIATE) != 0) { + if (pParams->Windowed || PresentationInterval == D3DPRESENT_INTERVAL_IMMEDIATE) { PresentationInterval = D3DPRESENT_INTERVAL_ONE; - // TODO: what does dx8 do if multiple D3DPRESENT_INTERVAL flags are set? } } diff --git a/src/d3d8/d3d8_device.cpp b/src/d3d8/d3d8_device.cpp index 5298d96d0..d84c779b1 100644 --- a/src/d3d8/d3d8_device.cpp +++ b/src/d3d8/d3d8_device.cpp @@ -237,6 +237,12 @@ namespace dxvk { && pPresentationParameters->BackBufferCount > 1)) return D3DERR_INVALIDCALL; + // In D3D8 nothing except D3DPRESENT_INTERVAL_DEFAULT can be used + // as a flag for windowed presentation. + if (unlikely(pPresentationParameters->Windowed + && pPresentationParameters->FullScreen_PresentationInterval != D3DPRESENT_INTERVAL_DEFAULT)) + return D3DERR_INVALIDCALL; + m_presentParams = *pPresentationParameters; ResetState(); diff --git a/src/d3d8/d3d8_interface.cpp b/src/d3d8/d3d8_interface.cpp index 442bbe56f..502f3cfb8 100644 --- a/src/d3d8/d3d8_interface.cpp +++ b/src/d3d8/d3d8_interface.cpp @@ -129,6 +129,12 @@ namespace dxvk { && pPresentationParameters->BackBufferCount > 1)) return D3DERR_INVALIDCALL; + // In D3D8 nothing except D3DPRESENT_INTERVAL_DEFAULT can be used + // as a flag for windowed presentation. + if (unlikely(pPresentationParameters->Windowed + && pPresentationParameters->FullScreen_PresentationInterval != D3DPRESENT_INTERVAL_DEFAULT)) + return D3DERR_INVALIDCALL; + Com pDevice9 = nullptr; d3d9::D3DPRESENT_PARAMETERS params = ConvertPresentParameters9(pPresentationParameters); HRESULT res = m_d3d9->CreateDevice( diff --git a/src/d3d9/d3d9_interface.cpp b/src/d3d9/d3d9_interface.cpp index 46ec5d654..4ed2dfdf2 100644 --- a/src/d3d9/d3d9_interface.cpp +++ b/src/d3d9/d3d9_interface.cpp @@ -457,6 +457,13 @@ namespace dxvk { || pPresentationParameters->PresentationInterval == D3DPRESENT_INTERVAL_IMMEDIATE))) return D3DERR_INVALIDCALL; + // In windowed mode, only a subset of the presentation interval flags can be used. + if (unlikely(pPresentationParameters->Windowed + && !(pPresentationParameters->PresentationInterval == D3DPRESENT_INTERVAL_DEFAULT + || pPresentationParameters->PresentationInterval == D3DPRESENT_INTERVAL_ONE + || pPresentationParameters->PresentationInterval == D3DPRESENT_INTERVAL_IMMEDIATE))) + return D3DERR_INVALIDCALL; + return D3D_OK; }