Skip to content

Commit

Permalink
Rename Texture::as_raw into Texture::raw
Browse files Browse the repository at this point in the history
For consistency with Buffer::raw.
  • Loading branch information
nical authored and teoxoy committed Jan 5, 2024
1 parent bfe235a commit defd43d
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion wgpu-core/src/command/clear.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ pub(crate) fn clear_texture<A: HalApi>(
) -> Result<(), ClearError> {
let snatch_guard = dst_texture.device.snatchable_lock.read();
let dst_raw = dst_texture
.as_raw(&snatch_guard)
.raw(&snatch_guard)
.ok_or_else(|| ClearError::InvalidTexture(dst_texture.as_info().id()))?;

// Issue the right barrier.
Expand Down
2 changes: 1 addition & 1 deletion wgpu-core/src/command/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ impl<A: HalApi> CommandBuffer<A> {
let texture_barriers = transitions
.into_iter()
.enumerate()
.map(|(i, p)| p.into_hal(textures[i].unwrap().as_raw().unwrap()));
.map(|(i, p)| p.into_hal(textures[i].unwrap().raw().unwrap()));

unsafe {
raw.transition_buffers(buffer_barriers);
Expand Down
8 changes: 4 additions & 4 deletions wgpu-core/src/command/transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
.set_single(&dst_texture, dst_range, hal::TextureUses::COPY_DST)
.ok_or(TransferError::InvalidTexture(destination.texture))?;
let dst_raw = dst_texture
.as_raw(&snatch_guard)
.raw(&snatch_guard)
.ok_or(TransferError::InvalidTexture(destination.texture))?;
if !dst_texture.desc.usage.contains(TextureUsages::COPY_DST) {
return Err(
Expand Down Expand Up @@ -949,7 +949,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
.set_single(&src_texture, src_range, hal::TextureUses::COPY_SRC)
.ok_or(TransferError::InvalidTexture(source.texture))?;
let src_raw = src_texture
.as_raw(&snatch_guard)
.raw(&snatch_guard)
.ok_or(TransferError::InvalidTexture(source.texture))?;
if !src_texture.desc.usage.contains(TextureUsages::COPY_SRC) {
return Err(TransferError::MissingCopySrcUsageFlag.into());
Expand Down Expand Up @@ -1163,7 +1163,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
.set_single(&src_texture, src_range, hal::TextureUses::COPY_SRC)
.ok_or(TransferError::InvalidTexture(source.texture))?;
let src_raw = src_texture
.as_raw(&snatch_guard)
.raw(&snatch_guard)
.ok_or(TransferError::InvalidTexture(source.texture))?;
if !src_texture.desc.usage.contains(TextureUsages::COPY_SRC) {
return Err(TransferError::MissingCopySrcUsageFlag.into());
Expand All @@ -1181,7 +1181,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
.set_single(&dst_texture, dst_range, hal::TextureUses::COPY_DST)
.ok_or(TransferError::InvalidTexture(destination.texture))?;
let dst_raw = dst_texture
.as_raw(&snatch_guard)
.raw(&snatch_guard)
.ok_or(TransferError::InvalidTexture(destination.texture))?;
if !dst_texture.desc.usage.contains(TextureUsages::COPY_DST) {
return Err(
Expand Down
8 changes: 4 additions & 4 deletions wgpu-core/src/device/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
.use_at(device.active_submission_index.load(Ordering::Relaxed) + 1);

let dst_raw = dst
.as_raw(&snatch_guard)
.raw(&snatch_guard)
.ok_or(TransferError::InvalidTexture(destination.texture))?;

let bytes_per_row = data_layout
Expand Down Expand Up @@ -1075,7 +1075,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {

let snatch_guard = device.snatchable_lock.read();
let dst_raw = dst
.as_raw(&snatch_guard)
.raw(&snatch_guard)
.ok_or(TransferError::InvalidTexture(destination.texture))?;

let regions = hal::TextureCopy {
Expand Down Expand Up @@ -1397,7 +1397,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
let texture_barriers = transitions
.into_iter()
.enumerate()
.map(|(i, p)| p.into_hal(textures[i].unwrap().as_raw().unwrap()));
.map(|(i, p)| p.into_hal(textures[i].unwrap().raw().unwrap()));
let present = unsafe {
baked.encoder.transition_textures(texture_barriers);
baked.encoder.end_encoding().unwrap()
Expand Down Expand Up @@ -1450,7 +1450,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
let texture_barriers = transitions
.into_iter()
.enumerate()
.map(|(i, p)| p.into_hal(textures[i].unwrap().as_raw().unwrap()));
.map(|(i, p)| p.into_hal(textures[i].unwrap().raw().unwrap()));
unsafe {
pending_writes
.command_encoder
Expand Down
2 changes: 1 addition & 1 deletion wgpu-core/src/device/resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -908,7 +908,7 @@ impl<A: HalApi> Device<A> {
let snatch_guard = texture.device.snatchable_lock.read();

let texture_raw = texture
.as_raw(&snatch_guard)
.raw(&snatch_guard)
.ok_or(resource::CreateTextureViewError::InvalidTexture)?;

// resolve TextureViewDescriptor defaults
Expand Down
8 changes: 4 additions & 4 deletions wgpu-core/src/resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@ pub(crate) enum TextureInner<A: HalApi> {
}

impl<A: HalApi> TextureInner<A> {
pub fn as_raw(&self) -> Option<&A::Texture> {
pub fn raw(&self) -> Option<&A::Texture> {
match self {
Self::Native { raw } => Some(raw),
Self::Surface { raw: Some(tex), .. } => Some(tex.borrow()),
Expand Down Expand Up @@ -797,8 +797,8 @@ impl<A: HalApi> Drop for Texture<A> {
}

impl<A: HalApi> Texture<A> {
pub(crate) fn as_raw<'a>(&'a self, snatch_guard: &'a SnatchGuard) -> Option<&'a A::Texture> {
self.inner.get(snatch_guard)?.as_raw()
pub(crate) fn raw<'a>(&'a self, snatch_guard: &'a SnatchGuard) -> Option<&'a A::Texture> {
self.inner.get(snatch_guard)?.raw()
}

pub(crate) fn inner_mut<'a>(
Expand Down Expand Up @@ -852,7 +852,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
let texture_opt = { hub.textures.try_get(id).ok().flatten() };
let texture = texture_opt.as_ref().unwrap();
let snatch_guard = texture.device.snatchable_lock.read();
let hal_texture = texture.as_raw(&snatch_guard);
let hal_texture = texture.raw(&snatch_guard);

hal_texture_callback(hal_texture);
}
Expand Down

0 comments on commit defd43d

Please sign in to comment.