From ffc87faed09c08836dfeb67e653c26399035a775 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Sun, 5 Aug 2018 20:55:16 +0200 Subject: [PATCH] [d3d11] Add private ref count helpers for ID3D11Resource --- src/d3d11/d3d11_resource.cpp | 28 ++++++++++++++++++++++++++++ src/d3d11/d3d11_resource.h | 22 ++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/src/d3d11/d3d11_resource.cpp b/src/d3d11/d3d11_resource.cpp index 88002bd93..55899c7c5 100644 --- a/src/d3d11/d3d11_resource.cpp +++ b/src/d3d11/d3d11_resource.cpp @@ -50,4 +50,32 @@ namespace dxvk { : true; /* for buffers */ } + + HRESULT ResourceAddRefPrivate(ID3D11Resource* pResource) { + D3D11_RESOURCE_DIMENSION dim; + pResource->GetType(&dim); + + switch (dim) { + 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; + case D3D11_RESOURCE_DIMENSION_TEXTURE3D: static_cast(pResource)->AddRefPrivate(); return S_OK; + default: return E_INVALIDARG; + } + } + + + HRESULT ResourceReleasePrivate(ID3D11Resource* pResource) { + D3D11_RESOURCE_DIMENSION dim; + pResource->GetType(&dim); + + switch (dim) { + 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; + case D3D11_RESOURCE_DIMENSION_TEXTURE3D: static_cast(pResource)->ReleasePrivate(); return S_OK; + default: return E_INVALIDARG; + } + } + } \ No newline at end of file diff --git a/src/d3d11/d3d11_resource.h b/src/d3d11/d3d11_resource.h index 5f93590a7..e20f2ff4e 100644 --- a/src/d3d11/d3d11_resource.h +++ b/src/d3d11/d3d11_resource.h @@ -59,5 +59,27 @@ namespace dxvk { BOOL CheckResourceViewFormatCompatibility( ID3D11Resource* pResource, DXGI_FORMAT Format); + + /** + * \brief Increments private reference count of a resource + * + * Helper method that figures out the exact type of + * the resource and calls its \c AddRefPrivate method. + * \param [in] pResource The resource to reference + * \returns \c S_OK, or \c E_INVALIDARG for an invalid resource + */ + 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 + * \returns \c S_OK, or \c E_INVALIDARG for an invalid resource + */ + HRESULT ResourceReleasePrivate( + ID3D11Resource* pResource); } \ No newline at end of file