From 9bdc65e5f722314ccbed7254b7a8e144f4fcd2d1 Mon Sep 17 00:00:00 2001 From: Sean Moulton <34073738+WindowsVista42@users.noreply.github.com> Date: Tue, 1 Jun 2021 21:31:02 -0500 Subject: [PATCH] [rs] Add include_wgsl!() macro (#922) * Add include_wgsl macro * Add include_wgsl macro * Change ShaderFlags to all --- wgpu/src/macros.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/wgpu/src/macros.rs b/wgpu/src/macros.rs index c15c1a785..a616ee795 100644 --- a/wgpu/src/macros.rs +++ b/wgpu/src/macros.rs @@ -57,3 +57,18 @@ macro_rules! include_spirv { } }; } + +/// Macro to load a WGSL module statically. +#[macro_export] +macro_rules! include_wgsl { + ($($token:tt)*) => { + { + //log::info!("including '{}'", $($token)*); + $crate::ShaderModuleDescriptor { + label: Some($($token)*), + source: $crate::ShaderSource::Wgsl(include_str!($($token)*).into()), + flags: $crate::ShaderFlags::all(), + } + } + }; +}