mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-24 00:11:11 +01:00
fix(hal): Clear query state on reused encoders
(cherry picked from commit 8042314262)
This commit is contained in:
1 parent
1ff557ddf6
commit
5815bbe7cb
6 files changed
+20
-2
No files matched your search
@@ -419,9 +419,12 @@ impl crate::CommandEncoder for super::CommandEncoder {
|
||||
list.set_name(label)?;
|
||||
}
|
||||
|
||||
self.list = Some(list);
|
||||
// Ensure clean state even if the last encoding did not complete normally.
|
||||
self.temp.clear();
|
||||
self.pass.clear();
|
||||
self.end_of_pass_timer_query = None;
|
||||
|
||||
self.list = Some(list);
|
||||
Ok(())
|
||||
}
|
||||
unsafe fn discard_encoding(&mut self) {
|
||||
|
||||
@@ -964,6 +964,8 @@ impl PassState {
|
||||
}
|
||||
}
|
||||
|
||||
// Any state in this struct that may be dirty after an abandoned encoding must
|
||||
// be reset for reused encoders in `begin_encoding`.
|
||||
pub struct CommandEncoder {
|
||||
allocator: Direct3D12::ID3D12CommandAllocator,
|
||||
device: Direct3D12::ID3D12Device,
|
||||
|
||||
@@ -490,6 +490,11 @@ impl crate::CommandEncoder for super::CommandEncoder {
|
||||
cmd_buf_ref.to_owned()
|
||||
});
|
||||
|
||||
// Queries should either be closed out, or cleared in `discard_encoding`.
|
||||
// This assertion is here mainly to facilitate comparison with the other
|
||||
// backends, which clear in `begin_encoding` rather than `discard_encoding`.
|
||||
debug_assert!(self.state.pending_timer_queries.is_empty());
|
||||
|
||||
self.raw_cmd_buf = Some(raw);
|
||||
|
||||
Ok(())
|
||||
@@ -506,6 +511,7 @@ impl crate::CommandEncoder for super::CommandEncoder {
|
||||
if let Some(encoder) = self.state.compute.take() {
|
||||
encoder.endEncoding();
|
||||
}
|
||||
self.state.pending_timer_queries.clear();
|
||||
let had_command_buffer = self.raw_cmd_buf.is_some();
|
||||
// Clear the Option first so the underlying `metal::CommandBuffer` is
|
||||
// dropped before we update the counter.
|
||||
|
||||
@@ -1080,6 +1080,8 @@ struct Temp {
|
||||
binding_sizes: Vec<u32>,
|
||||
}
|
||||
|
||||
// Any state in this struct that may be dirty after an abandoned encoding must
|
||||
// be reset in `discard_encoding` for possible encoder reuse.
|
||||
struct CommandState {
|
||||
blit: Option<Retained<ProtocolObject<dyn MTLBlitCommandEncoder>>>,
|
||||
acceleration_structure_builder:
|
||||
@@ -1119,6 +1121,8 @@ struct CommandState {
|
||||
pending_timer_queries: Vec<(QuerySet, u32)>,
|
||||
}
|
||||
|
||||
// Any state in this struct that may be dirty after an abandoned encoding must
|
||||
// be reset in `discard_encoding` for possible encoder reuse.
|
||||
pub struct CommandEncoder {
|
||||
shared: Arc<AdapterShared>,
|
||||
queue_shared: Arc<QueueShared>,
|
||||
|
||||
@@ -138,8 +138,9 @@ impl crate::CommandEncoder for super::CommandEncoder {
|
||||
// previous name assigned to this.
|
||||
unsafe { self.device.set_object_name(raw, label.unwrap_or_default()) };
|
||||
|
||||
// Reset this in case the last renderpass was never ended.
|
||||
// Reset some state in case the last renderpass was never ended.
|
||||
self.rpass_debug_marker_active = false;
|
||||
self.end_of_pass_timer_query = None;
|
||||
|
||||
let vk_info = vk::CommandBufferBeginInfo::default()
|
||||
.flags(vk::CommandBufferUsageFlags::ONE_TIME_SUBMIT);
|
||||
|
||||
@@ -984,6 +984,8 @@ struct TempTextureViewKey {
|
||||
depth_slice: u32,
|
||||
}
|
||||
|
||||
// Any state in this struct that may be dirty after an abandoned encoding must
|
||||
// be reset for reused encoders in `begin_encoding`.
|
||||
pub struct CommandEncoder {
|
||||
raw: vk::CommandPool,
|
||||
device: Arc<DeviceShared>,
|
||||
|
||||
Reference in new issue
Block a user