mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-22 06:44:14 +00:00
Global manager for instance names on the remote client
This commit is contained in:
parent
52ee3e019c
commit
0011d9f4ff
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -1428,6 +1428,7 @@ name = "wgpu-remote"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"ipc-channel 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
7
Makefile
7
Makefile
@ -30,9 +30,9 @@ else
|
||||
endif
|
||||
|
||||
|
||||
.PHONY: all check test doc clear lib-native lib-remote lib-rust ci-examples examples-native examples-rust examples-gfx gfx
|
||||
.PHONY: all check test doc clear lib-native lib-remote lib-rust ci-examples examples-rust examples-gfx gfx
|
||||
|
||||
all: examples-native examples-rust examples-gfx
|
||||
all: ci-examples examples-rust examples-gfx
|
||||
|
||||
check:
|
||||
cargo check --all
|
||||
@ -59,9 +59,6 @@ lib-rust: Cargo.lock wgpu-rs/Cargo.toml $(wildcard wgpu-rs/**/*.rs)
|
||||
wgpu-bindings/*.h: Cargo.lock $(wildcard wgpu-bindings/src/*.rs) lib-native lib-remote
|
||||
cargo +nightly run --manifest-path wgpu-bindings/Cargo.toml
|
||||
|
||||
examples-native: lib-native wgpu-bindings/wgpu.h $(wildcard wgpu-native/**/*.c)
|
||||
#$(MAKE) -C examples
|
||||
|
||||
ci-examples:
|
||||
cargo build --manifest-path wgpu-native/Cargo.toml --features=local,$(FEATURE_NATIVE)
|
||||
cargo build --manifest-path wgpu-remote/Cargo.toml --features=$(FEATURE_RUST)
|
||||
|
@ -156,7 +156,7 @@ int main() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
WGPUSurfaceId surface = {};
|
||||
WGPUSurfaceId surface;
|
||||
|
||||
#if WGPU_TARGET == WGPU_TARGET_MACOS
|
||||
{
|
||||
@ -183,6 +183,8 @@ int main() {
|
||||
surface = wgpu_instance_create_surface_from_windows_hwnd(
|
||||
instance, hinstance, hwnd);
|
||||
}
|
||||
#else
|
||||
#error "Unsupported WGPU_TARGET"
|
||||
#endif
|
||||
|
||||
WGPUSwapChainId swap_chain = wgpu_device_create_swap_chain(device, surface,
|
||||
|
@ -29,7 +29,7 @@ copyless = "0.1"
|
||||
lazy_static = "1.1.0"
|
||||
log = "0.4"
|
||||
parking_lot = { version = "0.7" }
|
||||
gfx-hal = "0.1.0"
|
||||
hal = { package = "gfx-hal", version = "0.1" }
|
||||
gfx-backend-empty = { version = "0.1.1" }
|
||||
gfx-backend-vulkan = { version = "0.1", optional = true }
|
||||
gfx-backend-dx11 = { version = "0.1", optional = true }
|
||||
|
@ -17,9 +17,6 @@ extern crate gfx_backend_metal as back;
|
||||
#[cfg(feature = "gfx-backend-vulkan")]
|
||||
extern crate gfx_backend_vulkan as back;
|
||||
|
||||
extern crate gfx_hal as hal;
|
||||
//extern crate rendy_memory;
|
||||
|
||||
mod binding_model;
|
||||
mod command;
|
||||
mod conv;
|
||||
|
@ -20,6 +20,7 @@ metal = ["wgn/gfx-backend-metal"]
|
||||
[dependencies]
|
||||
wgn = { package = "wgpu-native", path = "../wgpu-native", features = ["remote"] }
|
||||
ipc-channel = "0.11"
|
||||
lazy_static = "1"
|
||||
log = "0.4"
|
||||
parking_lot = { version = "0.7" }
|
||||
serde = { version = "1.0", features = ["serde_derive"] }
|
||||
|
@ -1,6 +1,7 @@
|
||||
use crate::server::Server;
|
||||
|
||||
use ipc_channel::ipc;
|
||||
use lazy_static::lazy_static;
|
||||
use log::error;
|
||||
use parking_lot::Mutex;
|
||||
use serde::{Deserialize, Serialize};
|
||||
@ -11,6 +12,10 @@ use std::ptr;
|
||||
mod server;
|
||||
|
||||
|
||||
lazy_static! {
|
||||
static ref INSTANCE_IDENTITIES: Mutex<wgn::IdentityManager> = Mutex::new(wgn::IdentityManager::default());
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
enum InstanceMessage {
|
||||
InstanceGetAdapter(wgn::InstanceId, wgn::AdapterDescriptor, wgn::AdapterId),
|
||||
@ -64,7 +69,7 @@ pub struct Infrastructure {
|
||||
pub extern "C" fn wgpu_initialize() -> Infrastructure {
|
||||
match ipc::channel() {
|
||||
Ok((sender, receiver)) => {
|
||||
let instance_id = wgn::IdentityManager::default().alloc(); // TODO: static
|
||||
let instance_id = INSTANCE_IDENTITIES.lock().alloc();
|
||||
let client = Client::new(sender, instance_id);
|
||||
let server = Server::new(receiver, instance_id);
|
||||
Infrastructure {
|
||||
@ -90,6 +95,7 @@ pub extern "C" fn wgpu_terminate(client: *mut Client) {
|
||||
let client = unsafe {
|
||||
Box::from_raw(client)
|
||||
};
|
||||
INSTANCE_IDENTITIES.lock().free(client.instance_id);
|
||||
let _ = client.channel.send(GlobalMessage::Instance(InstanceMessage::Terminate));
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,3 @@
|
||||
extern crate arrayvec;
|
||||
extern crate wgn;
|
||||
|
||||
use arrayvec::ArrayVec;
|
||||
|
||||
use std::ffi::CString;
|
||||
|
Loading…
Reference in New Issue
Block a user