1#ifndef _RENDERCOMMANDQUEUE_H
2#define _RENDERCOMMANDQUEUE_H
25 uint32_t startIndexLocation = 0,
26 int32_t baseVertexLocation = 0,
27 bool castsShadow =
true
35 uint32_t startVertexLocation = 0
102 CommandArena() =
default;
103 CommandArena(
const CommandArena&) =
delete;
104 CommandArena& operator=(
const CommandArena&) =
delete;
105 ~CommandArena() { Reset(); }
109 template <
typename T,
typename... Args>
110 T* Create(Args&&... args) {
111 void* memory = Allocate(
sizeof(T),
alignof(T));
112 T* command =
new (memory) T(std::forward<Args>(args)...);
113 m_commands.push_back(command);
120 const std::vector<RenderCommandBase*>& Commands()
const {
126 std::unique_ptr<std::byte[]> data;
132 void* Allocate(
size_t size,
size_t alignment);
134 static constexpr size_t BLOCK_SIZE = 64 * 1024;
135 std::vector<Block> m_blocks;
136 size_t m_blockIndex = 0;
138 std::vector<RenderCommandBase*> m_commands;
145 CommandArena& CurrentArena() {
return m_arenas[m_currentArena]; }
149 static constexpr int RETIRE_FRAMES = 3;
150 static constexpr int ARENA_COUNT = RETIRE_FRAMES + 2;
151 static RenderCommandQueue* Instance;
152 CommandArena m_arenas[ARENA_COUNT];
153 int m_currentArena = 0;
154 std::vector<ShadowDrawEntry> cachedShadowDraws;
155 std::vector<RenderCommandBase*> m_pendingState;
156 std::vector<RenderCommandBase*> m_forwardCmds;
Implements a dynamic array-like list for storing and managing a collection of elements.
std::function< void(RenderContext *)> ExecuteFunction
One recorded draw plus the state it needs to replay into a command list.
Frame-scoped queue of recorded draw/state commands, replayed into a RenderContext at flush time.
void Clear()
Drops queued commands for the current frame, keeping the cached shadow draw list.
void SubmitUpdateConstantBuffer(RefPtr< BufferBase > buffer, void *Data, uint16_t Size)
Queues a constant buffer write with data captured at submit time.
void SubmitSetRenderMode(RenderMode mode)
void SubmitCustomCommand(CustomCommand::ExecuteFunction function)
Queues an arbitrary callback to run inline with other render commands.
void ExecuteCommands(RenderContext *context)
static RenderCommandQueue * GetInstance()
Lazily creates and returns the process-wide singleton instance.
bool HasCachedShadowDraws() const
void SubmitBindMaterial(::Sleak::Material *material)
Queues a material bind, switching shader/texture state for subsequent draws.
void ExecuteShadowPass(RenderContext *context)
void SubmitDrawIndexed(RefPtr< BufferBase > vertexBuffer, RefPtr< BufferBase > indexBuffer, List< RefPtr< BufferBase > > constantBuffers, uint32_t indexCount, uint32_t startIndexLocation=0, int32_t baseVertexLocation=0, bool castsShadow=true)
Queues an indexed draw with its vertex/index buffers and constant buffers.
void ClearAll()
Drops queued commands and the cached shadow draw list.
void SubmitDraw(RefPtr< BufferBase > vertexBuffer, List< RefPtr< BufferBase > > constantBuffers, uint32_t vertexCount, uint32_t startVertexLocation=0)
Queues a non-indexed draw with its vertex buffer and constant buffers.
void SubmitSetRenderFace(RenderFace face)
void SubmitBindConstantBuffer(RefPtr< BufferBase > buffer, uint8_t slot)
Queues a constant buffer bind at the given slot.
Abstract interface for high-level graphics command execution and resource management.
Backend-facing rendering layer shared by the four graphics backends.
RenderMode
Rasterizer fill style for a draw.
RenderFace
Which triangle winding gets culled.
Root namespace for everything the engine exposes.
A draw command paired with the transform/bone buffers it needs to replay in the shadow pass.
const RefPtr< BufferBase > * boneBuffer
RenderCommandBase * command
const RefPtr< BufferBase > * transformBuffer