diff --git a/Cargo.toml b/Cargo.toml index 775e942..e0585b8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "pixels" description = "A tiny library providing a GPU-powered pixel frame buffer." -version = "0.0.2" +version = "0.0.3" authors = ["Jay Oster "] edition = "2018" repository = "https://github.com/parasyte/pixels" diff --git a/src/macros.rs b/src/macros.rs index f91746a..d39606b 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -7,36 +7,11 @@ //! //! This macro moves all of that complexity to build-time. At least for the SPIR-V part of the //! shader pipeline. (`gfx-hal` backends have their own SPIR-V-to-native compilers at runtime.) -//! -//! Cribbed with permission from Ralith -//! See: https://github.com/MaikKlein/ash/pull/245 -/// Include correctly aligned and typed precompiled SPIR-V -/// -/// Does not account for endianness mismatches between the SPIR-V file and the target. See -/// [`wgpu::read_spirv`] for a more general solution. #[macro_export] macro_rules! include_spv { ($path:expr) => { - &$crate::Align4(*include_bytes!($path)) as &$crate::Spirv + &wgpu::read_spirv(std::io::Cursor::new(&include_bytes!($path)[..])) + .expect(&format!("Invalid SPIR-V shader in file: {}", $path)) }; } - -/// Type returned by `include_spv`, convertible to `&[u32]` -/// -/// The definition of this type is unstable. -pub type Spirv = Align4<[u8]>; - -impl std::ops::Deref for Spirv { - type Target = [u32]; - fn deref(&self) -> &[u32] { - #[allow(clippy::cast_ptr_alignment)] - unsafe { - std::slice::from_raw_parts(self.0.as_ptr() as *const u32, self.0.len() / 4) - } - } -} - -#[repr(align(4))] -#[doc(hidden)] -pub struct Align4(pub T);