MayaFlux 0.5.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
RelaxationSpecs.hpp
Go to the documentation of this file.
1#pragma once
2
4
6
11
12/**
13 * @brief Jacobi-style diffusion rule: each cell blends toward the average
14 * of its 8 Moore neighbors at the given rate.
15 *
16 * Built on KernelTemplate::Stencil with KernelOp::WeightedBlend. PC layout
17 * is width, height, rate, neighbor_scale — neighbor_scale defaults to
18 * 1/8 to produce a true average over 8 neighbors.
19 *
20 * @param rate Blend rate per generation, 0 (no change) to 1 (full adopt).
21 */
22[[nodiscard]] inline Portal::Graphics::ShaderSpec jacobi_diffusion(float rate = 0.2F)
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)
31 .pc("neighbor_scale", Kakshya::GpuDataFormat::FLOAT32)
32 .op(KernelOp::WeightedBlend)
33 .workgroup(16, 16)
34 .build();
35 (void)rate;
36 return spec;
37}
38
39/**
40 * @brief Binary state-to-vertex emit: nonzero state draws at full scale,
41 * zero state degenerates to a zero-scale (invisible) vertex.
42 *
43 * Input state format: UINT32. Output: VEC4_F32 per vertex.
44 */
46{
47 return ShaderSpec::Assemble {}
48 .ssbo("cell_state", BindingDirection::Input, Kakshya::GpuDataFormat::UINT32)
49 .ssbo("vertices", BindingDirection::Output, Kakshya::GpuDataFormat::VEC4_F32)
51 .op(KernelOp::CompareGE)
52 .workgroup(256)
53 .build();
54}
55
56/**
57 * @brief Scalar-ramp state-to-vertex emit: float state value scaled and
58 * offset into a visible output range.
59 *
60 * Input state format: FLOAT32. Output: VEC4_F32 per vertex.
61 */
63{
64 return ShaderSpec::Assemble {}
65 .ssbo("cell_state", BindingDirection::Input, Kakshya::GpuDataFormat::FLOAT32)
66 .ssbo("vertices", BindingDirection::Output, Kakshya::GpuDataFormat::VEC4_F32)
69 .op(KernelOp::ScaleOffset)
70 .workgroup(256)
71 .build();
72}
73
74} // namespace MayaFlux::Buffers::RelaxationSpecs
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.
Portal::Graphics::ShaderSpec emit_binary()
Binary state-to-vertex emit: nonzero state draws at full scale, zero state degenerates to a zero-scal...
Portal::Graphics::ShaderSpec jacobi_diffusion(float rate=0.2F)
Jacobi-style diffusion rule: each cell blends toward the average of its 8 Moore neighbors at the give...
Portal::Graphics::ShaderSpec emit_scalar_ramp()
Scalar-ramp state-to-vertex emit: float state value scaled and offset into a visible output range.
KernelTemplate
Structural shape of the generated compute kernel.
BindingDirection
Data flow direction for a shader binding slot.
KernelOp
Named operation the SPIR-V emitter knows how to lower to opcodes.
Complete declarative description of a generated compute shader.