spirv: move the stimulus application out of gpu.rs

This commit is contained in:
2022-07-25 12:52:35 -07:00
parent 5b8978f0ec
commit 8c8e707407
2 changed files with 11 additions and 5 deletions

View File

@@ -1,5 +1,6 @@
use futures::FutureExt as _;
use log::{info, warn};
use ndarray::Array3;
use std::borrow::Cow;
use std::num::NonZeroU64;
use wgpu;
@@ -9,7 +10,6 @@ use coremem_types::vec::Vec3;
use coremem_types::mat::{FullyGenericMaterial, Material};
use crate::sim::SampleableSim as _;
use crate::stim::AbstractStimulus;
use super::bindings::entry_points;
use super::SpirvSim;
@@ -65,9 +65,13 @@ impl<M> SpirvSim<M>
where
M: Send + Sync + Material<f32> + 'static
{
pub(super) fn step_spirv<S: AbstractStimulus>(&mut self, num_steps: u32, stim: &S) {
pub(super) fn step_spirv(
&mut self,
num_steps: u32,
stim_cpu_e: Array3<Vec3<f32>>,
stim_cpu_h: Array3<Vec3<f32>>,
) {
let size = self.size();
let (stim_cpu_e, stim_cpu_h) = self.eval_stimulus(stim);
let field_bytes = size.product_sum() as usize * std::mem::size_of::<Vec3<f32>>();
let sim_meta = [self.meta.clone()];

View File

@@ -92,12 +92,14 @@ impl<M> GenericSim for SpirvSim<M>
where
M: Send + Sync + Material<f32> + 'static
{
fn step_multiple<S: AbstractStimulus>(&mut self, num_steps: u32, s: &S) {
fn step_multiple<S: AbstractStimulus>(&mut self, num_steps: u32, stim: &S) {
let vol = self.size().volume();
self.wgpu.get_or_insert_with(
|| Arc::new(WgpuData::new::<M>(vol))
);
self.step_spirv(num_steps, s);
let (stim_e, stim_h) = self.eval_stimulus(stim);
self.step_spirv(num_steps, stim_e, stim_h);
self.step_no += num_steps as u64;
}