use bevy::{
ecs::system::SystemParam,
prelude::{Commands, Entity, Res},
render::renderer::RenderDevice,
};
use bevy_gpu_compute_core::{
MaxOutputLengths, TypesSpec,
wgsl::shader_module::user_defined_portion::WgslShaderModuleUserPortion,
};
use crate::{prelude::IterationSpace, task::lib::BevyGpuComputeTask};
#[derive(SystemParam)]
pub struct BevyGpuComputeTaskCreator<'w, 's> {
commands: Commands<'w, 's>,
render_device: Res<'w, RenderDevice>,
}
impl BevyGpuComputeTaskCreator<'_, '_> {
pub fn create_task_from_rust_shader<ShaderModuleTypes: TypesSpec>(
&mut self,
name: &str,
wgsl_shader_module: WgslShaderModuleUserPortion,
iteration_space: IterationSpace,
max_output_vector_lengths: MaxOutputLengths,
) -> Entity {
let task = BevyGpuComputeTask::from_shader::<ShaderModuleTypes>(
name,
&self.render_device,
wgsl_shader_module,
iteration_space,
max_output_vector_lengths,
);
self.commands.spawn(task).id()
}
}