Toast Engine
Loading...
Searching...
No Matches
renderer::AsyncComputeTask Class Reference

#include <async_compute_task.hpp>

Inheritance diagram for renderer::AsyncComputeTask:

Classes

struct  Config
class  StepContext
 Handed to the step callback. Barriers between dispatches of one step are inserted for you. More...
class  FrameView
 Buffers the renderer may read this frame. More...

Public Types

enum class  Copy : uint8_t { current , previous }
 Which copy of a ring buffer a binding sees during a step. More...
using BufferId = uint32_t

Public Member Functions

 AsyncComputeTask (const AsyncComputeTask &)=delete
auto operator= (const AsyncComputeTask &) -> AsyncComputeTask &=delete
 AsyncComputeTask (AsyncComputeTask &&)=delete
auto operator= (AsyncComputeTask &&) -> AsyncComputeTask &=delete
auto acquireForFrame (vk::CommandBuffer cmd, uint32_t frame_index, sync::Usage next) -> FrameView
auto read (BufferId id, std::span< std::byte > out) -> bool
 Newest finished CPU copy of a ring buffer added with cpu_readback and false until one exists.
template<typename T>
auto read (BufferId id, std::span< T > out) -> bool
auto finishedStep () const -> uint64_t
 Steps finished so far.
auto isReady () const -> bool

Protected Member Functions

 AsyncComputeTask (Config config)
auto addRingBuffer (vk::DeviceSize size, bool cpu_readback=false) -> BufferId
 Constructor only.
auto addPersistentBuffer (vk::DeviceSize size) -> BufferId
auto addHostBuffer (vk::DeviceSize size) -> BufferId
void bind (uint32_t binding, BufferId id, Copy copy=Copy::current)
void bindExternal (uint32_t set, uint32_t binding, std::function< vk::Buffer()> source)
void setAcquireUsage (BufferId id, sync::Usage usage)
void upload (BufferId id, std::span< const std::byte > data)
 Owner thread, blocks until the copy landed gpu side.
template<typename T>
void upload (BufferId id, std::span< const T > data)
auto step (const std::function< void(StepContext &)> &record, std::string_view debug_name={}, std::shared_ptr< const void > keep_alive={}) -> uint64_t
 Owner thread.

Detailed Description

Base for a compute simulation that runs on the async compute queue and feeds the renderer

A derived class declares its buffers and bindings in its constructor and then calls step() from its own thread

Ring buffers are written once per step and read by the renderer and the CPU Persistent buffers are state only the task touches, like velocities

Member Enumeration Documentation

◆ Copy

enum class renderer::AsyncComputeTask::Copy : uint8_t
strong

Which copy of a ring buffer a binding sees during a step.

Enumerator
current 

Written by this step.

previous 

Result of the step before, read only.

Member Function Documentation

◆ acquireForFrame()

auto renderer::AsyncComputeTask::acquireForFrame ( vk::CommandBuffer cmd,
uint32_t frame_index,
sync::Usage next ) -> FrameView

Render thread after the fence of frame_index was waited on, empty until a step finished next is how the renderer reads the ring buffers

◆ addRingBuffer()

auto renderer::AsyncComputeTask::addRingBuffer ( vk::DeviceSize size,
bool cpu_readback = false ) -> BufferId
protected

Constructor only.

This is superturbobad do not overuse it.


The documentation for this class was generated from the following files: