-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[wgpu-core] split command encoders from command buffers #7979
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
base: trunk
Are you sure you want to change the base?
Conversation
043df3d
to
4faa0c5
Compare
4faa0c5
to
37f00f9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, thank you for taking care of this.
I left some minor comments but nothing that I see as blocking. I pushed a branch with all of my CommandEncoderStatus::Consumed
changes here.
command_buffer_id_manager: &mut wgc::identity::IdentityManager< | ||
wgc::id::markers::CommandBuffer, | ||
>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: since the type names are kind of unwieldy and are repeated a few times, maybe it's worth importing the components or defining type aliases for the two identity manager types?
Self::Error(CommandEncoderError::State(EncoderStateError::Ended)) => { | ||
Err(EncoderStateError::Ended) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make sense to add a new CommandEncoderStatus::Consumed
for the status of an encoder that has been finished? (vs. Finished
, which after this change is the CommandEncoderStatus
of a valid command buffer). Distinguishing it as a separate state makes it easier to distinguish "there's a bug in wgpu, I didn't expect to find this state here" from an application doing something illegal that results in objects being invalid.
st @ Self::Error(CommandEncoderError::State(EncoderStateError::Ended)) => { | ||
*self = st; | ||
Err(EncoderStateError::Ended) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is actually a comment about CommandEncoderStatus::finish
, below. We could change the API to reflect that the operation is no longer a mutation of the common state of encoders/buffers, but is more like an update to the state of a command encoder that also returns some information that will be given to the new command buffer. (Eventually, we could even split the buffer states out of CommandEncoderStatus
into CommandBufferStatus
, but that's a bigger refactoring that is probably better not to combine with this PR.)
Maybe something like:
fn finish(&mut self) -> Self {
// Replace our state with `Consumed`, and return either the inner
// state or an error, to be transferred to the command buffer.
match mem::replace(self, Self::Consumed) {
Self::Recording(mut inner) => {
if let Err(err) = inner.encoder.close_if_open() {
Self::Error(err.into())
} else {
// Note: if we want to stop tracking the swapchain texture view,
// this is the place to do it.
Self::Finished(inner)
}
}
Self::Consumed | Self::Finished(_) => Self::Error(EncoderStateError::Ended.into()),
Self::Locked(_) => Self::Error(EncoderStateError::Locked.into()),
st @ Self::Error(_) => st,
Self::Transitioning => unreachable!(),
}
}
Fixes #7812 and partially Bug 1972949.