#pragma once struct CommandFlags { enum Enumeration { None = 0x00, SubChainStart = 0x01, // Command will start a new command chain (UseShader for example) SubChainEnd = 0x02, // Command will end a command chain (Render) Unique = 0x04, // Similar commands should not be reduced to one Command StartChain = 0x08, // Command will generate a new command chain EndChain = 0x10, // Command will end the command chain (RenderGeometry for example) FlushChain = 0x20, // Command will end the command chain (RenderGeometry for example) }; }; struct ICommandUser; struct Command { Command(ICommandUser* inOwner, unsigned char inFlags, unsigned char inType, unsigned char inPriority, unsigned char inSubPriority = 0) : Owner(inOwner) , Flags(inFlags) , Priority(inPriority) , SubPriority(inSubPriority) , Type(inType) { } ICommandUser* Owner; union { struct { UINT8 Priority; UINT8 SubPriority; UINT8 Flags; UINT8 Type; }; UINT32 CommandInfo; }; }; struct CommandExecuteResult { enum Enumeration { None, // Execution done, proceed to the next Command RetrySubChain, // Execution should start from a previous "SubChainStart"-flagged Command RetrySubChainSkipHead // Equal to the above result but skips the as "SubChainStart"-flagged Command }; }; struct IRenderCommandNode; struct ICommandBuffer; struct __declspec(novtable) ICommandUser { virtual ~ICommandUser() {} virtual const std::vector& GetCommands() const = 0; virtual CommandExecuteResult::Enumeration ExecuteCommand(unsigned char argCommandType, ICommandBuffer& argCurrentBuffer, uint32 argCurrentPositon) = 0; virtual void AssignToRenderCommandNode(IRenderCommandNode& argNode) = 0; virtual void UnassignFromRenderCommandNode(IRenderCommandNode& argNode) = 0; // Commands should be applied before all following commands virtual bool get_IsPreconditionForNextCommands() const = 0; virtual string8 get_UserName() const; }; struct __declspec(novtable) ICommandBuffer { virtual ~ICommandBuffer() {} virtual void Clear() = 0; virtual void AddCommand(Command& argCommand) = 0; virtual void Perform(bool argUseOptimizedList) = 0; virtual void Optimize() = 0; virtual void AddChildCommandBuffer(ICommandBuffer& argCommandBuffer) = 0; virtual void RemoveChildCommandBuffer(ICommandBuffer& argCommandBuffer) = 0; virtual std::vector& get_BufferedCommands() = 0; virtual const std::vector& get_ChildCommandBuffers() const = 0; virtual ICommandBuffer* get_ParentBuffer() const = 0; virtual void set_ParentBuffer(ICommandBuffer* ar_CommandBuffer_) = 0; };