Shaders: rust-gpu integration to compile shader nodes to WGSL (#3097)

* shaders: shader compilation setup

* nix: use rustc_codegen_spirv.so from nix

* shaders: codegen for per_pixel_adjust shader nodes

* shaders: disable nodes needing bool

* shaders: `#[repr(u32)]` some enums

* shaders: add lint ignores from rust-gpu

* shaders: fix node-macro tests

* gcore-shaders: toml cleanup

* shader-nodes feature: put rust-gpu to wgsl compile behind feature gate

* shaders: fix use TokenStream2

* shaders: allow providing shader externally

* Update iai runner in workflow

---------

Co-authored-by: Timon Schelling <me@timon.zip>
Co-authored-by: Dennis Kobert <dennis@kobert.dev>
This commit is contained in:
Firestar99
2025-09-02 16:10:32 +02:00
committed by GitHub
parent 083dfa5f49
commit a10103311e
21 changed files with 717 additions and 20 deletions

View File

@@ -120,6 +120,8 @@ pub enum ParsedFieldType {
Node(NodeParsedField),
}
/// a param of any kind, either a concrete type or a generic type with a set of possible types specified via
/// `#[implementation(type)]`
#[derive(Clone, Debug)]
pub struct RegularParsedField {
pub ty: Type,
@@ -131,8 +133,10 @@ pub struct RegularParsedField {
pub number_hard_max: Option<LitFloat>,
pub number_mode_range: Option<ExprTuple>,
pub implementations: Punctuated<Type, Comma>,
pub gpu_image: bool,
}
/// a param of `impl Node` with `#[implementation(in -> out)]`
#[derive(Clone, Debug)]
pub struct NodeParsedField {
pub input_type: Type,
@@ -529,6 +533,7 @@ fn parse_field(pat_ident: PatIdent, ty: Type, attrs: &[Attribute]) -> syn::Resul
.map_err(|e| Error::new_spanned(attr, format!("Invalid `step` for argument '{ident}': {e}\nUSAGE EXAMPLE: #[step(2.)]")))
})
.transpose()?;
let gpu_image = extract_attribute(attrs, "gpu_image").is_some();
let (is_node, node_input_type, node_output_type) = parse_node_type(&ty);
let description = attrs
@@ -590,6 +595,7 @@ fn parse_field(pat_ident: PatIdent, ty: Type, attrs: &[Attribute]) -> syn::Resul
ty,
value_source,
implementations,
gpu_image,
}),
name,
description,
@@ -829,6 +835,7 @@ mod tests {
number_hard_max: None,
number_mode_range: None,
implementations: Punctuated::new(),
gpu_image: false,
}),
number_display_decimal_places: None,
number_step: None,
@@ -909,6 +916,7 @@ mod tests {
number_hard_max: None,
number_mode_range: None,
implementations: Punctuated::new(),
gpu_image: false,
}),
number_display_decimal_places: None,
number_step: None,
@@ -972,6 +980,7 @@ mod tests {
number_hard_max: None,
number_mode_range: None,
implementations: Punctuated::new(),
gpu_image: false,
}),
number_display_decimal_places: None,
number_step: None,
@@ -1038,6 +1047,7 @@ mod tests {
p.push(parse_quote!(f64));
p
},
gpu_image: false,
}),
number_display_decimal_places: None,
number_step: None,
@@ -1106,6 +1116,7 @@ mod tests {
number_hard_max: None,
number_mode_range: Some(parse_quote!((0., 100.))),
implementations: Punctuated::new(),
gpu_image: false,
}),
number_display_decimal_places: None,
number_step: None,
@@ -1167,6 +1178,7 @@ mod tests {
number_hard_max: None,
number_mode_range: None,
implementations: Punctuated::new(),
gpu_image: false,
}),
number_display_decimal_places: None,
number_step: None,