Skip to content

Gecko integration bits #349

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions wgpu-remote/cbindgen.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
header = ""
header = """/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */"""
autogen_warning = """/* DO NOT MODIFY THIS MANUALLY! This file was generated using cbindgen.
* To generate this file:
* 1. Get the latest cbindgen using `cargo install --force cbindgen`
* a. Alternatively, you can clone `https://github.com/eqrion/cbindgen` and use a tagged release
* 2. Run `rustup run nightly cbindgen toolkit/library/rust/ --lockfile Cargo.lock --crate wgpu-remote -o dom/webgpu/ffi/wgpu_ffi_generated.h`
*/

typedef void WGPUEmpty;
"""
include_version = true
braces = "SameLine"
line_length = 100
tab_width = 2
language = "C"
language = "C++"

[export]
prefix = "WGPU"
Expand All @@ -14,6 +25,10 @@ parse_deps = true
include = ["wgpu-native"]

[fn]
prefix = "WGPU_INLINE"
postfix = "WGPU_FUNC"
args = "Vertical"
rename_args = "GeckoCase"

[struct]
derive_eq = true
Expand All @@ -24,3 +39,8 @@ derive_helper_methods = true

[macro_expansion]
bitflags = true

[defines]
"target_os = windows" = "XP_WIN"
"target_os = macos" = "XP_MACOSX"
"target_os = android" = "ANDROID"
3 changes: 1 addition & 2 deletions wgpu-remote/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use wgn::{AdapterId, Backend, DeviceId, IdentityManager, SurfaceId};
use crate::server::Server;

use ipc_channel::ipc;
use log::error;
use parking_lot::Mutex;
use serde::{Deserialize, Serialize};

Expand Down Expand Up @@ -124,7 +123,7 @@ pub extern "C" fn wgpu_initialize() -> Infrastructure {
}
}
Err(e) => {
error!("WGPU initialize failed: {:?}", e);
log::error!("WGPU initialize failed: {:?}", e);
Infrastructure {
client: ptr::null_mut(),
server: ptr::null_mut(),
Expand Down
17 changes: 17 additions & 0 deletions wgpu-remote/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,20 @@ pub extern "C" fn wgpu_server_process(server: &Server) {
}
}
}

#[no_mangle]
pub extern "C" fn wgpu_server_loop(server: *mut Server) {
assert!(!server.is_null());
log::info!("WGPU server loop started");
while let Ok(message) = unsafe { server.as_ref() }
.unwrap().channel.recv()
{
match process(message) {
ControlFlow::Continue => {}
ControlFlow::Terminate => break,
}
}
// drop the server
log::info!("WGPU server loop finished");
let _ = unsafe { Box::from_raw(server) };
}