From 391c9e13cad3564d7243f331cac6c587795746ac Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Wed, 9 Feb 2022 03:55:39 +0100 Subject: [PATCH] [d3d11] Add ResourceAddRef/ReleasePrivate with known resource type --- src/d3d11/d3d11_resource.cpp | 24 +++++++++++++++++------- src/d3d11/d3d11_resource.h | 12 +++++++++++- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/src/d3d11/d3d11_resource.cpp b/src/d3d11/d3d11_resource.cpp index 7ba71367..5ee5fbf9 100644 --- a/src/d3d11/d3d11_resource.cpp +++ b/src/d3d11/d3d11_resource.cpp @@ -198,11 +198,8 @@ namespace dxvk { } - HRESULT ResourceAddRefPrivate(ID3D11Resource* pResource) { - D3D11_RESOURCE_DIMENSION dim; - pResource->GetType(&dim); - - switch (dim) { + HRESULT ResourceAddRefPrivate(ID3D11Resource* pResource, D3D11_RESOURCE_DIMENSION Type) { + switch (Type) { case D3D11_RESOURCE_DIMENSION_BUFFER: static_cast (pResource)->AddRefPrivate(); return S_OK; case D3D11_RESOURCE_DIMENSION_TEXTURE1D: static_cast(pResource)->AddRefPrivate(); return S_OK; case D3D11_RESOURCE_DIMENSION_TEXTURE2D: static_cast(pResource)->AddRefPrivate(); return S_OK; @@ -212,11 +209,16 @@ namespace dxvk { } - HRESULT ResourceReleasePrivate(ID3D11Resource* pResource) { + HRESULT ResourceAddRefPrivate(ID3D11Resource* pResource) { D3D11_RESOURCE_DIMENSION dim; pResource->GetType(&dim); - switch (dim) { + return ResourceAddRefPrivate(pResource, dim); + } + + + HRESULT ResourceReleasePrivate(ID3D11Resource* pResource, D3D11_RESOURCE_DIMENSION Type) { + switch (Type) { case D3D11_RESOURCE_DIMENSION_BUFFER: static_cast (pResource)->ReleasePrivate(); return S_OK; case D3D11_RESOURCE_DIMENSION_TEXTURE1D: static_cast(pResource)->ReleasePrivate(); return S_OK; case D3D11_RESOURCE_DIMENSION_TEXTURE2D: static_cast(pResource)->ReleasePrivate(); return S_OK; @@ -225,4 +227,12 @@ namespace dxvk { } } + + HRESULT ResourceReleasePrivate(ID3D11Resource* pResource) { + D3D11_RESOURCE_DIMENSION dim; + pResource->GetType(&dim); + + return ResourceReleasePrivate(pResource, dim); + } + } \ No newline at end of file diff --git a/src/d3d11/d3d11_resource.h b/src/d3d11/d3d11_resource.h index 7d91a305..966841b0 100644 --- a/src/d3d11/d3d11_resource.h +++ b/src/d3d11/d3d11_resource.h @@ -128,19 +128,29 @@ namespace dxvk { * Helper method that figures out the exact type of * the resource and calls its \c AddRefPrivate method. * \param [in] pResource The resource to reference + * \param [in] Type Resource type * \returns \c S_OK, or \c E_INVALIDARG for an invalid resource */ HRESULT ResourceAddRefPrivate( - ID3D11Resource* pResource); + ID3D11Resource* pResource, + D3D11_RESOURCE_DIMENSION Type); + HRESULT ResourceAddRefPrivate( + ID3D11Resource* pResource); + /** * \brief Decrements private reference count of a resource * * Helper method that figures out the exact type of * the resource and calls its \c ReleasePrivate method. * \param [in] pResource The resource to reference + * \param [in] Type Resource type * \returns \c S_OK, or \c E_INVALIDARG for an invalid resource */ + HRESULT ResourceReleasePrivate( + ID3D11Resource* pResource, + D3D11_RESOURCE_DIMENSION Type); + HRESULT ResourceReleasePrivate( ID3D11Resource* pResource);