diff --git a/src/d3d11/d3d11_resource.cpp b/src/d3d11/d3d11_resource.cpp index 88002bd9..55899c7c 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 5f93590a..e20f2ff4 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