Files
wgpu/wgpu-core/src/init_tracker/buffer.rs
T
Kevin Reid 7bcbfe0712 wgpu-core: Adjust imports to allow no_std.
Dependencies on `std` that still exist:
* Locks
* `std::error::Error` (waiting for Rust 1.81)
* `std::os::raw::c_char` for FFI
* `thread_local` and `Backtrace` in `snatch`
2025-02-21 08:47:16 +01:00

41 lines
1.2 KiB
Rust

use super::{InitTracker, MemoryInitKind};
use crate::resource::Buffer;
use alloc::sync::Arc;
use core::ops::Range;
#[derive(Debug, Clone)]
pub(crate) struct BufferInitTrackerAction {
pub buffer: Arc<Buffer>,
pub range: Range<wgt::BufferAddress>,
pub kind: MemoryInitKind,
}
pub(crate) type BufferInitTracker = InitTracker<wgt::BufferAddress>;
impl BufferInitTracker {
/// Checks if an action has/requires any effect on the initialization status
/// and shrinks its range if possible.
pub(crate) fn check_action(
&self,
action: &BufferInitTrackerAction,
) -> Option<BufferInitTrackerAction> {
self.create_action(&action.buffer, action.range.clone(), action.kind)
}
/// Creates an action if it would have any effect on the initialization
/// status and shrinks the range if possible.
pub(crate) fn create_action(
&self,
buffer: &Arc<Buffer>,
query_range: Range<wgt::BufferAddress>,
kind: MemoryInitKind,
) -> Option<BufferInitTrackerAction> {
self.check(query_range)
.map(|range| BufferInitTrackerAction {
buffer: buffer.clone(),
range,
kind,
})
}
}