Async API#598
Merged
almarklein merged 20 commits intomainpygfx/wgpu-py:mainfrom Sep 26, 2024
Merged
Conversation
Member
Author
|
Ready. This basically applies the API changes to move further with async support. Next up would be creating examples that use the API in an async setting with asyncio and trio. Another further step could be to change the implementation of wgpu-native so that using the async api actually helps performance. But I'll probably leave that for later. This PR also prepares the way for implementing update propagation, taking async and portability into account. |
10 tasks
Korijn
approved these changes
Sep 25, 2024
Korijn
approved these changes
Sep 25, 2024
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.
See #391, also relates to pygfx/pygfx#495
Introduction
This PR changes the API to expose the async methods and their sync (convenience) variants. This does not implement any of the async stuff at the level of wgpu-native (the async methods simply call the sync variant for now). That's for another PR. This does however, make it possible to look into using wgpu-py in an async setting.
In short
Promise), all get a_asyncsuffix in wgpu-py._syncsuffix in wgpu-py. This way, they are easily identified, to detect less portable code.Affected methods
gpu.request_adapter()gpu.enumerate_adapters()adapter.request_device()buffer.map()device.lost(but was not yet implemented)shadermodule.get_compilation_info()(but was not yet implemented)queue.on_submitted_work_done()(but was not yet implemented)These method also have (and already had) an async variant:
create_compute_pipeline()create_render_pipeline()Todo
_syncversion.API changes
gpu.request_adapteris deprecated,request_adapter_syncinstead.gpu.enumerate_adaptersis deprecated, useenumerate_adapters_syncinstead.adapter.request_deviceis deprecated, userequest_device_syncinstead.buffer.mapis deprecated, usemap_syncinstead.