mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-21 22:33:49 +00:00
use Storage.get_owned
in cases where we used to later clone the resource anyway
This commit is contained in:
parent
249c8023ff
commit
9308e15048
@ -710,14 +710,14 @@ fn set_index_buffer<A: HalApi>(
|
||||
size: Option<std::num::NonZeroU64>,
|
||||
) -> Result<(), RenderBundleErrorInner> {
|
||||
let buffer = buffer_guard
|
||||
.get(buffer_id)
|
||||
.get_owned(buffer_id)
|
||||
.map_err(|_| RenderCommandError::InvalidBufferId(buffer_id))?;
|
||||
|
||||
state
|
||||
.trackers
|
||||
.buffers
|
||||
.write()
|
||||
.merge_single(buffer, hal::BufferUses::INDEX)?;
|
||||
.merge_single(&buffer, hal::BufferUses::INDEX)?;
|
||||
|
||||
buffer.same_device(&state.device)?;
|
||||
buffer.check_usage(wgt::BufferUsages::INDEX)?;
|
||||
@ -729,11 +729,11 @@ fn set_index_buffer<A: HalApi>(
|
||||
state
|
||||
.buffer_memory_init_actions
|
||||
.extend(buffer.initialization_status.read().create_action(
|
||||
buffer,
|
||||
&buffer,
|
||||
offset..end,
|
||||
MemoryInitKind::NeedsInitializedMemory,
|
||||
));
|
||||
state.set_index_buffer(buffer.clone(), index_format, offset..end);
|
||||
state.set_index_buffer(buffer, index_format, offset..end);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -755,14 +755,14 @@ fn set_vertex_buffer<A: HalApi>(
|
||||
}
|
||||
|
||||
let buffer = buffer_guard
|
||||
.get(buffer_id)
|
||||
.get_owned(buffer_id)
|
||||
.map_err(|_| RenderCommandError::InvalidBufferId(buffer_id))?;
|
||||
|
||||
state
|
||||
.trackers
|
||||
.buffers
|
||||
.write()
|
||||
.merge_single(buffer, hal::BufferUses::VERTEX)?;
|
||||
.merge_single(&buffer, hal::BufferUses::VERTEX)?;
|
||||
|
||||
buffer.same_device(&state.device)?;
|
||||
buffer.check_usage(wgt::BufferUsages::VERTEX)?;
|
||||
@ -774,11 +774,11 @@ fn set_vertex_buffer<A: HalApi>(
|
||||
state
|
||||
.buffer_memory_init_actions
|
||||
.extend(buffer.initialization_status.read().create_action(
|
||||
buffer,
|
||||
&buffer,
|
||||
offset..end,
|
||||
MemoryInitKind::NeedsInitializedMemory,
|
||||
));
|
||||
state.vertex[slot as usize] = Some(VertexState::new(buffer.clone(), offset..end));
|
||||
state.vertex[slot as usize] = Some(VertexState::new(buffer, offset..end));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -897,14 +897,14 @@ fn multi_draw_indirect<A: HalApi>(
|
||||
let used_bind_groups = pipeline.used_bind_groups;
|
||||
|
||||
let buffer = buffer_guard
|
||||
.get(buffer_id)
|
||||
.get_owned(buffer_id)
|
||||
.map_err(|_| RenderCommandError::InvalidBufferId(buffer_id))?;
|
||||
|
||||
state
|
||||
.trackers
|
||||
.buffers
|
||||
.write()
|
||||
.merge_single(buffer, hal::BufferUses::INDIRECT)?;
|
||||
.merge_single(&buffer, hal::BufferUses::INDIRECT)?;
|
||||
|
||||
buffer.same_device(&state.device)?;
|
||||
buffer.check_usage(wgt::BufferUsages::INDIRECT)?;
|
||||
@ -912,7 +912,7 @@ fn multi_draw_indirect<A: HalApi>(
|
||||
state
|
||||
.buffer_memory_init_actions
|
||||
.extend(buffer.initialization_status.read().create_action(
|
||||
buffer,
|
||||
&buffer,
|
||||
offset..(offset + mem::size_of::<wgt::DrawIndirectArgs>() as u64),
|
||||
MemoryInitKind::NeedsInitializedMemory,
|
||||
));
|
||||
@ -928,7 +928,7 @@ fn multi_draw_indirect<A: HalApi>(
|
||||
state.flush_vertices();
|
||||
state.flush_binds(used_bind_groups, dynamic_offsets);
|
||||
state.commands.push(ArcRenderCommand::MultiDrawIndirect {
|
||||
buffer: buffer.clone(),
|
||||
buffer,
|
||||
offset,
|
||||
count: None,
|
||||
indexed,
|
||||
|
@ -430,17 +430,17 @@ impl<A: HalApi> CommandBuffer<A> {
|
||||
id: id::CommandEncoderId,
|
||||
lock_on_acquire: bool,
|
||||
) -> Result<Arc<Self>, CommandEncoderError> {
|
||||
let storage = hub.command_buffers.read();
|
||||
match storage.get(id.into_command_buffer_id()) {
|
||||
match hub.command_buffers.get(id.into_command_buffer_id()) {
|
||||
Ok(cmd_buf) => {
|
||||
let mut cmd_buf_data = cmd_buf.data.lock();
|
||||
let cmd_buf_data = cmd_buf_data.as_mut().unwrap();
|
||||
let mut cmd_buf_data_guard = cmd_buf.data.lock();
|
||||
let cmd_buf_data = cmd_buf_data_guard.as_mut().unwrap();
|
||||
match cmd_buf_data.status {
|
||||
CommandEncoderStatus::Recording => {
|
||||
if lock_on_acquire {
|
||||
cmd_buf_data.status = CommandEncoderStatus::Locked;
|
||||
}
|
||||
Ok(cmd_buf.clone())
|
||||
drop(cmd_buf_data_guard);
|
||||
Ok(cmd_buf)
|
||||
}
|
||||
CommandEncoderStatus::Locked => {
|
||||
// Any operation on a locked encoder is required to put it into the invalid/error state.
|
||||
|
@ -2113,9 +2113,8 @@ impl Global {
|
||||
{
|
||||
let hub = A::hub(self);
|
||||
let surface_guard = self.surfaces.read();
|
||||
let device_guard = hub.devices.read();
|
||||
|
||||
let device = match device_guard.get(device_id) {
|
||||
let device = match hub.devices.get(device_id) {
|
||||
Ok(device) => device,
|
||||
Err(_) => break 'error DeviceError::InvalidDeviceId.into(),
|
||||
};
|
||||
@ -2241,7 +2240,7 @@ impl Global {
|
||||
|
||||
let mut presentation = surface.presentation.lock();
|
||||
*presentation = Some(present::Presentation {
|
||||
device: super::any_device::AnyDevice::new(device.clone()),
|
||||
device: super::any_device::AnyDevice::new(device),
|
||||
config: config.clone(),
|
||||
acquired_texture: None,
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user