Skip to content

Commit

Permalink
Fix build issues when using the nalgebra feature (#2170)
Browse files Browse the repository at this point in the history
  • Loading branch information
marc0246 authored Apr 1, 2023
1 parent a7b9186 commit 44e6dfc
Showing 1 changed file with 1 addition and 68 deletions.
69 changes: 1 addition & 68 deletions vulkano/src/pipeline/graphics/vertex_input/impl_vertex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,68 +162,11 @@ where
}
}

#[allow(unused_macros)]
macro_rules! impl_vertex_member_generic {
($first:ident$(::$rest:ident)*, $len:literal) => {
#[allow(deprecated)]
unsafe impl<T> VertexMember for $first$(::$rest)*<T>
where
[T; $len]: VertexMember,
{
fn format() -> Format {
<[T; $len] as VertexMember>::format()
}
}
};
}

#[cfg(feature = "cgmath")]
impl_vertex_member_generic!(cgmath::Vector1, 1);
#[cfg(feature = "cgmath")]
impl_vertex_member_generic!(cgmath::Vector2, 2);
#[cfg(feature = "cgmath")]
impl_vertex_member_generic!(cgmath::Vector3, 3);
#[cfg(feature = "cgmath")]
impl_vertex_member_generic!(cgmath::Vector4, 4);
#[cfg(feature = "cgmath")]
impl_vertex_member_generic!(cgmath::Point1, 1);
#[cfg(feature = "cgmath")]
impl_vertex_member_generic!(cgmath::Point2, 2);
#[cfg(feature = "cgmath")]
impl_vertex_member_generic!(cgmath::Point3, 3);
#[cfg(feature = "cgmath")]
impl_vertex_member_generic!(cgmath::Matrix3, 9);
#[cfg(feature = "cgmath")]
impl_vertex_member_generic!(cgmath::Matrix4, 16);

#[cfg(feature = "nalgebra")]
impl_vertex_member_generic!(nalgebra::Vector1, 1);
#[cfg(feature = "nalgebra")]
impl_vertex_member_generic!(nalgebra::Vector2, 2);
#[cfg(feature = "nalgebra")]
impl_vertex_member_generic!(nalgebra::Vector3, 3);
#[cfg(feature = "nalgebra")]
impl_vertex_member_generic!(nalgebra::Vector4, 4);
#[cfg(feature = "nalgebra")]
impl_vertex_member_generic!(nalgebra::Point1, 1);
#[cfg(feature = "nalgebra")]
impl_vertex_member_generic!(nalgebra::Point2, 2);
#[cfg(feature = "nalgebra")]
impl_vertex_member_generic!(nalgebra::Point3, 3);
#[cfg(feature = "nalgebra")]
impl_vertex_member_generic!(nalgebra::Point4, 4);
#[cfg(feature = "nalgebra")]
impl_vertex_member_generic!(nalgebra::Matrix3, 9);
#[cfg(feature = "nalgebra")]
impl_vertex_member_generic!(nalgebra::Matrix4, 16);

#[cfg(test)]
mod tests {
use std::marker::PhantomData;

use crate::format::Format;
#[allow(deprecated)]
use crate::pipeline::graphics::vertex_input::{Vertex, VertexMember};
use crate::pipeline::graphics::vertex_input::Vertex;

use bytemuck::{Pod, Zeroable};

Expand Down Expand Up @@ -254,14 +197,4 @@ mod tests {
assert_eq!(scalar.offset, 16 * 5);
assert_eq!(scalar.num_elements, 1);
}

#[test]
#[allow(deprecated)]
fn impl_vertex_member_generic() {
struct TestGeneric<T> {
_data: PhantomData<T>,
}
impl_vertex_member_generic!(TestGeneric, 1);
assert_eq!(TestGeneric::<u8>::format(), Format::R8_UINT);
}
}

0 comments on commit 44e6dfc

Please sign in to comment.