mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-21 22:33:49 +00:00
Create general queue group
This commit is contained in:
parent
ed01eb04ad
commit
569c5fbeb7
@ -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<B: hal::Backend> {
|
||||
gpu: hal::Gpu<B>,
|
||||
device: B::Device,
|
||||
queue_group: QueueGroup<B, hal::General>,
|
||||
allocator: memory::SmartAllocator<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 {
|
||||
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,
|
||||
})
|
||||
|
@ -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))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user