-
Notifications
You must be signed in to change notification settings - Fork 53
Add lifetime management #94
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
Conversation
| typedef void (*WGPUProcCommandEncoderPushDebugGroup)(WGPUCommandEncoder commandEncoder, char const * groupLabel); | ||
| typedef void (*WGPUProcCommandEncoderResolveQuerySet)(WGPUCommandEncoder commandEncoder, WGPUQuerySet querySet, uint32_t firstQuery, uint32_t queryCount, WGPUBuffer destination, uint64_t destinationOffset); | ||
| typedef void (*WGPUProcCommandEncoderWriteTimestamp)(WGPUCommandEncoder commandEncoder, WGPUQuerySet querySet, uint32_t queryIndex); | ||
| typedef void (*WGPUProcCommandEncoderFree)(WGPUCommandEncoder commandEncoder); |
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.
Could we use the same naming suffix for the meaning of release/free for all objects?
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.
Basically using Release for all objects, just that sometimes objects don't have Reference?
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.
Yeah exactly
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.
Since these objects are special anyway, can't we just say encoder/bundle get freed by Finish, and pass encoders get freed by EndPass?
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.
Still should have a way to delete it (without errors) if you choose to never call Finish(). Finish() results in errors if you encoded something invalid.
|
What would you think about exposing the At least anecdotally I don't think we've been asked for |
|
There's been quite some discussion in #15 and the wgpu Matrix channel and I think we arrived to an agreement that encoders shouldn't be refcounted, but the rest of the objects could (so I think they should). wgpu-rs has refcounting for most of them already anyways. The refcount on the device, texture and buffer has been quite useful when using this API in Chromium already. |
|
For what it's worth, I think the API is reasonable and I don't feel too strongly about it either way. I'm just not sure that a lot of projects will use the
Just for my own understanding, would you mind elaborating how it it benefits Chromium? Do you mean it improves performance because of the shared refcount and/or or simplifies things because some level of wrapper (e.g. |
This is about to change with @pythonesque work. And that's exactly why we were hesitating in the beginning: we didn't want to draw ourselves in the corner with forced refcounting. |
Code in Chromium to deal with swapchain textures and other cross-systems images in the GPU process has complicated lifetime semantics. Having a refcounted object means that each piece of the code can keep a reference to the object to make sure it doesn't disappear unexpectedly. The more general idea is that every large project will have some very nice code, and some amount of spaghetti. Refcounting helps with lifetime semantics in the spaghetti. |
Thank you for the context! Is there anything that would prevent some kind of refcounting container (e.g. |
|
Nothing prevents using refcounting containers. They would just add unnecessary indirection since these objects are already internally refcounted. |
When programming in C++, I use @grovesNL mentioned weak references. While |
|
Folding into the updated version of #15 |
All objects are refcounted except for encoders that can have simpler lifetime semantics. +CC @pythonesque
Superseeds #15