From: Stefan Dösinger stefan@codeweavers.com
---
I don't see a method to wait for a fence, at least not without having a command queue. A suggestion I found online goes along the lines of:
if (fence->GetCompletedValue != expected) { HANDLE ev = CreateEvent(...); fence->SetEventOnCompletion(expected, ev); WaitForSingleObject(ev, INFINITE); CloseHandle(ev); }
Which I could write, but would be untested dead code as long as the other method is a stub. So busy waiting and writing one fixme every time we busy wait seems like a better choice for now. --- libs/vkd3d/device.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-)
diff --git a/libs/vkd3d/device.c b/libs/vkd3d/device.c index 8efaab854..2483999ab 100644 --- a/libs/vkd3d/device.c +++ b/libs/vkd3d/device.c @@ -3736,10 +3736,32 @@ static HRESULT STDMETHODCALLTYPE d3d12_device_OpenSharedHandleByName(ID3D12Devic static HRESULT STDMETHODCALLTYPE d3d12_device_MakeResident(ID3D12Device5 *iface, UINT object_count, ID3D12Pageable * const *objects) { - FIXME_ONCE("iface %p, object_count %u, objects %p stub!\n", - iface, object_count, objects); + ID3D12Fence *fence; + bool once = true; + HRESULT hr;
- return S_OK; + TRACE("iface %p, object_count %u, objects %p.\n", iface, object_count, objects); + + hr = ID3D12Device5_CreateFence(iface, 0, 0, &IID_ID3D12Fence, (void **)&fence); + if (FAILED(hr)) + return hr; + + hr = ID3D12Device5_EnqueueMakeResident(iface, 0, object_count, objects, fence, 1); + if (SUCCEEDED(hr)) + { + /* At the time this was written EnqueuMakeResident was a stub. This doesn't + * use FIXME_ONCE on purpose to write a fixme once per function call. */ + while (!ID3D12Fence_GetCompletedValue(fence)) + { + if (once) + { + FIXME("Handle async EnqueuMakeResident termination better.\n"); + once = false; + } + } + } + ID3D12Fence_Release(fence); + return hr; }
static HRESULT STDMETHODCALLTYPE d3d12_device_Evict(ID3D12Device5 *iface,