7 const std::string& target_field,
const std::string& scratch_field)
10 { .name =
"source", .binding = 0, .field = scratch_field, .access =
FieldAccess::WRITE },
11 { .name =
"target_a", .binding = 1, .field = target_field, .access =
FieldAccess::READ },
12 { .name =
"target_b", .binding = 2, .field = target_field, .access =
FieldAccess::WRITE },
17 std::string target_field,
18 std::string scratch_field,
19 const std::string& shader_path,
22 , m_target_field(
std::move(target_field))
23 , m_scratch_field(
std::move(scratch_field))
30 std::string target_field,
31 std::string scratch_field,
35 , m_target_field(
std::move(target_field))
36 , m_scratch_field(
std::move(scratch_field))
75 const std::shared_ptr<VKBuffer>& ,
84 const std::shared_ptr<VKBuffer>& ,
94 const auto src = vk::AccessFlagBits::eShaderWrite;
95 const auto dst = vk::AccessFlagBits::eShaderRead | vk::AccessFlagBits::eShaderWrite;
96 const auto stage = vk::PipelineStageFlagBits::eComputeShader;
98 foundry.buffer_barrier(cmd_id, volume->read_handle(
m_target_field), src, dst, stage, stage);
99 foundry.buffer_barrier(cmd_id, volume->write_handle(
m_target_field), src, dst, stage, stage);
100 foundry.buffer_barrier(cmd_id, volume->write_handle(
m_scratch_field), src, dst, stage, stage);
void set_iteration_count(uint32_t count)
Set how many dispatches are recorded per execute cycle.
uint32_t get_iteration_count() const
Dispatches recorded per execute cycle.
void write_coefficient()
Write the product of rate and time step into word seven.
std::string m_target_field
bool on_iteration(Portal::Graphics::CommandBufferID cmd_id, const std::shared_ptr< VKBuffer > &buffer, uint32_t index) override
Write this pass's parity and first-pass flag.
void on_volume_ready() override
Write the coefficient into the shared prefix.
std::string m_scratch_field
void on_iteration_barrier(Portal::Graphics::CommandBufferID cmd_id, const std::shared_ptr< VKBuffer > &buffer, uint32_t index) override
Barrier both target slots and the scratch between passes.
static std::vector< FieldBinding > make_bindings(const std::string &target_field, const std::string &scratch_field)
Build the binding table for the two field names.
DiffuseProcessor(std::string target_field, std::string scratch_field, const std::string &shader_path, uint32_t iterations=20)
Construct a diffusion stage.
bool wants_swap() const override
Swap only when the pass count leaves the result in the write slot.
void set_time_step(float dt)
Set the integration step.
void set_rate(float rate)
Set the diffusion rate.
void write_lattice_word7(float value)
Write word seven of the parameter prefix, at byte offset 28.
void write_lattice_word3(uint32_t value)
Write word three of the shared prefix.
@ READ
Resolves to VolumeGridBuffer::read_handle.
@ WRITE
Resolves to VolumeGridBuffer::write_handle.
const std::shared_ptr< VolumeGridBuffer > & get_volume() const
The attached volume, or null if attachment failed validation.
void add_swap_field(std::string field)
Register a field to swap after each dispatch.
ComputeProcessor operating on named fields of a VolumeGridBuffer.
MAYAFLUX_API ShaderFoundry & get_shader_foundry()
Get the global shader compiler instance.
Complete declarative description of a generated compute shader.