Create general queue group

This commit is contained in:
grovesNL 2018-09-15 11:43:22 -06:00
parent ed01eb04ad
commit 569c5fbeb7
2 changed files with 14 additions and 9 deletions

View File

@ -1,4 +1,4 @@
use hal::{self, Device as _Device}; use hal::{self, Device as _Device, QueueGroup};
use memory; use memory;
use {BufferHandle, CommandBufferHandle, DeviceHandle}; use {BufferHandle, CommandBufferHandle, DeviceHandle};
@ -17,14 +17,20 @@ pub struct CommandBufferDescriptor {
} }
pub struct Device<B: hal::Backend> { pub struct Device<B: hal::Backend> {
gpu: hal::Gpu<B>, device: B::Device,
queue_group: QueueGroup<B, hal::General>,
allocator: memory::SmartAllocator<B>, allocator: memory::SmartAllocator<B>,
} }
impl<B: hal::Backend> Device<B> { impl<B: hal::Backend> Device<B> {
pub(crate) fn new(gpu: hal::Gpu<B>, mem_props: hal::MemoryProperties) -> Self { pub(crate) fn new(
device: B::Device,
queue_group: QueueGroup<B, hal::General>,
mem_props: hal::MemoryProperties,
) -> Self {
Device { Device {
gpu, device,
queue_group,
allocator: memory::SmartAllocator::new(mem_props, 1, 1, 1, 1), allocator: memory::SmartAllocator::new(mem_props, 1, 1, 1, 1),
} }
} }
@ -38,7 +44,7 @@ pub extern "C"
fn device_create_buffer( fn device_create_buffer(
device: DeviceHandle, desc: BufferDescriptor device: DeviceHandle, desc: BufferDescriptor
) -> BufferHandle { ) -> 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 { BufferHandle::new(Buffer {
raw: buffer, raw: buffer,
}) })

View File

@ -61,10 +61,9 @@ fn instance_get_adapter(
pub extern "C" pub extern "C"
fn adapter_create_device( fn adapter_create_device(
adapter: AdapterHandle, desc: DeviceDescriptor mut adapter: AdapterHandle, desc: DeviceDescriptor
) -> DeviceHandle { ) -> DeviceHandle {
let queue_family = &adapter.queue_families[0]; let (device, queue_group) = adapter.open_with::<_, hal::General>(1, |_qf| true).unwrap();
let gpu = adapter.physical_device.open(&[(queue_family, &[1f32])]).unwrap();
let mem_props = adapter.physical_device.memory_properties(); let mem_props = adapter.physical_device.memory_properties();
DeviceHandle::new(Device::new(gpu, mem_props)) DeviceHandle::new(Device::new(device, queue_group, mem_props))
} }