mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-22 06:44:14 +00:00
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:
parent
ac8756c2d3
commit
60a5739df2
@ -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
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -386,7 +386,6 @@ impl fmt::Debug for CommandEncoder {
|
||||
#[derive(Debug)]
|
||||
pub struct CommandBuffer {
|
||||
raw: d3d12::GraphicsCommandList,
|
||||
closed: bool,
|
||||
}
|
||||
|
||||
unsafe impl Send for CommandBuffer {}
|
||||
|
Loading…
Reference in New Issue
Block a user