mirror of
https://github.com/italicsjenga/vello.git
synced 2025-01-10 12:41:30 +11:00
228bfc88cd
This patch adds a module that contains both scene and ptcl types (very lightly adapted from piet-metal), as well as infrastructure for encoding Rust-side. WIP, it's not wired up in either the shader or on the Rust side.
31 lines
785 B
Rust
31 lines
785 B
Rust
mod derive;
|
|
mod glsl;
|
|
mod layout;
|
|
mod parse;
|
|
|
|
use proc_macro::TokenStream;
|
|
use quote::{format_ident, quote};
|
|
use syn::parse_macro_input;
|
|
|
|
use layout::LayoutModule;
|
|
use parse::GpuModule;
|
|
|
|
#[proc_macro]
|
|
pub fn piet_gpu(input: TokenStream) -> TokenStream {
|
|
let input = parse_macro_input!(input as syn::ItemMod);
|
|
//println!("input: {:#?}", input);
|
|
let module = GpuModule::from_syn(&input).unwrap();
|
|
let layout = LayoutModule::from_gpu(&module);
|
|
let glsl = glsl::gen_glsl(&layout);
|
|
let gen_gpu_fn = format_ident!("gen_gpu_{}", layout.name);
|
|
let mut expanded = quote! {
|
|
pub fn #gen_gpu_fn() -> String {
|
|
#glsl.into()
|
|
}
|
|
};
|
|
if layout.rust_encode {
|
|
expanded.extend(derive::gen_derive(&layout));
|
|
}
|
|
expanded.into()
|
|
}
|