1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-03-02 04:29:14 +01:00

[d3d11] Optimize WaitForResource behaviour when resource is already idle

We don't have to flush everything in this case, just flushing the current
CS chunk is enough to determine if the resource is in use by the GPU.
This commit is contained in:
Philip Rebohle 2018-07-23 16:08:01 +02:00
parent 662b6429a8
commit adadf362a3
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99

View File

@ -521,16 +521,24 @@ namespace dxvk {
// Wait for the any pending D3D11 command to be executed
// on the CS thread so that we can determine whether the
// resource is currently in use or not.
Flush();
FlushCsChunk();
SynchronizeCsThread();
if (Resource->isInUse()) {
if (MapFlags & D3D11_MAP_FLAG_DO_NOT_WAIT)
if (MapFlags & D3D11_MAP_FLAG_DO_NOT_WAIT) {
// We don't have to wait, but misbehaving games may
// still try to spin on `Map` until the resource is
// idle, so we should flush pending commands
FlushImplicit();
return false;
// TODO implement properly in DxvkDevice
while (Resource->isInUse())
dxvk::this_thread::yield();
} else {
// Make sure pending commands using the resource get
// executed on the the GPU if we have to wait for it
Flush();
while (Resource->isInUse())
dxvk::this_thread::yield();
}
}
return true;