-
Notifications
You must be signed in to change notification settings - Fork 196
GPU compute API abstraction on top of WebGPU #3238
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from 25 commits
Commits
Show all changes
48 commits
Select commit
Hold shift + click to select a range
69855b0
Add Slang + Dawn dependencies
daljit46 e89112d
Add new GPU compute API
daljit46 d7c70cc
Add unit tests for GPU API
daljit46 c24a724
Reorder arguments for FetchContent_Declare
daljit46 9725022
Fix typos
daljit46 f63dd43
Remove DOWNLOAD_EXTRACT_TIMESTAMP
daljit46 0428640
Don't run unit tests in parallel
daljit46 9d9111e
Add Threads package requirement for Dawn integration
daljit46 1c58428
Update Dawn library path handling for Linux systems
daljit46 3e763d5
Update required cmake version in readme
daljit46 13a684b
Add mesa-vulkan-drivers to dependency installation for Linux builds
daljit46 50712c6
Fix instance descriptor initialization in ComputeContext constructor
daljit46 444d16a
Use supported device limits for storage buffer sizes
daljit46 887c710
Update Slang directory path handling for cross-platform compatibility
daljit46 f9a43fb
Fix filesystem path handling in ComputeContext constructor
daljit46 2308693
Add post-build command to copy imported dependencies
daljit46 95232f4
Add mesa package to MinGW dependencies for Windows build
daljit46 c543f2b
Catch exceptions during ComputeContext creation for gpu tests
daljit46 764fa3a
Use std::string_view where required by check_syntax
daljit46 c5691db
Add workaround for loading vulkan dll on MSYS2
daljit46 d3c008b
Fetch tcb::span with CMake
daljit46 9738f59
Introduce MRTRIX_USE_SYSTEM options for Slang, Dawn and tcb::span
daljit46 365f00d
Use FetchContent_Populate directly to avoid building tcb::span tests
daljit46 dc37898
Add copyright notice
daljit46 bfe549d
Apply clang-format-all
daljit46 f2af69c
Remove redundant this-> qualifiers in gpu.cpp
daljit46 49dbec2
Add new function to upload POD structs to GPU buffers
daljit46 ee18874
Remove redundant write_to_buffer overload with void*
daljit46 9027f69
Use constexpr for desired buffer size constants
daljit46 44078e2
Fix comment to correctly refer to Slang files instead of WGSL
daljit46 255a490
Align buffer writes to WebGPU requirements and add device limits
daljit46 9358f41
Mark new_buffer_from_host_image as [[nodiscard]]
daljit46 e6fe1af
Add test for kernel using uniform buffer
daljit46 d7cf148
Select correct Slang entry point end-to-end
daljit46 b59c2d0
Fix inconsistent parameter names
daljit46 c2af099
Fix formatting with clang-format
daljit46 d9de700
Update GPU code copyright to 2026
daljit46 20fc37f
Revert "Don't run unit tests in parallel"
daljit46 9cda131
Simplify selection of specialized entry point
daljit46 2c29bc8
Avoid nested conditional operator when resolving entry point name
daljit46 68103b9
Use uppercase unsigned literal suffixes
daljit46 a725e1c
Add missing include header
daljit46 4c94b1f
Suppress check_syntax for resolved variable
daljit46 488c6a8
Fix narrowing conversion for Slang entry point
daljit46 f6efe50
Remove hack to copy Vulkan dll on MSYS2
daljit46 3e63d21
Update copyright header for gputests.cpp
daljit46 ad22afc
Add option to enable/disable GPU compute functionality
daljit46 4617d68
Merge branch 'dev' into webgpu
daljit46 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,8 @@ find_package(FFTW REQUIRED) | |
| find_package(Git QUIET) | ||
| find_package(Threads REQUIRED) | ||
| find_package(PNG QUIET) | ||
| find_package(Dawn CONFIG REQUIRED) | ||
| find_package(slang CONFIG REQUIRED) | ||
|
|
||
| if(PNG_FOUND) | ||
| message(STATUS "Found PNG: ${PNG_LIBRARIES}") | ||
|
|
@@ -102,6 +104,7 @@ else() | |
| endif() | ||
|
|
||
| target_link_libraries(mrtrix-core PUBLIC | ||
| dawn::webgpu_dawn | ||
| Eigen3::Eigen | ||
| ZLIB::ZLIB | ||
| fftw3::fftw | ||
|
|
@@ -110,13 +113,36 @@ target_link_libraries(mrtrix-core PUBLIC | |
| Threads::Threads | ||
| nlohmann_json::nlohmann_json | ||
| nifti::nifti | ||
| slang::slang | ||
| tcb::span | ||
| ) | ||
|
|
||
| # On Windows, the libraries need to be in the same directory as the executables | ||
| if(WIN32) | ||
| set_target_properties(mrtrix-core PROPERTIES | ||
| RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin | ||
| ) | ||
|
|
||
| add_custom_command(TARGET mrtrix-core POST_BUILD | ||
| COMMAND ${CMAKE_COMMAND} -E copy_if_different | ||
| $<TARGET_FILE:dawn::webgpu_dawn> | ||
| $<TARGET_FILE:slang::slang> | ||
| $<TARGET_FILE_DIR:mrtrix-core> | ||
| COMMENT "Copying imported dependencies to output directory" | ||
| ) | ||
| # In an MSYS2 environment, dawn fails to load the required vulkan-1.dll library when | ||
| # creating a WebGPU instance. To remedy this, we copy the DLL from C:/Windows/System32 | ||
| # to the build output directory. | ||
| # TODO: Investigate further and find a better solution. | ||
|
||
| if(NOT MSVC) | ||
| add_custom_command(TARGET mrtrix-core POST_BUILD | ||
| COMMAND ${CMAKE_COMMAND} -E copy_if_different | ||
| $ENV{WINDIR}/System32/vulkan-1.dll | ||
| $<TARGET_FILE_DIR:mrtrix-core> | ||
| COMMENT "Copying vulkan-1.dll to output directory" | ||
| ) | ||
| endif() | ||
|
|
||
| endif() | ||
|
|
||
| install(TARGETS mrtrix-core | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this deletion intentional? The "compatibility" tests that were incompatible with parallel execution have been moved out of the "unittest" category (111947a), such that the parallelisation added in 2916ca4 became acceptable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was just a temporary solution to diagnose whether tests were failing due to parallelistation. I will restore it once I confirm things work without this.