mirror of
https://github.com/gfx-rs/wgpu.git
synced 2025-12-08 21:26:17 +00:00
First bits of wgpu-rs
This commit is contained in:
parent
fc3b6fc3cb
commit
53c75d6aed
7
Cargo.lock
generated
7
Cargo.lock
generated
@ -908,6 +908,13 @@ dependencies = [
|
|||||||
"lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wgpu"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"wgpu-native 0.1.0",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wgpu-bindings"
|
name = "wgpu-bindings"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
|||||||
@ -2,5 +2,6 @@
|
|||||||
members = [
|
members = [
|
||||||
"wgpu-native",
|
"wgpu-native",
|
||||||
"wgpu-bindings",
|
"wgpu-bindings",
|
||||||
|
"wgpu-rs",
|
||||||
"examples",
|
"examples",
|
||||||
]
|
]
|
||||||
|
|||||||
@ -14,9 +14,9 @@ path = "hello_triangle_rust/main.rs"
|
|||||||
[features]
|
[features]
|
||||||
default = []
|
default = []
|
||||||
remote = ["wgpu-native/remote"]
|
remote = ["wgpu-native/remote"]
|
||||||
metal = ["wgpu-native/metal"]
|
metal = ["wgpu-native/gfx-backend-metal"]
|
||||||
dx12 = ["wgpu-native/dx12"]
|
dx12 = ["wgpu-native/gfx-backend-dx12"]
|
||||||
vulkan = ["wgpu-native/vulkan"]
|
vulkan = ["wgpu-native/gfx-backend-vulkan"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
wgpu-native = { path = "../wgpu-native" }
|
wgpu-native = { path = "../wgpu-native" }
|
||||||
|
|||||||
@ -12,9 +12,6 @@ crate-type = ["lib", "cdylib", "staticlib"]
|
|||||||
[features]
|
[features]
|
||||||
default = []
|
default = []
|
||||||
remote = ["parking_lot"]
|
remote = ["parking_lot"]
|
||||||
metal = ["gfx-backend-metal"]
|
|
||||||
dx12 = ["gfx-backend-dx12"]
|
|
||||||
vulkan = ["gfx-backend-vulkan"]
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bitflags = "1.0"
|
bitflags = "1.0"
|
||||||
|
|||||||
18
wgpu-rs/Cargo.toml
Normal file
18
wgpu-rs/Cargo.toml
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
[package]
|
||||||
|
name = "wgpu"
|
||||||
|
version = "0.1.0"
|
||||||
|
authors = [
|
||||||
|
"Dzmitry Malyshau <kvark@mozilla.com>",
|
||||||
|
"Joshua Groves <josh@joshgroves.com>",
|
||||||
|
]
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = []
|
||||||
|
metal = ["wgpu-native/gfx-backend-metal"]
|
||||||
|
dx12 = ["wgpu-native/gfx-backend-dx12"]
|
||||||
|
vulkan = ["wgpu-native/gfx-backend-vulkan"]
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
wgpu-native = { path = "../wgpu-native" }
|
||||||
61
wgpu-rs/src/lib.rs
Normal file
61
wgpu-rs/src/lib.rs
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
extern crate wgpu_native as wgn;
|
||||||
|
|
||||||
|
pub use wgn::{
|
||||||
|
Color, Origin3d, Extent3d,
|
||||||
|
AdapterDescriptor, Extensions, DeviceDescriptor,
|
||||||
|
ShaderModuleDescriptor,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
pub struct Instance {
|
||||||
|
id: wgn::InstanceId,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct Adapter {
|
||||||
|
id: wgn::AdapterId,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct Device {
|
||||||
|
id: wgn::DeviceId,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct ShaderModule {
|
||||||
|
id: wgn::ShaderModuleId,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
impl Instance {
|
||||||
|
pub fn new() -> Self {
|
||||||
|
Instance {
|
||||||
|
id: wgn::wgpu_create_instance(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_adapter(&self, desc: AdapterDescriptor) -> Adapter {
|
||||||
|
Adapter {
|
||||||
|
id: wgn::wgpu_instance_get_adapter(self.id, desc),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Adapter {
|
||||||
|
pub fn create_device(&self, desc: DeviceDescriptor) -> Device {
|
||||||
|
Device {
|
||||||
|
id: wgn::wgpu_adapter_create_device(self.id, desc),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Device {
|
||||||
|
pub fn create_shader_module(&self, spv: &[u8]) -> ShaderModule {
|
||||||
|
let desc = wgn::ShaderModuleDescriptor{
|
||||||
|
code: wgn::ByteArray {
|
||||||
|
bytes: spv.as_ptr(),
|
||||||
|
length: spv.len(),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
ShaderModule {
|
||||||
|
id: wgn::wgpu_device_create_shader_module(self.id, desc),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user