1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-02-07 07:54:15 +01:00

[d3d8] Improve handling of FullScreen_PresentationInterval

This commit is contained in:
WinterSnowfall 2025-01-11 11:27:52 +02:00 committed by Robin Kertels
parent e40f03b96a
commit d846e89a4b
4 changed files with 23 additions and 12 deletions

View File

@ -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?
}
}

View File

@ -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();

View File

@ -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<d3d9::IDirect3DDevice9> pDevice9 = nullptr;
d3d9::D3DPRESENT_PARAMETERS params = ConvertPresentParameters9(pPresentationParameters);
HRESULT res = m_d3d9->CreateDevice(

View File

@ -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;
}