Rust wrapper update the command buffers and queues

This commit is contained in:
Dzmitry Malyshau 2018-09-27 19:17:43 -04:00
parent c013fc9498
commit 92c16a193e
3 changed files with 37 additions and 2 deletions

View File

@ -16,4 +16,4 @@ script:
- cargo test - cargo test
- cargo build --manifest-path wgpu-native/Cargo.toml --features remote - cargo build --manifest-path wgpu-native/Cargo.toml --features remote
- cargo build - cargo build
- (cd examples && make) #- (cd examples && make) #TODO

View File

@ -17,4 +17,9 @@ fn main() {
let _vs = device.create_shader_module(vs_bytes); let _vs = device.create_shader_module(vs_bytes);
let fs_bytes = include_bytes!("./../data/hello_triangle.frag.spv"); let fs_bytes = include_bytes!("./../data/hello_triangle.frag.spv");
let _fs = device.create_shader_module(fs_bytes); let _fs = device.create_shader_module(fs_bytes);
let cmd_buf = device.create_command_buffer(wgpu::CommandBufferDescriptor {
});
let queue = device.get_queue();
queue.submit(&[cmd_buf]);
} }

View File

@ -3,7 +3,7 @@ extern crate wgpu_native as wgn;
pub use wgn::{ pub use wgn::{
Color, Origin3d, Extent3d, Color, Origin3d, Extent3d,
AdapterDescriptor, Extensions, DeviceDescriptor, PowerPreference, AdapterDescriptor, Extensions, DeviceDescriptor, PowerPreference,
ShaderModuleDescriptor, ShaderModuleDescriptor, CommandBufferDescriptor,
}; };
@ -23,6 +23,14 @@ pub struct ShaderModule {
id: wgn::ShaderModuleId, id: wgn::ShaderModuleId,
} }
pub struct CommandBuffer {
id: wgn::CommandBufferId,
}
pub struct Queue {
id: wgn::QueueId,
}
impl Instance { impl Instance {
pub fn new() -> Self { pub fn new() -> Self {
@ -58,4 +66,26 @@ impl Device {
id: wgn::wgpu_device_create_shader_module(self.id, desc), id: wgn::wgpu_device_create_shader_module(self.id, desc),
} }
} }
pub fn get_queue(&self) -> Queue {
Queue {
id: wgn::wgpu_device_get_queue(self.id),
}
}
pub fn create_command_buffer(&self, desc: CommandBufferDescriptor) -> CommandBuffer {
CommandBuffer {
id: wgn::wgpu_device_create_command_buffer(self.id, desc),
}
}
}
impl Queue {
pub fn submit(&self, command_buffers: &[CommandBuffer]) {
wgn::wgpu_queue_submit(
self.id,
command_buffers.as_ptr() as *const _,
command_buffers.len(),
);
}
} }