mirror of
https://github.com/gfx-rs/wgpu.git
synced 2025-12-08 21:26:17 +00:00
Add TextureView::texture (#7907)
This commit is contained in:
parent
13fec87fb2
commit
a851eba5f6
@ -51,6 +51,13 @@ Previously, if you wanted to get access to the wgpu-hal or underlying api types,
|
||||
|
||||
### New Features
|
||||
|
||||
#### New method `TextureView::texture`
|
||||
|
||||
You can now call `texture_view.texture()` to get access to the texture that
|
||||
a given texture view points to.
|
||||
|
||||
By @cwfitzgerald in [#7907](https://github.com/gfx-rs/wgpu/pull/7907).
|
||||
|
||||
#### Naga
|
||||
|
||||
- Added `no_std` support with default features disabled. By @Bushrat011899 in [#7585](https://github.com/gfx-rs/wgpu/pull/7585).
|
||||
|
||||
@ -169,8 +169,9 @@ async fn draw_test_with_reports(
|
||||
assert_eq!(report.buffers.num_allocated, 1);
|
||||
assert_eq!(report.texture_views.num_allocated, 1);
|
||||
assert_eq!(report.texture_views.num_kept_from_user, 1);
|
||||
assert_eq!(report.textures.num_allocated, 0);
|
||||
assert_eq!(report.textures.num_kept_from_user, 0);
|
||||
// TextureViews in `wgpu` have a reference to the texture.
|
||||
assert_eq!(report.textures.num_allocated, 1);
|
||||
assert_eq!(report.textures.num_kept_from_user, 1);
|
||||
|
||||
let mut encoder = ctx
|
||||
.device
|
||||
@ -208,7 +209,7 @@ async fn draw_test_with_reports(
|
||||
assert_eq!(report.command_buffers.num_allocated, 1);
|
||||
assert_eq!(report.render_bundles.num_allocated, 0);
|
||||
assert_eq!(report.texture_views.num_allocated, 1);
|
||||
assert_eq!(report.textures.num_allocated, 0);
|
||||
assert_eq!(report.textures.num_allocated, 1);
|
||||
|
||||
function(&mut rpass);
|
||||
|
||||
|
||||
@ -70,7 +70,10 @@ impl Texture {
|
||||
pub fn create_view(&self, desc: &TextureViewDescriptor<'_>) -> TextureView {
|
||||
let view = self.inner.create_view(desc);
|
||||
|
||||
TextureView { inner: view }
|
||||
TextureView {
|
||||
inner: view,
|
||||
texture: self.clone(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Destroy the associated native resources as soon as possible.
|
||||
|
||||
@ -15,6 +15,7 @@ use crate::*;
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct TextureView {
|
||||
pub(crate) inner: dispatch::DispatchTextureView,
|
||||
pub(crate) texture: Texture,
|
||||
}
|
||||
#[cfg(send_sync)]
|
||||
static_assertions::assert_impl_all!(TextureView: Send, Sync);
|
||||
@ -22,6 +23,14 @@ static_assertions::assert_impl_all!(TextureView: Send, Sync);
|
||||
crate::cmp::impl_eq_ord_hash_proxy!(TextureView => .inner);
|
||||
|
||||
impl TextureView {
|
||||
/// Returns the [`Texture`] that this `TextureView` refers to.
|
||||
///
|
||||
/// All wgpu resources are refcounted, so you can own the returned [`Texture`]
|
||||
/// by cloning it.
|
||||
pub fn texture(&self) -> &Texture {
|
||||
&self.texture
|
||||
}
|
||||
|
||||
/// Get the [`wgpu_hal`] texture view from this `TextureView`.
|
||||
///
|
||||
/// Find the Api struct corresponding to the active backend in [`wgpu_hal::api`],
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user