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

◆ record_sequence()

void MayaFlux::Portal::Graphics::ComputePress::record_sequence ( CommandBufferID  cmd_id,
const std::vector< ComputeStage > &  stages 
)

Record multiple pipeline dispatches into one already-open command buffer, inserting a barrier between each consecutive stage for that stage's hazard_bindings.

Vulkan permits binding different pipelines sequentially within a single command buffer recording — this is not a render-pass-style batching mechanism, only direct multi-pipeline recording plus the hazard barriers each transition needs. Does not submit; caller owns the command buffer's lifetime via ShaderFoundry (begin_commands / submit_and_wait or submit_async), the same as any other recorded sequence of commands.

Image bindings receive an eGeneral -> eGeneral shader write/read hazard barrier via ShaderFoundry::image_barrier. Non-image bindings receive a buffer_barrier with the same access/stage masks. Both use compute-to-compute pipeline stages throughout, since this method is for chaining compute stages only.

Parameters
cmd_idCommand buffer to record into. Must already be active (begun via ShaderFoundry::begin_commands).
stagesOrdered list of pipeline dispatches to record.

Definition at line 395 of file ComputePress.cpp.

398{
399 auto& foundry = *m_shader_foundry;
400
401 for (size_t i = 0; i < stages.size(); ++i) {
402 const auto& stage = stages[i];
403
404 bind_all(
405 cmd_id,
406 stage.pipeline_id,
407 stage.descriptor_set_ids,
408 stage.push_constant_data.empty() ? nullptr : stage.push_constant_data.data(),
409 stage.push_constant_data.size());
410
411 dispatch(cmd_id, stage.groups[0], stage.groups[1], stage.groups[2]);
412
413 for (const auto& hazard : stage.hazard_resources) {
414 if (hazard.binding.direction != GpuBufferBinding::Direction::INPUT_OUTPUT)
415 continue;
416
417 const bool is_image = hazard.binding.element_type == GpuBufferBinding::ElementType::IMAGE_STORAGE
418 || hazard.binding.element_type == GpuBufferBinding::ElementType::IMAGE_SAMPLED;
419
420 if (is_image) {
421 foundry.image_barrier(
422 cmd_id,
423 hazard.image,
424 vk::ImageLayout::eGeneral,
425 vk::ImageLayout::eGeneral,
426 vk::AccessFlagBits::eShaderWrite | vk::AccessFlagBits::eShaderRead,
427 vk::AccessFlagBits::eShaderWrite | vk::AccessFlagBits::eShaderRead,
428 vk::PipelineStageFlagBits::eComputeShader,
429 vk::PipelineStageFlagBits::eComputeShader);
430 } else {
431 foundry.buffer_barrier(
432 cmd_id,
433 hazard.buffer,
434 vk::AccessFlagBits::eShaderWrite | vk::AccessFlagBits::eShaderRead,
435 vk::AccessFlagBits::eShaderWrite | vk::AccessFlagBits::eShaderRead,
436 vk::PipelineStageFlagBits::eComputeShader,
437 vk::PipelineStageFlagBits::eComputeShader);
438 }
439 }
440
442 "record_sequence: stage {} of {} recorded ({} hazard barriers)",
443 i + 1, stages.size(), stage.hazard_resources.size());
444 }
445}
#define MF_DEBUG(comp, ctx,...)
void bind_all(CommandBufferID cmd_id, ComputePipelineID pipeline_id, const std::vector< DescriptorSetID > &descriptor_set_ids, const void *push_constants_data=nullptr, size_t push_constant_size=0)
All-in-one: bind pipeline + descriptors + push constants.
void dispatch(CommandBufferID cmd_id, uint32_t x, uint32_t y, uint32_t z)
Dispatch compute workgroups.
@ GPUCompute
GPU compute operations (shaders, GPGPU tasks)
@ Portal
High-level user-facing API layer.
bool is_image(const fs::path &filepath)
Definition Depot.cpp:108

References bind_all(), dispatch(), MayaFlux::Journal::GPUCompute, MayaFlux::Portal::Graphics::GpuBufferBinding::IMAGE_SAMPLED, MayaFlux::Portal::Graphics::GpuBufferBinding::IMAGE_STORAGE, MayaFlux::Portal::Graphics::GpuBufferBinding::INPUT_OUTPUT, MayaFlux::is_image(), m_shader_foundry, MF_DEBUG, and MayaFlux::Journal::Portal.

+ Here is the call graph for this function: