#include <cstdint>
#include <vector>
#include "test-gl-abstraction.h"
-#include "test-graphics-pipeline.h"
#include "test-graphics-buffer.h"
+#include "test-graphics-pipeline.h"
#include "test-trace-call-stack.h"
namespace Dali
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
+ 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,
+ SET_SCISSOR = 1 << 10,
+ SET_SCISSOR_TEST = 1 << 11,
+ SET_VIEWPORT = 1 << 12,
+ SET_VIEWPORT_TEST = 1 << 13
};
using CommandTypeMask = uint32_t;
struct VertexBufferBindingDescriptor
{
const TestGraphicsBuffer* buffer{nullptr};
- uint32_t offset{0u};
+ uint32_t offset{0u};
};
/**
struct IndexBufferBindingDescriptor
{
const TestGraphicsBuffer* buffer{nullptr};
- uint32_t offset{};
- Graphics::Format format{};
+ uint32_t offset{};
+ Graphics::Format format{};
};
/**
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
+ uint32_t binding{0u};
+ uint32_t offset{0u};
+ bool emulated; ///<true if UBO is emulated for old gfx API
};
/**
struct
{
const TestGraphicsBuffer* buffer;
- uint32_t offset;
- uint32_t drawCount;
- uint32_t stride;
+ uint32_t offset;
+ uint32_t drawCount;
+ uint32_t stride;
} drawIndexedIndirect;
};
};
{
case CommandType::BIND_VERTEX_BUFFERS:
{
- bindVertexBuffers = rhs.bindVertexBuffers;
+ data.bindVertexBuffers = rhs.data.bindVertexBuffers;
break;
}
case CommandType::BIND_INDEX_BUFFER:
{
- bindIndexBuffer = rhs.bindIndexBuffer;
+ data.bindIndexBuffer = rhs.data.bindIndexBuffer;
break;
}
case CommandType::BIND_SAMPLERS:
{
- bindSamplers = rhs.bindSamplers;
+ data.bindSamplers = rhs.data.bindSamplers;
break;
}
case CommandType::BIND_TEXTURES:
{
- bindTextures = rhs.bindTextures;
+ data.bindTextures = rhs.data.bindTextures;
break;
}
case CommandType::BIND_PIPELINE:
{
- bindPipeline = rhs.bindPipeline;
+ data.bindPipeline = rhs.data.bindPipeline;
break;
}
case CommandType::BIND_UNIFORM_BUFFER:
{
- bindUniformBuffers = rhs.bindUniformBuffers;
+ data.bindUniformBuffers = rhs.data.bindUniformBuffers;
break;
}
case CommandType::DRAW:
{
- draw.type = rhs.draw.type;
- draw.draw = rhs.draw.draw;
+ data.draw.type = rhs.data.draw.type;
+ data.draw.draw = rhs.data.draw.draw;
break;
}
case CommandType::DRAW_INDEXED:
{
- draw.type = rhs.draw.type;
- draw.drawIndexed = rhs.draw.drawIndexed;
+ data.draw.type = rhs.data.draw.type;
+ data.draw.drawIndexed = rhs.data.draw.drawIndexed;
break;
}
case CommandType::DRAW_INDEXED_INDIRECT:
{
- draw.type = rhs.draw.type;
- draw.drawIndexedIndirect = rhs.draw.drawIndexedIndirect;
+ data.draw.type = rhs.data.draw.type;
+ data.draw.drawIndexedIndirect = rhs.data.draw.drawIndexedIndirect;
break;
}
case CommandType::FLUSH:
// Nothing to do
break;
}
+ case CommandType::SET_SCISSOR:
+ {
+ data.scissor.region = rhs.data.scissor.region;
+ break;
+ }
+ case CommandType::SET_SCISSOR_TEST:
+ {
+ data.scissorTest.enable = rhs.data.scissorTest.enable;
+ break;
+ }
+ case CommandType::SET_VIEWPORT:
+ {
+ data.viewport.region = rhs.data.viewport.region;
+ break;
+ }
+ case CommandType::SET_VIEWPORT_TEST:
+ {
+ data.viewportTest.enable = rhs.data.viewportTest.enable;
+ break;
+ }
}
type = rhs.type;
}
/**
- * @brief Copy constructor
+ * @brief move constructor
* @param[in] rhs Command
*/
Command(Command&& rhs) noexcept
{
case CommandType::BIND_VERTEX_BUFFERS:
{
- bindVertexBuffers = std::move(rhs.bindVertexBuffers);
+ data.bindVertexBuffers = std::move(rhs.data.bindVertexBuffers);
break;
}
case CommandType::BIND_INDEX_BUFFER:
{
- bindIndexBuffer = rhs.bindIndexBuffer;
+ data.bindIndexBuffer = rhs.data.bindIndexBuffer;
break;
}
case CommandType::BIND_UNIFORM_BUFFER:
{
- bindUniformBuffers = std::move(rhs.bindUniformBuffers);
+ data.bindUniformBuffers = std::move(rhs.data.bindUniformBuffers);
break;
}
case CommandType::BIND_SAMPLERS:
{
- bindSamplers = std::move(rhs.bindSamplers);
+ data.bindSamplers = std::move(rhs.data.bindSamplers);
break;
}
case CommandType::BIND_TEXTURES:
{
- bindTextures = std::move(rhs.bindTextures);
+ data.bindTextures = std::move(rhs.data.bindTextures);
break;
}
case CommandType::BIND_PIPELINE:
{
- bindPipeline = rhs.bindPipeline;
+ data.bindPipeline = rhs.data.bindPipeline;
break;
}
case CommandType::DRAW:
{
- draw.type = rhs.draw.type;
- draw.draw = rhs.draw.draw;
+ data.draw.type = rhs.data.draw.type;
+ data.draw.draw = rhs.data.draw.draw;
break;
}
case CommandType::DRAW_INDEXED:
{
- draw.type = rhs.draw.type;
- draw.drawIndexed = rhs.draw.drawIndexed;
+ data.draw.type = rhs.data.draw.type;
+ data.draw.drawIndexed = rhs.data.draw.drawIndexed;
break;
}
case CommandType::DRAW_INDEXED_INDIRECT:
{
- draw.type = rhs.draw.type;
- draw.drawIndexedIndirect = rhs.draw.drawIndexedIndirect;
+ data.draw.type = rhs.data.draw.type;
+ data.draw.drawIndexedIndirect = rhs.data.draw.drawIndexedIndirect;
break;
}
case CommandType::FLUSH:
// Nothing to do
break;
}
+ case CommandType::SET_SCISSOR:
+ {
+ data.scissor.region = rhs.data.scissor.region;
+ break;
+ }
+ case CommandType::SET_SCISSOR_TEST:
+ {
+ data.scissorTest.enable = rhs.data.scissorTest.enable;
+ break;
+ }
+ case CommandType::SET_VIEWPORT:
+ {
+ data.viewport.region = rhs.data.viewport.region;
+ break;
+ }
+ case CommandType::SET_VIEWPORT_TEST:
+ {
+ data.viewportTest.enable = rhs.data.viewportTest.enable;
+ break;
+ }
}
type = rhs.type;
}
CommandType type{CommandType::FLUSH}; ///< Type of command
- union
+ union CommandData
{
+ CommandData()
+ {
+ }
+
+ ~CommandData()
+ {
+ } // do nothing
+
struct
{
std::vector<Graphics::TextureBinding> textureBindings;
struct : public DrawCallDescriptor
{
} draw;
- };
-};
+ struct
+ {
+ Graphics::Rect2D region;
+ } scissor;
+ struct
+ {
+ bool enable;
+ } scissorTest;
+ struct
+ {
+ Graphics::Viewport region;
+ } viewport;
+ struct
+ {
+ bool enable;
+ } viewportTest;
+ } data;
+};
class TestGraphicsCommandBuffer : public Graphics::CommandBuffer
{
TestGraphicsCommandBuffer(TraceCallStack& callstack, TestGlAbstraction& glAbstraction);
~TestGraphicsCommandBuffer()
{
-
}
void BindVertexBuffers(uint32_t firstBinding,
{
mCommands.emplace_back();
mCommands.back().type = CommandType::BIND_VERTEX_BUFFERS;
- auto& bindings = mCommands.back().bindVertexBuffers.vertexBufferBindings;
+ auto& bindings = mCommands.back().data.bindVertexBuffers.vertexBufferBindings;
if(bindings.size() < firstBinding + buffers.size())
{
bindings.resize(firstBinding + buffers.size());
void BindUniformBuffers(const std::vector<Graphics::UniformBufferBinding>& bindings) override
{
- printf("BindUniformBuffers: bindings.size(): %lu\n", bindings.size());
-
mCommands.emplace_back();
auto& cmd = mCommands.back();
cmd.type = CommandType::BIND_UNIFORM_BUFFER;
- auto& bindCmd = cmd.bindUniformBuffers;
+ auto& bindCmd = cmd.data.bindUniformBuffers;
for(const auto& binding : bindings)
{
if(binding.buffer)
void BindPipeline(const Graphics::Pipeline& pipeline) override
{
mCommands.emplace_back();
- mCommands.back().type = CommandType::BIND_PIPELINE;
- mCommands.back().bindPipeline.pipeline = static_cast<const TestGraphicsPipeline*>(&pipeline);
+ mCommands.back().type = CommandType::BIND_PIPELINE;
+ mCommands.back().data.bindPipeline.pipeline = static_cast<const TestGraphicsPipeline*>(&pipeline);
mCallStack.PushCall("BindPipeline", "");
}
void BindTextures(std::vector<Graphics::TextureBinding>& textureBindings) override
{
mCommands.emplace_back();
- mCommands.back().type = CommandType::BIND_TEXTURES;
- mCommands.back().bindTextures.textureBindings = std::move(textureBindings);
+ mCommands.back().type = CommandType::BIND_TEXTURES;
+ mCommands.back().data.bindTextures.textureBindings = std::move(textureBindings);
mCallStack.PushCall("BindTextures", "");
}
void BindSamplers(std::vector<Graphics::SamplerBinding>& samplerBindings) override
{
mCommands.emplace_back();
- mCommands.back().bindSamplers.samplerBindings = std::move(samplerBindings);
+ mCommands.back().data.bindSamplers.samplerBindings = std::move(samplerBindings);
mCallStack.PushCall("BindSamplers", "");
}
void BindIndexBuffer(const Graphics::Buffer& buffer,
uint32_t offset,
- Graphics::Format format) override
+ Graphics::Format format) override
{
mCommands.emplace_back();
- mCommands.back().type = CommandType::BIND_INDEX_BUFFER;
- mCommands.back().bindIndexBuffer.buffer = static_cast<const TestGraphicsBuffer*>(&buffer);
- mCommands.back().bindIndexBuffer.offset = offset;
- mCommands.back().bindIndexBuffer.format = format;
+ mCommands.back().type = CommandType::BIND_INDEX_BUFFER;
+ mCommands.back().data.bindIndexBuffer.buffer = static_cast<const TestGraphicsBuffer*>(&buffer);
+ mCommands.back().data.bindIndexBuffer.offset = offset;
+ mCommands.back().data.bindIndexBuffer.format = format;
mCallStack.PushCall("BindIndexBuffer", "");
}
void BeginRenderPass(
- Graphics::RenderPass& renderPass,
- Graphics::RenderTarget& renderTarget,
+ Graphics::RenderPass& renderPass,
+ Graphics::RenderTarget& renderTarget,
Graphics::Extent2D renderArea,
std::vector<Graphics::ClearValue> clearValues) override
{
{
mCommands.emplace_back();
mCommands.back().type = CommandType::DRAW;
- auto& cmd = mCommands.back().draw;
+ auto& cmd = mCommands.back().data.draw;
cmd.type = DrawCallDescriptor::Type::DRAW;
cmd.draw.vertexCount = vertexCount;
cmd.draw.instanceCount = instanceCount;
{
mCommands.emplace_back();
mCommands.back().type = CommandType::DRAW_INDEXED;
- auto& cmd = mCommands.back().draw;
+ auto& cmd = mCommands.back().data.draw;
cmd.type = DrawCallDescriptor::Type::DRAW_INDEXED;
cmd.drawIndexed.firstIndex = firstIndex;
cmd.drawIndexed.firstInstance = firstInstance;
{
mCommands.emplace_back();
mCommands.back().type = CommandType::DRAW_INDEXED_INDIRECT;
- auto& cmd = mCommands.back().draw;
+ auto& cmd = mCommands.back().data.draw;
cmd.type = DrawCallDescriptor::Type::DRAW_INDEXED_INDIRECT;
cmd.drawIndexedIndirect.buffer = static_cast<const TestGraphicsBuffer*>(&buffer);
cmd.drawIndexedIndirect.offset = offset;
mCallStack.PushCall("Reset", "");
}
- void SetScissor(Graphics::Extent2D value) override
+ void SetScissor(Graphics::Rect2D value) override
{
- mCallStack.PushCall("SetScissor", "");
+ TraceCallStack::NamedParams params;
+ params["x"] << value.x;
+ params["y"] << value.y;
+ params["width"] << value.width;
+ params["height"] << value.height;
+ mCallStack.PushCall("SetScissor", params.str(), params);
+
+ mCommands.emplace_back();
+ mCommands.back().type = CommandType::SET_SCISSOR;
+ mCommands.back().data.scissor.region = value;
}
void SetScissorTestEnable(bool value) override
{
- mCallStack.PushCall("SetScissorTestEnable", "");
+ TraceCallStack::NamedParams params;
+ params["value"] << (value ? "T" : "F");
+ mCallStack.PushCall("SetScissorTestEnable", params.str(), params);
+
+ mCommands.emplace_back();
+ mCommands.back().type = CommandType::SET_SCISSOR_TEST;
+ mCommands.back().data.scissorTest.enable = value;
}
void SetViewport(Graphics::Viewport value) override
{
- mCallStack.PushCall("SetViewport", "");
+ TraceCallStack::NamedParams params;
+ params["x"] << value.x;
+ params["y"] << value.y;
+ params["width"] << value.width;
+ params["height"] << value.height;
+ params["minDepth"] << value.minDepth;
+ params["maxDepth"] << value.maxDepth;
+ mCallStack.PushCall("SetViewport", params.str(), params);
+
+ mCommands.emplace_back();
+ mCommands.back().type = CommandType::SET_VIEWPORT;
+ mCommands.back().data.viewport.region = value;
}
void SetViewportEnable(bool value) override
{
- mCallStack.PushCall("SetViewportEnable", "");
+ TraceCallStack::NamedParams params;
+ params["value"] << (value ? "T" : "F");
+ mCallStack.PushCall("SetViewportEnable", params.str(), params);
+
+ mCommands.emplace_back();
+ mCommands.back().type = CommandType::SET_VIEWPORT_TEST;
+ mCommands.back().data.viewportTest.enable = value;
}
[[nodiscard]] const std::vector<Command>& GetCommands() const
* Retrieves state resolve for selected draw call
* @param drawCommandIndex
*/
- void GetStateForDrawCall( int drawCallIndex );
+ void GetStateForDrawCall(int drawCallIndex);
/**
* Retrieves commands of specified type
*/
- std::vector<Command*> GetCommandsByType( CommandTypeMask mask );
-
+ std::vector<Command*> GetCommandsByType(CommandTypeMask mask);
private:
- TraceCallStack& mCallStack;
- TestGlAbstraction& mGlAbstraction;
+ TraceCallStack& mCallStack;
+ TestGlAbstraction& mGlAbstraction;
+
std::vector<Command> mCommands;
};