1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-12-12 22:08:59 +01:00

[d3d11] Add ResourceAddRef/ReleasePrivate with known resource type

This commit is contained in:
Philip Rebohle 2022-02-09 03:55:39 +01:00
parent 6b91b87dba
commit 391c9e13ca
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
2 changed files with 28 additions and 8 deletions

View File

@ -198,11 +198,8 @@ namespace dxvk {
} }
HRESULT ResourceAddRefPrivate(ID3D11Resource* pResource) { HRESULT ResourceAddRefPrivate(ID3D11Resource* pResource, D3D11_RESOURCE_DIMENSION Type) {
D3D11_RESOURCE_DIMENSION dim; switch (Type) {
pResource->GetType(&dim);
switch (dim) {
case D3D11_RESOURCE_DIMENSION_BUFFER: static_cast<D3D11Buffer*> (pResource)->AddRefPrivate(); return S_OK; 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_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_TEXTURE2D: static_cast<D3D11Texture2D*>(pResource)->AddRefPrivate(); return S_OK;
@ -212,11 +209,16 @@ namespace dxvk {
} }
HRESULT ResourceReleasePrivate(ID3D11Resource* pResource) { HRESULT ResourceAddRefPrivate(ID3D11Resource* pResource) {
D3D11_RESOURCE_DIMENSION dim; D3D11_RESOURCE_DIMENSION dim;
pResource->GetType(&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<D3D11Buffer*> (pResource)->ReleasePrivate(); return S_OK; 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_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_TEXTURE2D: static_cast<D3D11Texture2D*>(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);
}
} }

View File

@ -128,8 +128,13 @@ namespace dxvk {
* Helper method that figures out the exact type of * Helper method that figures out the exact type of
* the resource and calls its \c AddRefPrivate method. * the resource and calls its \c AddRefPrivate method.
* \param [in] pResource The resource to reference * \param [in] pResource The resource to reference
* \param [in] Type Resource type
* \returns \c S_OK, or \c E_INVALIDARG for an invalid resource * \returns \c S_OK, or \c E_INVALIDARG for an invalid resource
*/ */
HRESULT ResourceAddRefPrivate(
ID3D11Resource* pResource,
D3D11_RESOURCE_DIMENSION Type);
HRESULT ResourceAddRefPrivate( HRESULT ResourceAddRefPrivate(
ID3D11Resource* pResource); ID3D11Resource* pResource);
@ -139,8 +144,13 @@ namespace dxvk {
* Helper method that figures out the exact type of * Helper method that figures out the exact type of
* the resource and calls its \c ReleasePrivate method. * the resource and calls its \c ReleasePrivate method.
* \param [in] pResource The resource to reference * \param [in] pResource The resource to reference
* \param [in] Type Resource type
* \returns \c S_OK, or \c E_INVALIDARG for an invalid resource * \returns \c S_OK, or \c E_INVALIDARG for an invalid resource
*/ */
HRESULT ResourceReleasePrivate(
ID3D11Resource* pResource,
D3D11_RESOURCE_DIMENSION Type);
HRESULT ResourceReleasePrivate( HRESULT ResourceReleasePrivate(
ID3D11Resource* pResource); ID3D11Resource* pResource);