mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
[wgpu-core] Document and improve naming in PendingWrites.
This commit is contained in:
@@ -188,10 +188,17 @@ impl<A: HalApi> EncoderInFlight<A> {
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct PendingWrites<A: HalApi> {
|
||||
pub command_encoder: A::CommandEncoder,
|
||||
pub is_active: bool,
|
||||
|
||||
/// True if `command_encoder` is in the "recording" state, as
|
||||
/// described in the docs for the [`wgpu_hal::CommandEncoder`]
|
||||
/// trait.
|
||||
pub is_recording: bool,
|
||||
|
||||
pub temp_resources: Vec<TempResource<A>>,
|
||||
pub dst_buffers: FastHashMap<id::BufferId, Arc<Buffer<A>>>,
|
||||
pub dst_textures: FastHashMap<id::TextureId, Arc<Texture<A>>>,
|
||||
|
||||
/// All command buffers allocated from `command_encoder`.
|
||||
pub executing_command_buffers: Vec<A::CommandBuffer>,
|
||||
}
|
||||
|
||||
@@ -199,7 +206,7 @@ impl<A: HalApi> PendingWrites<A> {
|
||||
pub fn new(command_encoder: A::CommandEncoder) -> Self {
|
||||
Self {
|
||||
command_encoder,
|
||||
is_active: false,
|
||||
is_recording: false,
|
||||
temp_resources: Vec::new(),
|
||||
dst_buffers: FastHashMap::default(),
|
||||
dst_textures: FastHashMap::default(),
|
||||
@@ -209,7 +216,7 @@ impl<A: HalApi> PendingWrites<A> {
|
||||
|
||||
pub fn dispose(mut self, device: &A::Device) {
|
||||
unsafe {
|
||||
if self.is_active {
|
||||
if self.is_recording {
|
||||
self.command_encoder.discard_encoding();
|
||||
}
|
||||
self.command_encoder
|
||||
@@ -232,9 +239,9 @@ impl<A: HalApi> PendingWrites<A> {
|
||||
fn pre_submit(&mut self) -> Result<Option<&A::CommandBuffer>, DeviceError> {
|
||||
self.dst_buffers.clear();
|
||||
self.dst_textures.clear();
|
||||
if self.is_active {
|
||||
if self.is_recording {
|
||||
let cmd_buf = unsafe { self.command_encoder.end_encoding()? };
|
||||
self.is_active = false;
|
||||
self.is_recording = false;
|
||||
self.executing_command_buffers.push(cmd_buf);
|
||||
|
||||
return Ok(self.executing_command_buffers.last());
|
||||
@@ -262,23 +269,23 @@ impl<A: HalApi> PendingWrites<A> {
|
||||
}
|
||||
|
||||
pub fn activate(&mut self) -> &mut A::CommandEncoder {
|
||||
if !self.is_active {
|
||||
if !self.is_recording {
|
||||
unsafe {
|
||||
self.command_encoder
|
||||
.begin_encoding(Some("(wgpu internal) PendingWrites"))
|
||||
.unwrap();
|
||||
}
|
||||
self.is_active = true;
|
||||
self.is_recording = true;
|
||||
}
|
||||
&mut self.command_encoder
|
||||
}
|
||||
|
||||
pub fn deactivate(&mut self) {
|
||||
if self.is_active {
|
||||
if self.is_recording {
|
||||
unsafe {
|
||||
self.command_encoder.discard_encoding();
|
||||
}
|
||||
self.is_active = false;
|
||||
self.is_recording = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user