[wgpu-core] rename .strict_get() to .get()

This commit is contained in:
teoxoy 2024-09-07 02:21:50 +02:00 committed by Teodor Tanasoaia
parent 31edbfd0dc
commit ac74f36590
16 changed files with 391 additions and 431 deletions

View File

@ -594,7 +594,7 @@ fn set_bind_group(
let bind_group_id = bind_group_id.unwrap();
let bind_group = bind_group_guard.strict_get(bind_group_id).get()?;
let bind_group = bind_group_guard.get(bind_group_id).get()?;
bind_group.same_device(&state.device)?;
@ -637,7 +637,7 @@ fn set_pipeline(
is_stencil_read_only: bool,
pipeline_id: id::Id<id::markers::RenderPipeline>,
) -> Result<(), RenderBundleErrorInner> {
let pipeline = pipeline_guard.strict_get(pipeline_id).get()?;
let pipeline = pipeline_guard.get(pipeline_id).get()?;
pipeline.same_device(&state.device)?;
@ -678,7 +678,7 @@ fn set_index_buffer(
offset: u64,
size: Option<std::num::NonZeroU64>,
) -> Result<(), RenderBundleErrorInner> {
let buffer = buffer_guard.strict_get(buffer_id).get()?;
let buffer = buffer_guard.get(buffer_id).get()?;
state
.trackers
@ -720,7 +720,7 @@ fn set_vertex_buffer(
.into());
}
let buffer = buffer_guard.strict_get(buffer_id).get()?;
let buffer = buffer_guard.get(buffer_id).get()?;
state
.trackers
@ -859,7 +859,7 @@ fn multi_draw_indirect(
let pipeline = state.pipeline()?;
let used_bind_groups = pipeline.used_bind_groups;
let buffer = buffer_guard.strict_get(buffer_id).get()?;
let buffer = buffer_guard.get(buffer_id).get()?;
state
.trackers

View File

@ -90,7 +90,7 @@ impl Global {
let cmd_buf = hub
.command_buffers
.strict_get(command_encoder_id.into_command_buffer_id());
.get(command_encoder_id.into_command_buffer_id());
let mut cmd_buf_data = cmd_buf.try_get()?;
cmd_buf_data.check_recording()?;
@ -99,7 +99,7 @@ impl Global {
list.push(TraceCommand::ClearBuffer { dst, offset, size });
}
let dst_buffer = hub.buffers.strict_get(dst).get()?;
let dst_buffer = hub.buffers.get(dst).get()?;
dst_buffer.same_device_as(cmd_buf.as_ref())?;
@ -173,7 +173,7 @@ impl Global {
let cmd_buf = hub
.command_buffers
.strict_get(command_encoder_id.into_command_buffer_id());
.get(command_encoder_id.into_command_buffer_id());
let mut cmd_buf_data = cmd_buf.try_get()?;
cmd_buf_data.check_recording()?;
@ -189,7 +189,7 @@ impl Global {
return Err(ClearError::MissingClearTextureFeature);
}
let dst_texture = hub.textures.strict_get(dst).get()?;
let dst_texture = hub.textures.get(dst).get()?;
dst_texture.same_device_as(cmd_buf.as_ref())?;

View File

@ -292,9 +292,7 @@ impl Global {
let make_err = |e, arc_desc| (ComputePass::new(None, arc_desc), Some(e));
let cmd_buf = hub
.command_buffers
.strict_get(encoder_id.into_command_buffer_id());
let cmd_buf = hub.command_buffers.get(encoder_id.into_command_buffer_id());
match cmd_buf
.try_get()
@ -306,7 +304,7 @@ impl Global {
};
arc_desc.timestamp_writes = if let Some(tw) = desc.timestamp_writes {
let query_set = match hub.query_sets.strict_get(tw.query_set).get() {
let query_set = match hub.query_sets.get(tw.query_set).get() {
Ok(query_set) => query_set,
Err(e) => return make_err(e.into(), arc_desc),
};
@ -340,7 +338,7 @@ impl Global {
let cmd_buf = self
.hub
.command_buffers
.strict_get(encoder_id.into_command_buffer_id());
.get(encoder_id.into_command_buffer_id());
let mut cmd_buf_data = cmd_buf.try_get().map_pass_err(pass_scope)?;
if let Some(ref mut list) = cmd_buf_data.commands {
@ -975,7 +973,7 @@ impl Global {
let hub = &self.hub;
let bg = hub
.bind_groups
.strict_get(bind_group_id)
.get(bind_group_id)
.get()
.map_pass_err(scope)?;
bind_group = Some(bg);
@ -1008,7 +1006,7 @@ impl Global {
let hub = &self.hub;
let pipeline = hub
.compute_pipelines
.strict_get(pipeline_id)
.get(pipeline_id)
.get()
.map_pass_err(scope)?;
@ -1080,11 +1078,7 @@ impl Global {
let scope = PassErrorScope::Dispatch { indirect: true };
let base = pass.base_mut(scope)?;
let buffer = hub
.buffers
.strict_get(buffer_id)
.get()
.map_pass_err(scope)?;
let buffer = hub.buffers.get(buffer_id).get().map_pass_err(scope)?;
base.commands
.push(ArcComputeCommand::DispatchIndirect { buffer, offset });
@ -1151,11 +1145,7 @@ impl Global {
let base = pass.base_mut(scope)?;
let hub = &self.hub;
let query_set = hub
.query_sets
.strict_get(query_set_id)
.get()
.map_pass_err(scope)?;
let query_set = hub.query_sets.get(query_set_id).get().map_pass_err(scope)?;
base.commands.push(ArcComputeCommand::WriteTimestamp {
query_set,
@ -1175,11 +1165,7 @@ impl Global {
let base = pass.base_mut(scope)?;
let hub = &self.hub;
let query_set = hub
.query_sets
.strict_get(query_set_id)
.get()
.map_pass_err(scope)?;
let query_set = hub.query_sets.get(query_set_id).get().map_pass_err(scope)?;
base.commands
.push(ArcComputeCommand::BeginPipelineStatisticsQuery {

View File

@ -99,13 +99,12 @@ impl ComputeCommand {
}
let bind_group_id = bind_group_id.unwrap();
let bg = bind_group_guard
.strict_get(bind_group_id)
.get()
.map_err(|e| ComputePassError {
let bg = bind_group_guard.get(bind_group_id).get().map_err(|e| {
ComputePassError {
scope: PassErrorScope::SetBindGroup,
inner: e.into(),
})?;
}
})?;
ArcComputeCommand::SetBindGroup {
index,
@ -114,12 +113,13 @@ impl ComputeCommand {
}
}
ComputeCommand::SetPipeline(pipeline_id) => ArcComputeCommand::SetPipeline(
pipelines_guard.strict_get(pipeline_id).get().map_err(|e| {
ComputePassError {
pipelines_guard
.get(pipeline_id)
.get()
.map_err(|e| ComputePassError {
scope: PassErrorScope::SetPipelineCompute,
inner: e.into(),
}
})?,
})?,
),
ComputeCommand::SetPushConstant {
@ -136,7 +136,7 @@ impl ComputeCommand {
ComputeCommand::DispatchIndirect { buffer_id, offset } => {
ArcComputeCommand::DispatchIndirect {
buffer: buffers_guard.strict_get(buffer_id).get().map_err(|e| {
buffer: buffers_guard.get(buffer_id).get().map_err(|e| {
ComputePassError {
scope: PassErrorScope::Dispatch { indirect: true },
inner: e.into(),
@ -160,13 +160,12 @@ impl ComputeCommand {
query_set_id,
query_index,
} => ArcComputeCommand::WriteTimestamp {
query_set: query_set_guard
.strict_get(query_set_id)
.get()
.map_err(|e| ComputePassError {
query_set: query_set_guard.get(query_set_id).get().map_err(|e| {
ComputePassError {
scope: PassErrorScope::WriteTimestamp,
inner: e.into(),
})?,
}
})?,
query_index,
},
@ -174,13 +173,12 @@ impl ComputeCommand {
query_set_id,
query_index,
} => ArcComputeCommand::BeginPipelineStatisticsQuery {
query_set: query_set_guard
.strict_get(query_set_id)
.get()
.map_err(|e| ComputePassError {
query_set: query_set_guard.get(query_set_id).get().map_err(|e| {
ComputePassError {
scope: PassErrorScope::BeginPipelineStatisticsQuery,
inner: e.into(),
})?,
}
})?,
query_index,
},

View File

@ -654,9 +654,7 @@ impl Global {
let hub = &self.hub;
let cmd_buf = hub
.command_buffers
.strict_get(encoder_id.into_command_buffer_id());
let cmd_buf = hub.command_buffers.get(encoder_id.into_command_buffer_id());
let error = match cmd_buf
.try_get()
@ -680,9 +678,7 @@ impl Global {
let hub = &self.hub;
let cmd_buf = hub
.command_buffers
.strict_get(encoder_id.into_command_buffer_id());
let cmd_buf = hub.command_buffers.get(encoder_id.into_command_buffer_id());
let mut cmd_buf_data = cmd_buf.try_get()?;
cmd_buf_data.check_recording()?;
@ -714,9 +710,7 @@ impl Global {
let hub = &self.hub;
let cmd_buf = hub
.command_buffers
.strict_get(encoder_id.into_command_buffer_id());
let cmd_buf = hub.command_buffers.get(encoder_id.into_command_buffer_id());
let mut cmd_buf_data = cmd_buf.try_get()?;
cmd_buf_data.check_recording()?;
@ -747,9 +741,7 @@ impl Global {
let hub = &self.hub;
let cmd_buf = hub
.command_buffers
.strict_get(encoder_id.into_command_buffer_id());
let cmd_buf = hub.command_buffers.get(encoder_id.into_command_buffer_id());
let mut cmd_buf_data = cmd_buf.try_get()?;
cmd_buf_data.check_recording()?;

View File

@ -320,7 +320,7 @@ impl Global {
let cmd_buf = hub
.command_buffers
.strict_get(command_encoder_id.into_command_buffer_id());
.get(command_encoder_id.into_command_buffer_id());
let mut cmd_buf_data = cmd_buf.try_get()?;
cmd_buf_data.check_recording()?;
@ -338,7 +338,7 @@ impl Global {
let raw_encoder = cmd_buf_data.encoder.open(&cmd_buf.device)?;
let query_set = hub.query_sets.strict_get(query_set_id).get()?;
let query_set = hub.query_sets.get(query_set_id).get()?;
query_set.validate_and_write_timestamp(raw_encoder, query_index, None)?;
@ -360,7 +360,7 @@ impl Global {
let cmd_buf = hub
.command_buffers
.strict_get(command_encoder_id.into_command_buffer_id());
.get(command_encoder_id.into_command_buffer_id());
let mut cmd_buf_data = cmd_buf.try_get()?;
cmd_buf_data.check_recording()?;
@ -379,11 +379,11 @@ impl Global {
return Err(QueryError::Resolve(ResolveError::BufferOffsetAlignment));
}
let query_set = hub.query_sets.strict_get(query_set_id).get()?;
let query_set = hub.query_sets.get(query_set_id).get()?;
query_set.same_device_as(cmd_buf.as_ref())?;
let dst_buffer = hub.buffers.strict_get(destination).get()?;
let dst_buffer = hub.buffers.get(destination).get()?;
dst_buffer.same_device_as(cmd_buf.as_ref())?;

View File

@ -1355,10 +1355,10 @@ impl Global {
channel,
}) = color_attachment
{
let view = texture_views.strict_get(*view_id).get()?;
let view = texture_views.get(*view_id).get()?;
let resolve_target = if let Some(resolve_target_id) = resolve_target {
let rt_arc = texture_views.strict_get(*resolve_target_id).get()?;
let rt_arc = texture_views.get(*resolve_target_id).get()?;
Some(rt_arc)
} else {
@ -1379,9 +1379,7 @@ impl Global {
arc_desc.depth_stencil_attachment =
if let Some(depth_stencil_attachment) = desc.depth_stencil_attachment {
let view = texture_views
.strict_get(depth_stencil_attachment.view)
.get()?;
let view = texture_views.get(depth_stencil_attachment.view).get()?;
Some(ArcRenderPassDepthStencilAttachment {
view,
@ -1393,7 +1391,7 @@ impl Global {
};
arc_desc.timestamp_writes = if let Some(tw) = desc.timestamp_writes {
let query_set = query_sets.strict_get(tw.query_set).get()?;
let query_set = query_sets.get(tw.query_set).get()?;
Some(ArcPassTimestampWrites {
query_set,
@ -1406,7 +1404,7 @@ impl Global {
arc_desc.occlusion_query_set =
if let Some(occlusion_query_set) = desc.occlusion_query_set {
let query_set = query_sets.strict_get(occlusion_query_set).get()?;
let query_set = query_sets.get(occlusion_query_set).get()?;
Some(query_set)
} else {
@ -1427,9 +1425,7 @@ impl Global {
let make_err = |e, arc_desc| (RenderPass::new(None, arc_desc), Some(e));
let cmd_buf = hub
.command_buffers
.strict_get(encoder_id.into_command_buffer_id());
let cmd_buf = hub.command_buffers.get(encoder_id.into_command_buffer_id());
match cmd_buf
.try_get()
@ -1465,7 +1461,7 @@ impl Global {
let cmd_buf = self
.hub
.command_buffers
.strict_get(encoder_id.into_command_buffer_id());
.get(encoder_id.into_command_buffer_id());
let mut cmd_buf_data = cmd_buf.try_get().map_pass_err(pass_scope)?;
if let Some(ref mut list) = cmd_buf_data.commands {
@ -2746,11 +2742,7 @@ impl Global {
buffer_id: id::Id<id::markers::Buffer>,
) -> Result<Arc<crate::resource::Buffer>, RenderPassError> {
let hub = &self.hub;
let buffer = hub
.buffers
.strict_get(buffer_id)
.get()
.map_pass_err(scope)?;
let buffer = hub.buffers.get(buffer_id).get().map_pass_err(scope)?;
Ok(buffer)
}
@ -2761,11 +2753,7 @@ impl Global {
query_set_id: id::Id<id::markers::QuerySet>,
) -> Result<Arc<QuerySet>, RenderPassError> {
let hub = &self.hub;
let query_set = hub
.query_sets
.strict_get(query_set_id)
.get()
.map_pass_err(scope)?;
let query_set = hub.query_sets.get(query_set_id).get().map_pass_err(scope)?;
Ok(query_set)
}
@ -2801,7 +2789,7 @@ impl Global {
let hub = &self.hub;
let bg = hub
.bind_groups
.strict_get(bind_group_id)
.get(bind_group_id)
.get()
.map_pass_err(scope)?;
bind_group = Some(bg);
@ -2834,7 +2822,7 @@ impl Global {
let hub = &self.hub;
let pipeline = hub
.render_pipelines
.strict_get(pipeline_id)
.get(pipeline_id)
.get()
.map_pass_err(scope)?;
@ -3322,7 +3310,7 @@ impl Global {
let bundles = hub.render_bundles.read();
for &bundle_id in render_bundle_ids {
let bundle = bundles.strict_get(bundle_id).get().map_pass_err(scope)?;
let bundle = bundles.get(bundle_id).get().map_pass_err(scope)?;
base.commands.push(ArcRenderCommand::ExecuteBundle(bundle));
}

View File

@ -137,255 +137,253 @@ impl RenderCommand {
let pipelines_guard = hub.render_pipelines.read();
let render_bundles_guard = hub.render_bundles.read();
let resolved_commands: Vec<ArcRenderCommand> = commands
.iter()
.map(|c| -> Result<ArcRenderCommand, RenderPassError> {
Ok(match *c {
RenderCommand::SetBindGroup {
index,
num_dynamic_offsets,
bind_group_id,
} => {
if bind_group_id.is_none() {
return Ok(ArcRenderCommand::SetBindGroup {
index,
num_dynamic_offsets,
bind_group: None,
});
}
let bind_group_id = bind_group_id.unwrap();
let bg = bind_group_guard
.strict_get(bind_group_id)
.get()
.map_err(|e| RenderPassError {
scope: PassErrorScope::SetBindGroup,
inner: e.into(),
})?;
ArcRenderCommand::SetBindGroup {
let resolved_commands: Vec<ArcRenderCommand> =
commands
.iter()
.map(|c| -> Result<ArcRenderCommand, RenderPassError> {
Ok(match *c {
RenderCommand::SetBindGroup {
index,
num_dynamic_offsets,
bind_group: Some(bg),
}
}
RenderCommand::SetPipeline(pipeline_id) => ArcRenderCommand::SetPipeline(
pipelines_guard.strict_get(pipeline_id).get().map_err(|e| {
RenderPassError {
scope: PassErrorScope::SetPipelineRender,
inner: e.into(),
bind_group_id,
} => {
if bind_group_id.is_none() {
return Ok(ArcRenderCommand::SetBindGroup {
index,
num_dynamic_offsets,
bind_group: None,
});
}
})?,
),
RenderCommand::SetPushConstant {
offset,
size_bytes,
values_offset,
stages,
} => ArcRenderCommand::SetPushConstant {
offset,
size_bytes,
values_offset,
stages,
},
RenderCommand::PushDebugGroup { color, len } => {
ArcRenderCommand::PushDebugGroup { color, len }
}
RenderCommand::PopDebugGroup => ArcRenderCommand::PopDebugGroup,
RenderCommand::InsertDebugMarker { color, len } => {
ArcRenderCommand::InsertDebugMarker { color, len }
}
RenderCommand::WriteTimestamp {
query_set_id,
query_index,
} => ArcRenderCommand::WriteTimestamp {
query_set: query_set_guard
.strict_get(query_set_id)
.get()
.map_err(|e| RenderPassError {
scope: PassErrorScope::WriteTimestamp,
inner: e.into(),
})?,
query_index,
},
RenderCommand::BeginPipelineStatisticsQuery {
query_set_id,
query_index,
} => ArcRenderCommand::BeginPipelineStatisticsQuery {
query_set: query_set_guard
.strict_get(query_set_id)
.get()
.map_err(|e| RenderPassError {
scope: PassErrorScope::BeginPipelineStatisticsQuery,
inner: e.into(),
})?,
query_index,
},
RenderCommand::EndPipelineStatisticsQuery => {
ArcRenderCommand::EndPipelineStatisticsQuery
}
RenderCommand::SetIndexBuffer {
buffer_id,
index_format,
offset,
size,
} => ArcRenderCommand::SetIndexBuffer {
buffer: buffers_guard.strict_get(buffer_id).get().map_err(|e| {
RenderPassError {
scope: PassErrorScope::SetIndexBuffer,
inner: e.into(),
}
})?,
index_format,
offset,
size,
},
RenderCommand::SetVertexBuffer {
slot,
buffer_id,
offset,
size,
} => ArcRenderCommand::SetVertexBuffer {
slot,
buffer: buffers_guard.strict_get(buffer_id).get().map_err(|e| {
RenderPassError {
scope: PassErrorScope::SetVertexBuffer,
inner: e.into(),
}
})?,
offset,
size,
},
RenderCommand::SetBlendConstant(color) => {
ArcRenderCommand::SetBlendConstant(color)
}
RenderCommand::SetStencilReference(reference) => {
ArcRenderCommand::SetStencilReference(reference)
}
RenderCommand::SetViewport {
rect,
depth_min,
depth_max,
} => ArcRenderCommand::SetViewport {
rect,
depth_min,
depth_max,
},
RenderCommand::SetScissor(scissor) => ArcRenderCommand::SetScissor(scissor),
RenderCommand::Draw {
vertex_count,
instance_count,
first_vertex,
first_instance,
} => ArcRenderCommand::Draw {
vertex_count,
instance_count,
first_vertex,
first_instance,
},
RenderCommand::DrawIndexed {
index_count,
instance_count,
first_index,
base_vertex,
first_instance,
} => ArcRenderCommand::DrawIndexed {
index_count,
instance_count,
first_index,
base_vertex,
first_instance,
},
RenderCommand::MultiDrawIndirect {
buffer_id,
offset,
count,
indexed,
} => ArcRenderCommand::MultiDrawIndirect {
buffer: buffers_guard.strict_get(buffer_id).get().map_err(|e| {
RenderPassError {
scope: PassErrorScope::Draw {
kind: if count.is_some() {
DrawKind::MultiDrawIndirect
} else {
DrawKind::DrawIndirect
},
indexed,
},
inner: e.into(),
}
})?,
offset,
count,
indexed,
},
RenderCommand::MultiDrawIndirectCount {
buffer_id,
offset,
count_buffer_id,
count_buffer_offset,
max_count,
indexed,
} => {
let scope = PassErrorScope::Draw {
kind: DrawKind::MultiDrawIndirectCount,
indexed,
};
ArcRenderCommand::MultiDrawIndirectCount {
buffer: buffers_guard.strict_get(buffer_id).get().map_err(|e| {
let bind_group_id = bind_group_id.unwrap();
let bg = bind_group_guard.get(bind_group_id).get().map_err(|e| {
RenderPassError {
scope,
scope: PassErrorScope::SetBindGroup,
inner: e.into(),
}
})?;
ArcRenderCommand::SetBindGroup {
index,
num_dynamic_offsets,
bind_group: Some(bg),
}
}
RenderCommand::SetPipeline(pipeline_id) => ArcRenderCommand::SetPipeline(
pipelines_guard.get(pipeline_id).get().map_err(|e| {
RenderPassError {
scope: PassErrorScope::SetPipelineRender,
inner: e.into(),
}
})?,
),
RenderCommand::SetPushConstant {
offset,
size_bytes,
values_offset,
stages,
} => ArcRenderCommand::SetPushConstant {
offset,
size_bytes,
values_offset,
stages,
},
RenderCommand::PushDebugGroup { color, len } => {
ArcRenderCommand::PushDebugGroup { color, len }
}
RenderCommand::PopDebugGroup => ArcRenderCommand::PopDebugGroup,
RenderCommand::InsertDebugMarker { color, len } => {
ArcRenderCommand::InsertDebugMarker { color, len }
}
RenderCommand::WriteTimestamp {
query_set_id,
query_index,
} => ArcRenderCommand::WriteTimestamp {
query_set: query_set_guard.get(query_set_id).get().map_err(|e| {
RenderPassError {
scope: PassErrorScope::WriteTimestamp,
inner: e.into(),
}
})?,
query_index,
},
RenderCommand::BeginPipelineStatisticsQuery {
query_set_id,
query_index,
} => ArcRenderCommand::BeginPipelineStatisticsQuery {
query_set: query_set_guard.get(query_set_id).get().map_err(|e| {
RenderPassError {
scope: PassErrorScope::BeginPipelineStatisticsQuery,
inner: e.into(),
}
})?,
query_index,
},
RenderCommand::EndPipelineStatisticsQuery => {
ArcRenderCommand::EndPipelineStatisticsQuery
}
RenderCommand::SetIndexBuffer {
buffer_id,
index_format,
offset,
size,
} => ArcRenderCommand::SetIndexBuffer {
buffer: buffers_guard.get(buffer_id).get().map_err(|e| {
RenderPassError {
scope: PassErrorScope::SetIndexBuffer,
inner: e.into(),
}
})?,
index_format,
offset,
size,
},
RenderCommand::SetVertexBuffer {
slot,
buffer_id,
offset,
size,
} => ArcRenderCommand::SetVertexBuffer {
slot,
buffer: buffers_guard.get(buffer_id).get().map_err(|e| {
RenderPassError {
scope: PassErrorScope::SetVertexBuffer,
inner: e.into(),
}
})?,
offset,
count_buffer: buffers_guard.strict_get(count_buffer_id).get().map_err(
|e| RenderPassError {
scope,
size,
},
RenderCommand::SetBlendConstant(color) => {
ArcRenderCommand::SetBlendConstant(color)
}
RenderCommand::SetStencilReference(reference) => {
ArcRenderCommand::SetStencilReference(reference)
}
RenderCommand::SetViewport {
rect,
depth_min,
depth_max,
} => ArcRenderCommand::SetViewport {
rect,
depth_min,
depth_max,
},
RenderCommand::SetScissor(scissor) => ArcRenderCommand::SetScissor(scissor),
RenderCommand::Draw {
vertex_count,
instance_count,
first_vertex,
first_instance,
} => ArcRenderCommand::Draw {
vertex_count,
instance_count,
first_vertex,
first_instance,
},
RenderCommand::DrawIndexed {
index_count,
instance_count,
first_index,
base_vertex,
first_instance,
} => ArcRenderCommand::DrawIndexed {
index_count,
instance_count,
first_index,
base_vertex,
first_instance,
},
RenderCommand::MultiDrawIndirect {
buffer_id,
offset,
count,
indexed,
} => ArcRenderCommand::MultiDrawIndirect {
buffer: buffers_guard.get(buffer_id).get().map_err(|e| {
RenderPassError {
scope: PassErrorScope::Draw {
kind: if count.is_some() {
DrawKind::MultiDrawIndirect
} else {
DrawKind::DrawIndirect
},
indexed,
},
inner: e.into(),
},
)?,
}
})?,
offset,
count,
indexed,
},
RenderCommand::MultiDrawIndirectCount {
buffer_id,
offset,
count_buffer_id,
count_buffer_offset,
max_count,
indexed,
}
}
RenderCommand::BeginOcclusionQuery { query_index } => {
ArcRenderCommand::BeginOcclusionQuery { query_index }
}
RenderCommand::EndOcclusionQuery => ArcRenderCommand::EndOcclusionQuery,
RenderCommand::ExecuteBundle(bundle) => ArcRenderCommand::ExecuteBundle(
render_bundles_guard.strict_get(bundle).get().map_err(|e| {
RenderPassError {
scope: PassErrorScope::ExecuteBundle,
inner: e.into(),
} => {
let scope = PassErrorScope::Draw {
kind: DrawKind::MultiDrawIndirectCount,
indexed,
};
ArcRenderCommand::MultiDrawIndirectCount {
buffer: buffers_guard.get(buffer_id).get().map_err(|e| {
RenderPassError {
scope,
inner: e.into(),
}
})?,
offset,
count_buffer: buffers_guard.get(count_buffer_id).get().map_err(
|e| RenderPassError {
scope,
inner: e.into(),
},
)?,
count_buffer_offset,
max_count,
indexed,
}
})?,
),
}
RenderCommand::BeginOcclusionQuery { query_index } => {
ArcRenderCommand::BeginOcclusionQuery { query_index }
}
RenderCommand::EndOcclusionQuery => ArcRenderCommand::EndOcclusionQuery,
RenderCommand::ExecuteBundle(bundle) => ArcRenderCommand::ExecuteBundle(
render_bundles_guard.get(bundle).get().map_err(|e| {
RenderPassError {
scope: PassErrorScope::ExecuteBundle,
inner: e.into(),
}
})?,
),
})
})
})
.collect::<Result<Vec<_>, RenderPassError>>()?;
.collect::<Result<Vec<_>, RenderPassError>>()?;
Ok(resolved_commands)
}
}

View File

@ -534,7 +534,7 @@ impl Global {
let cmd_buf = hub
.command_buffers
.strict_get(command_encoder_id.into_command_buffer_id());
.get(command_encoder_id.into_command_buffer_id());
let mut cmd_buf_data = cmd_buf.try_get()?;
cmd_buf_data.check_recording()?;
@ -554,7 +554,7 @@ impl Global {
let snatch_guard = device.snatchable_lock.read();
let src_buffer = hub.buffers.strict_get(source).get()?;
let src_buffer = hub.buffers.get(source).get()?;
src_buffer.same_device_as(cmd_buf.as_ref())?;
@ -570,7 +570,7 @@ impl Global {
// expecting only a single barrier
let src_barrier = src_pending.map(|pending| pending.into_hal(&src_buffer, &snatch_guard));
let dst_buffer = hub.buffers.strict_get(destination).get()?;
let dst_buffer = hub.buffers.get(destination).get()?;
dst_buffer.same_device_as(cmd_buf.as_ref())?;
@ -692,7 +692,7 @@ impl Global {
let cmd_buf = hub
.command_buffers
.strict_get(command_encoder_id.into_command_buffer_id());
.get(command_encoder_id.into_command_buffer_id());
let mut cmd_buf_data = cmd_buf.try_get()?;
cmd_buf_data.check_recording()?;
@ -713,7 +713,7 @@ impl Global {
return Ok(());
}
let dst_texture = hub.textures.strict_get(destination.texture).get()?;
let dst_texture = hub.textures.get(destination.texture).get()?;
dst_texture.same_device_as(cmd_buf.as_ref())?;
@ -740,7 +740,7 @@ impl Global {
&snatch_guard,
)?;
let src_buffer = hub.buffers.strict_get(source.buffer).get()?;
let src_buffer = hub.buffers.get(source.buffer).get()?;
src_buffer.same_device_as(cmd_buf.as_ref())?;
@ -845,7 +845,7 @@ impl Global {
let cmd_buf = hub
.command_buffers
.strict_get(command_encoder_id.into_command_buffer_id());
.get(command_encoder_id.into_command_buffer_id());
let mut cmd_buf_data = cmd_buf.try_get()?;
cmd_buf_data.check_recording()?;
@ -866,7 +866,7 @@ impl Global {
return Ok(());
}
let src_texture = hub.textures.strict_get(source.texture).get()?;
let src_texture = hub.textures.get(source.texture).get()?;
src_texture.same_device_as(cmd_buf.as_ref())?;
@ -915,7 +915,7 @@ impl Global {
.map(|pending| pending.into_hal(src_raw))
.collect::<Vec<_>>();
let dst_buffer = hub.buffers.strict_get(destination.buffer).get()?;
let dst_buffer = hub.buffers.get(destination.buffer).get()?;
dst_buffer.same_device_as(cmd_buf.as_ref())?;
@ -1012,7 +1012,7 @@ impl Global {
let cmd_buf = hub
.command_buffers
.strict_get(command_encoder_id.into_command_buffer_id());
.get(command_encoder_id.into_command_buffer_id());
let mut cmd_buf_data = cmd_buf.try_get()?;
cmd_buf_data.check_recording()?;
@ -1035,8 +1035,8 @@ impl Global {
return Ok(());
}
let src_texture = hub.textures.strict_get(source.texture).get()?;
let dst_texture = hub.textures.strict_get(destination.texture).get()?;
let src_texture = hub.textures.get(source.texture).get()?;
let dst_texture = hub.textures.get(destination.texture).get()?;
src_texture.same_device_as(cmd_buf.as_ref())?;
dst_texture.same_device_as(cmd_buf.as_ref())?;

View File

@ -42,8 +42,8 @@ impl Global {
adapter_id: AdapterId,
surface_id: SurfaceId,
) -> bool {
let surface = self.surfaces.strict_get(surface_id);
let adapter = self.hub.adapters.strict_get(adapter_id);
let surface = self.surfaces.get(surface_id);
let adapter = self.hub.adapters.get(adapter_id);
adapter.is_surface_supported(&surface)
}
@ -75,23 +75,23 @@ impl Global {
adapter_id: AdapterId,
get_supported_callback: F,
) -> B {
let surface = self.surfaces.strict_get(surface_id);
let adapter = self.hub.adapters.strict_get(adapter_id);
let surface = self.surfaces.get(surface_id);
let adapter = self.hub.adapters.get(adapter_id);
get_supported_callback(&adapter, &surface)
}
pub fn device_features(&self, device_id: DeviceId) -> wgt::Features {
let device = self.hub.devices.strict_get(device_id);
let device = self.hub.devices.get(device_id);
device.features
}
pub fn device_limits(&self, device_id: DeviceId) -> wgt::Limits {
let device = self.hub.devices.strict_get(device_id);
let device = self.hub.devices.get(device_id);
device.limits.clone()
}
pub fn device_downlevel_properties(&self, device_id: DeviceId) -> wgt::DownlevelCapabilities {
let device = self.hub.devices.strict_get(device_id);
let device = self.hub.devices.get(device_id);
device.downlevel.clone()
}
@ -107,7 +107,7 @@ impl Global {
let fid = hub.buffers.prepare(device_id.backend(), id_in);
let error = 'error: {
let device = self.hub.devices.strict_get(device_id);
let device = self.hub.devices.get(device_id);
#[cfg(feature = "trace")]
if let Some(ref mut trace) = *device.trace.lock() {
@ -215,7 +215,7 @@ impl Global {
) -> BufferAccessResult {
let hub = &self.hub;
let buffer = hub.buffers.strict_get(buffer_id).get()?;
let buffer = hub.buffers.get(buffer_id).get()?;
let device = &buffer.device;
@ -262,7 +262,7 @@ impl Global {
let hub = &self.hub;
let buffer = hub.buffers.strict_get(buffer_id).get()?;
let buffer = hub.buffers.get(buffer_id).get()?;
#[cfg(feature = "trace")]
if let Some(trace) = buffer.device.trace.lock().as_mut() {
@ -314,7 +314,7 @@ impl Global {
let fid = hub.textures.prepare(device_id.backend(), id_in);
let error = 'error: {
let device = self.hub.devices.strict_get(device_id);
let device = self.hub.devices.get(device_id);
#[cfg(feature = "trace")]
if let Some(ref mut trace) = *device.trace.lock() {
@ -357,7 +357,7 @@ impl Global {
let fid = hub.textures.prepare(device_id.backend(), id_in);
let error = 'error: {
let device = self.hub.devices.strict_get(device_id);
let device = self.hub.devices.get(device_id);
// NB: Any change done through the raw texture handle will not be
// recorded in the replay
@ -400,7 +400,7 @@ impl Global {
let hub = &self.hub;
let fid = hub.buffers.prepare(A::VARIANT, id_in);
let device = self.hub.devices.strict_get(device_id);
let device = self.hub.devices.get(device_id);
// NB: Any change done through the raw buffer handle will not be
// recorded in the replay
@ -423,7 +423,7 @@ impl Global {
let hub = &self.hub;
let texture = hub.textures.strict_get(texture_id).get()?;
let texture = hub.textures.get(texture_id).get()?;
#[cfg(feature = "trace")]
if let Some(trace) = texture.device.trace.lock().as_mut() {
@ -461,7 +461,7 @@ impl Global {
let fid = hub.texture_views.prepare(texture_id.backend(), id_in);
let error = 'error: {
let texture = match hub.textures.strict_get(texture_id).get() {
let texture = match hub.textures.get(texture_id).get() {
Ok(texture) => texture,
Err(e) => break 'error e.into(),
};
@ -525,7 +525,7 @@ impl Global {
let fid = hub.samplers.prepare(device_id.backend(), id_in);
let error = 'error: {
let device = self.hub.devices.strict_get(device_id);
let device = self.hub.devices.get(device_id);
#[cfg(feature = "trace")]
if let Some(ref mut trace) = *device.trace.lock() {
@ -578,7 +578,7 @@ impl Global {
let fid = hub.bind_group_layouts.prepare(device_id.backend(), id_in);
let error = 'error: {
let device = self.hub.devices.strict_get(device_id);
let device = self.hub.devices.get(device_id);
#[cfg(feature = "trace")]
if let Some(ref mut trace) = *device.trace.lock() {
@ -652,7 +652,7 @@ impl Global {
let fid = hub.pipeline_layouts.prepare(device_id.backend(), id_in);
let error = 'error: {
let device = self.hub.devices.strict_get(device_id);
let device = self.hub.devices.get(device_id);
#[cfg(feature = "trace")]
if let Some(ref mut trace) = *device.trace.lock() {
@ -663,7 +663,7 @@ impl Global {
let bind_group_layouts_guard = hub.bind_group_layouts.read();
desc.bind_group_layouts
.iter()
.map(|bgl_id| bind_group_layouts_guard.strict_get(*bgl_id).get())
.map(|bgl_id| bind_group_layouts_guard.get(*bgl_id).get())
.collect::<Result<Vec<_>, _>>()
};
@ -720,14 +720,14 @@ impl Global {
let fid = hub.bind_groups.prepare(device_id.backend(), id_in);
let error = 'error: {
let device = self.hub.devices.strict_get(device_id);
let device = self.hub.devices.get(device_id);
#[cfg(feature = "trace")]
if let Some(ref mut trace) = *device.trace.lock() {
trace.add(trace::Action::CreateBindGroup(fid.id(), desc.clone()));
}
let layout = match hub.bind_group_layouts.strict_get(desc.layout).get() {
let layout = match hub.bind_group_layouts.get(desc.layout).get() {
Ok(layout) => layout,
Err(e) => break 'error e.into(),
};
@ -741,7 +741,7 @@ impl Global {
{
let resolve_buffer = |bb: &BufferBinding| {
buffer_storage
.strict_get(bb.buffer_id)
.get(bb.buffer_id)
.get()
.map(|buffer| ResolvedBufferBinding {
buffer,
@ -752,13 +752,13 @@ impl Global {
};
let resolve_sampler = |id: &id::SamplerId| {
sampler_storage
.strict_get(*id)
.get(*id)
.get()
.map_err(binding_model::CreateBindGroupError::from)
};
let resolve_view = |id: &id::TextureViewId| {
texture_view_storage
.strict_get(*id)
.get(*id)
.get()
.map_err(binding_model::CreateBindGroupError::from)
};
@ -882,7 +882,7 @@ impl Global {
let fid = hub.shader_modules.prepare(device_id.backend(), id_in);
let error = 'error: {
let device = self.hub.devices.strict_get(device_id);
let device = self.hub.devices.get(device_id);
#[cfg(feature = "trace")]
if let Some(ref mut trace) = *device.trace.lock() {
@ -954,7 +954,7 @@ impl Global {
let fid = hub.shader_modules.prepare(device_id.backend(), id_in);
let error = 'error: {
let device = self.hub.devices.strict_get(device_id);
let device = self.hub.devices.get(device_id);
#[cfg(feature = "trace")]
if let Some(ref mut trace) = *device.trace.lock() {
@ -1013,7 +1013,7 @@ impl Global {
id_in.map(|id| id.into_command_buffer_id()),
);
let device = self.hub.devices.strict_get(device_id);
let device = self.hub.devices.get(device_id);
let error = 'error: {
let command_buffer = match device.create_command_encoder(&desc.label) {
@ -1079,7 +1079,7 @@ impl Global {
.prepare(bundle_encoder.parent().backend(), id_in);
let error = 'error: {
let device = self.hub.devices.strict_get(bundle_encoder.parent());
let device = self.hub.devices.get(bundle_encoder.parent());
#[cfg(feature = "trace")]
if let Some(ref mut trace) = *device.trace.lock() {
@ -1138,7 +1138,7 @@ impl Global {
let fid = hub.query_sets.prepare(device_id.backend(), id_in);
let error = 'error: {
let device = self.hub.devices.strict_get(device_id);
let device = self.hub.devices.get(device_id);
#[cfg(feature = "trace")]
if let Some(ref mut trace) = *device.trace.lock() {
@ -1205,7 +1205,7 @@ impl Global {
break 'error pipeline::ImplicitLayoutError::MissingImplicitPipelineIds.into();
}
let device = self.hub.devices.strict_get(device_id);
let device = self.hub.devices.get(device_id);
#[cfg(feature = "trace")]
if let Some(ref mut trace) = *device.trace.lock() {
@ -1218,7 +1218,7 @@ impl Global {
let layout = desc
.layout
.map(|layout| hub.pipeline_layouts.strict_get(layout).get())
.map(|layout| hub.pipeline_layouts.get(layout).get())
.transpose();
let layout = match layout {
Ok(layout) => layout,
@ -1227,7 +1227,7 @@ impl Global {
let cache = desc
.cache
.map(|cache| hub.pipeline_caches.strict_get(cache).get())
.map(|cache| hub.pipeline_caches.get(cache).get())
.transpose();
let cache = match cache {
Ok(cache) => cache,
@ -1237,7 +1237,7 @@ impl Global {
let vertex = {
let module = hub
.shader_modules
.strict_get(desc.vertex.stage.module)
.get(desc.vertex.stage.module)
.get()
.map_err(|e| pipeline::CreateRenderPipelineError::Stage {
stage: wgt::ShaderStages::VERTEX,
@ -1265,7 +1265,7 @@ impl Global {
let fragment = if let Some(ref state) = desc.fragment {
let module = hub
.shader_modules
.strict_get(state.stage.module)
.get(state.stage.module)
.get()
.map_err(|e| pipeline::CreateRenderPipelineError::Stage {
stage: wgt::ShaderStages::FRAGMENT,
@ -1383,7 +1383,7 @@ impl Global {
let fid = hub.bind_group_layouts.prepare(pipeline_id.backend(), id_in);
let error = 'error: {
let pipeline = match hub.render_pipelines.strict_get(pipeline_id).get() {
let pipeline = match hub.render_pipelines.get(pipeline_id).get() {
Ok(pipeline) => pipeline,
Err(e) => break 'error e.into(),
};
@ -1442,7 +1442,7 @@ impl Global {
break 'error pipeline::ImplicitLayoutError::MissingImplicitPipelineIds.into();
}
let device = self.hub.devices.strict_get(device_id);
let device = self.hub.devices.get(device_id);
#[cfg(feature = "trace")]
if let Some(ref mut trace) = *device.trace.lock() {
@ -1455,7 +1455,7 @@ impl Global {
let layout = desc
.layout
.map(|layout| hub.pipeline_layouts.strict_get(layout).get())
.map(|layout| hub.pipeline_layouts.get(layout).get())
.transpose();
let layout = match layout {
Ok(layout) => layout,
@ -1464,14 +1464,14 @@ impl Global {
let cache = desc
.cache
.map(|cache| hub.pipeline_caches.strict_get(cache).get())
.map(|cache| hub.pipeline_caches.get(cache).get())
.transpose();
let cache = match cache {
Ok(cache) => cache,
Err(e) => break 'error e.into(),
};
let module = hub.shader_modules.strict_get(desc.stage.module).get();
let module = hub.shader_modules.get(desc.stage.module).get();
let module = match module {
Ok(module) => module,
Err(e) => break 'error e.into(),
@ -1567,7 +1567,7 @@ impl Global {
let fid = hub.bind_group_layouts.prepare(pipeline_id.backend(), id_in);
let error = 'error: {
let pipeline = match hub.compute_pipelines.strict_get(pipeline_id).get() {
let pipeline = match hub.compute_pipelines.get(pipeline_id).get() {
Ok(pipeline) => pipeline,
Err(e) => break 'error e.into(),
};
@ -1620,7 +1620,7 @@ impl Global {
let fid = hub.pipeline_caches.prepare(device_id.backend(), id_in);
let error: pipeline::CreatePipelineCacheError = 'error: {
let device = self.hub.devices.strict_get(device_id);
let device = self.hub.devices.get(device_id);
#[cfg(feature = "trace")]
if let Some(ref mut trace) = *device.trace.lock() {
@ -1789,7 +1789,7 @@ impl Global {
// User callbacks must not be called while we are holding locks.
let user_callbacks;
{
let device = self.hub.devices.strict_get(device_id);
let device = self.hub.devices.get(device_id);
#[cfg(feature = "trace")]
if let Some(ref mut trace) = *device.trace.lock() {
@ -1800,7 +1800,7 @@ impl Global {
break 'error e.into();
}
let surface = self.surfaces.strict_get(surface_id);
let surface = self.surfaces.get(surface_id);
let caps = match surface.get_capabilities(&device.adapter) {
Ok(caps) => caps,
@ -1927,7 +1927,7 @@ impl Global {
) -> Result<bool, WaitIdleError> {
api_log!("Device::poll {maintain:?}");
let device = self.hub.devices.strict_get(device_id);
let device = self.hub.devices.get(device_id);
let DevicePoll {
closures,
@ -2037,7 +2037,7 @@ impl Global {
pub fn device_start_capture(&self, device_id: DeviceId) {
api_log!("Device::start_capture");
let device = self.hub.devices.strict_get(device_id);
let device = self.hub.devices.get(device_id);
if !device.is_valid() {
return;
@ -2048,7 +2048,7 @@ impl Global {
pub fn device_stop_capture(&self, device_id: DeviceId) {
api_log!("Device::stop_capture");
let device = self.hub.devices.strict_get(device_id);
let device = self.hub.devices.get(device_id);
if !device.is_valid() {
return;
@ -2061,7 +2061,7 @@ impl Global {
api_log!("PipelineCache::get_data");
let hub = &self.hub;
if let Ok(cache) = hub.pipeline_caches.strict_get(id).get() {
if let Ok(cache) = hub.pipeline_caches.get(id).get() {
// TODO: Is this check needed?
if !cache.device.is_valid() {
return None;
@ -2112,7 +2112,7 @@ impl Global {
device_id: DeviceId,
device_lost_closure: DeviceLostClosure,
) {
let device = self.hub.devices.strict_get(device_id);
let device = self.hub.devices.get(device_id);
let mut life_tracker = device.lock_life();
if let Some(existing_closure) = life_tracker.device_lost_closure.take() {
@ -2127,7 +2127,7 @@ impl Global {
pub fn device_destroy(&self, device_id: DeviceId) {
api_log!("Device::destroy {device_id:?}");
let device = self.hub.devices.strict_get(device_id);
let device = self.hub.devices.get(device_id);
// Follow the steps at
// https://gpuweb.github.io/gpuweb/#dom-gpudevice-destroy.
@ -2149,7 +2149,7 @@ impl Global {
}
pub fn device_get_internal_counters(&self, device_id: DeviceId) -> wgt::InternalCounters {
let device = self.hub.devices.strict_get(device_id);
let device = self.hub.devices.get(device_id);
wgt::InternalCounters {
hal: device.get_hal_counters(),
core: wgt::CoreCounters {},
@ -2160,7 +2160,7 @@ impl Global {
&self,
device_id: DeviceId,
) -> Option<wgt::AllocatorReport> {
let device = self.hub.devices.strict_get(device_id);
let device = self.hub.devices.get(device_id);
device.generate_allocator_report()
}
@ -2184,7 +2184,7 @@ impl Global {
let hub = &self.hub;
let op_and_err = 'error: {
let buffer = match hub.buffers.strict_get(buffer_id).get() {
let buffer = match hub.buffers.get(buffer_id).get() {
Ok(buffer) => buffer,
Err(e) => break 'error Some((op, e.into())),
};
@ -2217,7 +2217,7 @@ impl Global {
let hub = &self.hub;
let buffer = hub.buffers.strict_get(buffer_id).get()?;
let buffer = hub.buffers.get(buffer_id).get()?;
{
let snatch_guard = buffer.device.snatchable_lock.read();
@ -2290,7 +2290,7 @@ impl Global {
let hub = &self.hub;
let buffer = hub.buffers.strict_get(buffer_id).get()?;
let buffer = hub.buffers.get(buffer_id).get()?;
let snatch_guard = buffer.device.snatchable_lock.read();
buffer.check_destroyed(&snatch_guard)?;

View File

@ -375,9 +375,9 @@ impl Global {
let hub = &self.hub;
let buffer = hub.buffers.strict_get(buffer_id).get()?;
let buffer = hub.buffers.get(buffer_id).get()?;
let queue = hub.queues.strict_get(queue_id);
let queue = hub.queues.get(queue_id);
let device = &queue.device;
@ -437,7 +437,7 @@ impl Global {
profiling::scope!("Queue::create_staging_buffer");
let hub = &self.hub;
let queue = hub.queues.strict_get(queue_id);
let queue = hub.queues.get(queue_id);
let device = &queue.device;
@ -461,7 +461,7 @@ impl Global {
profiling::scope!("Queue::write_staging_buffer");
let hub = &self.hub;
let queue = hub.queues.strict_get(queue_id);
let queue = hub.queues.get(queue_id);
let device = &queue.device;
@ -498,7 +498,7 @@ impl Global {
profiling::scope!("Queue::validate_write_buffer");
let hub = &self.hub;
let buffer = hub.buffers.strict_get(buffer_id).get()?;
let buffer = hub.buffers.get(buffer_id).get()?;
self.queue_validate_write_buffer_impl(&buffer, buffer_offset, buffer_size)?;
@ -541,7 +541,7 @@ impl Global {
) -> Result<(), QueueWriteError> {
let hub = &self.hub;
let dst = hub.buffers.strict_get(buffer_id).get()?;
let dst = hub.buffers.get(buffer_id).get()?;
let transition = {
let mut trackers = device.trackers.lock();
@ -598,7 +598,7 @@ impl Global {
let hub = &self.hub;
let queue = hub.queues.strict_get(queue_id);
let queue = hub.queues.get(queue_id);
let device = &queue.device;
@ -618,7 +618,7 @@ impl Global {
return Ok(());
}
let dst = hub.textures.strict_get(destination.texture).get()?;
let dst = hub.textures.get(destination.texture).get()?;
dst.same_device_as(queue.as_ref())?;
@ -827,7 +827,7 @@ impl Global {
let hub = &self.hub;
let queue = hub.queues.strict_get(queue_id);
let queue = hub.queues.get(queue_id);
let device = &queue.device;
@ -855,7 +855,7 @@ impl Global {
let src_width = source.source.width();
let src_height = source.source.height();
let dst = hub.textures.strict_get(destination.texture).get()?;
let dst = hub.textures.get(destination.texture).get()?;
if !conv::is_valid_external_image_copy_dst_texture_format(dst.desc.format) {
return Err(
@ -1034,7 +1034,7 @@ impl Global {
let (submit_index, callbacks) = {
let hub = &self.hub;
let queue = hub.queues.strict_get(queue_id);
let queue = hub.queues.get(queue_id);
let device = &queue.device;
@ -1074,7 +1074,7 @@ impl Global {
// it, so make sure to set_size on it.
used_surface_textures.set_size(device.tracker_indices.textures.size());
let command_buffer = command_buffer_guard.strict_get(*command_buffer_id);
let command_buffer = command_buffer_guard.get(*command_buffer_id);
// Note that we are required to invalidate all command buffers in both the success and failure paths.
// This is why we `continue` and don't early return via `?`.
@ -1297,7 +1297,7 @@ impl Global {
}
pub fn queue_get_timestamp_period(&self, queue_id: QueueId) -> f32 {
let queue = self.hub.queues.strict_get(queue_id);
let queue = self.hub.queues.get(queue_id);
unsafe { queue.raw().get_timestamp_period() }
}
@ -1309,7 +1309,7 @@ impl Global {
api_log!("Queue::on_submitted_work_done {queue_id:?}");
//TODO: flush pending writes
let queue = self.hub.queues.strict_get(queue_id);
let queue = self.hub.queues.get(queue_id);
queue.device.lock_life().add_work_done_closure(closure);
}
}

View File

@ -710,9 +710,7 @@ impl Global {
}
}
let compatible_surface = desc
.compatible_surface
.map(|id| self.surfaces.strict_get(id));
let compatible_surface = desc.compatible_surface.map(|id| self.surfaces.get(id));
let compatible_surface = compatible_surface.as_ref().map(|surface| surface.as_ref());
let mut device_types = Vec::new();
@ -844,7 +842,7 @@ impl Global {
}
pub fn adapter_get_info(&self, adapter_id: AdapterId) -> wgt::AdapterInfo {
let adapter = self.hub.adapters.strict_get(adapter_id);
let adapter = self.hub.adapters.get(adapter_id);
adapter.raw.info.clone()
}
@ -853,17 +851,17 @@ impl Global {
adapter_id: AdapterId,
format: wgt::TextureFormat,
) -> wgt::TextureFormatFeatures {
let adapter = self.hub.adapters.strict_get(adapter_id);
let adapter = self.hub.adapters.get(adapter_id);
adapter.get_texture_format_features(format)
}
pub fn adapter_features(&self, adapter_id: AdapterId) -> wgt::Features {
let adapter = self.hub.adapters.strict_get(adapter_id);
let adapter = self.hub.adapters.get(adapter_id);
adapter.raw.features
}
pub fn adapter_limits(&self, adapter_id: AdapterId) -> wgt::Limits {
let adapter = self.hub.adapters.strict_get(adapter_id);
let adapter = self.hub.adapters.get(adapter_id);
adapter.raw.capabilities.limits.clone()
}
@ -871,7 +869,7 @@ impl Global {
&self,
adapter_id: AdapterId,
) -> wgt::DownlevelCapabilities {
let adapter = self.hub.adapters.strict_get(adapter_id);
let adapter = self.hub.adapters.get(adapter_id);
adapter.raw.capabilities.downlevel.clone()
}
@ -879,7 +877,7 @@ impl Global {
&self,
adapter_id: AdapterId,
) -> wgt::PresentationTimestamp {
let adapter = self.hub.adapters.strict_get(adapter_id);
let adapter = self.hub.adapters.get(adapter_id);
unsafe { adapter.raw.adapter.get_presentation_timestamp() }
}
@ -907,7 +905,7 @@ impl Global {
let device_fid = self.hub.devices.prepare(backend, device_id_in);
let queue_fid = self.hub.queues.prepare(backend, queue_id_in);
let adapter = self.hub.adapters.strict_get(adapter_id);
let adapter = self.hub.adapters.get(adapter_id);
let (device, queue) =
adapter.create_device_and_queue(desc, self.instance.flags, trace_path)?;
@ -939,7 +937,7 @@ impl Global {
let devices_fid = self.hub.devices.prepare(backend, device_id_in);
let queues_fid = self.hub.queues.prepare(backend, queue_id_in);
let adapter = self.hub.adapters.strict_get(adapter_id);
let adapter = self.hub.adapters.get(adapter_id);
let (device, queue) = adapter.create_device_and_queue_from_hal(
hal_device,
desc,

View File

@ -122,7 +122,7 @@ impl Global {
let hub = &self.hub;
let surface = self.surfaces.strict_get(surface_id);
let surface = self.surfaces.get(surface_id);
let (device, config) = if let Some(ref present) = *surface.presentation.lock() {
present.device.check_is_valid()?;
@ -254,7 +254,7 @@ impl Global {
let hub = &self.hub;
let surface = self.surfaces.strict_get(surface_id);
let surface = self.surfaces.get(surface_id);
let mut presentation = surface.presentation.lock();
let present = match presentation.as_mut() {
@ -326,7 +326,7 @@ impl Global {
let hub = &self.hub;
let surface = self.surfaces.strict_get(surface_id);
let surface = self.surfaces.get(surface_id);
let mut presentation = surface.presentation.lock();
let present = match presentation.as_mut() {
Some(present) => present,

View File

@ -128,8 +128,8 @@ impl<T: StorageItem> Registry<T> {
}
impl<T: StorageItem + Clone> Registry<T> {
pub(crate) fn strict_get(&self, id: Id<T::Marker>) -> T {
self.read().strict_get(id)
pub(crate) fn get(&self, id: Id<T::Marker>) -> T {
self.read().get(id)
}
}

View File

@ -1243,7 +1243,7 @@ impl Global {
let hub = &self.hub;
if let Ok(buffer) = hub.buffers.strict_get(id).get() {
if let Ok(buffer) = hub.buffers.get(id).get() {
let snatch_guard = buffer.device.snatchable_lock.read();
let hal_buffer = buffer
.raw(&snatch_guard)
@ -1266,7 +1266,7 @@ impl Global {
let hub = &self.hub;
if let Ok(texture) = hub.textures.strict_get(id).get() {
if let Ok(texture) = hub.textures.get(id).get() {
let snatch_guard = texture.device.snatchable_lock.read();
let hal_texture = texture.raw(&snatch_guard);
let hal_texture = hal_texture
@ -1290,7 +1290,7 @@ impl Global {
let hub = &self.hub;
if let Ok(texture_view) = hub.texture_views.strict_get(id).get() {
if let Ok(texture_view) = hub.texture_views.get(id).get() {
let snatch_guard = texture_view.device.snatchable_lock.read();
let hal_texture_view = texture_view.raw(&snatch_guard);
let hal_texture_view = hal_texture_view
@ -1313,7 +1313,7 @@ impl Global {
profiling::scope!("Adapter::as_hal");
let hub = &self.hub;
let adapter = hub.adapters.strict_get(id);
let adapter = hub.adapters.get(id);
let hal_adapter = adapter.raw.adapter.as_any().downcast_ref();
hal_adapter_callback(hal_adapter)
@ -1329,7 +1329,7 @@ impl Global {
) -> R {
profiling::scope!("Device::as_hal");
let device = self.hub.devices.strict_get(id);
let device = self.hub.devices.get(id);
let hal_device = device.raw().as_any().downcast_ref();
hal_device_callback(hal_device)
@ -1345,7 +1345,7 @@ impl Global {
) -> R {
profiling::scope!("Device::fence_as_hal");
let device = self.hub.devices.strict_get(id);
let device = self.hub.devices.get(id);
let fence = device.fence.read();
hal_fence_callback(fence.as_any().downcast_ref())
}
@ -1359,7 +1359,7 @@ impl Global {
) -> R {
profiling::scope!("Surface::as_hal");
let surface = self.surfaces.strict_get(id);
let surface = self.surfaces.get(id);
let hal_surface = surface
.raw(A::VARIANT)
.and_then(|surface| surface.as_any().downcast_ref());
@ -1383,7 +1383,7 @@ impl Global {
let hub = &self.hub;
let cmd_buf = hub.command_buffers.strict_get(id.into_command_buffer_id());
let cmd_buf = hub.command_buffers.get(id.into_command_buffer_id());
let cmd_buf_data = cmd_buf.try_get();
if let Ok(mut cmd_buf_data) = cmd_buf_data {

View File

@ -130,7 +130,7 @@ where
{
/// Get an owned reference to an item.
/// Panics if there is an epoch mismatch, the entry is empty or in error.
pub(crate) fn strict_get(&self, id: Id<T::Marker>) -> T {
pub(crate) fn get(&self, id: Id<T::Marker>) -> T {
let (index, epoch, _) = id.unzip();
let (result, storage_epoch) = match self.map.get(index as usize) {
Some(&Element::Occupied(ref v, epoch)) => (v.clone(), epoch),