1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-01-31 14:52:11 +01:00

[d3d9] Synchronize only to given sequence number in WaitForResources

This commit is contained in:
Robin Kertels 2022-02-12 21:37:12 +01:00 committed by Joshie
parent 917a8d00a2
commit 97ae14b6a0
2 changed files with 16 additions and 14 deletions

View File

@ -112,7 +112,7 @@ namespace dxvk {
D3D9DeviceEx::~D3D9DeviceEx() { D3D9DeviceEx::~D3D9DeviceEx() {
Flush(); Flush();
SynchronizeCsThread(); SynchronizeCsThread(DxvkCsThread::SynchronizeAll);
delete m_initializer; delete m_initializer;
delete m_converter; delete m_converter;
@ -328,7 +328,7 @@ namespace dxvk {
return hr; return hr;
Flush(); Flush();
SynchronizeCsThread(); SynchronizeCsThread(DxvkCsThread::SynchronizeAll);
return D3D_OK; return D3D_OK;
} }
@ -4064,6 +4064,7 @@ namespace dxvk {
bool D3D9DeviceEx::WaitForResource( bool D3D9DeviceEx::WaitForResource(
const Rc<DxvkResource>& Resource, const Rc<DxvkResource>& Resource,
uint64_t SequenceNumber,
DWORD MapFlags) { DWORD MapFlags) {
// Wait for the any pending D3D9 command to be executed // Wait for the any pending D3D9 command to be executed
// on the CS thread so that we can determine whether the // on the CS thread so that we can determine whether the
@ -4075,7 +4076,7 @@ namespace dxvk {
: DxvkAccess::Read; : DxvkAccess::Read;
if (!Resource->isInUse(access)) if (!Resource->isInUse(access))
SynchronizeCsThread(); SynchronizeCsThread(SequenceNumber);
if (Resource->isInUse(access)) { if (Resource->isInUse(access)) {
if (MapFlags & D3DLOCK_DONOTWAIT) { if (MapFlags & D3DLOCK_DONOTWAIT) {
@ -4089,7 +4090,7 @@ namespace dxvk {
// Make sure pending commands using the resource get // Make sure pending commands using the resource get
// executed on the the GPU if we have to wait for it // executed on the the GPU if we have to wait for it
Flush(); Flush();
SynchronizeCsThread(); SynchronizeCsThread(SequenceNumber);
m_dxvkDevice->waitForResource(Resource, access); m_dxvkDevice->waitForResource(Resource, access);
} }
@ -4242,10 +4243,10 @@ namespace dxvk {
std::memset(physSlice.mapPtr, 0, physSlice.length); std::memset(physSlice.mapPtr, 0, physSlice.length);
} }
else if (!skipWait) { else if (!skipWait) {
if (!(Flags & D3DLOCK_DONOTWAIT) && !WaitForResource(mappedBuffer, D3DLOCK_DONOTWAIT)) if (!(Flags & D3DLOCK_DONOTWAIT) && !WaitForResource(mappedBuffer, pResource->GetMappingBufferSequenceNumber(Subresource), D3DLOCK_DONOTWAIT))
pResource->EnableStagingBufferUploads(Subresource); pResource->EnableStagingBufferUploads(Subresource);
if (!WaitForResource(mappedBuffer, Flags)) if (!WaitForResource(mappedBuffer, pResource->GetMappingBufferSequenceNumber(Subresource), Flags))
return D3DERR_WASSTILLDRAWING; return D3DERR_WASSTILLDRAWING;
} }
} }
@ -4324,7 +4325,7 @@ namespace dxvk {
}); });
} }
if (!WaitForResource(mappedBuffer, Flags)) if (!WaitForResource(mappedBuffer, DxvkCsThread::SynchronizeAll, Flags))
return D3DERR_WASSTILLDRAWING; return D3DERR_WASSTILLDRAWING;
} else { } else {
// If we are a new alloc, and we weren't written by the GPU // If we are a new alloc, and we weren't written by the GPU
@ -4536,7 +4537,7 @@ namespace dxvk {
pitch, std::min(convertFormat.PlaneCount, 2u) * pitch * texLevelExtentBlockCount.height); pitch, std::min(convertFormat.PlaneCount, 2u) * pitch * texLevelExtentBlockCount.height);
Flush(); Flush();
SynchronizeCsThread(); SynchronizeCsThread(DxvkCsThread::SynchronizeAll);
m_converter->ConvertFormat( m_converter->ConvertFormat(
convertFormat, convertFormat,
@ -4653,10 +4654,10 @@ namespace dxvk {
const bool directMapping = pResource->GetMapMode() == D3D9_COMMON_BUFFER_MAP_MODE_DIRECT; const bool directMapping = pResource->GetMapMode() == D3D9_COMMON_BUFFER_MAP_MODE_DIRECT;
const bool skipWait = (!wasWrittenByGPU && (usesStagingBuffer || readOnly || (noOverlap && !directMapping))) || noOverwrite; const bool skipWait = (!wasWrittenByGPU && (usesStagingBuffer || readOnly || (noOverlap && !directMapping))) || noOverwrite;
if (!skipWait) { if (!skipWait) {
if (!(Flags & D3DLOCK_DONOTWAIT) && !WaitForResource(mappingBuffer, D3DLOCK_DONOTWAIT)) if (!(Flags & D3DLOCK_DONOTWAIT) && !WaitForResource(mappingBuffer, pResource->GetMappingBufferSequenceNumber(), D3DLOCK_DONOTWAIT))
pResource->EnableStagingBufferUploads(); pResource->EnableStagingBufferUploads();
if (!WaitForResource(mappingBuffer, Flags)) if (!WaitForResource(mappingBuffer, pResource->GetMappingBufferSequenceNumber(), Flags))
return D3DERR_WASSTILLDRAWING; return D3DERR_WASSTILLDRAWING;
pResource->SetWrittenByGPU(false); pResource->SetWrittenByGPU(false);
@ -4772,14 +4773,14 @@ namespace dxvk {
} }
void D3D9DeviceEx::SynchronizeCsThread() { void D3D9DeviceEx::SynchronizeCsThread(uint64_t SequenceNumber) {
D3D9DeviceLock lock = LockDevice(); D3D9DeviceLock lock = LockDevice();
// Dispatch current chunk so that all commands // Dispatch current chunk so that all commands
// recorded prior to this function will be run // recorded prior to this function will be run
FlushCsChunk(); FlushCsChunk();
m_csThread.synchronize(DxvkCsThread::SynchronizeAll); m_csThread.synchronize(SequenceNumber);
} }
@ -7348,7 +7349,7 @@ namespace dxvk {
return hr; return hr;
Flush(); Flush();
SynchronizeCsThread(); SynchronizeCsThread(DxvkCsThread::SynchronizeAll);
return D3D_OK; return D3D_OK;
} }

View File

@ -662,6 +662,7 @@ namespace dxvk {
bool WaitForResource( bool WaitForResource(
const Rc<DxvkResource>& Resource, const Rc<DxvkResource>& Resource,
uint64_t SequenceNumber,
DWORD MapFlags); DWORD MapFlags);
/** /**
@ -731,7 +732,7 @@ namespace dxvk {
void CreateConstantBuffers(); void CreateConstantBuffers();
void SynchronizeCsThread(); void SynchronizeCsThread(uint64_t SequenceNumber);
void Flush(); void Flush();