diff --git a/ffi/wgpu.h b/ffi/wgpu.h index 49781794..356fe306 100644 --- a/ffi/wgpu.h +++ b/ffi/wgpu.h @@ -70,6 +70,9 @@ void wgpuSetLogLevel(WGPULogLevel level); uint32_t wgpuGetVersion(void); +// Returns resource usage C string; caller owns the string and must free() it +char* wgpuGetResourceUsageString(); + void wgpuRenderPassEncoderSetPushConstants(WGPURenderPassEncoder encoder, WGPUShaderStageFlags stages, uint32_t offset, uint32_t sizeBytes, void* const data); void wgpuBufferDrop(WGPUBuffer buffer); diff --git a/src/lib.rs b/src/lib.rs index 57012cd7..fd0fb758 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -213,6 +213,14 @@ pub extern "C" fn wgpuCreateInstance( 8 as native::WGPUInstance } +#[no_mangle] +pub extern "C" fn wgpuGetResourceUsageString() -> *const std::os::raw::c_char { + let c_string = CString::new(format!("{:?}", GLOBAL.generate_report())).unwrap(); + let ptr = c_string.as_ptr(); + std::mem::forget(c_string); + ptr +} + #[no_mangle] pub unsafe extern "C" fn wgpuInstanceCreateSurface( _: native::WGPUInstance,