File tree Expand file tree Collapse file tree 4 files changed +23
-3
lines changed Expand file tree Collapse file tree 4 files changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -42,6 +42,13 @@ Bottom level categories:
4242
4343### New Features
4444
45+ #### New method ` TextureView::texture `
46+
47+ You can now call ` texture_view.texture() ` to get access to the texture that
48+ a given texture view points to.
49+
50+ By @cwfitzgerald in [ #7907 ] ( https://github.com/gfx-rs/wgpu/pull/7907 ) .
51+
4552#### Naga
4653
4754- Added ` no_std ` support with default features disabled. By @Bushrat011899 in [ #7585 ] ( https://github.com/gfx-rs/wgpu/pull/7585 ) .
Original file line number Diff line number Diff line change @@ -169,8 +169,9 @@ async fn draw_test_with_reports(
169169 assert_eq ! ( report. buffers. num_allocated, 1 ) ;
170170 assert_eq ! ( report. texture_views. num_allocated, 1 ) ;
171171 assert_eq ! ( report. texture_views. num_kept_from_user, 1 ) ;
172- assert_eq ! ( report. textures. num_allocated, 0 ) ;
173- assert_eq ! ( report. textures. num_kept_from_user, 0 ) ;
172+ // TextureViews in `wgpu` have a reference to the texture.
173+ assert_eq ! ( report. textures. num_allocated, 1 ) ;
174+ assert_eq ! ( report. textures. num_kept_from_user, 1 ) ;
174175
175176 let mut encoder = ctx
176177 . device
Original file line number Diff line number Diff line change @@ -51,7 +51,10 @@ impl Texture {
5151 pub fn create_view ( & self , desc : & TextureViewDescriptor < ' _ > ) -> TextureView {
5252 let view = self . inner . create_view ( desc) ;
5353
54- TextureView { inner : view }
54+ TextureView {
55+ inner : view,
56+ texture : self . clone ( ) ,
57+ }
5558 }
5659
5760 /// Destroy the associated native resources as soon as possible.
Original file line number Diff line number Diff line change @@ -12,13 +12,22 @@ use crate::*;
1212#[ derive( Debug , Clone ) ]
1313pub struct TextureView {
1414 pub ( crate ) inner : dispatch:: DispatchTextureView ,
15+ pub ( crate ) texture : Texture ,
1516}
1617#[ cfg( send_sync) ]
1718static_assertions:: assert_impl_all!( TextureView : Send , Sync ) ;
1819
1920crate :: cmp:: impl_eq_ord_hash_proxy!( TextureView => . inner) ;
2021
2122impl TextureView {
23+ /// Returns the [`Texture`] that this `TextureView` refers to.
24+ ///
25+ /// All wgpu resources are refcounted, so you can own the returned [`Texture`]
26+ /// by cloning it.
27+ pub fn texture ( & self ) -> & Texture {
28+ & self . texture
29+ }
30+
2231 /// Returns the inner hal `TextureView` using a callback. The hal texture will be `None` if the
2332 /// backend type argument does not match with this wgpu Texture
2433 ///
You can’t perform that action at this time.
0 commit comments