[d3d11] Avoid unnecessary buffer slice copy when mapping buffer

This commit is contained in:
Philip Rebohle 2018-09-17 22:04:31 +02:00
parent 820904f22d
commit 72106a02cb
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
1 changed files with 5 additions and 3 deletions

View File

@ -333,12 +333,14 @@ namespace dxvk {
Logger::err("D3D11: Cannot map a device-local buffer");
return E_INVALIDARG;
}
DxvkPhysicalBufferSlice physicalSlice;
if (MapType == D3D11_MAP_WRITE_DISCARD) {
// Allocate a new backing slice for the buffer and set
// it as the 'new' mapped slice. This assumes that the
// only way to invalidate a buffer is by mapping it.
auto physicalSlice = buffer->allocPhysicalSlice();
physicalSlice = buffer->allocPhysicalSlice();
pResource->SetMappedSlice(physicalSlice);
EmitCs([
@ -350,13 +352,13 @@ namespace dxvk {
} else if (MapType != D3D11_MAP_WRITE_NO_OVERWRITE) {
if (!WaitForResource(buffer->resource(), MapFlags))
return DXGI_ERROR_WAS_STILL_DRAWING;
physicalSlice = pResource->GetMappedSlice();
}
// Use map pointer from previous map operation. This
// way we don't have to synchronize with the CS thread
// if the map mode is D3D11_MAP_WRITE_NO_OVERWRITE.
DxvkPhysicalBufferSlice physicalSlice = pResource->GetMappedSlice();
pMappedResource->pData = physicalSlice.mapPtr(0);
pMappedResource->RowPitch = pResource->GetSize();
pMappedResource->DepthPitch = pResource->GetSize();