spirv: plumb the material all the way to the gpu interface
This commit is contained in:
parent
e3cd39db7e
commit
2885a517d6
|
@ -748,14 +748,14 @@ fn make_pipelines(device: &wgpu::Device, shader_module: &wgpu::ShaderModule) ->
|
|||
label: None,
|
||||
layout: Some(&pipeline_layout),
|
||||
module: shader_module,
|
||||
entry_point: "step_h",
|
||||
entry_point: "step_h_generic_material",
|
||||
});
|
||||
|
||||
let compute_step_e_pipeline = device.create_compute_pipeline(&wgpu::ComputePipelineDescriptor {
|
||||
label: None,
|
||||
layout: Some(&pipeline_layout),
|
||||
module: shader_module,
|
||||
entry_point: "step_e",
|
||||
entry_point: "step_e_generic_material",
|
||||
});
|
||||
|
||||
(bind_group_layout, compute_step_h_pipeline, compute_step_e_pipeline)
|
||||
|
@ -858,7 +858,7 @@ mod test {
|
|||
use super::*;
|
||||
use crate::sim::Meters;
|
||||
use crate::stim::{NoopStimulus, RngStimulus};
|
||||
use spirv_backend_lib::{step_e, step_h, UVec3};
|
||||
use spirv_backend_lib::{step_e_generic_material as step_e, step_h_generic_material as step_h, UVec3};
|
||||
|
||||
fn do_step<S: AbstractStimulus>(state: &mut SpirvSim, stim: &S) {
|
||||
let meta = state.meta.clone();
|
||||
|
|
|
@ -19,11 +19,42 @@ pub mod support;
|
|||
pub use sim::{SerializedSimMeta, SerializedStepE, SerializedStepH};
|
||||
pub use support::{Optional, UnsizedArray, UVec3Std, Vec3Std};
|
||||
|
||||
use mat::GenericMaterial;
|
||||
use mat::{GenericMaterial, Material};
|
||||
|
||||
fn step_h<M: Material>(
|
||||
id: UVec3,
|
||||
meta: &SerializedSimMeta,
|
||||
material: &UnsizedArray<M>,
|
||||
e: &UnsizedArray<Vec3Std>,
|
||||
h: &mut UnsizedArray<Vec3Std>,
|
||||
m: &mut UnsizedArray<Vec3Std>,
|
||||
) {
|
||||
if id.x < meta.dim.x() && id.y < meta.dim.y() && id.z < meta.dim.z() {
|
||||
let sim_state = SerializedStepH::new(meta, material, e, h, m);
|
||||
let update_state = sim_state.index(id);
|
||||
update_state.step_h();
|
||||
}
|
||||
}
|
||||
|
||||
fn step_e<M: Material>(
|
||||
id: UVec3,
|
||||
meta: &SerializedSimMeta,
|
||||
stimulus: &UnsizedArray<Vec3Std>,
|
||||
material: &UnsizedArray<M>,
|
||||
e: &mut UnsizedArray<Vec3Std>,
|
||||
h: &UnsizedArray<Vec3Std>,
|
||||
) {
|
||||
if id.x < meta.dim.x() && id.y < meta.dim.y() && id.z < meta.dim.z() {
|
||||
let sim_state = SerializedStepE::new(meta, stimulus, material, e, h);
|
||||
|
||||
let update_state = sim_state.index(id);
|
||||
update_state.step_e();
|
||||
}
|
||||
}
|
||||
|
||||
// LocalSize/numthreads
|
||||
#[spirv(compute(threads(4, 4, 4)))]
|
||||
pub fn step_h(
|
||||
pub fn step_h_generic_material(
|
||||
#[spirv(global_invocation_id)] id: UVec3,
|
||||
#[spirv(storage_buffer, descriptor_set = 0, binding = 0)] meta: &SerializedSimMeta,
|
||||
// XXX: delete this input?
|
||||
|
@ -33,15 +64,11 @@ pub fn step_h(
|
|||
#[spirv(storage_buffer, descriptor_set = 0, binding = 4)] h: &mut UnsizedArray<Vec3Std>,
|
||||
#[spirv(storage_buffer, descriptor_set = 0, binding = 5)] m: &mut UnsizedArray<Vec3Std>,
|
||||
) {
|
||||
if id.x < meta.dim.x() && id.y < meta.dim.y() && id.z < meta.dim.z() {
|
||||
let sim_state = SerializedStepH::new(meta, material, e, h, m);
|
||||
let update_state = sim_state.index(id);
|
||||
update_state.step_h();
|
||||
}
|
||||
step_h(id, meta, material, e, h, m)
|
||||
}
|
||||
|
||||
#[spirv(compute(threads(4, 4, 4)))]
|
||||
pub fn step_e(
|
||||
pub fn step_e_generic_material(
|
||||
#[spirv(global_invocation_id)] id: UVec3,
|
||||
#[spirv(storage_buffer, descriptor_set = 0, binding = 0)] meta: &SerializedSimMeta,
|
||||
#[spirv(storage_buffer, descriptor_set = 0, binding = 1)] stimulus: &UnsizedArray<Vec3Std>,
|
||||
|
@ -51,10 +78,5 @@ pub fn step_e(
|
|||
// XXX: can/should this m input be deleted?
|
||||
#[spirv(storage_buffer, descriptor_set = 0, binding = 5)] _unused_m: &UnsizedArray<Vec3Std>,
|
||||
) {
|
||||
if id.x < meta.dim.x() && id.y < meta.dim.y() && id.z < meta.dim.z() {
|
||||
let sim_state = SerializedStepE::new(meta, stimulus, material, e, h);
|
||||
|
||||
let update_state = sim_state.index(id);
|
||||
update_state.step_e();
|
||||
}
|
||||
step_e(id, meta, stimulus, material, e, h)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user