Skip to content

Add Buffer functions and fix misleading comments #7

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

Merged
merged 2 commits into from
Dec 1, 2024

Conversation

Copper280z
Copy link
Contributor

Hi, I've implemented several more functions in the zig Buffer interface, and modified a couple of comments that were confusing or incorrect.

Particularly, in mapAsync, size==0 will not map the entire buffer per the webgpu spec. If you call mapAsync with size=0, get[Const]MappedRange will always return null because any size to get will always be larger than the mapped range.

Source:
https://www.w3.org/TR/webgpu/#dom-gpubuffer-mapasync

// `offset` has to be a multiple of 8 (otherwise `null` will be returned).
// `@sizeOf(T) * len` has to be a multiple of 4 (otherwise `null` will be returned).
// `offset` - in bytes, has to be a multiple of 8 (otherwise `null` will be returned).
// `len` - length of slice to return, in elements of type T, `@sizeOf(T) * len` has to be a multiple of 4 (otherwise `null` will be returned).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!
We should probably use doc-comments /// here so this gets displayed in users editors.

@hazeycode hazeycode merged commit dbb3e60 into zig-gamedev:main Dec 1, 2024
3 checks passed
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