make return type of TextureTracker.set_single non-optional

This commit is contained in:
teoxoy 2024-06-20 00:56:09 +02:00 committed by Teodor Tanasoaia
parent d2218398ff
commit 97a038a768
4 changed files with 28 additions and 29 deletions

View File

@ -304,7 +304,6 @@ pub(crate) fn clear_texture<A: HalApi>(
// change_replace_tracked whenever possible.
let dst_barrier = texture_tracker
.set_single(dst_texture, selector, clear_usage)
.unwrap()
.map(|pending| pending.into_hal(dst_raw));
unsafe {
encoder.transition_textures(dst_barrier.into_iter());

View File

@ -814,10 +814,10 @@ impl Global {
}
let src_barrier = src_pending.map(|pending| pending.into_hal(&src_buffer, &snatch_guard));
let dst_pending = tracker
.textures
.set_single(&dst_texture, dst_range, hal::TextureUses::COPY_DST)
.ok_or(TransferError::InvalidTexture(destination.texture))?;
let dst_pending =
tracker
.textures
.set_single(&dst_texture, dst_range, hal::TextureUses::COPY_DST);
let dst_raw = dst_texture
.raw(&snatch_guard)
.ok_or(TransferError::InvalidTexture(destination.texture))?;
@ -952,10 +952,10 @@ impl Global {
&snatch_guard,
)?;
let src_pending = tracker
.textures
.set_single(&src_texture, src_range, hal::TextureUses::COPY_SRC)
.ok_or(TransferError::InvalidTexture(source.texture))?;
let src_pending =
tracker
.textures
.set_single(&src_texture, src_range, hal::TextureUses::COPY_SRC);
let src_raw = src_texture
.raw(&snatch_guard)
.ok_or(TransferError::InvalidTexture(source.texture))?;
@ -1169,11 +1169,11 @@ impl Global {
&snatch_guard,
)?;
let src_pending = cmd_buf_data
.trackers
.textures
.set_single(&src_texture, src_range, hal::TextureUses::COPY_SRC)
.ok_or(TransferError::InvalidTexture(source.texture))?;
let src_pending = cmd_buf_data.trackers.textures.set_single(
&src_texture,
src_range,
hal::TextureUses::COPY_SRC,
);
let src_raw = src_texture
.raw(&snatch_guard)
.ok_or(TransferError::InvalidTexture(source.texture))?;
@ -1187,11 +1187,11 @@ impl Global {
.map(|pending| pending.into_hal(src_raw))
.collect();
let dst_pending = cmd_buf_data
.trackers
.textures
.set_single(&dst_texture, dst_range, hal::TextureUses::COPY_DST)
.ok_or(TransferError::InvalidTexture(destination.texture))?;
let dst_pending = cmd_buf_data.trackers.textures.set_single(
&dst_texture,
dst_range,
hal::TextureUses::COPY_DST,
);
let dst_raw = dst_texture
.raw(&snatch_guard)
.ok_or(TransferError::InvalidTexture(destination.texture))?;

View File

@ -909,10 +909,10 @@ impl Global {
};
let mut trackers = device.trackers.lock();
let transition = trackers
.textures
.set_single(&dst, selector, hal::TextureUses::COPY_DST)
.ok_or(TransferError::InvalidTexture(destination.texture))?;
let transition =
trackers
.textures
.set_single(&dst, selector, hal::TextureUses::COPY_DST);
unsafe {
encoder.transition_textures(transition.map(|pending| pending.into_hal(dst_raw)));
encoder.transition_buffers(iter::once(barrier));
@ -1110,10 +1110,10 @@ impl Global {
unsafe {
let mut trackers = device.trackers.lock();
let transitions = trackers
.textures
.set_single(&dst, selector, hal::TextureUses::COPY_DST)
.ok_or(TransferError::InvalidTexture(destination.texture))?;
let transitions =
trackers
.textures
.set_single(&dst, selector, hal::TextureUses::COPY_DST);
encoder.transition_textures(transitions.map(|pending| pending.into_hal(dst_raw)));
encoder.copy_external_image_to_texture(
source,

View File

@ -575,7 +575,7 @@ impl<A: HalApi> TextureTracker<A> {
texture: &Arc<Texture<A>>,
selector: TextureSelector,
new_state: TextureUses,
) -> Option<Drain<'_, PendingTransition<TextureUses>>> {
) -> Drain<'_, PendingTransition<TextureUses>> {
let index = texture.as_info().tracker_index().as_usize();
self.allow_index(index);
@ -601,7 +601,7 @@ impl<A: HalApi> TextureTracker<A> {
)
}
Some(self.temp.drain(..))
self.temp.drain(..)
}
/// Sets the given state for all texture in the given tracker.