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

Return submission index to track down completion of async callbacks #6360

Draft
wants to merge 4 commits into
base: trunk
Choose a base branch
from

Conversation

eliemichel
Copy link
Contributor

Problem
wgpu-native is upgrading to latest versions of webgpu-headers (see gfx-rs/wgpu-native#427), and a notable change since the last sync is the introduction of WGPUFuture. Such structure holds a u64, from which we must be able to tell whether the async operation has completed.

A good candidate for the payload of WGPUFuture is the submission index already used in some places (and u64::MAX to mean "a future that is already resolved, probably because submission failed"). The only issue is that submit operations do not necessarily return a submission index.

Description
This PR makes functions buffer_map_async, add_work_done_closure, map_async, queue_on_submitted_work_done return the submission index that can later be used to check that the operation completed.

Testing
This is a WIP, I need feedback on the use of last_successful_submission_index in queue_on_submitted_work_done (is this the right fallback?), feedback about how to check that an operation completed from its submission index, and there is something to discuss about map_async:

  • What I do here is to increment the active_submission_index to make sure the operation is not considered complete too early, but maybe this can have the callback be invoked with some delay if the buffer mapping operation was not the last in queue?
  • The problem is that triage comes later, so when map_async returns, we do not know yet the true submission index of the map operation (it may be lower than the active_submission_index, right? If not then the proposed solution is ok, otherwise should we trigger triage right away? I guess there is a good reason why it is done separately though.

@eliemichel eliemichel requested a review from a team as a code owner October 3, 2024 07:11
@eliemichel eliemichel changed the title Eliemichel/future Return submission index to track down completion of async callbacks Oct 3, 2024
@eliemichel eliemichel marked this pull request as draft October 3, 2024 07:15
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.

1 participant