2020-11-20 04:29:57 +11:00
|
|
|
//! An example to exercise the dx12 backend, while it's being developed.
|
|
|
|
//! This will probably go away when it's fully implemented and we can
|
|
|
|
//! just use the hub.
|
|
|
|
|
2021-04-30 15:06:13 +10:00
|
|
|
use piet_gpu_hal::{dx12, Device, Error, MemFlags};
|
2020-11-20 04:29:57 +11:00
|
|
|
|
|
|
|
fn toy() -> Result<(), Error> {
|
|
|
|
let instance = dx12::Dx12Instance::new()?;
|
|
|
|
let device = instance.device()?;
|
2021-04-30 15:06:13 +10:00
|
|
|
let buf = device.create_buffer(1024, MemFlags::host_coherent())?;
|
|
|
|
let data: Vec<u32> = (0..256).collect();
|
|
|
|
unsafe {
|
|
|
|
device.write_buffer(&buf, &data)?;
|
|
|
|
let mut readback: Vec<u32> = Vec::new();
|
|
|
|
device.read_buffer(&buf, &mut readback)?;
|
|
|
|
println!("{:?}", readback);
|
|
|
|
}
|
2020-11-20 04:29:57 +11:00
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
toy().unwrap();
|
|
|
|
println!("hello dx12");
|
|
|
|
}
|