From 35352b9c52b9e50ed079aed8a94f27e1b57b83f2 Mon Sep 17 00:00:00 2001 From: WinterSnowfall Date: Mon, 28 Oct 2024 21:26:31 +0200 Subject: [PATCH] [d3d8] Set D3D8 compatibility at D3D9 interface level --- src/d3d8/d3d8_device.cpp | 4 ---- src/d3d8/d3d8_interface.cpp | 2 ++ src/d3d9/d3d9_bridge.cpp | 8 +++---- src/d3d9/d3d9_bridge.h | 17 ++++++++------- src/d3d9/d3d9_device.cpp | 43 +++++++++++++++++++------------------ src/d3d9/d3d9_device.h | 9 +------- src/d3d9/d3d9_interface.h | 13 +++++++++++ 7 files changed, 51 insertions(+), 45 deletions(-) diff --git a/src/d3d8/d3d8_device.cpp b/src/d3d8/d3d8_device.cpp index 8c4f4f18d..f56fb80d7 100644 --- a/src/d3d8/d3d8_device.cpp +++ b/src/d3d8/d3d8_device.cpp @@ -52,10 +52,6 @@ namespace dxvk { } m_bridge->SetAPIName("D3D8"); - m_bridge->SetD3D8CompatibilityMode(true); - // The default value of D3DRS_POINTSIZE_MIN in D3D8 is 0.0f, - // whereas it's initialized to 1.0f in D3D9 by default - GetD3D9()->SetRenderState(d3d9::D3DRS_POINTSIZE_MIN, bit::cast(0.0f)); ResetState(); RecreateBackBuffersAndAutoDepthStencil(); diff --git a/src/d3d8/d3d8_interface.cpp b/src/d3d8/d3d8_interface.cpp index dd187cf3f..6324946b6 100644 --- a/src/d3d8/d3d8_interface.cpp +++ b/src/d3d8/d3d8_interface.cpp @@ -15,6 +15,8 @@ namespace dxvk throw DxvkError("D3D8Device: ERROR! Failed to get D3D9 Bridge. d3d9.dll might not be DXVK!"); } + m_bridge->SetD3D8CompatibilityMode(true); + m_d3d8Options = D3D8Options(*m_bridge->GetConfig()); m_adapterCount = m_d3d9->GetAdapterCount(); diff --git a/src/d3d9/d3d9_bridge.cpp b/src/d3d9/d3d9_bridge.cpp index 6bb4801a7..5e43117d5 100644 --- a/src/d3d9/d3d9_bridge.cpp +++ b/src/d3d9/d3d9_bridge.cpp @@ -32,10 +32,6 @@ namespace dxvk { m_device->m_implicitSwapchain->SetApiName(name); } - void DxvkD3D8Bridge::SetD3D8CompatibilityMode(const bool compatMode) { - m_device->SetD3D8CompatibilityMode(compatMode); - } - HRESULT DxvkD3D8Bridge::UpdateTextureFromBuffer( IDirect3DSurface9* pDestSurface, IDirect3DSurface9* pSrcSurface, @@ -105,6 +101,10 @@ namespace dxvk { return m_interface->QueryInterface(riid, ppvObject); } + void DxvkD3D8InterfaceBridge::SetD3D8CompatibilityMode(const bool compatMode) { + m_interface->SetD3D8CompatibilityMode(compatMode); + } + const Config* DxvkD3D8InterfaceBridge::GetConfig() const { return &m_interface->GetInstance()->config(); } diff --git a/src/d3d9/d3d9_bridge.h b/src/d3d9/d3d9_bridge.h index 9214f9e27..4285aa0e2 100644 --- a/src/d3d9/d3d9_bridge.h +++ b/src/d3d9/d3d9_bridge.h @@ -28,13 +28,6 @@ IDxvkD3D8Bridge : public IUnknown { */ virtual void SetAPIName(const char* name) = 0; - /** - * \brief Enables or disables D3D9-specific device features and validations - * - * \param [in] compatMode Compatibility state - */ - virtual void SetD3D8CompatibilityMode(const bool compatMode) = 0; - /** * \brief Updates a D3D9 surface from a D3D9 buffer * @@ -55,6 +48,13 @@ IDxvkD3D8Bridge : public IUnknown { */ MIDL_INTERFACE("D3D9D3D8-A407-773E-18E9-CAFEBEEF3000") IDxvkD3D8InterfaceBridge : public IUnknown { + /** + * \brief Enables or disables D3D9-specific features and validations + * + * \param [in] compatMode Compatibility state + */ + virtual void SetD3D8CompatibilityMode(const bool compatMode) = 0; + /** * \brief Retrieves the DXVK configuration * @@ -85,7 +85,6 @@ namespace dxvk { void** ppvObject); void SetAPIName(const char* name); - void SetD3D8CompatibilityMode(const bool compatMode); HRESULT UpdateTextureFromBuffer( IDirect3DSurface9* pDestSurface, @@ -108,6 +107,8 @@ namespace dxvk { REFIID riid, void** ppvObject); + void SetD3D8CompatibilityMode(const bool compatMode); + const Config* GetConfig() const; protected: diff --git a/src/d3d9/d3d9_device.cpp b/src/d3d9/d3d9_device.cpp index 0aeb09518..5818a39a4 100644 --- a/src/d3d9/d3d9_device.cpp +++ b/src/d3d9/d3d9_device.cpp @@ -40,27 +40,28 @@ namespace dxvk { HWND hFocusWindow, DWORD BehaviorFlags, Rc dxvkDevice) - : m_parent ( pParent ) - , m_deviceType ( DeviceType ) - , m_window ( hFocusWindow ) - , m_behaviorFlags ( BehaviorFlags ) - , m_adapter ( pAdapter ) - , m_dxvkDevice ( dxvkDevice ) - , m_memoryAllocator ( ) - , m_shaderAllocator ( ) - , m_shaderModules ( new D3D9ShaderModuleSet ) - , m_stagingBuffer ( dxvkDevice, StagingBufferSize ) - , m_stagingBufferFence(new sync::Fence()) - , m_d3d9Options ( dxvkDevice, pParent->GetInstance()->config() ) - , m_multithread ( BehaviorFlags & D3DCREATE_MULTITHREADED ) - , m_isSWVP ( (BehaviorFlags & D3DCREATE_SOFTWARE_VERTEXPROCESSING) ? true : false ) - , m_csThread ( dxvkDevice, dxvkDevice->createContext() ) - , m_csChunk ( AllocCsChunk() ) - , m_submissionFence (new sync::Fence()) - , m_flushTracker (m_d3d9Options.reproducibleCommandStream) - , m_d3d9Interop ( this ) - , m_d3d9On12 ( this ) - , m_d3d8Bridge ( this ) { + : m_parent ( pParent ) + , m_deviceType ( DeviceType ) + , m_window ( hFocusWindow ) + , m_behaviorFlags ( BehaviorFlags ) + , m_adapter ( pAdapter ) + , m_dxvkDevice ( dxvkDevice ) + , m_memoryAllocator ( ) + , m_shaderAllocator ( ) + , m_shaderModules ( new D3D9ShaderModuleSet ) + , m_stagingBuffer ( dxvkDevice, StagingBufferSize ) + , m_stagingBufferFence ( new sync::Fence() ) + , m_d3d9Options ( dxvkDevice, pParent->GetInstance()->config() ) + , m_multithread ( BehaviorFlags & D3DCREATE_MULTITHREADED ) + , m_isSWVP ( (BehaviorFlags & D3DCREATE_SOFTWARE_VERTEXPROCESSING) ? true : false ) + , m_isD3D8Compatible ( pParent->IsD3D8Compatible() ) + , m_csThread ( dxvkDevice, dxvkDevice->createContext() ) + , m_csChunk ( AllocCsChunk() ) + , m_submissionFence ( new sync::Fence() ) + , m_flushTracker ( m_d3d9Options.reproducibleCommandStream ) + , m_d3d9Interop ( this ) + , m_d3d9On12 ( this ) + , m_d3d8Bridge ( this ) { // If we can SWVP, then we use an extended constant set // as SWVP has many more slots available than HWVP. bool canSWVP = CanSWVP(); diff --git a/src/d3d9/d3d9_device.h b/src/d3d9/d3d9_device.h index 2abe35336..c9c75a8b5 100644 --- a/src/d3d9/d3d9_device.h +++ b/src/d3d9/d3d9_device.h @@ -1024,13 +1024,6 @@ namespace dxvk { return m_isD3D8Compatible; } - void SetD3D8CompatibilityMode(bool compatMode) { - if (compatMode) - Logger::info("The D3D9 device is now operating in D3D8 compatibility mode."); - - m_isD3D8Compatible = compatMode; - } - // Device Lost bool IsDeviceLost() const { return m_deviceLostState != D3D9DeviceLostState::Ok; @@ -1505,7 +1498,7 @@ namespace dxvk { D3D9ShaderMasks m_psShaderMasks = FixedFunctionMask; bool m_isSWVP; - bool m_isD3D8Compatible = false; + bool m_isD3D8Compatible; bool m_amdATOC = false; bool m_nvATOC = false; bool m_ffZTest = false; diff --git a/src/d3d9/d3d9_interface.h b/src/d3d9/d3d9_interface.h index 43046f73a..2bb0e0a82 100644 --- a/src/d3d9/d3d9_interface.h +++ b/src/d3d9/d3d9_interface.h @@ -131,6 +131,17 @@ namespace dxvk { bool IsExtended() { return m_extended; } + bool IsD3D8Compatible() const { + return m_isD3D8Compatible; + } + + void SetD3D8CompatibilityMode(bool compatMode) { + if (compatMode) + Logger::info("The D3D9 interface is now operating in D3D8 compatibility mode."); + + m_isD3D8Compatible = compatMode; + } + Rc GetInstance() { return m_instance; } private: @@ -145,6 +156,8 @@ namespace dxvk { bool m_extended; + bool m_isD3D8Compatible = false; + D3D9Options m_d3d9Options; std::vector m_adapters;