-
-
Notifications
You must be signed in to change notification settings - Fork 21
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
Question: Why no automatic reference counting? #18
Comments
I did not want to have this wrapper do anything automagic on top of the raw C API, so that it is only about a nicer C++ style syntax but not about extra features. What you are looking for is commonly refered to as a RAII idiom and there is the beginning of something in the WebGPU-RAII repo. I've been using my WebGPU-RAII wrapper for some time, it is nice although what it is still missing is support for Reference: it behaves more like a std::unique_ptr that you cannot copy around. Typically, the owner of a WebGPU entity stores it as ag a |
Dawn's own cpp header also does RAII, so you can use that instead if that's desirable |
@petar-andrejic How do I obtain that header? I found this but it's basically empty, and I don't see what it's pointing to. |
They use code generation to make the headers from a json description of the API, so it's mostly empty until you actually build the library |
Correct, once you've built Dawn once, it is found in |
Since d1573ee a |
Apologies if this is a simple question, I'm just getting started with wgpu—
I'm quickly finding that it's a necessary pattern for every class that retains a
Handle
type wgpu object to:obj.reference()
orobj.release()
as appropriate to maintain the lifetime of everywgpu::
Handle memberobj.release()
all the handles in the destructorand failing to do this (afaict) would result in either leaked resources, or prematurely-freed ones.
From this it seems like it would be very ergonomic and reduce errors to have the
HANDLE()
template overload the copy/move ctors/dtors/assignment ops to do this implicitly.Is there a Chesterton's Fence here I'm missing? Why is this not already done? Do I misunderstand how
.reference()
and.release()
are intended to be used?thanks!
The text was updated successfully, but these errors were encountered: