implements #8119 : Metal backend's wgpu_hal::Device::wait implementat…#9328
implements #8119 : Metal backend's wgpu_hal::Device::wait implementat…#932839ali wants to merge 3 commits into
Conversation
|
If |
This comment was marked as resolved.
This comment was marked as resolved.
inner-daemons
left a comment
There was a problem hiding this comment.
Looks good overall. 2 questions. Also going to CC @cwfitzgerald because this will almost certainly have to be reassigned
| // to create command buffers for internal purposes. In those cases we always | ||
| // commit the buffer immediately, so we don't adjust the counter for them.) | ||
| command_buffer_created_not_submitted: atomic::AtomicUsize, | ||
| sync: Arc<(Mutex<()>, Condvar)>, |
There was a problem hiding this comment.
I'm skeptical about why this is Mutex<()> instead of just keeping track of the last completed submission index directly like Mutex<u64>.
There was a problem hiding this comment.
There is also pub type AtomicFenceValue = core::sync::atomic::AtomicU64
There was a problem hiding this comment.
@andyleiserson I get that but I feel like that could be replaced at this point, combined into the mutex
| shared: Arc::new(QueueShared { | ||
| raw: queue, | ||
| command_buffer_created_not_submitted: atomic::AtomicUsize::new(0), | ||
| sync: Arc::clone(&self.shared.queue_sync), |
There was a problem hiding this comment.
Should the sync really be shared between devices in the same adapter?
|
made couple of changes that should address both comments :
|
…mentation polls instead of waiting
andyleiserson
left a comment
There was a problem hiding this comment.
It pains me a little to replace an Atomic with a Mutex, but this is the right way of using the Condvar, and I don't think it's worth speculatively adding a shadow copy in an atomic.
| if start.elapsed() >= timeout { | ||
| return Ok(false); | ||
| if let Some(deadline) = | ||
| timeout.and_then(|timeout| std::time::Instant::now().checked_add(timeout)) |
There was a problem hiding this comment.
I think it would be better to unwrap here on overflow. Or maybe use wait_while_for so we don't have to do timeout accounting ourselves (unless our build configuration doesn't support wait_for?).
| if cmd_buf.status() == MTLCommandBufferStatus::Completed { | ||
| max_value = value; | ||
| } |
There was a problem hiding this comment.
I noted in #9532 (comment) that this check isn't correct -- it should be looking for MTLCommandBufferStatus::Error as well. Although, I'm also not sure why it's necessary to scan for additional completed command buffers here, maybe we could remove this entirely.
…ion polls instead of waiting
Connections
#8119
Description
this uses a CondVar and lets the thread sleep instead of polling every 1ms
Testing
ran poll tests
Squash or Rebase?
either
Checklist
cargo fmt.taplo format.cargo clippy --tests. If applicable, add:--target wasm32-unknown-unknowncargo xtask testto run tests.CHANGELOG.mdentry.