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

[dxvk] Implement native discardBuffer function in the backend

This may be more efficient because it avoids renaming the buffer
in case it can be used without inserting additional barriers.
This commit is contained in:
Philip Rebohle 2018-08-03 11:28:00 +02:00
parent fb88070888
commit fe66e668e5
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
3 changed files with 24 additions and 2 deletions

View File

@ -2728,8 +2728,7 @@ namespace dxvk {
void D3D11DeviceContext::DiscardBuffer(
D3D11Buffer* pBuffer) {
EmitCs([cBuffer = pBuffer->GetBuffer()] (DxvkContext* ctx) {
ctx->invalidateBuffer(cBuffer,
cBuffer->allocPhysicalSlice());
ctx->discardBuffer(cBuffer);
});
}

View File

@ -941,6 +941,17 @@ namespace dxvk {
}
void DxvkContext::discardBuffer(
const Rc<DxvkBuffer>& buffer) {
DxvkAccessFlags accessFlags(
DxvkAccess::Read,
DxvkAccess::Write);
if (m_barriers.isBufferDirty(buffer->slice(), accessFlags))
this->invalidateBuffer(buffer, buffer->allocPhysicalSlice());
}
void DxvkContext::dispatch(
uint32_t x,
uint32_t y,

View File

@ -322,6 +322,18 @@ namespace dxvk {
VkOffset3D srcOffset,
VkExtent3D srcExtent);
/**
* \brief Discards a buffer
*
* Renames the buffer in case it is currently
* used by the GPU in order to avoid having to
* insert barriers before future commands using
* the buffer.
* \param [in] buffer The buffer to discard
*/
void discardBuffer(
const Rc<DxvkBuffer>& buffer);
/**
* \brief Starts compute jobs
*