From 837861ffdd8417025ca11204a11785e97c864455 Mon Sep 17 00:00:00 2001 From: Joshua Ashton Date: Sat, 18 Apr 2020 20:46:30 +0100 Subject: [PATCH] [d3d9] Cleanup private ref code for subresources --- src/d3d9/d3d9_surface.cpp | 30 ++++++++++++------------------ src/d3d9/d3d9_volume.cpp | 14 ++++---------- 2 files changed, 16 insertions(+), 28 deletions(-) diff --git a/src/d3d9/d3d9_surface.cpp b/src/d3d9/d3d9_surface.cpp index b2538149..b36c7203 100644 --- a/src/d3d9/d3d9_surface.cpp +++ b/src/d3d9/d3d9_surface.cpp @@ -31,21 +31,18 @@ namespace dxvk { pBaseTexture) { } void D3D9Surface::AddRefPrivate(bool swapchain) { - IDirect3DBaseTexture9* pBaseTexture = this->m_baseTexture; - IUnknown* pSwapChain = this->m_container; - - if (pBaseTexture != nullptr) { - D3DRESOURCETYPE type = pBaseTexture->GetType(); + if (m_baseTexture != nullptr) { + D3DRESOURCETYPE type = m_baseTexture->GetType(); if (type == D3DRTYPE_TEXTURE) - reinterpret_cast (pBaseTexture)->AddRefPrivate(); + static_cast (m_baseTexture)->AddRefPrivate(); else //if (type == D3DRTYPE_CUBETEXTURE) - reinterpret_cast(pBaseTexture)->AddRefPrivate(); + static_cast(m_baseTexture)->AddRefPrivate(); return; } - else if (pSwapChain != nullptr && !swapchain) { + else if (m_container != nullptr && !swapchain) { // Container must be a swapchain if it isn't a base texture. - reinterpret_cast(pSwapChain)->AddRefPrivate(); + static_cast(m_container)->AddRefPrivate(); return; } @@ -54,21 +51,18 @@ namespace dxvk { } void D3D9Surface::ReleasePrivate(bool swapchain) { - IDirect3DBaseTexture9* pBaseTexture = this->m_baseTexture; - IUnknown* pSwapChain = this->m_container; - - if (pBaseTexture != nullptr) { - D3DRESOURCETYPE type = pBaseTexture->GetType(); + if (m_baseTexture != nullptr) { + D3DRESOURCETYPE type = m_baseTexture->GetType(); if (type == D3DRTYPE_TEXTURE) - reinterpret_cast (pBaseTexture)->ReleasePrivate(); + static_cast (m_baseTexture)->ReleasePrivate(); else //if (type == D3DRTYPE_CUBETEXTURE) - reinterpret_cast(pBaseTexture)->ReleasePrivate(); + static_cast(m_baseTexture)->ReleasePrivate(); return; } - else if (pSwapChain != nullptr && !swapchain) { + else if (m_container != nullptr && !swapchain) { // Container must be a swapchain if it isn't a base texture. - reinterpret_cast(pSwapChain)->ReleasePrivate(); + static_cast(m_container)->ReleasePrivate(); return; } diff --git a/src/d3d9/d3d9_volume.cpp b/src/d3d9/d3d9_volume.cpp index 855a7a32..dddb166e 100644 --- a/src/d3d9/d3d9_volume.cpp +++ b/src/d3d9/d3d9_volume.cpp @@ -31,12 +31,9 @@ namespace dxvk { void D3D9Volume::AddRefPrivate() { - IDirect3DBaseTexture9* pContainer = this->m_baseTexture; - // Can't have a swapchain container for a volume. - - if (pContainer != nullptr) { - reinterpret_cast (pContainer)->AddRefPrivate(); + if (m_baseTexture != nullptr) { + static_cast(m_baseTexture)->AddRefPrivate(); return; } @@ -45,12 +42,9 @@ namespace dxvk { void D3D9Volume::ReleasePrivate() { - IDirect3DBaseTexture9* pContainer = this->m_baseTexture; - // Can't have a swapchain container for a volume. - - if (pContainer != nullptr) { - reinterpret_cast (pContainer)->ReleasePrivate(); + if (m_baseTexture != nullptr) { + static_cast(m_baseTexture)->ReleasePrivate(); return; }