From c0a97b62245c455cb44c0187e2c9c08b596d64bc Mon Sep 17 00:00:00 2001 From: Nathan Kent Date: Thu, 18 Jun 2020 13:47:29 -0400 Subject: [PATCH 1/2] [rs] Allow `concat` in SpirV macro The `include_spirv` macros was set to accept literals only. Unfortunately, this means that other macros, such as `concat` and `env` aren't accepted, making it unusable with build script-compiled shaders. This change allows those macros to be used to load the SpirV at the expense of a potentially less helpful error message as the `literal` requirement is differed to the `include_bytes` invocation. --- wgpu/src/macros.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wgpu/src/macros.rs b/wgpu/src/macros.rs index 24786ff54c..439f451f5b 100644 --- a/wgpu/src/macros.rs +++ b/wgpu/src/macros.rs @@ -143,7 +143,7 @@ fn test_vertex_attr_array() { /// It ensure the word alignment as well as the magic number. #[macro_export] macro_rules! include_spirv { - ($path:literal) => { + ($path:expr) => { $crate::util::make_spirv(&$crate::util::WordAligned(*include_bytes!($path)).0) }; } From b2eca13fcc05499fe3b6113475ff6d8f90044c13 Mon Sep 17 00:00:00 2001 From: Nathan Kent Date: Thu, 18 Jun 2020 13:56:48 -0400 Subject: [PATCH 2/2] [rs] Change SpirV macro from `expr` to `tt` As suggested in the pull request. --- wgpu/src/macros.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wgpu/src/macros.rs b/wgpu/src/macros.rs index 439f451f5b..3cf649ed1a 100644 --- a/wgpu/src/macros.rs +++ b/wgpu/src/macros.rs @@ -143,7 +143,7 @@ fn test_vertex_attr_array() { /// It ensure the word alignment as well as the magic number. #[macro_export] macro_rules! include_spirv { - ($path:expr) => { - $crate::util::make_spirv(&$crate::util::WordAligned(*include_bytes!($path)).0) + ($($token:tt)*) => { + $crate::util::make_spirv(&$crate::util::WordAligned(*include_bytes!($($token)*)).0) }; }