MayaFlux 0.5.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ jacobi_diffusion()

Portal::Graphics::ShaderSpec MayaFlux::Buffers::RelaxationSpecs::jacobi_diffusion ( float  rate = 0.2F)
inline

Jacobi-style diffusion rule: each cell blends toward the average of its 8 Moore neighbors at the given rate.

Built on KernelTemplate::Stencil with KernelOp::WeightedBlend. PC layout is width, height, rate, neighbor_scale — neighbor_scale defaults to 1/8 to produce a true average over 8 neighbors.

Parameters
rateBlend rate per generation, 0 (no change) to 1 (full adopt).

Definition at line 22 of file RelaxationSpecs.hpp.

23{
24 auto spec = ShaderSpec::Assemble {}
25 .tmpl(KernelTemplate::Stencil)
26 .ssbo("state_in", BindingDirection::Input, Kakshya::GpuDataFormat::FLOAT32)
27 .ssbo("state_out", BindingDirection::Output, Kakshya::GpuDataFormat::FLOAT32)
28 .pc("width", Kakshya::GpuDataFormat::UINT32)
29 .pc("height", Kakshya::GpuDataFormat::UINT32)
30 .pc("rate", Kakshya::GpuDataFormat::FLOAT32)
31 .pc("neighbor_scale", Kakshya::GpuDataFormat::FLOAT32)
32 .op(KernelOp::WeightedBlend)
33 .workgroup(16, 16)
34 .build();
35 (void)rate;
36 return spec;
37}
Assemble & op(KernelOp o)
Set the named operation the emitter will lower to SPIR-V.
ShaderSpec build()
Finalise and return the ShaderSpec.
Assemble & pc(std::string name, Kakshya::GpuDataFormat format)
Declare a push constant field with explicit format.
Assemble & ssbo(std::string name, BindingDirection direction, Kakshya::GpuDataFormat format, Kakshya::DataModality modality=Kakshya::DataModality::SCALAR_F32)
Declare an SSBO binding.
Assemble & workgroup(uint32_t x, uint32_t y=1, uint32_t z=1)
Override workgroup size.
Assemble & tmpl(KernelTemplate t)
Set the kernel template.
Fluent assembler producing a ShaderSpec.

References MayaFlux::Portal::Graphics::ShaderSpec::Assemble::build(), MayaFlux::Kakshya::FLOAT32, MayaFlux::Portal::Graphics::ShaderSpec::Assemble::op(), MayaFlux::Portal::Graphics::ShaderSpec::Assemble::pc(), MayaFlux::Portal::Graphics::ShaderSpec::Assemble::ssbo(), MayaFlux::Portal::Graphics::ShaderSpec::Assemble::tmpl(), MayaFlux::Kakshya::UINT32, and MayaFlux::Portal::Graphics::ShaderSpec::Assemble::workgroup().

+ Here is the call graph for this function: