Skip to content

Commit

Permalink
[d3d9] Allow changing API name for d3d8
Browse files Browse the repository at this point in the history
  • Loading branch information
AlpyneDreams authored and misyltoad committed Jun 24, 2023
1 parent d6e7e3e commit 022bf1d
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/d3d9/d3d9_bridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 10 additions & 0 deletions src/d3d9/d3d9_bridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand All @@ -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;
Expand Down Expand Up @@ -74,6 +82,8 @@ namespace dxvk {
REFIID riid,
void** ppvObject);

void SetAPIName(const char* name);

HRESULT UpdateTextureFromBuffer(
IDirect3DSurface9* pDestSurface,
IDirect3DSurface9* pSrcSurface,
Expand Down
12 changes: 10 additions & 2 deletions src/d3d9/d3d9_swapchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions src/d3d9/d3d9_swapchain.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ namespace dxvk {

void DestroyBackBuffers();

void SetApiName(const char* name);

private:

enum BindingIds : uint32_t {
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 022bf1d

Please sign in to comment.