From a7d4d2c79f5917cde2836ff34993ba258a067da2 Mon Sep 17 00:00:00 2001 From: 9SMTM6 <44668330+9SMTM6@users.noreply.github.com> Date: Mon, 24 Jun 2024 19:46:30 +0200 Subject: [PATCH] Allow using include_wgsl! in const contexts (#5872) * include_wgsl! Switch from into() call to construction This allows usage in const contexts. * Describe constification of include_wgsl! in changelog --- CHANGELOG.md | 4 ++++ wgpu/src/macros.rs | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1fc326c30c..a2ea1b8fa5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -131,6 +131,10 @@ By @atlv24 in [#5383](https://github.com/gfx-rs/wgpu/pull/5383) - Implement `WGSL`'s `unpack4xI8`,`unpack4xU8`,`pack4xI8` and `pack4xU8`. By @VlaDexa in [#5424](https://github.com/gfx-rs/wgpu/pull/5424) - Began work adding support for atomics to the SPIR-V frontend. Tracking issue is [here](https://github.com/gfx-rs/wgpu/issues/4489). By @schell in [#5702](https://github.com/gfx-rs/wgpu/pull/5702). +#### WebGPU + +- `include_wgsl!` is now callable in const contexts by @9SMTM6 in [#5872](https://github.com/gfx-rs/wgpu/pull/5872) + ### Changes #### General diff --git a/wgpu/src/macros.rs b/wgpu/src/macros.rs index f1a15e764e..594388528f 100644 --- a/wgpu/src/macros.rs +++ b/wgpu/src/macros.rs @@ -95,7 +95,7 @@ macro_rules! include_wgsl { //log::info!("including '{}'", $($token)*); $crate::ShaderModuleDescriptor { label: Some($($token)*), - source: $crate::ShaderSource::Wgsl(include_str!($($token)*).into()), + source: $crate::ShaderSource::Wgsl(std::borrow::Cow::Borrowed(include_str!($($token)*))), } } };