1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-12-02 01:24:11 +01:00

[d3d11] Add private ref count helpers for ID3D11Resource

This commit is contained in:
Philip Rebohle 2018-08-05 20:55:16 +02:00
parent c223e35608
commit ffc87faed0
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
2 changed files with 50 additions and 0 deletions

View File

@ -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<D3D11Buffer*> (pResource)->AddRefPrivate(); return S_OK;
case D3D11_RESOURCE_DIMENSION_TEXTURE1D: static_cast<D3D11Texture1D*>(pResource)->AddRefPrivate(); return S_OK;
case D3D11_RESOURCE_DIMENSION_TEXTURE2D: static_cast<D3D11Texture2D*>(pResource)->AddRefPrivate(); return S_OK;
case D3D11_RESOURCE_DIMENSION_TEXTURE3D: static_cast<D3D11Texture3D*>(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<D3D11Buffer*> (pResource)->ReleasePrivate(); return S_OK;
case D3D11_RESOURCE_DIMENSION_TEXTURE1D: static_cast<D3D11Texture1D*>(pResource)->ReleasePrivate(); return S_OK;
case D3D11_RESOURCE_DIMENSION_TEXTURE2D: static_cast<D3D11Texture2D*>(pResource)->ReleasePrivate(); return S_OK;
case D3D11_RESOURCE_DIMENSION_TEXTURE3D: static_cast<D3D11Texture3D*>(pResource)->ReleasePrivate(); return S_OK;
default: return E_INVALIDARG;
}
}
}

View File

@ -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);
}