4#ifndef GREM_EXECUTION_TASK_HPP
5#define GREM_EXECUTION_TASK_HPP
22#pragma warning(disable : 4324)
78 , sharedMemoryOffset(sharedMemoryOffset)
79 , parallelIndex(parallelIndex)
80 , parallelism(parallelism)
81 , dependencyIndices(std::move(dependencyIndices))
82 , name(std::move(name)) {}
96 void execute(
void* context,
byte* sharedMemory)
const {
97 byte*
const taskSharedMemory = sharedMemory + sharedMemoryOffset;
98 function(context, taskSharedMemory, parallelIndex, parallelism);
108 return sharedMemoryOffset;
117 return dependencyIndices;
157 : function(function) {}
175 function(subTaskContext, taskSharedMemory, subTaskIndex, subTaskCount);
Definition SmallArrayList.hpp:26
Nullable RAII data pointer with exclusive ownership of an object that is automatically destroyed on p...
Definition UniquePointer.hpp:77
ParallelTask(Function function) noexcept
Construct a parallel task.
Definition Task.hpp:156
void(*)(void *subTaskContext, byte *taskSharedMemory, Task::ParallelIndex subTaskIndex, Task::ParallelCount subTaskCount) Function
Callback function pointer that executes a chunk of a parallel task.
Definition Task.hpp:148
void execute(void *subTaskContext, byte *taskSharedMemory, Task::ParallelIndex subTaskIndex, Task::ParallelCount subTaskCount) const
Execute a chunk of the parallel task.
Definition Task.hpp:174
uint32_t SharedMemorySize
Size, in bytes, of shared memory allocated for a task.
Definition Task.hpp:51
ParallelIndex ParallelCount
Number of a parallel sub-tasks.
Definition Task.hpp:36
void execute(void *context, byte *sharedMemory) const
Execute the task.
Definition Task.hpp:96
ParallelIndex GraphIndex
Index of a task in a task graph.
Definition Task.hpp:42
uint16_t ParallelIndex
Index of a parallel sub-task.
Definition Task.hpp:33
uint32_t SharedMemoryOffset
Byte offset into the shared memory allocated for a task.
Definition Task.hpp:48
SharedMemoryOffset getSharedMemoryOffset() const noexcept
Get the expected offset of this task's reserved memory range in the total shared task memory allocate...
Definition Task.hpp:107
ParallelCount Count
Number of tasks in a task graph.
Definition Task.hpp:45
SmallArrayList< GraphIndex, 12 > DependencyIndices
List of indices of previous tasks that a task depends on.
Definition Task.hpp:54
void(*)(void *context, byte *taskSharedMemory, ParallelIndex parallelIndex, ParallelCount parallelism) Function
Callback function pointer that executes a task.
Definition Task.hpp:39
CStringView getName() const noexcept
Get the human-readable name of the task.
Definition Task.hpp:126
Span< const GraphIndex > getDependencyIndices() const noexcept
Get the task indices of this task's dependencies in the task graph.
Definition Task.hpp:116
static constexpr size_t MAX_GRAPH_SIZE
The maximum supported number of tasks in a task graph.
Definition Task.hpp:57
Task(Function function, SharedMemoryOffset sharedMemoryOffset, ParallelIndex parallelIndex, ParallelCount parallelism, DependencyIndices dependencyIndices, UniquePointer< char[]> name) noexcept
Construct a task.
Definition Task.hpp:75
std::function< Signature > Function
Definition Function.hpp:14
CStringViewBase< char, std::char_traits< char > > CStringView
Definition CStringView.hpp:635
static constexpr T MAX
Definition fundamentals.hpp:29