diff options
| author | lucy96chen <47800040+lucy96chen@users.noreply.github.com> | 2022-02-18 22:17:13 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-02-18 22:17:13 -0800 |
| commit | e993ff5f8d21d77dd3fb579f7afc51c6dcad834c (patch) | |
| tree | 37e5a9fc2f285a2bdd073cd11835d020d20d5c33 /tools/gfx/d3d12/render-d3d12.cpp | |
| parent | 7953c0b6e4e6328bacf9945763013f9e0af6e435 (diff) | |
Added implementations for IFence::getSharedHandle() for Vulkan and D3D12 (#2137)
Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'tools/gfx/d3d12/render-d3d12.cpp')
| -rw-r--r-- | tools/gfx/d3d12/render-d3d12.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/tools/gfx/d3d12/render-d3d12.cpp b/tools/gfx/d3d12/render-d3d12.cpp index 9be157605..5500b024a 100644 --- a/tools/gfx/d3d12/render-d3d12.cpp +++ b/tools/gfx/d3d12/render-d3d12.cpp @@ -4947,8 +4947,19 @@ public: virtual SLANG_NO_THROW Result SLANG_MCALL getSharedHandle(InteropHandle* outHandle) override { - outHandle->handleValue = 0; - return SLANG_FAIL; + // Check if a shared handle already exists. + if (sharedHandle.handleValue != 0) + { + *outHandle = sharedHandle; + return SLANG_OK; + } + + ComPtr<ID3D12Device> devicePtr; + m_fence->GetDevice(IID_PPV_ARGS(devicePtr.writeRef())); + SLANG_RETURN_ON_FAIL(devicePtr->CreateSharedHandle(m_fence, NULL, GENERIC_ALL, nullptr, (HANDLE*)&outHandle->handleValue)); + outHandle->api = InteropHandleAPI::D3D12; + sharedHandle = *outHandle; + return SLANG_OK; } virtual SLANG_NO_THROW Result SLANG_MCALL |
