+class TestGraphicsTexture;
+class TestGraphicsBuffer;
+class TestGraphicsSampler;
+class TestGraphicsPipeline;
+
+enum class CommandType
+{
+ FLUSH = 1 << 0,
+ BIND_TEXTURES = 1 << 1,
+ BIND_SAMPLERS = 1 << 2,
+ BIND_VERTEX_BUFFERS = 1 << 3,
+ BIND_INDEX_BUFFER = 1 << 4,
+ BIND_UNIFORM_BUFFER = 1 << 5,
+ BIND_PIPELINE = 1 << 6,
+ DRAW = 1 << 7,
+ DRAW_INDEXED = 1 << 8,
+ DRAW_INDEXED_INDIRECT = 1 << 9
+};
+
+using CommandTypeMask = uint32_t;
+template<typename T>
+inline CommandTypeMask operator|(T flags, CommandType bit)
+{
+ return static_cast<CommandTypeMask>(flags) | static_cast<CommandTypeMask>(bit);
+}
+
+/**
+ * @brief Descriptor of single buffer binding within
+ * command buffer.
+ */
+struct VertexBufferBindingDescriptor
+{
+ const TestGraphicsBuffer* buffer{nullptr};
+ uint32_t offset{0u};
+};
+
+/**
+ * @brief Descriptor of ix buffer binding within
+ * command buffer.
+ */
+struct IndexBufferBindingDescriptor
+{
+ const TestGraphicsBuffer* buffer{nullptr};
+ uint32_t offset{};
+ Graphics::Format format{};
+};
+
+/**
+ * @brief Descriptor of uniform buffer binding within
+ * command buffer.
+ */
+struct UniformBufferBindingDescriptor
+{
+ const TestGraphicsBuffer* buffer{nullptr};
+ uint32_t binding{0u};
+ uint32_t offset{0u};
+ bool emulated; ///<true if UBO is emulated for old gfx API
+};
+
+/**
+ * @brief The descriptor of draw call
+ */
+struct DrawCallDescriptor
+{
+ /**
+ * @brief Enum specifying type of the draw call
+ */
+ enum class Type
+ {
+ DRAW,
+ DRAW_INDEXED,
+ DRAW_INDEXED_INDIRECT
+ };
+
+ Type type{}; ///< Type of the draw call
+
+ /**
+ * Union contains data for all types of draw calls.
+ */
+ union
+ {
+ /**
+ * @brief Vertex array draw
+ */
+ struct
+ {
+ uint32_t vertexCount;
+ uint32_t instanceCount;
+ uint32_t firstVertex;
+ uint32_t firstInstance;
+ } draw;
+
+ /**
+ * @brief Indexed draw
+ */
+ struct
+ {
+ uint32_t indexCount;
+ uint32_t instanceCount;
+ uint32_t firstIndex;
+ int32_t vertexOffset;
+ uint32_t firstInstance;
+ } drawIndexed;
+
+ /**
+ * @brief Indexed draw indirect
+ */
+ struct
+ {
+ const TestGraphicsBuffer* buffer;
+ uint32_t offset;
+ uint32_t drawCount;
+ uint32_t stride;
+ } drawIndexedIndirect;
+ };
+};
+
+/**
+ * Command structure allocates memory to store a single command
+ */
+struct Command
+{
+ Command()
+ {
+ }
+
+ ~Command()
+ {
+ }
+
+ /**
+ * @brief Copy constructor
+ * @param[in] rhs Command
+ */
+ Command(const Command& rhs)
+ {
+ switch(rhs.type)
+ {
+ case CommandType::BIND_VERTEX_BUFFERS:
+ {
+ bindVertexBuffers = rhs.bindVertexBuffers;
+ break;
+ }
+ case CommandType::BIND_INDEX_BUFFER:
+ {
+ bindIndexBuffer = rhs.bindIndexBuffer;
+ break;
+ }
+ case CommandType::BIND_SAMPLERS:
+ {
+ bindSamplers = rhs.bindSamplers;
+ break;
+ }
+ case CommandType::BIND_TEXTURES:
+ {
+ bindTextures = rhs.bindTextures;
+ break;
+ }
+ case CommandType::BIND_PIPELINE:
+ {
+ bindPipeline = rhs.bindPipeline;
+ break;
+ }
+ case CommandType::BIND_UNIFORM_BUFFER:
+ {
+ bindUniformBuffers = rhs.bindUniformBuffers;
+ break;
+ }
+ case CommandType::DRAW:
+ {
+ draw.type = rhs.draw.type;
+ draw.draw = rhs.draw.draw;
+ break;
+ }
+ case CommandType::DRAW_INDEXED:
+ {
+ draw.type = rhs.draw.type;
+ draw.drawIndexed = rhs.draw.drawIndexed;
+ break;
+ }
+ case CommandType::DRAW_INDEXED_INDIRECT:
+ {
+ draw.type = rhs.draw.type;
+ draw.drawIndexedIndirect = rhs.draw.drawIndexedIndirect;
+ break;
+ }
+ case CommandType::FLUSH:
+ {
+ // Nothing to do
+ break;
+ }
+ }
+ type = rhs.type;
+ }
+
+ /**
+ * @brief Copy constructor
+ * @param[in] rhs Command
+ */
+ Command(Command&& rhs) noexcept
+ {
+ switch(rhs.type)
+ {
+ case CommandType::BIND_VERTEX_BUFFERS:
+ {
+ bindVertexBuffers = std::move(rhs.bindVertexBuffers);
+ break;
+ }
+ case CommandType::BIND_INDEX_BUFFER:
+ {
+ bindIndexBuffer = rhs.bindIndexBuffer;
+ break;
+ }
+ case CommandType::BIND_UNIFORM_BUFFER:
+ {
+ bindUniformBuffers = std::move(rhs.bindUniformBuffers);
+ break;
+ }
+ case CommandType::BIND_SAMPLERS:
+ {
+ bindSamplers = std::move(rhs.bindSamplers);
+ break;
+ }
+ case CommandType::BIND_TEXTURES:
+ {
+ bindTextures = std::move(rhs.bindTextures);
+ break;
+ }
+ case CommandType::BIND_PIPELINE:
+ {
+ bindPipeline = rhs.bindPipeline;
+ break;
+ }
+ case CommandType::DRAW:
+ {
+ draw.type = rhs.draw.type;
+ draw.draw = rhs.draw.draw;
+ break;
+ }
+ case CommandType::DRAW_INDEXED:
+ {
+ draw.type = rhs.draw.type;
+ draw.drawIndexed = rhs.draw.drawIndexed;
+ break;
+ }
+ case CommandType::DRAW_INDEXED_INDIRECT:
+ {
+ draw.type = rhs.draw.type;
+ draw.drawIndexedIndirect = rhs.draw.drawIndexedIndirect;
+ break;
+ }
+ case CommandType::FLUSH:
+ {
+ // Nothing to do
+ break;
+ }
+ }
+ type = rhs.type;
+ }
+
+ CommandType type{CommandType::FLUSH}; ///< Type of command
+
+ union
+ {
+ struct
+ {
+ std::vector<Graphics::TextureBinding> textureBindings;
+ } bindTextures{};
+
+ // BindSampler command
+ struct
+ {
+ std::vector<Graphics::SamplerBinding> samplerBindings;
+ } bindSamplers;
+
+ struct
+ {
+ using Binding = VertexBufferBindingDescriptor;
+ std::vector<Binding> vertexBufferBindings;
+ } bindVertexBuffers;
+
+ struct : public IndexBufferBindingDescriptor
+ {
+ } bindIndexBuffer;
+
+ struct
+ {
+ std::vector<UniformBufferBindingDescriptor> uniformBufferBindings{};
+ UniformBufferBindingDescriptor standaloneUniformsBufferBinding{};
+ } bindUniformBuffers;
+
+ struct
+ {
+ const TestGraphicsPipeline* pipeline{nullptr};
+ } bindPipeline;
+
+ struct : public DrawCallDescriptor
+ {
+ } draw;
+ };
+};
+
+