···763763static void
764764client_d3d11_compositor_init_try_timeline_semaphores(struct client_d3d11_compositor *c)
765765{
766766+ struct xrt_compositor_semaphore *xcsem{nullptr};
767767+ HANDLE timeline_semaphore_handle_raw{};
768768+ xrt_result_t xret;
769769+770770+ // Set the value to something non-zero.
766771 c->timeline_semaphore_value = 1;
772772+767773 // See if we can make a "timeline semaphore", also known as ID3D11Fence
768774 if (!c->xcn->base.create_semaphore || !c->xcn->base.layer_commit_with_semaphore) {
769775 return;
770776 }
771771- struct xrt_compositor_semaphore *xcsem = nullptr;
772772- wil::unique_handle timeline_semaphore_handle;
773773- if (XRT_SUCCESS != xrt_comp_create_semaphore(&(c->xcn->base), timeline_semaphore_handle.put(), &xcsem)) {
777777+778778+ /*
779779+ * This call returns a HANDLE in the out_handle argument, it is owned by
780780+ * the returned xrt_compositor_semaphore object we should not track it.
781781+ */
782782+ xret = xrt_comp_create_semaphore( //
783783+ &(c->xcn->base), // xc
784784+ &timeline_semaphore_handle_raw, // out_handle
785785+ &xcsem); // out_xcsem
786786+ if (xret != XRT_SUCCESS) {
774787 D3D_WARN(c, "Native compositor tried but failed to created a timeline semaphore for us.");
775788 return;
776789 }
···779792 // Because importFence throws on failure we use this ref.
780793 unique_compositor_semaphore_ref timeline_semaphore{xcsem};
781794782782- // unique_compositor_semaphore_ref now owns the handle.
783783- HANDLE timeline_semaphore_handle_raw = timeline_semaphore_handle.release();
784784-785785- // try to import and signal
795795+ // Try to import the fence.
786796 wil::com_ptr<ID3D11Fence> fence = import_fence(*(c->fence_device), timeline_semaphore_handle_raw);
797797+798798+ // And try to signal the fence to make sure it works.
787799 HRESULT hr = c->fence_context->Signal(fence.get(), c->timeline_semaphore_value);
788800 if (!SUCCEEDED(hr)) {
789801 D3D_WARN(c,
+14-6
src/xrt/compositor/client/comp_d3d12_client.cpp
···10221022static void
10231023client_d3d12_compositor_init_try_timeline_semaphores(struct client_d3d12_compositor *c)
10241024{
10251025+ struct xrt_compositor_semaphore *xcsem{nullptr};
10261026+ HANDLE timeline_semaphore_handle_raw{};
10271027+ xrt_result_t xret;
10281028+10291029+ // Set the value to something non-zero.
10251030 c->timeline_semaphore_value = 1;
1026103110271032 // See if we can make a "timeline semaphore", also known as ID3D12Fence
···10291034 return;
10301035 }
1031103610321032- struct xrt_compositor_semaphore *xcsem = nullptr;
10331033- wil::unique_handle timeline_semaphore_handle;
10341034- if (XRT_SUCCESS != xrt_comp_create_semaphore(&(c->xcn->base), timeline_semaphore_handle.put(), &xcsem)) {
10371037+ /*
10381038+ * This call returns a HANDLE in the out_handle argument, it is owned by
10391039+ * the returned xrt_compositor_semaphore object we should not track it.
10401040+ */
10411041+ xret = xrt_comp_create_semaphore( //
10421042+ &(c->xcn->base), // xc
10431043+ &timeline_semaphore_handle_raw, // out_handle
10441044+ &xcsem); // out_xcsem
10451045+ if (xret != XRT_SUCCESS) {
10351046 D3D_WARN(c, "Native compositor tried but failed to created a timeline semaphore for us.");
10361047 return;
10371048 }
···1039105010401051 // Because importFence throws on failure we use this ref.
10411052 unique_compositor_semaphore_ref timeline_semaphore{xcsem};
10421042-10431043- // unique_compositor_semaphore_ref now owns the handle.
10441044- HANDLE timeline_semaphore_handle_raw = timeline_semaphore_handle.release();
1045105310461054 // Try to import, importFence throws on failure.
10471055 wil::com_ptr<ID3D12Fence1> fence = xrt::auxiliary::d3d::d3d12::importFence( //