mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-19 14:01:08 +01:00
Root Makefile
This commit is contained in:
1 parent
0cad1f5d56
commit
32b92afa5c
7 files changed
+104
-25
No files matched your search
Generated
+3
-3
@@ -82,7 +82,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "cbindgen"
|
||||
version = "0.6.4"
|
||||
version = "0.6.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -1033,7 +1033,7 @@ dependencies = [
|
||||
name = "wgpu-bindings"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"cbindgen 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cbindgen 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1139,7 +1139,7 @@ dependencies = [
|
||||
"checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12"
|
||||
"checksum block 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a"
|
||||
"checksum byteorder 1.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "90492c5858dd7d2e78691cfb89f90d273a2800fc11d98f60786e5d87e2f83781"
|
||||
"checksum cbindgen 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "33dfad88cda0bab90ef91c4ae338f132ba6934ea59b6e352eb96f558b5a879d7"
|
||||
"checksum cbindgen 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "660a462ad3acdc79f83dcc84161d9e87f01cb29754b7ab5196785e1f0c11f714"
|
||||
"checksum cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)" = "f159dfd43363c4d08055a07703eb7a3406b0dac4d0584d96965a3262db3c9d16"
|
||||
"checksum cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0c4e7bb64a8ebb0d856483e1e682ea3422f883c5f5615a90d51a2c82fe87fdd3"
|
||||
"checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e"
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
RUST_BACKTRACE:=1
|
||||
EXCLUDES:=
|
||||
FEATURE_RUST:=
|
||||
FEATURE_NATIVE:=
|
||||
|
||||
ifeq (,$(TARGET))
|
||||
CHECK_TARGET_FLAG=
|
||||
else
|
||||
CHECK_TARGET_FLAG=--target $(TARGET)
|
||||
endif
|
||||
|
||||
ifeq ($(OS),Windows_NT)
|
||||
ifeq ($(TARGET),x86_64-pc-windows-gnu)
|
||||
FEATURE_RUST=vulkan
|
||||
FEATURE_NATIVE=gfx-backend-vulkan
|
||||
else
|
||||
FEATURE_RUST=dx12
|
||||
FEATURE_NATIVE=gfx-backend-dx12
|
||||
endif
|
||||
else
|
||||
UNAME_S:=$(shell uname -s)
|
||||
ifeq ($(UNAME_S),Linux)
|
||||
FEATURE_RUST=vulkan
|
||||
FEATURE_NATIVE=gfx-backend-vulkan
|
||||
endif
|
||||
ifeq ($(UNAME_S),Darwin)
|
||||
FEATURE_RUST=metal
|
||||
FEATURE_NATIVE=gfx-backend-metal
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
.PHONY: all check test doc clear lib-native lib-rust examples-native examples-rust
|
||||
|
||||
all: examples-native examples-rust
|
||||
|
||||
check:
|
||||
cargo check --all
|
||||
|
||||
test:
|
||||
cargo test --all --features "$(FEATURE_NATIVE) $(FEATURE_RUST)"
|
||||
|
||||
doc:
|
||||
cargo doc --all
|
||||
|
||||
clear:
|
||||
cargo clear
|
||||
rm wgpu-bindings/wgpu.h
|
||||
|
||||
lib-native: Cargo.lock wgpu-native/Cargo.toml $(wildcard wgpu-native/**/*.rs)
|
||||
cargo build --manifest-path wgpu-native/Cargo.toml --features $(FEATURE_NATIVE)
|
||||
|
||||
lib-rust: Cargo.lock wgpu-rs/Cargo.toml $(wildcard wgpu-rs/**/*.rs)
|
||||
cargo build --manifest-path wgpu-rs/Cargo.toml --features $(FEATURE_RUST)
|
||||
|
||||
wgpu-bindings/wgpu.h: Cargo.lock wgpu-bindings/src/*.rs lib-native
|
||||
cargo +nightly run --manifest-path wgpu-bindings/Cargo.toml
|
||||
|
||||
examples-native: lib-native wgpu-bindings/wgpu.h $(wildcard wgpu-native/**/*.c)
|
||||
$(MAKE) -C examples
|
||||
|
||||
examples-rust: lib-rust examples/Cargo.toml $(wildcard wgpu-native/**/*.rs)
|
||||
cargo build --manifest-path examples/Cargo.toml --bin hello_triangle --features $(FEATURE_RUST)
|
||||
@@ -40,7 +40,7 @@ int main()
|
||||
.bindings_length = 0,
|
||||
};
|
||||
WGPUBindGroupLayoutId _bind_group_layout = wgpu_device_create_bind_group_layout(device, &bind_group_layout_desc);
|
||||
|
||||
|
||||
WGPUPipelineLayoutDescriptor pipeline_layout_desc = {
|
||||
.bind_group_layouts = NULL,
|
||||
.bind_group_layouts_length = 0,
|
||||
@@ -116,7 +116,7 @@ int main()
|
||||
.formats_length = FORMATS_LENGTH,
|
||||
};
|
||||
WGPUAttachmentStateId attachment_state = wgpu_device_create_attachment_state(device, &attachment_state_desc);
|
||||
|
||||
|
||||
WGPURenderPipelineDescriptor render_pipeline_desc = {
|
||||
.layout = layout,
|
||||
.stages = stages,
|
||||
|
||||
@@ -10,4 +10,4 @@ authors = [
|
||||
default = []
|
||||
|
||||
[dependencies]
|
||||
cbindgen = "0.6.3"
|
||||
cbindgen = "0.6.6"
|
||||
@@ -11,8 +11,8 @@ const HEADER: &str = "
|
||||
";
|
||||
|
||||
fn main() {
|
||||
let mut crate_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
||||
crate_dir.push("../wgpu-native");
|
||||
let crate_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
||||
let source_dir = crate_dir.parent().unwrap().join("wgpu-native");
|
||||
|
||||
let config = cbindgen::Config {
|
||||
header: Some(String::from(HEADER.trim())),
|
||||
@@ -33,9 +33,10 @@ fn main() {
|
||||
};
|
||||
|
||||
cbindgen::Builder::new()
|
||||
.with_crate(crate_dir)
|
||||
.with_crate(source_dir)
|
||||
.with_config(config)
|
||||
.with_parse_expand(&["wgpu-native"])
|
||||
.generate()
|
||||
.unwrap()
|
||||
.write_to_file("wgpu.h");
|
||||
.write_to_file(crate_dir.join("wgpu.h"));
|
||||
}
|
||||
+28
-14
@@ -28,20 +28,6 @@
|
||||
|
||||
#define WGPUShaderStageFlags_VERTEX 1
|
||||
|
||||
#define WGPUTextureUsageFlags_NONE 0
|
||||
|
||||
#define WGPUTextureUsageFlags_OUTPUT_ATTACHMENT 16
|
||||
|
||||
#define WGPUTextureUsageFlags_PRESENT 32
|
||||
|
||||
#define WGPUTextureUsageFlags_SAMPLED 4
|
||||
|
||||
#define WGPUTextureUsageFlags_STORAGE 8
|
||||
|
||||
#define WGPUTextureUsageFlags_TRANSFER_DST 2
|
||||
|
||||
#define WGPUTextureUsageFlags_TRANSFER_SRC 1
|
||||
|
||||
typedef enum {
|
||||
WGPUBindingType_UniformBuffer = 0,
|
||||
WGPUBindingType_Sampler = 1,
|
||||
@@ -276,12 +262,40 @@ typedef struct {
|
||||
|
||||
#define WGPUBLUE (Color){ .r = 0, .g = 0, .b = 1, .a = 1 }
|
||||
|
||||
#define WGPUEXTEND (TrackPermit){ .bits = 1 }
|
||||
|
||||
#define WGPUGREEN (Color){ .r = 0, .g = 1, .b = 0, .a = 1 }
|
||||
|
||||
#define WGPUINDEX (BufferUsageFlags){ .bits = 16 }
|
||||
|
||||
#define WGPUMAP_READ (BufferUsageFlags){ .bits = 1 }
|
||||
|
||||
#define WGPUMAP_WRITE (BufferUsageFlags){ .bits = 2 }
|
||||
|
||||
#define WGPUNONE (BufferUsageFlags){ .bits = 0 }
|
||||
|
||||
#define WGPUOUTPUT_ATTACHMENT (TextureUsageFlags){ .bits = 16 }
|
||||
|
||||
#define WGPUPRESENT (TextureUsageFlags){ .bits = 32 }
|
||||
|
||||
#define WGPURED (Color){ .r = 1, .g = 0, .b = 0, .a = 1 }
|
||||
|
||||
#define WGPUREPLACE (TrackPermit){ .bits = 2 }
|
||||
|
||||
#define WGPUSAMPLED (TextureUsageFlags){ .bits = 4 }
|
||||
|
||||
#define WGPUSTORAGE (BufferUsageFlags){ .bits = 128 }
|
||||
|
||||
#define WGPUTRANSFER_DST (BufferUsageFlags){ .bits = 8 }
|
||||
|
||||
#define WGPUTRANSFER_SRC (BufferUsageFlags){ .bits = 4 }
|
||||
|
||||
#define WGPUTRANSPARENT (Color){ .r = 0, .g = 0, .b = 0, .a = 0 }
|
||||
|
||||
#define WGPUUNIFORM (BufferUsageFlags){ .bits = 64 }
|
||||
|
||||
#define WGPUVERTEX (BufferUsageFlags){ .bits = 32 }
|
||||
|
||||
#define WGPUWHITE (Color){ .r = 1, .g = 1, .b = 1, .a = 1 }
|
||||
|
||||
WGPUDeviceId wgpu_adapter_create_device(WGPUAdapterId adapter_id,
|
||||
|
||||
@@ -26,7 +26,8 @@ pub struct BufferDescriptor {
|
||||
}
|
||||
|
||||
pub(crate) struct Buffer<B: hal::Backend> {
|
||||
pub raw: B::UnboundBuffer,
|
||||
//pub raw: B::UnboundBuffer,
|
||||
pub raw: B::Buffer,
|
||||
pub memory_properties: hal::memory::Properties,
|
||||
// TODO: mapping, unmap()
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user