show-image 0.14.1

quickly show images in a window for debugging
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
/// Reinterpret an object as bytes.
unsafe fn as_bytes<T>(value: &T) -> &[u8] {
	std::slice::from_raw_parts(value as *const T as *const u8, std::mem::size_of_val(value))
}

/// Create a [`wgpu::Buffer`] with an arbitrary object as contents.
pub fn create_buffer_with_value<T: Copy>(device: &wgpu::Device, label: Option<&str>, value: &T, usage: wgpu::BufferUsages) -> wgpu::Buffer {
	use wgpu::util::DeviceExt;
	unsafe {
		let contents = as_bytes(value);
		device.create_buffer_init(&wgpu::util::BufferInitDescriptor { label, contents, usage })
	}
}