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:
42
42
43
43
### New Features
44
44
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
+
45
52
#### Naga
46
53
47
54
- 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(
169
169
assert_eq ! ( report. buffers. num_allocated, 1 ) ;
170
170
assert_eq ! ( report. texture_views. num_allocated, 1 ) ;
171
171
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 ) ;
174
175
175
176
let mut encoder = ctx
176
177
. device
Original file line number Diff line number Diff line change @@ -51,7 +51,10 @@ impl Texture {
51
51
pub fn create_view ( & self , desc : & TextureViewDescriptor < ' _ > ) -> TextureView {
52
52
let view = self . inner . create_view ( desc) ;
53
53
54
- TextureView { inner : view }
54
+ TextureView {
55
+ inner : view,
56
+ texture : self . clone ( ) ,
57
+ }
55
58
}
56
59
57
60
/// 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::*;
12
12
#[ derive( Debug , Clone ) ]
13
13
pub struct TextureView {
14
14
pub ( crate ) inner : dispatch:: DispatchTextureView ,
15
+ pub ( crate ) texture : Texture ,
15
16
}
16
17
#[ cfg( send_sync) ]
17
18
static_assertions:: assert_impl_all!( TextureView : Send , Sync ) ;
18
19
19
20
crate :: cmp:: impl_eq_ord_hash_proxy!( TextureView => . inner) ;
20
21
21
22
impl 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
+
22
31
/// Returns the inner hal `TextureView` using a callback. The hal texture will be `None` if the
23
32
/// backend type argument does not match with this wgpu Texture
24
33
///
You can’t perform that action at this time.
0 commit comments