constexpr uint32_t RENDER_COMMAND_UPDATE_PUSH_CONSTANTS_BIT = 1 << 8;
constexpr uint32_t RENDER_COMMAND_UPDATE_ALL_BITS = 0xffff;
+/**
+ * Class which defines a render operation.
+ * First, bind the relevant graphics objects to the command, finally call the Draw method.
+ */
class RenderCommand
{
public:
INDEX_TYPE_UINT32,
};
+ /**
+ * DrawType defines whether vertices are read contiguously, or use a secondary index
+ */
enum class DrawType
{
UNDEFINED_DRAW,
*/
struct UniformBufferBinding
{
- UniformBufferBinding() :
- buffer( nullptr ), offset( 0u ), dataSize( 0u ), binding( 0u ) {}
+ UniformBufferBinding()
+ : buffer( nullptr ),
+ offset( 0u ),
+ dataSize( 0u ),
+ binding( 0u )
+ {
+ }
+
const Buffer* buffer;
uint32_t offset;
uint32_t dataSize;
};
/**
- *
+ * Structure describes texture binding
*/
struct TextureBinding
{
}
friend std::ostream& operator<<(std::ostream& ss, const TextureBinding& object);
-
};
/**
- *
+ * structure defining the sampler binding
*/
struct SamplerBinding
{
};
/**
- *
+ * structure defining the index buffer binding
*/
struct IndexBufferBinding
{
friend std::ostream& operator<<(std::ostream& ss, const IndexBufferBinding&);
};
+ /**
+ * structure defining the framebuffer (if any) of the render target
+ */
struct RenderTargetBinding
{
const Framebuffer* framebuffer { nullptr };
Framebuffer::DepthStencilClearColor depthStencilClearColor {};
float framebufferWidth; // Store the framebuffer size in case we need to set viewport
float framebufferHeight;
+ void* pNext{ nullptr };
- void* pNext{ nullptr };
RenderTargetBinding() = default;
RenderTargetBinding& SetFramebuffer( const Framebuffer* value )
friend std::ostream& operator<<(std::ostream& ss, const RenderTargetBinding&);
};
+ /**
+ * Structure defining the draw command
+ */
struct DrawCommand
{
DrawCommand() : drawType( DrawType::UNDEFINED_DRAW )
};
/**
- *
+ * Structure defining the push constants
*/
struct PushConstantsBinding
{
friend std::ostream& operator<<(std::ostream& ss, const PushConstantsBinding&);
};
+ /**
+ * Constructor
+ */
RenderCommand()
: mVertexBufferBindings(),
mUniformBufferBindings(),
return *this;
}
- RenderCommand& Draw( DrawCommand&& drawCommand )
- {
- mDrawCommand = drawCommand;
- mUpdateFlags |= RENDER_COMMAND_UPDATE_DRAW_BIT;
- return *this;
- }
-
RenderCommand& BindPipeline( const Pipeline* pipeline )
{
if( !mPipeline || mPipeline != pipeline )
return *this;
}
+ RenderCommand& Draw( DrawCommand&& drawCommand )
+ {
+ mDrawCommand = drawCommand;
+ mUpdateFlags |= RENDER_COMMAND_UPDATE_DRAW_BIT;
+ return *this;
+ }
+
static std::vector<TextureBinding> NewTextureBindings()
{
return std::vector<TextureBinding>{};
const std::vector<TextureBinding>* mTextureBindings;
std::vector<SamplerBinding> mSamplerBindings;
-
IndexBufferBinding mIndexBufferBinding;
RenderTargetBinding mRenderTargetBinding;
DrawCommand mDrawCommand;
public:
// WARNING: Be careful with these - all libraries must be built with DEBUG_ENABLED
// to ensure every instantiation has the same size.
+ // They should always be the last attributes in this class.
#if defined(DEBUG_ENABLED)
// Debug
std::string mDebugString{""};
void* mDebugObject{nullptr};
#endif
-
};
} // namespace Graphics
mImpl->messageQueue.IsSceneUpdateRequired() || // ..a message that modifies the scene graph node tree is queued OR
gestureUpdated; // ..a gesture property was updated OR
- // Although the scene-graph may not require an update, we still need to synchronize double-buffered
- // values if the scene was updated in the previous frame.
+ // Although the scene-graph may not require an update, we still need to synchronize
+ // double-buffered values if the scene was updated in the previous frame.
if( updateScene || mImpl->previousUpdateScene )
{
//Reset properties from the previous update
mImpl->transformManager.ResetToBaseValue();
}
- // Process the queued scene messages. Note, MessageQueue::FlushQueue may be called
- // between calling IsSceneUpdateRequired() above and here, so updateScene should
- // be set again
+ // Process the queued scene messages. Note, MessageQueue::FlushQueue may be called between calling
+ // IsSceneUpdateRequired() above and here, so updateScene should be set again
updateScene |= mImpl->messageQueue.ProcessMessages( bufferIndex );
updateScene |= resumed;
- // Although the scene-graph may not require an update, we still need to synchronize double-buffered
- // renderer lists if the scene was updated in the previous frame.
- // We should not start skipping update steps or reusing lists until there has been two frames where nothing changes
+ // Although the scene-graph may not require an update, we still need to synchronize
+ // double-buffered renderer lists if the scene was updated in the previous frame. We should not
+ // start skipping update steps or reusing lists until there have been two frames where nothing
+ // changes
if( updateScene || mImpl->previousUpdateScene )
{
//Animate
}
}
- // Pass the graphics back end the total number of renderers that were discarded this frame.
+ // Pass the total number of renderers that were discarded this frame to the graphics backend.
// This may trigger garbage collection.
if( numberOfDiscardedRenderers > 0 )
{