mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-01-30 21:32:50 +00:00
d3d12: Start using heap for depth buffer readback
This commit is contained in:
parent
90fb4396fe
commit
6877e5e3ba
@ -314,10 +314,19 @@ D3D12GSRender::D3D12GSRender()
|
|||||||
nullptr,
|
nullptr,
|
||||||
IID_PPV_ARGS(&m_dummyTexture))
|
IID_PPV_ARGS(&m_dummyTexture))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
D3D12_HEAP_DESC hd = {};
|
||||||
|
hd.SizeInBytes = 1024 * 1024 * 128;
|
||||||
|
hd.Properties.Type = D3D12_HEAP_TYPE_READBACK;
|
||||||
|
hd.Flags = D3D12_HEAP_FLAG_ALLOW_ONLY_BUFFERS;
|
||||||
|
check(m_device->CreateHeap(&hd, IID_PPV_ARGS(&m_readbackResources.m_heap)));
|
||||||
|
m_readbackResources.m_putPos = 0;
|
||||||
|
m_readbackResources.m_getPos = 1024 * 1024 * 128 - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
D3D12GSRender::~D3D12GSRender()
|
D3D12GSRender::~D3D12GSRender()
|
||||||
{
|
{
|
||||||
|
m_readbackResources.m_heap->Release();
|
||||||
m_texturesRTTs.clear();
|
m_texturesRTTs.clear();
|
||||||
m_dummyTexture->Release();
|
m_dummyTexture->Release();
|
||||||
m_convertPSO->Release();
|
m_convertPSO->Release();
|
||||||
@ -1352,20 +1361,28 @@ void D3D12GSRender::semaphorePGRAPHBackendRelease(u32 offset, u32 value)
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
size_t heapOffset = m_readbackResources.m_putPos.load();
|
||||||
|
heapOffset = powerOf2Align(heapOffset, 65536);
|
||||||
|
size_t sizeInByte = depthRowPitch * RSXThread::m_height;
|
||||||
|
|
||||||
|
if (heapOffset + sizeInByte >= 1024 * 1024 * 128) // If it will be stored past heap size
|
||||||
|
heapOffset = 0;
|
||||||
|
|
||||||
heapProp = {};
|
heapProp = {};
|
||||||
heapProp.Type = D3D12_HEAP_TYPE_READBACK;
|
heapProp.Type = D3D12_HEAP_TYPE_READBACK;
|
||||||
resdesc = getBufferResourceDesc(depthRowPitch * RSXThread::m_height);
|
resdesc = getBufferResourceDesc(sizeInByte);
|
||||||
|
|
||||||
check(
|
check(
|
||||||
m_device->CreateCommittedResource(
|
m_device->CreatePlacedResource(
|
||||||
&heapProp,
|
m_readbackResources.m_heap,
|
||||||
D3D12_HEAP_FLAG_NONE,
|
heapOffset,
|
||||||
&resdesc,
|
&resdesc,
|
||||||
D3D12_RESOURCE_STATE_COPY_DEST,
|
D3D12_RESOURCE_STATE_COPY_DEST,
|
||||||
nullptr,
|
nullptr,
|
||||||
IID_PPV_ARGS(&writeDest)
|
IID_PPV_ARGS(&writeDest)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
m_readbackResources.m_putPos.store(heapOffset + sizeInByte);
|
||||||
|
|
||||||
check(
|
check(
|
||||||
m_device->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, m_perFrameStorage.m_commandAllocator, nullptr, IID_PPV_ARGS(&convertCommandList))
|
m_device->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, m_perFrameStorage.m_commandAllocator, nullptr, IID_PPV_ARGS(&convertCommandList))
|
||||||
|
@ -95,6 +95,16 @@ private:
|
|||||||
|
|
||||||
ResourceStorage m_perFrameStorage;
|
ResourceStorage m_perFrameStorage;
|
||||||
|
|
||||||
|
|
||||||
|
struct ReadbackHeap
|
||||||
|
{
|
||||||
|
ID3D12Heap *m_heap;
|
||||||
|
std::atomic<int> m_putPos, // Start of free space
|
||||||
|
m_getPos; // End of free space
|
||||||
|
};
|
||||||
|
|
||||||
|
ReadbackHeap m_readbackResources;
|
||||||
|
|
||||||
bool m_forcedIndexBuffer;
|
bool m_forcedIndexBuffer;
|
||||||
size_t indexCount;
|
size_t indexCount;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user