9 #ifndef TALVOS_PIPELINEEXECUTOR_H
10 #define TALVOS_PIPELINEEXECUTOR_H
13 #include <condition_variable>
27 class DispatchCommand;
28 class DrawCommandBase;
34 class RenderPassInstance;
92 struct RenderPipelineState;
98 struct PointPrimitive;
101 struct TrianglePrimitive;
113 void doWork(std::function<
void()> Task);
125 const VkViewport &Viewport);
139 uint64_t PushConstantAddress);
143 int YMinFB,
int YMaxFB);
147 std::function<
void(uint32_t, uint32_t,
const Variable *,
165 uint64_t Address, uint32_t VertexIndex,
166 uint32_t InstanceIndex, uint32_t Location,
167 uint32_t Component,
const Type *ElemTy)
const;
245 bool brk(
const std::vector<std::string> &Args);
246 bool breakpoint(
const std::vector<std::string> &Args);
247 bool cont(
const std::vector<std::string> &Args);
248 bool help(
const std::vector<std::string> &Args);
249 bool print(
const std::vector<std::string> &Args);
250 bool quit(
const std::vector<std::string> &Args);
251 bool step(
const std::vector<std::string> &Args);
252 bool swtch(
const std::vector<std::string> &Args);
This class represents a module-scope variable declaration.
std::vector< Workgroup * > RunningGroups
Pool of groups that have begun execution and been suspended.
uint32_t Y
Framebuffer y-coordinate.
const PipelineStage * CurrentStage
The pipeline stage currently being executed.
Only allow Device objects to create PipelineExecutor instances.
void run(const DispatchCommand &Cmd)
Run a compute dispatch command to completion.
bool isWorkerThread() const
Returns true if the calling thread is a PipelineExecutor worker thread.
bool brk(const std::vector< std::string > &Args)
void printContext() const
Print the context for the current invocation.
uint32_t X
Framebuffer x-coordinate.
const Command * CurrentCommand
The command currently being executed.
bool ShutDownWorkers
Signal to shut down worker threads.
std::vector< Dim3 > PendingFragments
Pool of framebuffer coordinates pending fragment processing.
~PipelineExecutor()
Destroy a pipeline executor.
void doWork(std::function< void()> Task)
Execute a function on every worker thread.
void initializeVariables(const DescriptorSetMap &DSM, uint64_t PushConstantAddress)
Initialize variables.
static std::map< uint32_t, uint32_t > Breakpoints
Map from breakpoint ID to instruction result ID.
void runComputeWorker()
Worker thread entry point for compute shaders.
const Invocation * getCurrentInvocation() const
Returns the current invocation being executed.
std::condition_variable MasterSignal
Condition variable used to notify master thread that work is complete.
This class encapsulates information about a compute kernel launch.
void signalError()
Signal that an error has occurred, breaking the interactive debugger.
const PipelineStage & getCurrentStage() const
Returns the pipeline stage that is currently being executed.
const Workgroup * getCurrentWorkgroup() const
Returns the current workgroup being executed.
void finalizeVariables(const DescriptorSetMap &DSM)
Finalize variables.
std::condition_variable WorkerSignal
Condition variable used to wake worker threads.
void runPointFragmentWorker(PointPrimitive Primitive, const RenderPassInstance &RPI)
Worker thread entry point for point rasterization.
This class is a base class for all commands.
This class represents an instance of a render pass being used for drawing.
This class encapsulates pipeline state and bound resources.
bool print(const std::vector< std::string > &Args)
std::atomic< size_t > NextWorkIndex
Index of next item of work to execute in the current task.
This class represents a single execution of a SPIR-V entry point.
std::vector< Object > Objects
The initial object values for each invocation.
Triangle primitive data, used for rasterization.
Workgroup * createWorkgroup(Dim3 GroupId) const
Create a compute shader workgroup and its work-item invocations.
void interact()
Trigger interaction with the user (if necessary).
Class representing a 3-dimensional size or ID.
void loadVertexInput(const PipelineContext &PC, Memory *PipelineMemory, uint64_t Address, uint32_t VertexIndex, uint32_t InstanceIndex, uint32_t Location, uint32_t Component, const Type *ElemTy) const
Helper function to copy vertex input data to pipeline memory.
bool breakpoint(const std::vector< std::string > &Args)
std::map< uint32_t, talvos::DescriptorSet > DescriptorSetMap
Mapping from set numbers to descriptor sets.
This is an abstract base class for draw commands.
bool cont(const std::vector< std::string > &Args)
std::vector< std::string > LastLine
Tokens for the most recent interactive command entered.
std::mutex WorkerMutex
Mutex used to synchronize with worker threads.
This file declares the Dim3 class.
bool step(const std::vector< std::string > &Args)
This class represents an address space in the virtual device.
void processFragment(const Fragment &Frag, const RenderPassInstance &RPI, std::function< void(uint32_t, uint32_t, const Variable *, const Type *, Memory *, uint64_t)> GenLocData)
Helper function to process a fragment.
An internal class that handles pipeline execution, including the interactive debugger.
void runWorker()
Worker thread entry point.
Device & Dev
The device this shader is executing on.
PipelineExecutor & operator=(const PipelineExecutor &)=delete
void rasterizePoint(const DrawCommandBase &Cmd, const VkViewport &Viewport, const VertexOutput &Vertex)
Helper function to rasterize a point primitive.
A Device instance encapsulates properties and state for the virtual device.
Outputs from a vertex shading stage.
This class represents a workgroup executing a compute command.
std::atomic< uint32_t > NumWorkersFinished
Tally of the number of workers that have finished the current task.
Point primitive data, used for rasterization.
This file declares the PipelineContext class and related typedefs.
This class encapsulates information about a pipeline stage.
void rasterizeTriangle(const DrawCommandBase &Cmd, const VkViewport &Viewport, const VertexOutput &VA, const VertexOutput &VB, const VertexOutput &VC)
Helper function to rasterize a triangle primitive.
std::vector< std::thread > WorkerThreads
List of worker threads.
uint32_t CurrentTaskID
ID used to identify the current task.
PipelineExecutor(PipelineExecutorKey Key, Device &Dev)
Create a pipeline executor on Dev.
bool swtch(const std::vector< std::string > &Args)
std::function< void()> CurrentTask
The function that worker threads should execute.
bool help(const std::vector< std::string > &Args)
This class represents a SPIR-V type.
float InvW
Inverse of the interpolated clip w coordinate.
void runVertexWorker(RenderPipelineState *State, uint32_t InstanceIndex)
Worker thread entry point for vertex shaders.
static Vec4 getPosition(const VertexOutput &Out)
Helper function to get the position from vertex output builtin data.
void buildPendingFragments(const DrawCommandBase &Cmd, int XMinFB, int XMaxFB, int YMinFB, int YMaxFB)
Helper function to build list of pending fragments in a bounding box.
static uint32_t NextBreakpoint
Index of the next breakpoint to create.
bool quit(const std::vector< std::string > &Args)
bool Continue
True when the user has used continue command.
std::vector< Dim3 > PendingGroups
Pool of group IDs pending creation and execution.
void runTriangleFragmentWorker(TrianglePrimitive Primitive, const PipelineContext &PC, const RenderPassInstance &RPI, const VkViewport &Viewport)
Worker thread entry point for triangle rasterization.
unsigned NumThreads
The number of worker threads currently executing.
State to be carried through the execution of a render pipeline.
float Depth
Fragment depth.
bool Interactive
True when interactive mode is enabled.
Internal structure to hold fragment data.