Replies: 3 comments
-
@mhawryluk @reczkok Thoughts? 🧠 |
Beta Was this translation helpful? Give feedback.
0 replies
-
agreed, makes total sense |
Beta Was this translation helpful? Give feedback.
0 replies
-
Great idea 💡 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Currently, a root can be created with the
tgpu.init
method. When passing a device, it will wrap it instead of requesting a new one.Note that both calls are asynchronous, even though the second call could be synchronous. It would be weird and inconsistant to return either a Promise of something, or that thing depending on the passed in parameters.
If we keep the existing-device root creation asynchronous though, we can encounter some troubling limitations:
Limitation 1: Having to wrap everything in an immediately-invoked function
In cases like
react-native-wgpu
, we get the device in a callback:Limitation 2: Hard to create resources in a constructor
Passing devices throughout the app is a common pattern in WebGPU apps. When incorporating TypeGPU, we have to create
roots in sync-places (e.g., constructors):
Proposed solution
A separate API for initializing a root from an existing device that is synchronous:
Beta Was this translation helpful? Give feedback.
All reactions