#[repr(C)]
#[derive(Clone, Copy, Debug, Default, PartialEq, bytemuck::Pod, bytemuck::Zeroable)]
pub(crate) struct InfluenceRecord {
pub joints: [u32; 4],
pub weights: [f32; 4],
}
#[repr(C)]
#[derive(Clone, Copy, Debug, Default, PartialEq, bytemuck::Pod, bytemuck::Zeroable)]
pub(crate) struct MorphDeltaRecord {
pub position: [f32; 3],
pub normal: [f32; 3],
pub tangent: [f32; 3],
}
pub(crate) const JOINT_WORDS: u32 = 16;
pub(crate) const DEFORMED_POSITION_WORDS: u32 = words::<crate::shading::vertex::CasterVertex>();
pub(crate) const DEFORMED_NORMAL_WORDS: u32 = 7;
#[repr(C)]
#[derive(Clone, Copy, Debug, Default, PartialEq, bytemuck::Pod, bytemuck::Zeroable)]
pub(crate) struct DeformDispatch {
pub vertices: u32,
pub vertex_count: u32,
pub influences: u32,
pub morph_targets: u32,
pub morph_target_count: u32,
pub joints: u32,
pub weights: u32,
pub positions: u32,
pub normals: u32,
}
pub(crate) const fn words<T>() -> u32 {
(std::mem::size_of::<T>() / 4) as u32
}
#[cfg(test)]
pub(crate) fn constants() -> Vec<crate::shading::layout_tests::Constant> {
use std::mem::offset_of;
let word = |bytes: usize| naga::Literal::U32((bytes / 4) as u32);
[
(
"INFLUENCE_WORDS",
word(std::mem::size_of::<InfluenceRecord>()),
),
(
"INFLUENCE_WEIGHTS",
word(offset_of!(InfluenceRecord, weights)),
),
(
"MORPH_DELTA_WORDS",
word(std::mem::size_of::<MorphDeltaRecord>()),
),
(
"MORPH_DELTA_NORMAL",
word(offset_of!(MorphDeltaRecord, normal)),
),
(
"MORPH_DELTA_TANGENT",
word(offset_of!(MorphDeltaRecord, tangent)),
),
("JOINT_WORDS", naga::Literal::U32(JOINT_WORDS)),
(
"DEFORM_MOST_MORPH_TARGETS",
naga::Literal::U32(crate::content::deformation::MAX_MORPH_TARGETS as u32),
),
(
"DEFORMED_POSITION_WORDS",
naga::Literal::U32(DEFORMED_POSITION_WORDS),
),
(
"DEFORMED_NORMAL_WORDS",
naga::Literal::U32(DEFORMED_NORMAL_WORDS),
),
]
.into_iter()
.map(|(name, value)| crate::shading::layout_tests::Constant::new("deform", name, value))
.collect()
}
#[cfg(test)]
pub(crate) fn mirrors() -> [crate::shading::layout_tests::Mirror; 1] {
[crate::shading::layout_tests::mirror!(
"deform",
"DeformDispatch",
DeformDispatch,
[
vertices,
vertex_count,
influences,
morph_targets,
morph_target_count,
joints,
weights,
positions,
normals
]
)]
}