[SYCL] add support for bindless image resource_win32_name (named handles)#21899
Open
cperkinsintel wants to merge 9 commits intointel:syclfrom
Open
[SYCL] add support for bindless image resource_win32_name (named handles)#21899cperkinsintel wants to merge 9 commits intointel:syclfrom
cperkinsintel wants to merge 9 commits intointel:syclfrom
Conversation
| #if defined(_WIN32) || defined(_WIN64) | ||
| #include <mutex> | ||
| #include <unordered_map> | ||
| #define WIN32_LEAN_AND_MEAN |
Contributor
There was a problem hiding this comment.
Sorry, I didn't really get why we define this macro here? Maybe add a comment.
Contributor
Author
There was a problem hiding this comment.
It's a standard windows thing. You do it right before including windows.h if you want "the minimum".
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds Windows-only support for importing bindless image interop resources via resource_win32_name (Win32 named handles) by opening the named handle through a D3D12 device and delegating to the existing resource_win32_handle import path.
Changes:
- Add
resource_win32_nameimport support for external memory and external semaphores on Windows (open-by-name + handle lifetime tracking). - Extend the interop descriptor type to carry the originating D3D device pointer needed to open the named handle.
- Add a DX12 end-to-end test and update the Windows ABI symbol dump.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
sycl/source/detail/bindless_images.cpp |
Implements resource_win32_name imports on Windows and adds handle tracking/cleanup logic. |
sycl/include/sycl/ext/oneapi/bindless_images_interop.hpp |
Extends resource_win32_name to include a device pointer for opening named handles. |
sycl/test-e2e/bindless_images/dx12_interop/D3D12_sycl_buffer_win32_name_native.cpp |
Adds an e2e DX12↔SYCL interop test that imports buffers/fence by name. |
sycl/test/abi/sycl_symbols_windows.dump |
Updates ABI symbol expectations for the new template instantiations. |
Comment on lines
+1115
to
+1129
| // Delegate to existing resource_win32_handle implementation | ||
| external_semaphore_descriptor<resource_win32_handle> handleDesc{ | ||
| {openedHandle}, externalSemaphoreDesc.handle_type}; | ||
|
|
||
| external_semaphore result = | ||
| import_external_semaphore(handleDesc, syclDevice, syclContext); | ||
|
|
||
| // Track the opened handle so we can close it on release | ||
| { | ||
| std::lock_guard<std::mutex> lock(g_win32NameHandlesMutex); | ||
| g_win32NameHandles[reinterpret_cast<ur_exp_external_mem_handle_t>( | ||
| result.raw_handle)] = openedHandle; | ||
| } | ||
|
|
||
| return result; |
| // Windows external name type | ||
| struct resource_win32_name { | ||
| const void *name; | ||
| void *device; // ID3D12Device* or ID3D11Device* for opening named handle |
Comment on lines
+90
to
+92
| std::cout << "[D3D12] Created named buffer: " << name << std::endl; | ||
|
|
||
| return result; |
Comment on lines
+114
to
+116
| std::cout << "[D3D12] Created named fence: " << name << std::endl; | ||
|
|
||
| return result; |
Comment on lines
+728
to
+735
| #if defined(_WIN32) || defined(_WIN64) | ||
| // Close handle if it was opened via resource_win32_name | ||
| { | ||
| std::lock_guard<std::mutex> lock(g_win32NameHandlesMutex); | ||
| auto it = | ||
| g_win32NameHandles.find(reinterpret_cast<ur_exp_external_mem_handle_t>( | ||
| externalSemaphore.raw_handle)); | ||
| if (it != g_win32NameHandles.end()) { |
Comment on lines
+1069
to
+1083
| // Use existing resource_win32_handle implementation | ||
| external_mem_descriptor<resource_win32_handle> handleDesc{ | ||
| {openedHandle}, | ||
| externalMemDesc.handle_type, | ||
| externalMemDesc.size_in_bytes}; | ||
|
|
||
| // Delegate to existing resource_win32_handle implementation | ||
| external_mem result = import_external_memory<resource_win32_handle>( | ||
| handleDesc, syclDevice, syclContext); | ||
|
|
||
| // Track the opened handle so we can close it on release | ||
| { | ||
| std::lock_guard<std::mutex> lock(g_win32NameHandlesMutex); | ||
| g_win32NameHandles[result.raw_handle] = openedHandle; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Neither the UR nor L0 have affordances for win32 named handles. SYCL substitutes a regular win32_handle instead.