Skip to content
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

Fix usage of active_submission_index.fetch_add #6

Merged
merged 1 commit into from
Apr 7, 2023
Merged

Fix usage of active_submission_index.fetch_add #6

merged 1 commit into from
Apr 7, 2023

Conversation

niklaskorz
Copy link

@niklaskorz niklaskorz commented Apr 7, 2023

From https://doc.rust-lang.org/std/sync/atomic/struct.AtomicU64.html#method.fetch_add:

Adds to the current value, returning the previous value.

Thus, receiving the new active submission index after incrementing it requires adding 1 to the return value locally as well.

For comparison, the other uses of fetch_add in wgpu (unrelated to the current changes) treat the atomic as a "next id" variable instead of an "active id", thus not requiring to increment the return value of fetch_add:

https://github.com/gfx-rs/wgpu/blob/dd64343f942ff519f980a2adc02fa60f3a7b72a3/wgpu/src/backend/web.rs#L29

https://github.com/gfx-rs/wgpu/blob/dd64343f942ff519f980a2adc02fa60f3a7b72a3/wgpu-hal/src/gles/device.rs#L1094

@gents83
Copy link
Owner

gents83 commented Apr 7, 2023

Very good catch!

@gents83 gents83 merged commit c7b08db into gents83:master Apr 7, 2023
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