From b030902945878c868e51944dc66dca2879b229c5 Mon Sep 17 00:00:00 2001 From: WinterSnowfall Date: Sat, 5 Oct 2024 17:44:46 +0300 Subject: [PATCH] [d3d9] Fix (most) cursor-related Wine tests --- src/d3d9/d3d9_cursor.cpp | 4 ++++ src/d3d9/d3d9_device.cpp | 12 +++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/d3d9/d3d9_cursor.cpp b/src/d3d9/d3d9_cursor.cpp index 7977955c5e19..aac0a73201ae 100644 --- a/src/d3d9/d3d9_cursor.cpp +++ b/src/d3d9/d3d9_cursor.cpp @@ -40,6 +40,10 @@ namespace dxvk { BOOL D3D9Cursor::ShowCursor(BOOL bShow) { + // Cursor visibility remains unchanged (typically FALSE) if the cursor isn't set. + if (unlikely(m_hCursor == nullptr && m_sCursor.Width == 0 && m_sCursor.Height == 0)) + return m_visible; + if (likely(m_hCursor != nullptr)) ::SetCursor(bShow ? m_hCursor : nullptr); diff --git a/src/d3d9/d3d9_device.cpp b/src/d3d9/d3d9_device.cpp index db5924fcef12..e202784a436c 100644 --- a/src/d3d9/d3d9_device.cpp +++ b/src/d3d9/d3d9_device.cpp @@ -345,9 +345,19 @@ namespace dxvk { uint32_t inputWidth = cursorTex->Desc()->Width; uint32_t inputHeight = cursorTex->Desc()->Height; - // Always use a hardware cursor when windowed. + // Check if surface dimensions are powers of two. + if ((inputWidth && (inputWidth & (inputWidth - 1))) + || (inputHeight && (inputHeight & (inputHeight - 1)))) + return D3DERR_INVALIDCALL; + D3DPRESENT_PARAMETERS params; m_implicitSwapchain->GetPresentParameters(¶ms); + + if (inputWidth > params.BackBufferWidth + || inputHeight > params.BackBufferHeight) + return D3DERR_INVALIDCALL; + + // Always use a hardware cursor when windowed. bool hwCursor = params.Windowed; // Always use a hardware cursor w/h <= 32 px