Skip to content

More idiomatic Adapter structs and methods - #26

Merged
bronter merged 2 commits into
bronter:idiomatic-zigfrom
TotoShampoin:idiomatic-zig
Jul 3, 2025
Merged

More idiomatic Adapter structs and methods#26
bronter merged 2 commits into
bronter:idiomatic-zigfrom
TotoShampoin:idiomatic-zig

Conversation

@TotoShampoin

Copy link
Copy Markdown

I did the work for Adapter too.

There is one caveat, however: Apparently, AdapterInfo may contain extra stuff. However, I have searched all throughout the various documentations of WebGPU, and I have not found a single thing about it.
In fact, I am starting to suspect that there isn't any...

In any case, here's what I did.

@TotoShampoin

Copy link
Copy Markdown
Author

Do tell me if I'm going too fast, or if you want to wait to decide how you'd handle the other stuff like the async callbacks before tackling all the rest XD

Comment thread src/adapter.zig Outdated
@bronter

bronter commented Jul 2, 2025

Copy link
Copy Markdown
Owner

Going fast is okay here, we still have time to review things in the draft PR before it gets merged into main anyway.

As far as AdapterInfo containing extra stuff, ChainedStruct/ChainedStructOut are on most structs as a way for webgpu implementations to add things that aren't standard, so it has to be there to be compatible with the webgpu headers, even if it isn't used.

@bronter

bronter commented Jul 2, 2025

Copy link
Copy Markdown
Owner

In fact, since the chained struct isn't used here, the wrapper code doesn't need it, as long as the underlying struct still has it. So you could remove it from AdapterInfo as long as it still remains in WGPUAdapterInfo. But if wgpu-native ever decides to use it, we'd have to add it back in so that it we can free it when we do freeMembers.

@TotoShampoin

Copy link
Copy Markdown
Author

Yeah, that's my concern
I would have removed it, but I knew that if webgpu was gonna place anything there, then removing it from the wrapper would lead to a lost pointer and a memory leak.

@bronter
bronter merged commit ba7a6fd into bronter:idiomatic-zig Jul 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants