mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-25 00:03:29 +00:00
[wgpu-core] use Fallible
for TextureView
This commit is contained in:
parent
c630821f1d
commit
04f17d4197
@ -81,8 +81,6 @@ pub enum CreateBindGroupError {
|
||||
Device(#[from] DeviceError),
|
||||
#[error("Bind group layout is invalid")]
|
||||
InvalidLayout,
|
||||
#[error("TextureViewId {0:?} is invalid")]
|
||||
InvalidTextureViewId(TextureViewId),
|
||||
#[error("SamplerId {0:?} is invalid")]
|
||||
InvalidSamplerId(SamplerId),
|
||||
#[error(transparent)]
|
||||
|
@ -31,7 +31,7 @@ use crate::lock::{rank, Mutex};
|
||||
use crate::snatch::SnatchGuard;
|
||||
|
||||
use crate::init_tracker::BufferInitTrackerAction;
|
||||
use crate::resource::Labeled;
|
||||
use crate::resource::{InvalidResourceError, Labeled};
|
||||
use crate::track::{DeviceTracker, Tracker, UsageScope};
|
||||
use crate::LabelHelpers;
|
||||
use crate::{api_log, global::Global, id, resource_log, Label};
|
||||
@ -599,16 +599,12 @@ pub enum CommandEncoderError {
|
||||
|
||||
#[error("QuerySet {0:?} for pass timestamp writes is invalid.")]
|
||||
InvalidTimestampWritesQuerySetId(id::QuerySetId),
|
||||
#[error("Attachment TextureViewId {0:?} is invalid")]
|
||||
InvalidAttachmentId(id::TextureViewId),
|
||||
#[error(transparent)]
|
||||
InvalidColorAttachment(#[from] ColorAttachmentError),
|
||||
#[error("Resolve attachment TextureViewId {0:?} is invalid")]
|
||||
InvalidResolveTargetId(id::TextureViewId),
|
||||
#[error("Depth stencil attachment TextureViewId {0:?} is invalid")]
|
||||
InvalidDepthStencilAttachmentId(id::TextureViewId),
|
||||
#[error("Occlusion QuerySetId {0:?} is invalid")]
|
||||
InvalidOcclusionQuerySetId(id::QuerySetId),
|
||||
#[error(transparent)]
|
||||
InvalidResource(#[from] InvalidResourceError),
|
||||
}
|
||||
|
||||
impl Global {
|
||||
|
@ -1363,14 +1363,10 @@ impl Global {
|
||||
channel,
|
||||
}) = color_attachment
|
||||
{
|
||||
let view = texture_views
|
||||
.get_owned(*view_id)
|
||||
.map_err(|_| CommandEncoderError::InvalidAttachmentId(*view_id))?;
|
||||
let view = texture_views.strict_get(*view_id).get()?;
|
||||
|
||||
let resolve_target = if let Some(resolve_target_id) = resolve_target {
|
||||
let rt_arc = texture_views.get_owned(*resolve_target_id).map_err(|_| {
|
||||
CommandEncoderError::InvalidResolveTargetId(*resolve_target_id)
|
||||
})?;
|
||||
let rt_arc = texture_views.strict_get(*resolve_target_id).get()?;
|
||||
|
||||
Some(rt_arc)
|
||||
} else {
|
||||
@ -1392,12 +1388,8 @@ impl Global {
|
||||
arc_desc.depth_stencil_attachment =
|
||||
if let Some(depth_stencil_attachment) = desc.depth_stencil_attachment {
|
||||
let view = texture_views
|
||||
.get_owned(depth_stencil_attachment.view)
|
||||
.map_err(|_| {
|
||||
CommandEncoderError::InvalidDepthStencilAttachmentId(
|
||||
depth_stencil_attachment.view,
|
||||
)
|
||||
})?;
|
||||
.strict_get(depth_stencil_attachment.view)
|
||||
.get()?;
|
||||
|
||||
Some(ArcRenderPassDepthStencilAttachment {
|
||||
view,
|
||||
|
@ -481,7 +481,7 @@ impl Global {
|
||||
Err(e) => break 'error e,
|
||||
};
|
||||
|
||||
let id = fid.assign(view);
|
||||
let id = fid.assign(Fallible::Valid(view));
|
||||
|
||||
api_log!("Texture::create_view({texture_id:?}) -> {id:?}");
|
||||
|
||||
@ -489,7 +489,7 @@ impl Global {
|
||||
};
|
||||
|
||||
log::error!("Texture::create_view({texture_id:?}) error: {error}");
|
||||
let id = fid.assign_error();
|
||||
let id = fid.assign(Fallible::Invalid(Arc::new(desc.label.to_string())));
|
||||
(id, Some(error))
|
||||
}
|
||||
|
||||
@ -502,9 +502,11 @@ impl Global {
|
||||
|
||||
let hub = &self.hub;
|
||||
|
||||
if let Some(_view) = hub.texture_views.unregister(texture_view_id) {
|
||||
#[cfg(feature = "trace")]
|
||||
if let Some(t) = _view.device.trace.lock().as_mut() {
|
||||
let _view = hub.texture_views.strict_unregister(texture_view_id);
|
||||
|
||||
#[cfg(feature = "trace")]
|
||||
if let Ok(view) = _view.get() {
|
||||
if let Some(t) = view.device.trace.lock().as_mut() {
|
||||
t.add(trace::Action::DestroyTextureView(texture_view_id));
|
||||
}
|
||||
}
|
||||
@ -732,7 +734,7 @@ impl Global {
|
||||
e: &BindGroupEntry<'a>,
|
||||
buffer_storage: &Storage<Fallible<resource::Buffer>>,
|
||||
sampler_storage: &Storage<Arc<resource::Sampler>>,
|
||||
texture_view_storage: &Storage<Arc<resource::TextureView>>,
|
||||
texture_view_storage: &Storage<Fallible<resource::TextureView>>,
|
||||
) -> Result<ResolvedBindGroupEntry<'a>, binding_model::CreateBindGroupError>
|
||||
{
|
||||
let resolve_buffer = |bb: &BufferBinding| {
|
||||
@ -753,8 +755,9 @@ impl Global {
|
||||
};
|
||||
let resolve_view = |id: &id::TextureViewId| {
|
||||
texture_view_storage
|
||||
.get_owned(*id)
|
||||
.map_err(|_| binding_model::CreateBindGroupError::InvalidTextureViewId(*id))
|
||||
.strict_get(*id)
|
||||
.get()
|
||||
.map_err(binding_model::CreateBindGroupError::from)
|
||||
};
|
||||
let resource = match e.resource {
|
||||
BindingResource::Buffer(ref buffer) => {
|
||||
|
@ -178,7 +178,7 @@ pub struct Hub {
|
||||
pub(crate) buffers: Registry<Fallible<Buffer>>,
|
||||
pub(crate) staging_buffers: Registry<Arc<StagingBuffer>>,
|
||||
pub(crate) textures: Registry<Fallible<Texture>>,
|
||||
pub(crate) texture_views: Registry<Arc<TextureView>>,
|
||||
pub(crate) texture_views: Registry<Fallible<TextureView>>,
|
||||
pub(crate) samplers: Registry<Arc<Sampler>>,
|
||||
}
|
||||
|
||||
|
@ -1290,7 +1290,7 @@ impl Global {
|
||||
|
||||
let hub = &self.hub;
|
||||
|
||||
if let Ok(texture_view) = hub.texture_views.get(id) {
|
||||
if let Ok(texture_view) = hub.texture_views.strict_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
|
||||
|
Loading…
Reference in New Issue
Block a user