bevy_render_macros/
lib.rs1#![expect(missing_docs, reason = "Not all docs are written yet, see #3492.")]
2#![cfg_attr(docsrs, feature(doc_auto_cfg))]
3
4mod as_bind_group;
5mod extract_component;
6mod extract_resource;
7
8use bevy_macro_utils::{derive_label, BevyManifest};
9use proc_macro::TokenStream;
10use quote::format_ident;
11use syn::{parse_macro_input, DeriveInput};
12
13pub(crate) fn bevy_render_path() -> syn::Path {
14 BevyManifest::shared().get_path("bevy_render")
15}
16
17#[proc_macro_derive(ExtractResource)]
18pub fn derive_extract_resource(input: TokenStream) -> TokenStream {
19 extract_resource::derive_extract_resource(input)
20}
21
22#[proc_macro_derive(ExtractComponent, attributes(extract_component_filter))]
50pub fn derive_extract_component(input: TokenStream) -> TokenStream {
51 extract_component::derive_extract_component(input)
52}
53
54#[proc_macro_derive(
55 AsBindGroup,
56 attributes(
57 uniform,
58 storage_texture,
59 texture,
60 sampler,
61 bind_group_data,
62 storage,
63 bindless,
64 data
65 )
66)]
67pub fn derive_as_bind_group(input: TokenStream) -> TokenStream {
68 let input = parse_macro_input!(input as DeriveInput);
69
70 as_bind_group::derive_as_bind_group(input).unwrap_or_else(|err| err.to_compile_error().into())
71}
72
73#[proc_macro_derive(RenderLabel)]
77pub fn derive_render_label(input: TokenStream) -> TokenStream {
78 let input = parse_macro_input!(input as DeriveInput);
79 let mut trait_path = bevy_render_path();
80 trait_path
81 .segments
82 .push(format_ident!("render_graph").into());
83 let mut dyn_eq_path = trait_path.clone();
84 trait_path
85 .segments
86 .push(format_ident!("RenderLabel").into());
87 dyn_eq_path.segments.push(format_ident!("DynEq").into());
88 derive_label(input, "RenderLabel", &trait_path, &dyn_eq_path)
89}
90
91#[proc_macro_derive(RenderSubGraph)]
95pub fn derive_render_sub_graph(input: TokenStream) -> TokenStream {
96 let input = parse_macro_input!(input as DeriveInput);
97 let mut trait_path = bevy_render_path();
98 trait_path
99 .segments
100 .push(format_ident!("render_graph").into());
101 let mut dyn_eq_path = trait_path.clone();
102 trait_path
103 .segments
104 .push(format_ident!("RenderSubGraph").into());
105 dyn_eq_path.segments.push(format_ident!("DynEq").into());
106 derive_label(input, "RenderSubGraph", &trait_path, &dyn_eq_path)
107}