mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-25 00:03:29 +00:00
[wgpu-core] use Fallible
for Sampler
This commit is contained in:
parent
04f17d4197
commit
3ed1abc492
@ -81,8 +81,6 @@ pub enum CreateBindGroupError {
|
||||
Device(#[from] DeviceError),
|
||||
#[error("Bind group layout is invalid")]
|
||||
InvalidLayout,
|
||||
#[error("SamplerId {0:?} is invalid")]
|
||||
InvalidSamplerId(SamplerId),
|
||||
#[error(transparent)]
|
||||
DestroyedResource(#[from] DestroyedResourceError),
|
||||
#[error(
|
||||
|
@ -537,13 +537,13 @@ impl Global {
|
||||
Err(e) => break 'error e,
|
||||
};
|
||||
|
||||
let id = fid.assign(sampler);
|
||||
let id = fid.assign(Fallible::Valid(sampler));
|
||||
api_log!("Device::create_sampler -> {id:?}");
|
||||
|
||||
return (id, None);
|
||||
};
|
||||
|
||||
let id = fid.assign_error();
|
||||
let id = fid.assign(Fallible::Invalid(Arc::new(desc.label.to_string())));
|
||||
(id, Some(error))
|
||||
}
|
||||
|
||||
@ -553,9 +553,11 @@ impl Global {
|
||||
|
||||
let hub = &self.hub;
|
||||
|
||||
if let Some(_sampler) = hub.samplers.unregister(sampler_id) {
|
||||
#[cfg(feature = "trace")]
|
||||
if let Some(t) = _sampler.device.trace.lock().as_mut() {
|
||||
let _sampler = hub.samplers.strict_unregister(sampler_id);
|
||||
|
||||
#[cfg(feature = "trace")]
|
||||
if let Ok(sampler) = _sampler.get() {
|
||||
if let Some(t) = sampler.device.trace.lock().as_mut() {
|
||||
t.add(trace::Action::DestroySampler(sampler_id));
|
||||
}
|
||||
}
|
||||
@ -733,7 +735,7 @@ impl Global {
|
||||
fn resolve_entry<'a>(
|
||||
e: &BindGroupEntry<'a>,
|
||||
buffer_storage: &Storage<Fallible<resource::Buffer>>,
|
||||
sampler_storage: &Storage<Arc<resource::Sampler>>,
|
||||
sampler_storage: &Storage<Fallible<resource::Sampler>>,
|
||||
texture_view_storage: &Storage<Fallible<resource::TextureView>>,
|
||||
) -> Result<ResolvedBindGroupEntry<'a>, binding_model::CreateBindGroupError>
|
||||
{
|
||||
@ -750,8 +752,9 @@ impl Global {
|
||||
};
|
||||
let resolve_sampler = |id: &id::SamplerId| {
|
||||
sampler_storage
|
||||
.get_owned(*id)
|
||||
.map_err(|_| binding_model::CreateBindGroupError::InvalidSamplerId(*id))
|
||||
.strict_get(*id)
|
||||
.get()
|
||||
.map_err(binding_model::CreateBindGroupError::from)
|
||||
};
|
||||
let resolve_view = |id: &id::TextureViewId| {
|
||||
texture_view_storage
|
||||
|
@ -179,7 +179,7 @@ pub struct Hub {
|
||||
pub(crate) staging_buffers: Registry<Arc<StagingBuffer>>,
|
||||
pub(crate) textures: Registry<Fallible<Texture>>,
|
||||
pub(crate) texture_views: Registry<Fallible<TextureView>>,
|
||||
pub(crate) samplers: Registry<Arc<Sampler>>,
|
||||
pub(crate) samplers: Registry<Fallible<Sampler>>,
|
||||
}
|
||||
|
||||
impl Hub {
|
||||
|
Loading…
Reference in New Issue
Block a user