mirror of
https://github.com/italicsjenga/vello.git
synced 2025-01-10 12:41:30 +11:00
Make pgpu-render
compile on non apple platforms
Also add `resolver="2"` to the entire workspace, in case we gain a wgpu dependency
This commit is contained in:
parent
60d197bb4e
commit
28cbc8f199
|
@ -1,4 +1,5 @@
|
||||||
[workspace]
|
[workspace]
|
||||||
|
resolver = "2"
|
||||||
|
|
||||||
members = [
|
members = [
|
||||||
"pgpu-render",
|
"pgpu-render",
|
||||||
|
@ -7,5 +8,5 @@ members = [
|
||||||
"piet-gpu-hal",
|
"piet-gpu-hal",
|
||||||
"piet-gpu-types",
|
"piet-gpu-types",
|
||||||
"piet-scene",
|
"piet-scene",
|
||||||
"tests"
|
"tests",
|
||||||
]
|
]
|
||||||
|
|
|
@ -13,6 +13,7 @@ piet-gpu = { path = "../piet-gpu" }
|
||||||
piet-gpu-hal = { path = "../piet-gpu-hal" }
|
piet-gpu-hal = { path = "../piet-gpu-hal" }
|
||||||
piet-scene = { path = "../piet-scene" }
|
piet-scene = { path = "../piet-scene" }
|
||||||
|
|
||||||
|
[target.'cfg(all(not(target_arch = "wasm32"), any(target_os = "ios", target_os = "macos")))'.dependencies]
|
||||||
metal = "0.22"
|
metal = "0.22"
|
||||||
cocoa = "0.24.0"
|
cocoa = "0.24.0"
|
||||||
objc = "0.2.5"
|
objc = "0.2.5"
|
||||||
|
|
|
@ -22,6 +22,7 @@ fn main() {
|
||||||
let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
|
let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
|
||||||
cbindgen::Builder::new()
|
cbindgen::Builder::new()
|
||||||
.with_crate(crate_dir)
|
.with_crate(crate_dir)
|
||||||
|
.with_define("target_os", "ios", "__APPLE__")
|
||||||
.with_header("/** Automatically generated from pgpu-render/src/lib.rs with cbindgen. **/")
|
.with_header("/** Automatically generated from pgpu-render/src/lib.rs with cbindgen. **/")
|
||||||
.generate()
|
.generate()
|
||||||
.expect("Unable to generate bindings")
|
.expect("Unable to generate bindings")
|
||||||
|
|
|
@ -61,13 +61,16 @@ struct PgpuRect {
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
|
#if defined(__APPLE__)
|
||||||
/// Creates a new piet-gpu renderer for the specified Metal device and
|
/// Creates a new piet-gpu renderer for the specified Metal device and
|
||||||
/// command queue.
|
/// command queue.
|
||||||
///
|
///
|
||||||
/// device: MTLDevice*
|
/// device: MTLDevice*
|
||||||
/// queue: MTLCommandQueue*
|
/// queue: MTLCommandQueue*
|
||||||
PgpuRenderer *pgpu_renderer_new(void *device, void *queue);
|
PgpuRenderer *pgpu_renderer_new(void *device, void *queue);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__APPLE__)
|
||||||
/// Renders a prepared scene into a texture target. Commands for rendering are
|
/// Renders a prepared scene into a texture target. Commands for rendering are
|
||||||
/// recorded into the specified command buffer. Returns an id representing
|
/// recorded into the specified command buffer. Returns an id representing
|
||||||
/// resources that may have been allocated during this process. After the
|
/// resources that may have been allocated during this process. After the
|
||||||
|
@ -80,6 +83,7 @@ uint32_t pgpu_renderer_render(PgpuRenderer *renderer,
|
||||||
const PgpuScene *scene,
|
const PgpuScene *scene,
|
||||||
void *target,
|
void *target,
|
||||||
void *cmdbuf);
|
void *cmdbuf);
|
||||||
|
#endif
|
||||||
|
|
||||||
/// Releases the internal resources associated with the specified id from a
|
/// Releases the internal resources associated with the specified id from a
|
||||||
/// previous render operation.
|
/// previous render operation.
|
||||||
|
|
|
@ -14,6 +14,16 @@
|
||||||
//
|
//
|
||||||
// Also licensed under MIT license, at your choice.
|
// Also licensed under MIT license, at your choice.
|
||||||
|
|
||||||
|
// We only really have implementations for IOS targets so far
|
||||||
|
// Note that this is the same cfg that wgpu uses for metal support
|
||||||
|
#![cfg_attr(
|
||||||
|
not(all(
|
||||||
|
not(target_arch = "wasm32"),
|
||||||
|
any(target_os = "ios", target_os = "macos")
|
||||||
|
)),
|
||||||
|
allow(unused)
|
||||||
|
)]
|
||||||
|
|
||||||
mod render;
|
mod render;
|
||||||
|
|
||||||
use render::*;
|
use render::*;
|
||||||
|
@ -26,6 +36,10 @@ use std::mem::transmute;
|
||||||
/// device: MTLDevice*
|
/// device: MTLDevice*
|
||||||
/// queue: MTLCommandQueue*
|
/// queue: MTLCommandQueue*
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
|
#[cfg(all(
|
||||||
|
not(target_arch = "wasm32"),
|
||||||
|
any(target_os = "ios", target_os = "macos")
|
||||||
|
))]
|
||||||
pub unsafe extern "C" fn pgpu_renderer_new(
|
pub unsafe extern "C" fn pgpu_renderer_new(
|
||||||
device: *mut c_void,
|
device: *mut c_void,
|
||||||
queue: *mut c_void,
|
queue: *mut c_void,
|
||||||
|
@ -44,6 +58,10 @@ pub unsafe extern "C" fn pgpu_renderer_new(
|
||||||
/// target: MTLTexture*
|
/// target: MTLTexture*
|
||||||
/// cmdbuf: MTLCommandBuffer*
|
/// cmdbuf: MTLCommandBuffer*
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
|
#[cfg(all(
|
||||||
|
not(target_arch = "wasm32"),
|
||||||
|
any(target_os = "ios", target_os = "macos")
|
||||||
|
))]
|
||||||
pub unsafe extern "C" fn pgpu_renderer_render(
|
pub unsafe extern "C" fn pgpu_renderer_render(
|
||||||
renderer: *mut PgpuRenderer,
|
renderer: *mut PgpuRenderer,
|
||||||
scene: *const PgpuScene,
|
scene: *const PgpuScene,
|
||||||
|
|
|
@ -33,6 +33,10 @@ pub struct PgpuRenderer {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PgpuRenderer {
|
impl PgpuRenderer {
|
||||||
|
#[cfg(all(
|
||||||
|
not(target_arch = "wasm32"),
|
||||||
|
any(target_os = "ios", target_os = "macos")
|
||||||
|
))]
|
||||||
pub fn new(device: &metal::DeviceRef, queue: &metal::CommandQueueRef) -> Self {
|
pub fn new(device: &metal::DeviceRef, queue: &metal::CommandQueueRef) -> Self {
|
||||||
let piet_device = piet_gpu_hal::Device::new_from_raw_mtl(device, &queue);
|
let piet_device = piet_gpu_hal::Device::new_from_raw_mtl(device, &queue);
|
||||||
let session = Session::new(piet_device);
|
let session = Session::new(piet_device);
|
||||||
|
@ -47,6 +51,10 @@ impl PgpuRenderer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(all(
|
||||||
|
not(target_arch = "wasm32"),
|
||||||
|
any(target_os = "ios", target_os = "macos")
|
||||||
|
))]
|
||||||
pub fn render(
|
pub fn render(
|
||||||
&mut self,
|
&mut self,
|
||||||
scene: &PgpuScene,
|
scene: &PgpuScene,
|
||||||
|
|
Loading…
Reference in a new issue