diff --git a/src/device.rs b/src/device.rs index 5a6eb9878..36041ed6f 100644 --- a/src/device.rs +++ b/src/device.rs @@ -1,4 +1,4 @@ -use hal::{self, Device as _Device}; +use hal::{self, Device as _Device, QueueGroup}; use memory; use {BufferHandle, CommandBufferHandle, DeviceHandle}; @@ -17,14 +17,20 @@ pub struct CommandBufferDescriptor { } pub struct Device { - gpu: hal::Gpu, + device: B::Device, + queue_group: QueueGroup, allocator: memory::SmartAllocator, } impl Device { - pub(crate) fn new(gpu: hal::Gpu, mem_props: hal::MemoryProperties) -> Self { + pub(crate) fn new( + device: B::Device, + queue_group: QueueGroup, + mem_props: hal::MemoryProperties, + ) -> Self { Device { - gpu, + device, + queue_group, allocator: memory::SmartAllocator::new(mem_props, 1, 1, 1, 1), } } @@ -38,7 +44,7 @@ pub extern "C" fn device_create_buffer( device: DeviceHandle, desc: BufferDescriptor ) -> BufferHandle { - let buffer = device.gpu.device.create_buffer(desc.size, desc.usage).unwrap(); + let buffer = device.device.create_buffer(desc.size, desc.usage).unwrap(); BufferHandle::new(Buffer { raw: buffer, }) diff --git a/src/instance.rs b/src/instance.rs index 316ee1e4f..de11a2bab 100644 --- a/src/instance.rs +++ b/src/instance.rs @@ -61,10 +61,9 @@ fn instance_get_adapter( pub extern "C" fn adapter_create_device( - adapter: AdapterHandle, desc: DeviceDescriptor + mut adapter: AdapterHandle, desc: DeviceDescriptor ) -> DeviceHandle { - let queue_family = &adapter.queue_families[0]; - let gpu = adapter.physical_device.open(&[(queue_family, &[1f32])]).unwrap(); + let (device, queue_group) = adapter.open_with::<_, hal::General>(1, |_qf| true).unwrap(); let mem_props = adapter.physical_device.memory_properties(); - DeviceHandle::new(Device::new(gpu, mem_props)) + DeviceHandle::new(Device::new(device, queue_group, mem_props)) }