plumb the R type parameter through spirv code
This commit is contained in:
@@ -19,6 +19,7 @@ pub use sim::{SerializedSimMeta, SerializedStepE, SerializedStepH};
|
||||
pub use support::{Optional, UnsizedArray};
|
||||
|
||||
use coremem_types::mat::{Ferroxcube3R1MH, FullyGenericMaterial, IsoConductorOr, Material};
|
||||
use coremem_types::real::Real;
|
||||
use coremem_types::vec::{Vec3, Vec3u};
|
||||
|
||||
type Iso3R1<R> = IsoConductorOr<R, Ferroxcube3R1MH>;
|
||||
@@ -27,14 +28,14 @@ fn glam_vec_to_internal(v: glam::UVec3) -> Vec3u {
|
||||
Vec3u::new(v.x, v.y, v.z)
|
||||
}
|
||||
|
||||
fn step_h<M: Material<f32>>(
|
||||
fn step_h<R: Real, M: Material<R>>(
|
||||
id: Vec3u,
|
||||
meta: &SerializedSimMeta,
|
||||
stimulus_h: &UnsizedArray<Vec3<f32>>,
|
||||
meta: &SerializedSimMeta<R>,
|
||||
stimulus_h: &UnsizedArray<Vec3<R>>,
|
||||
material: &UnsizedArray<M>,
|
||||
e: &UnsizedArray<Vec3<f32>>,
|
||||
h: &mut UnsizedArray<Vec3<f32>>,
|
||||
m: &mut UnsizedArray<Vec3<f32>>,
|
||||
e: &UnsizedArray<Vec3<R>>,
|
||||
h: &mut UnsizedArray<Vec3<R>>,
|
||||
m: &mut UnsizedArray<Vec3<R>>,
|
||||
) {
|
||||
if id.x() < meta.dim.x() && id.y() < meta.dim.y() && id.z() < meta.dim.z() {
|
||||
let sim_state = SerializedStepH::new(meta, stimulus_h, material, e, h, m);
|
||||
@@ -43,13 +44,13 @@ fn step_h<M: Material<f32>>(
|
||||
}
|
||||
}
|
||||
|
||||
fn step_e<M: Material<f32>>(
|
||||
fn step_e<R: Real, M: Material<R>>(
|
||||
id: Vec3u,
|
||||
meta: &SerializedSimMeta,
|
||||
stimulus_e: &UnsizedArray<Vec3<f32>>,
|
||||
meta: &SerializedSimMeta<R>,
|
||||
stimulus_e: &UnsizedArray<Vec3<R>>,
|
||||
material: &UnsizedArray<M>,
|
||||
e: &mut UnsizedArray<Vec3<f32>>,
|
||||
h: &UnsizedArray<Vec3<f32>>,
|
||||
e: &mut UnsizedArray<Vec3<R>>,
|
||||
h: &UnsizedArray<Vec3<R>>,
|
||||
) {
|
||||
if id.x() < meta.dim.x() && id.y() < meta.dim.y() && id.z() < meta.dim.z() {
|
||||
let sim_state = SerializedStepE::new(meta, stimulus_e, material, e, h);
|
||||
@@ -80,19 +81,19 @@ pub fn entry_points<M: 'static>() -> Optional<(&'static str, &'static str)> {
|
||||
}
|
||||
|
||||
macro_rules! steps {
|
||||
($mat:ty, $step_h:ident, $step_e:ident) => {
|
||||
($flt:ty, $mat:ty, $step_h:ident, $step_e:ident) => {
|
||||
// LocalSize/numthreads
|
||||
#[spirv(compute(threads(4, 4, 4)))]
|
||||
pub fn $step_h(
|
||||
#[spirv(global_invocation_id)] id: glam::UVec3,
|
||||
#[spirv(storage_buffer, descriptor_set = 0, binding = 0)] meta: &SerializedSimMeta,
|
||||
#[spirv(storage_buffer, descriptor_set = 0, binding = 0)] meta: &SerializedSimMeta<$flt>,
|
||||
// XXX: delete this input?
|
||||
#[spirv(storage_buffer, descriptor_set = 0, binding = 1)] _unused_stimulus_e: &UnsizedArray<Vec3<f32>>,
|
||||
#[spirv(storage_buffer, descriptor_set = 0, binding = 2)] stimulus_h: &UnsizedArray<Vec3<f32>>,
|
||||
#[spirv(storage_buffer, descriptor_set = 0, binding = 1)] _unused_stimulus_e: &UnsizedArray<Vec3<$flt>>,
|
||||
#[spirv(storage_buffer, descriptor_set = 0, binding = 2)] stimulus_h: &UnsizedArray<Vec3<$flt>>,
|
||||
#[spirv(storage_buffer, descriptor_set = 0, binding = 3)] material: &UnsizedArray<$mat>,
|
||||
#[spirv(storage_buffer, descriptor_set = 0, binding = 4)] e: &UnsizedArray<Vec3<f32>>,
|
||||
#[spirv(storage_buffer, descriptor_set = 0, binding = 5)] h: &mut UnsizedArray<Vec3<f32>>,
|
||||
#[spirv(storage_buffer, descriptor_set = 0, binding = 6)] m: &mut UnsizedArray<Vec3<f32>>,
|
||||
#[spirv(storage_buffer, descriptor_set = 0, binding = 4)] e: &UnsizedArray<Vec3<$flt>>,
|
||||
#[spirv(storage_buffer, descriptor_set = 0, binding = 5)] h: &mut UnsizedArray<Vec3<$flt>>,
|
||||
#[spirv(storage_buffer, descriptor_set = 0, binding = 6)] m: &mut UnsizedArray<Vec3<$flt>>,
|
||||
) {
|
||||
step_h(glam_vec_to_internal(id), meta, stimulus_h, material, e, h, m)
|
||||
}
|
||||
@@ -100,20 +101,20 @@ macro_rules! steps {
|
||||
#[spirv(compute(threads(4, 4, 4)))]
|
||||
pub fn $step_e(
|
||||
#[spirv(global_invocation_id)] id: glam::UVec3,
|
||||
#[spirv(storage_buffer, descriptor_set = 0, binding = 0)] meta: &SerializedSimMeta,
|
||||
#[spirv(storage_buffer, descriptor_set = 0, binding = 1)] stimulus_e: &UnsizedArray<Vec3<f32>>,
|
||||
#[spirv(storage_buffer, descriptor_set = 0, binding = 0)] meta: &SerializedSimMeta<$flt>,
|
||||
#[spirv(storage_buffer, descriptor_set = 0, binding = 1)] stimulus_e: &UnsizedArray<Vec3<$flt>>,
|
||||
// XXX: delete this input?
|
||||
#[spirv(storage_buffer, descriptor_set = 0, binding = 2)] _unused_stimulus_h: &UnsizedArray<Vec3<f32>>,
|
||||
#[spirv(storage_buffer, descriptor_set = 0, binding = 2)] _unused_stimulus_h: &UnsizedArray<Vec3<$flt>>,
|
||||
#[spirv(storage_buffer, descriptor_set = 0, binding = 3)] material: &UnsizedArray<$mat>,
|
||||
#[spirv(storage_buffer, descriptor_set = 0, binding = 4)] e: &mut UnsizedArray<Vec3<f32>>,
|
||||
#[spirv(storage_buffer, descriptor_set = 0, binding = 5)] h: &UnsizedArray<Vec3<f32>>,
|
||||
#[spirv(storage_buffer, descriptor_set = 0, binding = 4)] e: &mut UnsizedArray<Vec3<$flt>>,
|
||||
#[spirv(storage_buffer, descriptor_set = 0, binding = 5)] h: &UnsizedArray<Vec3<$flt>>,
|
||||
// XXX: can/should this m input be deleted?
|
||||
#[spirv(storage_buffer, descriptor_set = 0, binding = 6)] _unused_m: &UnsizedArray<Vec3<f32>>,
|
||||
#[spirv(storage_buffer, descriptor_set = 0, binding = 6)] _unused_m: &UnsizedArray<Vec3<$flt>>,
|
||||
) {
|
||||
step_e(glam_vec_to_internal(id), meta, stimulus_e, material, e, h)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
steps!(FullyGenericMaterial<f32>, step_h_generic_material, step_e_generic_material);
|
||||
steps!(Iso3R1<f32>, step_h_iso_3r1, step_e_iso_3r1);
|
||||
steps!(f32, FullyGenericMaterial<f32>, step_h_generic_material, step_e_generic_material);
|
||||
steps!(f32, Iso3R1<f32>, step_h_iso_3r1, step_e_iso_3r1);
|
||||
|
Reference in New Issue
Block a user