+7
-16
tests/tests_aux_d3d_d3d11.cpp
+7
-16
tests/tests_aux_d3d_d3d11.cpp
···
88
88
std::vector<xrt_image_native> xins;
89
89
xins.reserve(image_count);
90
90
91
-
// Keep this around until after successful import, then detach all.
92
-
std::vector<wil::unique_handle> handlesForImport;
93
-
handlesForImport.reserve(image_count);
94
-
95
91
for (HANDLE handle : handles) {
96
92
/*!
97
93
* If shared resources have been allocated without using NT handles we can't use DuplicateHandle
98
-
* (like u_graphics_buffer_ref does internally).
94
+
*(like u_graphics_buffer_ref does internally) or CloseHandle (which wil::~unique_handle will call).
99
95
* More info:
100
96
* https://learn.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgiresource-getsharedhandle#remarks
97
+
* When using KMT handles, their validity is tied to the underlying video memory (I guess that means a
98
+
* ID3D11Texture2D object).
101
99
*/
102
-
wil::unique_handle h{handle};
103
100
xrt_image_native xin;
104
-
xin.handle = h.get();
101
+
xin.handle = handle;
105
102
xin.size = 0;
106
103
xin.use_dedicated_allocation = use_dedicated_allocation;
107
104
xin.is_dxgi_handle = true;
108
105
109
-
handlesForImport.emplace_back(std::move(h));
110
106
xins.emplace_back(xin);
111
107
}
112
108
113
109
// Import into a vulkan image collection
114
-
bool result = VK_SUCCESS == vk_ic_from_natives(vk, &vk_info, xins.data(), (uint32_t)xins.size(), vkic.get());
110
+
const VkResult ret = vk_ic_from_natives(vk, &vk_info, xins.data(), (uint32_t)xins.size(), vkic.get());
111
+
VK_CHK_WITH_RET(ret, "vk_ic_from_natives", false);
115
112
116
-
if (result) {
117
-
// The imported swapchain took ownership of them now, release them from ownership here.
118
-
for (auto &h : handlesForImport) {
119
-
h.release();
120
-
}
121
-
}
122
-
return result;
113
+
return true;
123
114
}
124
115
#else
125
116