Skip to content

Commit 736a4c2

Browse files
committed
Added resource counter. Bumped the version number
1 parent e00ff3e commit 736a4c2

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
[package]
1616
name = "gfx"
17-
version = "0.2.1"
17+
version = "0.2.2"
1818
description = "A high-performance, bindless graphics API"
1919
homepage = "https://github.com/gfx-rs/gfx-rs"
2020
repository = "https://github.com/gfx-rs/gfx-rs"

src/device/handle.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,8 @@ pub trait Producer<R: Resources> {
177177
fn make_surface(&mut self, R::Surface, tex::SurfaceInfo) -> Surface<R>;
178178
fn make_texture(&mut self, R::Texture, tex::TextureInfo) -> Texture<R>;
179179
fn make_sampler(&mut self, R::Sampler, tex::SamplerInfo) -> Sampler<R>;
180+
/// Walk through all the handles, keep ones that are reference elsewhere
181+
/// and call the provided delete function (resource-specific) for others
180182
fn clean_with<T,
181183
F1: Fn(&mut T, &R::Buffer),
182184
F2: Fn(&mut T, &R::ArrayBuffer),
@@ -298,6 +300,17 @@ impl<R: Resources> Manager<R> {
298300
self.textures .extend(other.textures .iter().map(|h| h.clone()));
299301
self.samplers .extend(other.samplers .iter().map(|h| h.clone()));
300302
}
303+
/// Count the total number of referenced resources
304+
pub fn count(&self) -> usize {
305+
self.buffers.len() +
306+
self.array_buffers.len() +
307+
self.shaders.len() +
308+
self.programs.len() +
309+
self.frame_buffers.len() +
310+
self.surfaces.len() +
311+
self.textures.len() +
312+
self.samplers.len()
313+
}
301314
/// Reference a buffer
302315
pub fn ref_buffer(&mut self, handle: &RawBuffer<R>) -> R::Buffer {
303316
self.buffers.push(handle.0.clone());

0 commit comments

Comments
 (0)