remove TextureBindGroupState.add_single's return type

This commit is contained in:
teoxoy 2024-06-19 14:35:08 +02:00 committed by Teodor Tanasoaia
parent 43177d78d6
commit 8d805c99d3
3 changed files with 6 additions and 14 deletions

View File

@ -6,7 +6,7 @@ use crate::{
},
error::{ErrorFormatter, PrettyError},
hal_api::HalApi,
id::{BindGroupLayoutId, BufferId, SamplerId, TextureId, TextureViewId},
id::{BindGroupLayoutId, BufferId, SamplerId, TextureViewId},
init_tracker::{BufferInitTrackerAction, TextureInitTrackerAction},
resource::{ParentDevice, Resource, ResourceInfo, ResourceType},
resource_log,
@ -80,8 +80,6 @@ pub enum CreateBindGroupError {
InvalidBuffer(BufferId),
#[error("Texture view {0:?} is invalid")]
InvalidTextureView(TextureViewId),
#[error("Texture {0:?} is invalid")]
InvalidTexture(TextureId),
#[error("Sampler {0:?} is invalid")]
InvalidSampler(SamplerId),
#[error(

View File

@ -2054,15 +2054,10 @@ impl<A: HalApi> Device<A> {
"SampledTexture, ReadonlyStorageTexture or WriteonlyStorageTexture",
)?;
let texture = &view.parent;
let texture_id = texture.as_info().id();
// Careful here: the texture may no longer have its own ref count,
// if it was deleted by the user.
let texture = used
.textures
.add_single(texture, Some(view.selector.clone()), internal_use)
.ok_or(binding_model::CreateBindGroupError::InvalidTexture(
texture_id,
))?;
used.textures
.add_single(texture, Some(view.selector.clone()), internal_use);
texture.same_device_as(view)?;

View File

@ -189,19 +189,18 @@ impl<A: HalApi> TextureBindGroupState<A> {
}
/// Adds the given resource with the given state.
pub fn add_single<'a>(
pub fn add_single(
&self,
texture: &'a Arc<Texture<A>>,
texture: &Arc<Texture<A>>,
selector: Option<TextureSelector>,
state: TextureUses,
) -> Option<&'a Arc<Texture<A>>> {
) {
let mut textures = self.textures.lock();
textures.push(TextureBindGroupStateData {
selector,
texture: texture.clone(),
usage: state,
});
Some(texture)
}
}