d3d12: Propagate errors when closing command lists (#5125)

Before this commit, command lists that we failed to close were used anyway during submit, causing device loss.
This commit is contained in:
Nicolas Silva 2024-01-23 14:30:08 +01:00 committed by GitHub
parent ac8756c2d3
commit 60a5739df2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 11 additions and 13 deletions

View File

@ -228,18 +228,18 @@ impl<A: HalApi> PendingWrites<A> {
.push(TempResource::StagingBuffer(buffer));
}
#[must_use]
fn pre_submit(&mut self) -> Option<&A::CommandBuffer> {
fn pre_submit(&mut self) -> Result<Option<&A::CommandBuffer>, DeviceError> {
self.dst_buffers.clear();
self.dst_textures.clear();
if self.is_active {
let cmd_buf = unsafe { self.command_encoder.end_encoding().unwrap() };
let cmd_buf = unsafe { self.command_encoder.end_encoding()? };
self.is_active = false;
self.executing_command_buffers.push(cmd_buf);
self.executing_command_buffers.last()
} else {
None
return Ok(self.executing_command_buffers.last());
}
Ok(None)
}
#[must_use]
@ -1463,7 +1463,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
}
let refs = pending_writes
.pre_submit()
.pre_submit()?
.into_iter()
.chain(
active_executions

View File

@ -289,14 +289,13 @@ impl crate::CommandEncoder<super::Api> for super::CommandEncoder {
}
unsafe fn end_encoding(&mut self) -> Result<super::CommandBuffer, crate::DeviceError> {
let raw = self.list.take().unwrap();
let closed = raw.close().into_result().is_ok();
Ok(super::CommandBuffer { raw, closed })
raw.close()
.into_device_result("GraphicsCommandList::close")?;
Ok(super::CommandBuffer { raw })
}
unsafe fn reset_all<I: Iterator<Item = super::CommandBuffer>>(&mut self, command_buffers: I) {
for cmd_buf in command_buffers {
if cmd_buf.closed {
self.free_lists.push(cmd_buf.raw);
}
self.free_lists.push(cmd_buf.raw);
}
self.allocator.reset();
}

View File

@ -386,7 +386,6 @@ impl fmt::Debug for CommandEncoder {
#[derive(Debug)]
pub struct CommandBuffer {
raw: d3d12::GraphicsCommandList,
closed: bool,
}
unsafe impl Send for CommandBuffer {}