Debian Codegraph @

third_party/rust/wgpu-core/src/init_tracker/buffer.rs

raw
1 use super::{InitTracker, MemoryInitKind};
2 use crate::resource::Buffer;
3 use alloc::sync::Arc;
4 use core::ops::Range;
5
6 #[derive(Debug, Clone)]
7 pub(crate) struct BufferInitTrackerAction {
8 pub buffer: Arc<Buffer>,
9 pub range: Range<wgt::BufferAddress>,
10 pub kind: MemoryInitKind,
11 }
12
13 pub(crate) type BufferInitTracker = InitTracker<wgt::BufferAddress>;
14
15 impl BufferInitTracker {
16 /// Checks if an action has/requires any effect on the initialization status
17 /// and shrinks its range if possible.
18 pub(crate) fn check_action(
19 &self,
20 action: &BufferInitTrackerAction,
21 ) -> Option<BufferInitTrackerAction> {
22 self.create_action(&action.buffer, action.range.clone(), action.kind)
23 }
24
25 /// Creates an action if it would have any effect on the initialization
26 /// status and shrinks the range if possible.
27 pub(crate) fn create_action(
28 &self,
29 buffer: &Arc<Buffer>,
30 query_range: Range<wgt::BufferAddress>,
31 kind: MemoryInitKind,
32 ) -> Option<BufferInitTrackerAction> {
33 self.check(query_range)
34 .map(|range| BufferInitTrackerAction {
35 buffer: buffer.clone(),
36 range,
37 kind,
38 })
39 }
40 }