From 022bf1d134d035c5d0efed321400c314a1ad8eb9 Mon Sep 17 00:00:00 2001 From: Alpyne Date: Mon, 19 Jun 2023 23:54:48 +0100 Subject: [PATCH] [d3d9] Allow changing API name for d3d8 --- src/d3d9/d3d9_bridge.cpp | 4 ++++ src/d3d9/d3d9_bridge.h | 10 ++++++++++ src/d3d9/d3d9_swapchain.cpp | 12 ++++++++++-- src/d3d9/d3d9_swapchain.h | 4 ++++ 4 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/d3d9/d3d9_bridge.cpp b/src/d3d9/d3d9_bridge.cpp index d5248e53..88448ba9 100644 --- a/src/d3d9/d3d9_bridge.cpp +++ b/src/d3d9/d3d9_bridge.cpp @@ -28,6 +28,10 @@ namespace dxvk { return m_device->QueryInterface(riid, ppvObject); } + void DxvkD3D8Bridge::SetAPIName(const char* name) { + m_device->m_implicitSwapchain->SetApiName(name); + } + HRESULT DxvkD3D8Bridge::UpdateTextureFromBuffer( IDirect3DSurface9* pDestSurface, IDirect3DSurface9* pSrcSurface, diff --git a/src/d3d9/d3d9_bridge.h b/src/d3d9/d3d9_bridge.h index 99c53031..f1c12104 100644 --- a/src/d3d9/d3d9_bridge.h +++ b/src/d3d9/d3d9_bridge.h @@ -23,6 +23,13 @@ IDxvkD3D8Bridge : public IUnknown { using IDirect3DSurface9 = d3d9::IDirect3DSurface9; #endif + /** + * \brief Changes the API name displayed on the HUD + * + * \param [in] name The new API name + */ + virtual void SetAPIName(const char* name) = 0; + /** * \brief Updates a D3D9 surface from a D3D9 buffer * @@ -45,6 +52,7 @@ MIDL_INTERFACE("D3D9D3D8-A407-773E-18E9-CAFEBEEF3000") IDxvkD3D8InterfaceBridge : public IUnknown { /** * \brief Retrieves the DXVK configuration + * * \returns The DXVK Config object */ virtual const dxvk::Config* GetConfig() const = 0; @@ -74,6 +82,8 @@ namespace dxvk { REFIID riid, void** ppvObject); + void SetAPIName(const char* name); + HRESULT UpdateTextureFromBuffer( IDirect3DSurface9* pDestSurface, IDirect3DSurface9* pSrcSurface, diff --git a/src/d3d9/d3d9_swapchain.cpp b/src/d3d9/d3d9_swapchain.cpp index 90fb35b0..3807af03 100644 --- a/src/d3d9/d3d9_swapchain.cpp +++ b/src/d3d9/d3d9_swapchain.cpp @@ -1066,9 +1066,13 @@ namespace dxvk { void D3D9SwapChainEx::SyncFrameLatency() { // Wait for the sync event so that we respect the maximum frame latency m_frameLatencySignal->wait(m_frameId - GetActualFrameLatency()); + } + + void D3D9SwapChainEx::SetApiName(const char* name) { + m_apiName = name; + CreateHud(); } - uint32_t D3D9SwapChainEx::GetActualFrameLatency() { uint32_t maxFrameLatency = m_parent->GetFrameLatency(); @@ -1298,7 +1302,11 @@ namespace dxvk { std::string D3D9SwapChainEx::GetApiName() { - return this->GetParent()->IsExtended() ? "D3D9Ex" : "D3D9"; + if (m_apiName == nullptr) { + return this->GetParent()->IsExtended() ? "D3D9Ex" : "D3D9"; + } else { + return m_apiName; + } } D3D9VkExtSwapchain::D3D9VkExtSwapchain(D3D9SwapChainEx *pSwapChain) diff --git a/src/d3d9/d3d9_swapchain.h b/src/d3d9/d3d9_swapchain.h index 5d925227..662e4664 100644 --- a/src/d3d9/d3d9_swapchain.h +++ b/src/d3d9/d3d9_swapchain.h @@ -122,6 +122,8 @@ namespace dxvk { void DestroyBackBuffers(); + void SetApiName(const char* name); + private: enum BindingIds : uint32_t { @@ -167,6 +169,8 @@ namespace dxvk { double m_displayRefreshRate = 0.0; + const char* m_apiName = nullptr; + bool m_warnedAboutGDIFallback = false; VkColorSpaceKHR m_colorspace = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR;