d3d12: Implement semaphore

This commit is contained in:
vlj 2015-05-26 18:36:05 +02:00 committed by Vincent Lejeune
parent c5a1f8930f
commit 9c193e0282
2 changed files with 45 additions and 0 deletions

View File

@ -1162,4 +1162,46 @@ void D3D12GSRender::WriteDepthBuffer()
fence->Release();
downloadCommandList->Release();
}
void D3D12GSRender::semaphorePGRAPHBackendRelease(u32 offset, u32 value)
{
ID3D12Fence *fence;
check(
m_device->CreateFence(0, D3D12_FENCE_FLAG_NONE, IID_PPV_ARGS(&fence))
);
HANDLE handle = CreateEvent(0, FALSE, FALSE, 0);
fence->SetEventOnCompletion(1, handle);
m_commandQueueGraphic->Signal(fence, 1);
std::thread valueChangerThread([=]() {
WaitForSingleObject(handle, INFINITE);
CloseHandle(handle);
fence->Release();
vm::write32(m_label_addr + offset, value);
});
valueChangerThread.detach();
}
void D3D12GSRender::semaphorePFIFOAcquire(u32 offset, u32 value)
{
ID3D12Fence *fence;
check(
m_device->CreateFence(0, D3D12_FENCE_FLAG_NONE, IID_PPV_ARGS(&fence))
);
m_commandQueueGraphic->Wait(fence, 1);
std::thread valueChangerThread([=]() {
while (true)
{
u32 val = vm::read32(m_label_addr + offset);
if (val == value) break;
}
fence->Signal(1);
fence->Release();
}
);
valueChangerThread.join();
}
#endif

View File

@ -119,6 +119,9 @@ public:
D3D12GSRender();
virtual ~D3D12GSRender();
virtual void semaphorePGRAPHBackendRelease(u32 offset, u32 value) override;
virtual void semaphorePFIFOAcquire(u32 offset, u32 value) override;
private:
virtual void Close() override;