17 uint32_t startVertexLocation) {
19 commands.push(std::move(command));
25 uint32_t startIndexLocation, int32_t baseVertexLocation,
28 vertexBuffer, indexBuffer, constantBuffers, indexCount,
29 startIndexLocation, baseVertexLocation));
30 command->SetCastsShadow(castsShadow);
31 commands.push(std::move(command));
36 commands.push(std::move(command));
41 commands.push(std::move(command));
46 commands.push(std::move(command));
51 commands.push(command);
56 commands.push(command);
62 commands.push(std::move(command));
73 m_retiredShadowDraws[m_retireIndex].clear();
74 m_retiredShadowDraws[m_retireIndex] = std::move(cachedShadowDraws);
75 m_retireIndex = (m_retireIndex + 1) % RETIRE_FRAMES;
76 cachedShadowDraws.clear();
80 for (
auto& cmd : commands) {
81 auto type = cmd->GetType();
84 if (bindCmd->GetSlot() == 0) {
85 lastSlot0Buffer = bindCmd->GetBuffer();
86 }
else if (bindCmd->GetSlot() == 3) {
87 lastSlot3Buffer = bindCmd->GetBuffer();
91 && lastSlot0Buffer && cmd->CastsShadow()) {
99 cachedShadowDraws.add(entry);
119 bool lastMaterialForward =
false;
128 for (
auto& cmd : commands) {
129 auto type = cmd->GetType();
133 lastMaterial = bmc->GetMaterial();
136 pendingState.
add(cmd);
143 for (
auto& s : pendingState) forwardCmds.
add(s);
144 pendingState.clear();
145 forwardCmds.
add(cmd);
146 lastMaterial =
nullptr;
147 lastMaterialForward =
false;
151 if (isStateCmd(type)) {
152 pendingState.
add(cmd);
160 const bool isSkinned = cmd->IsSkinned();
161 if (lastMaterialForward || isSkinned) {
163 for (
auto& s : pendingState) forwardCmds.
add(s);
164 forwardCmds.
add(cmd);
167 for (
auto& s : pendingState) s->Execute(context);
168 cmd->Execute(context);
170 pendingState.
clear();
175 cmd->Execute(context);
182 for (
auto& cmd : forwardCmds)
183 cmd->Execute(context);
191 for (
auto& cmd : commands)
192 cmd->Execute(context);
197 for (
size_t i = 0; i < cachedShadowDraws.GetSize(); ++i) {
198 auto& entry = cachedShadowDraws[i];
201 if (entry.transformBuffer) {
206 if (entry.boneBuffer) {
209 entry.command->ExecuteShadow(context);
227 while (!commands.isEmpty())
232 while (!commands.isEmpty())
234 cachedShadowDraws.clear();
235 for (
int i = 0; i < RETIRE_FRAMES; ++i)
236 m_retiredShadowDraws[i].clear();
242 Instance->ClearAll();
Implements a dynamic array-like list for storing and managing a collection of elements.
bool IsForwardRendered() const
True when this material must skip the GBuffer and render in the forward transparent pass.
Binds a constant buffer to a pipeline slot.
Binds a material's shader and textures for subsequent draws.
std::function< void(RenderContext *)> ExecuteFunction
Non-indexed draw command with its vertex and constant buffers.
Indexed draw command with its vertex, index, and constant buffers.
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)
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.
virtual void BeginForwardTransparentPass()
virtual void BindBoneBuffer(RefPtr< BufferBase > buffer)
virtual void EndForwardTransparentPass()
virtual bool IsDeferredEnabled() const
virtual void ExecuteDeferredLightingPass()
virtual void BindConstantBuffer(RefPtr< BufferBase > buffer, uint32_t slot=0)=0
Switches the cull-face mode.
Switches the rasterizer fill mode.
Constant buffer write, captured by value into inline storage or a heap fallback for larger payloads.
Backend-facing rendering layer shared by the four graphics backends.
CommandType
Discriminator for RenderCommandBase subclasses, used for sorting and batching.
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.
RefPtr< BufferBase > boneBuffer
RefPtr< RenderCommandBase > command
RefPtr< BufferBase > transformBuffer