mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-22 06:44:14 +00:00
Rust wrapper update the command buffers and queues
This commit is contained in:
parent
c013fc9498
commit
92c16a193e
@ -16,4 +16,4 @@ script:
|
||||
- cargo test
|
||||
- cargo build --manifest-path wgpu-native/Cargo.toml --features remote
|
||||
- cargo build
|
||||
- (cd examples && make)
|
||||
#- (cd examples && make) #TODO
|
||||
|
@ -17,4 +17,9 @@ fn main() {
|
||||
let _vs = device.create_shader_module(vs_bytes);
|
||||
let fs_bytes = include_bytes!("./../data/hello_triangle.frag.spv");
|
||||
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]);
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ extern crate wgpu_native as wgn;
|
||||
pub use wgn::{
|
||||
Color, Origin3d, Extent3d,
|
||||
AdapterDescriptor, Extensions, DeviceDescriptor, PowerPreference,
|
||||
ShaderModuleDescriptor,
|
||||
ShaderModuleDescriptor, CommandBufferDescriptor,
|
||||
};
|
||||
|
||||
|
||||
@ -23,6 +23,14 @@ pub struct ShaderModule {
|
||||
id: wgn::ShaderModuleId,
|
||||
}
|
||||
|
||||
pub struct CommandBuffer {
|
||||
id: wgn::CommandBufferId,
|
||||
}
|
||||
|
||||
pub struct Queue {
|
||||
id: wgn::QueueId,
|
||||
}
|
||||
|
||||
|
||||
impl Instance {
|
||||
pub fn new() -> Self {
|
||||
@ -58,4 +66,26 @@ impl Device {
|
||||
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(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user