mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-09 16:31:28 +12:00
d3d12: Support size changing depth buffer
This commit is contained in:
parent
2043181501
commit
449c41aca2
2 changed files with 37 additions and 24 deletions
|
@ -160,7 +160,10 @@ void D3D12GSRender::prepare_render_targets(ID3D12GraphicsCommandList *copycmdlis
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ID3D12Resource *ds = m_rtts.bindAddressAsDepthStencil(m_device.Get(), copycmdlist, address_z, clip_width, clip_height, m_surface.depth_format, 1., 0);
|
ComPtr<ID3D12Resource> oldDS;
|
||||||
|
ID3D12Resource *ds = m_rtts.bindAddressAsDepthStencil(m_device.Get(), copycmdlist, address_z, clip_width, clip_height, m_surface.depth_format, 1., 0, oldDS);
|
||||||
|
if (oldDS)
|
||||||
|
getCurrentResourceStorage().dirty_textures.push_back(oldDS);
|
||||||
|
|
||||||
D3D12_DEPTH_STENCIL_VIEW_DESC depthStencilViewDesc = {};
|
D3D12_DEPTH_STENCIL_VIEW_DESC depthStencilViewDesc = {};
|
||||||
depthStencilViewDesc.Format = get_depth_stencil_surface_format(m_surface.depth_format);
|
depthStencilViewDesc.Format = get_depth_stencil_surface_format(m_surface.depth_format);
|
||||||
|
@ -205,19 +208,29 @@ ID3D12Resource *RenderTargets::bindAddressAsRenderTargets(ID3D12Device *device,
|
||||||
return rtt;
|
return rtt;
|
||||||
}
|
}
|
||||||
|
|
||||||
ID3D12Resource * RenderTargets::bindAddressAsDepthStencil(ID3D12Device * device, ID3D12GraphicsCommandList * cmdList, u32 address, size_t width, size_t height, u8 surfaceDepthFormat, float depthClear, u8 stencilClear)
|
ID3D12Resource * RenderTargets::bindAddressAsDepthStencil(ID3D12Device * device, ID3D12GraphicsCommandList * cmdList, u32 address, size_t width, size_t height, u8 surfaceDepthFormat, float depthClear, u8 stencilClear, ComPtr<ID3D12Resource> &dirtyDS)
|
||||||
{
|
{
|
||||||
ID3D12Resource* ds;
|
|
||||||
auto It = m_depthStencil.find(address);
|
auto It = m_depthStencil.find(address);
|
||||||
// TODO: Check if sizes and surface depth format match
|
m_currentlyBoundDepthStencilAddress = address;
|
||||||
|
|
||||||
|
// TODO: Check if surface depth format match
|
||||||
|
|
||||||
if (It != m_depthStencil.end())
|
if (It != m_depthStencil.end())
|
||||||
{
|
{
|
||||||
ds = It->second;
|
ComPtr<ID3D12Resource> ds = It->second;
|
||||||
cmdList->ResourceBarrier(1, &CD3DX12_RESOURCE_BARRIER::Transition(ds, D3D12_RESOURCE_STATE_GENERIC_READ, D3D12_RESOURCE_STATE_DEPTH_WRITE));
|
if (ds->GetDesc().Width == width && ds->GetDesc().Height == height)
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
|
// set the resource as depth write
|
||||||
|
cmdList->ResourceBarrier(1, &CD3DX12_RESOURCE_BARRIER::Transition(ds.Get(), D3D12_RESOURCE_STATE_GENERIC_READ, D3D12_RESOURCE_STATE_DEPTH_WRITE));
|
||||||
|
m_currentlyBoundDepthStencil = ds.Get();
|
||||||
|
return ds.Get();
|
||||||
|
}
|
||||||
|
// If size doesn't match, remove ds from cache
|
||||||
|
m_depthStencil.erase(address);
|
||||||
|
dirtyDS = ds;
|
||||||
|
}
|
||||||
|
|
||||||
D3D12_CLEAR_VALUE clearDepthValue = {};
|
D3D12_CLEAR_VALUE clearDepthValue = {};
|
||||||
clearDepthValue.DepthStencil.Depth = depthClear;
|
clearDepthValue.DepthStencil.Depth = depthClear;
|
||||||
|
|
||||||
|
@ -227,19 +240,19 @@ ID3D12Resource * RenderTargets::bindAddressAsDepthStencil(ID3D12Device * device,
|
||||||
DXGI_FORMAT dxgiFormat = get_depth_typeless_surface_format(surfaceDepthFormat);
|
DXGI_FORMAT dxgiFormat = get_depth_typeless_surface_format(surfaceDepthFormat);
|
||||||
clearDepthValue.Format = get_depth_stencil_surface_clear_format(surfaceDepthFormat);
|
clearDepthValue.Format = get_depth_stencil_surface_clear_format(surfaceDepthFormat);
|
||||||
|
|
||||||
|
ComPtr<ID3D12Resource> newds;
|
||||||
device->CreateCommittedResource(
|
device->CreateCommittedResource(
|
||||||
&CD3DX12_HEAP_PROPERTIES(D3D12_HEAP_TYPE_DEFAULT),
|
&CD3DX12_HEAP_PROPERTIES(D3D12_HEAP_TYPE_DEFAULT),
|
||||||
D3D12_HEAP_FLAG_NONE,
|
D3D12_HEAP_FLAG_NONE,
|
||||||
&CD3DX12_RESOURCE_DESC::Tex2D(dxgiFormat, (UINT)width, (UINT)height, 1, 1, 1, 0, D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL),
|
&CD3DX12_RESOURCE_DESC::Tex2D(dxgiFormat, (UINT)width, (UINT)height, 1, 1, 1, 0, D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL),
|
||||||
D3D12_RESOURCE_STATE_DEPTH_WRITE,
|
D3D12_RESOURCE_STATE_DEPTH_WRITE,
|
||||||
&clearDepthValue,
|
&clearDepthValue,
|
||||||
IID_PPV_ARGS(&ds)
|
IID_PPV_ARGS(newds.GetAddressOf())
|
||||||
);
|
);
|
||||||
m_depthStencil[address] = ds;
|
m_depthStencil[address] = newds;
|
||||||
}
|
m_currentlyBoundDepthStencil = newds.Get();
|
||||||
m_currentlyBoundDepthStencil = ds;
|
|
||||||
m_currentlyBoundDepthStencilAddress = address;
|
return newds.Get();
|
||||||
return ds;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderTargets::Init(ID3D12Device *device)//, u8 surfaceDepthFormat, size_t width, size_t height, float clearColor[4], float clearDepth)
|
void RenderTargets::Init(ID3D12Device *device)//, u8 surfaceDepthFormat, size_t width, size_t height, float clearColor[4], float clearDepth)
|
||||||
|
|
|
@ -7,7 +7,7 @@ struct RenderTargets
|
||||||
std::unordered_map<u32, ID3D12Resource* > m_renderTargets;
|
std::unordered_map<u32, ID3D12Resource* > m_renderTargets;
|
||||||
ID3D12Resource *m_currentlyBoundRenderTargets[4];
|
ID3D12Resource *m_currentlyBoundRenderTargets[4];
|
||||||
u32 m_currentlyBoundRenderTargetsAddress[4];
|
u32 m_currentlyBoundRenderTargetsAddress[4];
|
||||||
std::unordered_map<u32, ID3D12Resource *> m_depthStencil;
|
std::unordered_map<u32, ComPtr<ID3D12Resource> > m_depthStencil;
|
||||||
ID3D12Resource *m_currentlyBoundDepthStencil;
|
ID3D12Resource *m_currentlyBoundDepthStencil;
|
||||||
u32 m_currentlyBoundDepthStencilAddress;
|
u32 m_currentlyBoundDepthStencilAddress;
|
||||||
ID3D12DescriptorHeap *m_renderTargetsDescriptorsHeap;
|
ID3D12DescriptorHeap *m_renderTargetsDescriptorsHeap;
|
||||||
|
@ -22,7 +22,7 @@ struct RenderTargets
|
||||||
size_t width, size_t height, u8 surfaceColorFormat, const std::array<float, 4> &clearColor);
|
size_t width, size_t height, u8 surfaceColorFormat, const std::array<float, 4> &clearColor);
|
||||||
|
|
||||||
ID3D12Resource *bindAddressAsDepthStencil(ID3D12Device *device, ID3D12GraphicsCommandList *cmdList, u32 address,
|
ID3D12Resource *bindAddressAsDepthStencil(ID3D12Device *device, ID3D12GraphicsCommandList *cmdList, u32 address,
|
||||||
size_t width, size_t height, u8 surfaceDepthFormat, float depthClear, u8 stencilClear);
|
size_t width, size_t height, u8 surfaceDepthFormat, float depthClear, u8 stencilClear, ComPtr<ID3D12Resource> &dirtyDS);
|
||||||
|
|
||||||
void Init(ID3D12Device *device);
|
void Init(ID3D12Device *device);
|
||||||
void Release();
|
void Release();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue