mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-22 06:44:14 +00:00
use TrackerIndex
instead of IDs in PendingWrites
's fields
This commit is contained in:
parent
2e1e1cd26e
commit
1e784c9c0a
@ -519,8 +519,7 @@ impl Global {
|
|||||||
.lock()
|
.lock()
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.dst_buffers
|
.contains_buffer(&buffer)
|
||||||
.contains_key(&buffer_id)
|
|
||||||
{
|
{
|
||||||
device.lock_life().future_suspected_buffers.push(buffer);
|
device.lock_life().future_suspected_buffers.push(buffer);
|
||||||
} else {
|
} else {
|
||||||
@ -744,8 +743,7 @@ impl Global {
|
|||||||
.lock()
|
.lock()
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.dst_textures
|
.contains_texture(&texture)
|
||||||
.contains_key(&texture_id)
|
|
||||||
{
|
{
|
||||||
device
|
device
|
||||||
.lock_life()
|
.lock_life()
|
||||||
|
@ -20,7 +20,9 @@ use crate::{
|
|||||||
DestroyedTexture, ParentDevice, Resource, ResourceErrorIdent, ResourceInfo, ResourceType,
|
DestroyedTexture, ParentDevice, Resource, ResourceErrorIdent, ResourceInfo, ResourceType,
|
||||||
StagingBuffer, Texture, TextureInner,
|
StagingBuffer, Texture, TextureInner,
|
||||||
},
|
},
|
||||||
resource_log, track, FastHashMap, SubmissionIndex,
|
resource_log,
|
||||||
|
track::{self, TrackerIndex},
|
||||||
|
FastHashMap, SubmissionIndex,
|
||||||
};
|
};
|
||||||
|
|
||||||
use hal::{CommandEncoder as _, Device as _, Queue as _};
|
use hal::{CommandEncoder as _, Device as _, Queue as _};
|
||||||
@ -211,9 +213,9 @@ pub(crate) struct PendingWrites<A: HalApi> {
|
|||||||
/// [`wgpu_hal::CommandEncoder`]: hal::CommandEncoder
|
/// [`wgpu_hal::CommandEncoder`]: hal::CommandEncoder
|
||||||
pub is_recording: bool,
|
pub is_recording: bool,
|
||||||
|
|
||||||
pub temp_resources: Vec<TempResource<A>>,
|
temp_resources: Vec<TempResource<A>>,
|
||||||
pub dst_buffers: FastHashMap<id::BufferId, Arc<Buffer<A>>>,
|
dst_buffers: FastHashMap<TrackerIndex, Arc<Buffer<A>>>,
|
||||||
pub dst_textures: FastHashMap<id::TextureId, Arc<Texture<A>>>,
|
dst_textures: FastHashMap<TrackerIndex, Arc<Texture<A>>>,
|
||||||
|
|
||||||
/// All command buffers allocated from `command_encoder`.
|
/// All command buffers allocated from `command_encoder`.
|
||||||
pub executing_command_buffers: Vec<A::CommandBuffer>,
|
pub executing_command_buffers: Vec<A::CommandBuffer>,
|
||||||
@ -244,6 +246,25 @@ impl<A: HalApi> PendingWrites<A> {
|
|||||||
self.temp_resources.clear();
|
self.temp_resources.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn insert_buffer(&mut self, buffer: &Arc<Buffer<A>>) {
|
||||||
|
self.dst_buffers
|
||||||
|
.insert(buffer.info.tracker_index(), buffer.clone());
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn insert_texture(&mut self, texture: &Arc<Texture<A>>) {
|
||||||
|
self.dst_textures
|
||||||
|
.insert(texture.info.tracker_index(), texture.clone());
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn contains_buffer(&self, buffer: &Arc<Buffer<A>>) -> bool {
|
||||||
|
self.dst_buffers.contains_key(&buffer.info.tracker_index())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn contains_texture(&self, texture: &Arc<Texture<A>>) -> bool {
|
||||||
|
self.dst_textures
|
||||||
|
.contains_key(&texture.info.tracker_index())
|
||||||
|
}
|
||||||
|
|
||||||
pub fn consume_temp(&mut self, resource: TempResource<A>) {
|
pub fn consume_temp(&mut self, resource: TempResource<A>) {
|
||||||
self.temp_resources.push(resource);
|
self.temp_resources.push(resource);
|
||||||
}
|
}
|
||||||
@ -647,7 +668,7 @@ impl Global {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
pending_writes.dst_buffers.insert(buffer_id, dst.clone());
|
pending_writes.insert_buffer(&dst);
|
||||||
|
|
||||||
// Ensure the overwritten bytes are marked as initialized so
|
// Ensure the overwritten bytes are marked as initialized so
|
||||||
// they don't need to be nulled prior to mapping or binding.
|
// they don't need to be nulled prior to mapping or binding.
|
||||||
@ -916,9 +937,7 @@ impl Global {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pending_writes.consume(staging_buffer);
|
pending_writes.consume(staging_buffer);
|
||||||
pending_writes
|
pending_writes.insert_texture(&dst);
|
||||||
.dst_textures
|
|
||||||
.insert(destination.texture, dst.clone());
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -702,9 +702,7 @@ impl<A: HalApi> Buffer<A> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
pending_writes.consume_temp(queue::TempResource::Buffer(stage_buffer));
|
pending_writes.consume_temp(queue::TempResource::Buffer(stage_buffer));
|
||||||
pending_writes
|
pending_writes.insert_buffer(self);
|
||||||
.dst_buffers
|
|
||||||
.insert(self.info.id(), self.clone());
|
|
||||||
}
|
}
|
||||||
BufferMapState::Idle => {
|
BufferMapState::Idle => {
|
||||||
return Err(BufferAccessError::NotMapped);
|
return Err(BufferAccessError::NotMapped);
|
||||||
@ -775,8 +773,8 @@ impl<A: HalApi> Buffer<A> {
|
|||||||
|
|
||||||
let mut pending_writes = device.pending_writes.lock();
|
let mut pending_writes = device.pending_writes.lock();
|
||||||
let pending_writes = pending_writes.as_mut().unwrap();
|
let pending_writes = pending_writes.as_mut().unwrap();
|
||||||
if pending_writes.dst_buffers.contains_key(&self.info.id()) {
|
if pending_writes.contains_buffer(self) {
|
||||||
pending_writes.temp_resources.push(temp);
|
pending_writes.consume_temp(temp);
|
||||||
} else {
|
} else {
|
||||||
let last_submit_index = self.info.submission_index();
|
let last_submit_index = self.info.submission_index();
|
||||||
device
|
device
|
||||||
@ -1167,8 +1165,8 @@ impl<A: HalApi> Texture<A> {
|
|||||||
|
|
||||||
let mut pending_writes = device.pending_writes.lock();
|
let mut pending_writes = device.pending_writes.lock();
|
||||||
let pending_writes = pending_writes.as_mut().unwrap();
|
let pending_writes = pending_writes.as_mut().unwrap();
|
||||||
if pending_writes.dst_textures.contains_key(&self.info.id()) {
|
if pending_writes.contains_texture(self) {
|
||||||
pending_writes.temp_resources.push(temp);
|
pending_writes.consume_temp(temp);
|
||||||
} else {
|
} else {
|
||||||
let last_submit_index = self.info.submission_index();
|
let last_submit_index = self.info.submission_index();
|
||||||
device
|
device
|
||||||
|
Loading…
Reference in New Issue
Block a user