pub struct ComputeShaderPlugin {
pub shader_path: &'static str,
/* private fields */
}Expand description
Bevy plugin that runs compute shader passes once per frame, before any camera renders.
Every buffer registered through ShaderAppExt is visible to
both the compute passes and the FullscreenFragmentPlugin
shader, at the same @group/@binding. Each binding must be declared with the same
access mode (read or read_write) in every shader that uses it.
Only one ComputeShaderPlugin is supported per app. Add it after DefaultPlugins.
§Example
struct Particles;
App::new()
.add_plugins(DefaultPlugins)
.add_plugins(
ComputeShaderPlugin::new("shaders/particles.wgsl")
.init_pass("init", Workgroups::over::<Particles>())
.pass("update", Workgroups::over::<Particles>()),
)
.register_gpu_buffer::<Particles, Particle>(0, 0, 1024)
.run();Fields§
§shader_path: &'static strPath to the compute shader asset (e.g. "shaders/simulation.wgsl").
Implementations§
Source§impl ComputeShaderPlugin
impl ComputeShaderPlugin
Sourcepub fn pass(self, entry: &'static str, workgroups: Workgroups) -> Self
pub fn pass(self, entry: &'static str, workgroups: Workgroups) -> Self
Run the @compute entry point entry every frame. Passes run in the order they
are added, and each sees the writes of the passes before it. The same entry point
may be added more than once (e.g. for simulation substeps).
Sourcepub fn init_pass(self, entry: &'static str, workgroups: Workgroups) -> Self
pub fn init_pass(self, entry: &'static str, workgroups: Workgroups) -> Self
Run the @compute entry point entry once, on the first frame everything is
ready. Every-frame passes don’t start until all init passes have run. Use
ComputePasses::rerun to run it again later.
Trait Implementations§
Source§impl Plugin for ComputeShaderPlugin
impl Plugin for ComputeShaderPlugin
Source§fn ready(&self, _app: &App) -> bool
fn ready(&self, _app: &App) -> bool
finish should be called.Source§fn finish(&self, _app: &mut App)
fn finish(&self, _app: &mut App)
App, once all plugins registered are ready. This can
be useful for plugins that depends on another plugin asynchronous setup, like the renderer.Source§fn cleanup(&self, _app: &mut App)
fn cleanup(&self, _app: &mut App)
Auto Trait Implementations§
impl Freeze for ComputeShaderPlugin
impl RefUnwindSafe for ComputeShaderPlugin
impl Send for ComputeShaderPlugin
impl Sync for ComputeShaderPlugin
impl Unpin for ComputeShaderPlugin
impl UnsafeUnpin for ComputeShaderPlugin
impl UnwindSafe for ComputeShaderPlugin
Blanket Implementations§
Source§impl<T, U> AsBindGroupShaderType<U> for T
impl<T, U> AsBindGroupShaderType<U> for T
Source§fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
T ShaderType for self. When used in AsBindGroup
derives, it is safe to assume that all images in self exist.Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<T> ConditionalSend for Twhere
T: Send,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more