1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-01-18 02:52:10 +01:00

[d3d11] Do not hold strong references to the ID3D11Resource in views

Emulates Windows behaviour more closely. Fixes refcount-related
error messages in Unreal Engine 4 (see #302), as well as a crash
in Yakuza 0 (see #533).
This commit is contained in:
Philip Rebohle 2018-08-05 20:56:04 +02:00
parent ffc87faed0
commit 3359b89166
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
8 changed files with 25 additions and 11 deletions

View File

@ -1,5 +1,6 @@
#include "d3d11_device.h"
#include "d3d11_buffer.h"
#include "d3d11_resource.h"
#include "d3d11_texture.h"
#include "d3d11_view_dsv.h"
@ -10,6 +11,8 @@ namespace dxvk {
ID3D11Resource* pResource,
const D3D11_DEPTH_STENCIL_VIEW_DESC* pDesc)
: m_device(pDevice), m_resource(pResource), m_desc(*pDesc) {
ResourceAddRefPrivate(m_resource);
DxvkImageViewCreateInfo viewInfo;
viewInfo.format = pDevice->LookupFormat(pDesc->Format, DXGI_VK_FORMAT_MODE_DEPTH).Format;
viewInfo.aspect = imageFormatInfo(viewInfo.format)->aspectMask;
@ -82,7 +85,7 @@ namespace dxvk {
D3D11DepthStencilView::~D3D11DepthStencilView() {
ResourceReleasePrivate(m_resource);
}
@ -109,7 +112,7 @@ namespace dxvk {
void STDMETHODCALLTYPE D3D11DepthStencilView::GetResource(ID3D11Resource** ppResource) {
*ppResource = m_resource.ref();
*ppResource = ref(m_resource);
}

View File

@ -72,7 +72,7 @@ namespace dxvk {
private:
Com<D3D11Device> m_device;
Com<ID3D11Resource> m_resource;
ID3D11Resource* m_resource;
D3D11_DEPTH_STENCIL_VIEW_DESC m_desc;
Rc<DxvkImageView> m_view;

View File

@ -1,5 +1,6 @@
#include "d3d11_device.h"
#include "d3d11_buffer.h"
#include "d3d11_resource.h"
#include "d3d11_texture.h"
#include "d3d11_view_rtv.h"
@ -10,6 +11,8 @@ namespace dxvk {
ID3D11Resource* pResource,
const D3D11_RENDER_TARGET_VIEW_DESC* pDesc)
: m_device(pDevice), m_resource(pResource), m_desc(*pDesc) {
ResourceAddRefPrivate(m_resource);
DxvkImageViewCreateInfo viewInfo;
viewInfo.format = pDevice->LookupFormat(pDesc->Format, DXGI_VK_FORMAT_MODE_COLOR).Format;
viewInfo.aspect = imageFormatInfo(viewInfo.format)->aspectMask;
@ -90,7 +93,7 @@ namespace dxvk {
D3D11RenderTargetView::~D3D11RenderTargetView() {
ResourceReleasePrivate(m_resource);
}
@ -117,7 +120,7 @@ namespace dxvk {
void STDMETHODCALLTYPE D3D11RenderTargetView::GetResource(ID3D11Resource** ppResource) {
*ppResource = m_resource.ref();
*ppResource = ref(m_resource);
}

View File

@ -57,7 +57,7 @@ namespace dxvk {
private:
Com<D3D11Device> m_device;
Com<ID3D11Resource> m_resource;
ID3D11Resource* m_resource;
D3D11_RENDER_TARGET_VIEW_DESC m_desc;
Rc<DxvkImageView> m_view;

View File

@ -1,5 +1,6 @@
#include "d3d11_device.h"
#include "d3d11_buffer.h"
#include "d3d11_resource.h"
#include "d3d11_texture.h"
#include "d3d11_view_srv.h"
@ -10,6 +11,8 @@ namespace dxvk {
ID3D11Resource* pResource,
const D3D11_SHADER_RESOURCE_VIEW_DESC* pDesc)
: m_device(pDevice), m_resource(pResource), m_desc(*pDesc) {
ResourceAddRefPrivate(m_resource);
D3D11_RESOURCE_DIMENSION resourceDim = D3D11_RESOURCE_DIMENSION_UNKNOWN;
pResource->GetType(&resourceDim);
@ -159,7 +162,7 @@ namespace dxvk {
D3D11ShaderResourceView::~D3D11ShaderResourceView() {
ResourceReleasePrivate(m_resource);
}
@ -186,7 +189,7 @@ namespace dxvk {
void STDMETHODCALLTYPE D3D11ShaderResourceView::GetResource(ID3D11Resource** ppResource) {
*ppResource = m_resource.ref();
*ppResource = ref(m_resource);
}

View File

@ -55,7 +55,7 @@ namespace dxvk {
private:
Com<D3D11Device> m_device;
Com<ID3D11Resource> m_resource;
ID3D11Resource* m_resource;
D3D11_SHADER_RESOURCE_VIEW_DESC m_desc;
Rc<DxvkBufferView> m_bufferView;
Rc<DxvkImageView> m_imageView;

View File

@ -1,5 +1,6 @@
#include "d3d11_device.h"
#include "d3d11_buffer.h"
#include "d3d11_resource.h"
#include "d3d11_texture.h"
#include "d3d11_view_uav.h"
@ -10,6 +11,8 @@ namespace dxvk {
ID3D11Resource* pResource,
const D3D11_UNORDERED_ACCESS_VIEW_DESC* pDesc)
: m_device(pDevice), m_resource(pResource), m_desc(*pDesc) {
ResourceAddRefPrivate(m_resource);
D3D11_RESOURCE_DIMENSION resourceDim = D3D11_RESOURCE_DIMENSION_UNKNOWN;
pResource->GetType(&resourceDim);
@ -103,6 +106,8 @@ namespace dxvk {
D3D11UnorderedAccessView::~D3D11UnorderedAccessView() {
ResourceReleasePrivate(m_resource);
if (m_counterSlice.defined())
m_device->FreeCounterSlice(m_counterSlice);
}
@ -131,7 +136,7 @@ namespace dxvk {
void STDMETHODCALLTYPE D3D11UnorderedAccessView::GetResource(ID3D11Resource** ppResource) {
*ppResource = m_resource.ref();
*ppResource = ref(m_resource);
}

View File

@ -63,7 +63,7 @@ namespace dxvk {
private:
Com<D3D11Device> m_device;
Com<ID3D11Resource> m_resource;
ID3D11Resource* m_resource;
D3D11_UNORDERED_ACCESS_VIEW_DESC m_desc;
Rc<DxvkBufferView> m_bufferView;
Rc<DxvkImageView> m_imageView;