X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit%2Fdali-toolkit-test-utils%2Ftest-graphics-command-buffer.h;h=c10c3f113c4ffa903903f7c82d78f2b0dd2d32fc;hb=d74d70d51ed70b00e29a2b6feac5419124fffc49;hp=b4cb9b00697a3a7cfad09f490580496a9cb0e5ba;hpb=f1876c34a8f667f79182fa8a772ee889e27290c1;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-command-buffer.h b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-command-buffer.h index b4cb9b0..c10c3f1 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-command-buffer.h +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-command-buffer.h @@ -24,8 +24,8 @@ #include #include #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 @@ -37,16 +37,20 @@ 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 + 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; @@ -63,7 +67,7 @@ inline CommandTypeMask operator|(T flags, CommandType bit) struct VertexBufferBindingDescriptor { const TestGraphicsBuffer* buffer{nullptr}; - uint32_t offset{0u}; + uint32_t offset{0u}; }; /** @@ -73,8 +77,8 @@ struct VertexBufferBindingDescriptor struct IndexBufferBindingDescriptor { const TestGraphicsBuffer* buffer{nullptr}; - uint32_t offset{}; - Graphics::Format format{}; + uint32_t offset{}; + Graphics::Format format{}; }; /** @@ -84,9 +88,9 @@ struct IndexBufferBindingDescriptor struct UniformBufferBindingDescriptor { const TestGraphicsBuffer* buffer{nullptr}; - uint32_t binding{0u}; - uint32_t offset{0u}; - bool emulated; /// textureBindings; @@ -329,9 +381,25 @@ struct Command 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 { @@ -339,7 +407,6 @@ public: TestGraphicsCommandBuffer(TraceCallStack& callstack, TestGlAbstraction& glAbstraction); ~TestGraphicsCommandBuffer() { - } void BindVertexBuffers(uint32_t firstBinding, @@ -348,7 +415,7 @@ public: { 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()); @@ -365,12 +432,10 @@ public: void BindUniformBuffers(const std::vector& 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) @@ -404,23 +469,23 @@ public: void BindPipeline(const Graphics::Pipeline& pipeline) override { mCommands.emplace_back(); - mCommands.back().type = CommandType::BIND_PIPELINE; - mCommands.back().bindPipeline.pipeline = static_cast(&pipeline); + mCommands.back().type = CommandType::BIND_PIPELINE; + mCommands.back().data.bindPipeline.pipeline = static_cast(&pipeline); mCallStack.PushCall("BindPipeline", ""); } void BindTextures(std::vector& 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& samplerBindings) override { mCommands.emplace_back(); - mCommands.back().bindSamplers.samplerBindings = std::move(samplerBindings); + mCommands.back().data.bindSamplers.samplerBindings = std::move(samplerBindings); mCallStack.PushCall("BindSamplers", ""); } @@ -433,19 +498,19 @@ public: 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(&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(&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 clearValues) override { @@ -474,7 +539,7 @@ public: { 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; @@ -492,7 +557,7 @@ public: { 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; @@ -510,7 +575,7 @@ public: { 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(&buffer); cmd.drawIndexedIndirect.offset = offset; @@ -525,24 +590,56 @@ public: 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& GetCommands() const @@ -560,17 +657,17 @@ public: * Retrieves state resolve for selected draw call * @param drawCommandIndex */ - void GetStateForDrawCall( int drawCallIndex ); + void GetStateForDrawCall(int drawCallIndex); /** * Retrieves commands of specified type */ - std::vector GetCommandsByType( CommandTypeMask mask ); - + std::vector GetCommandsByType(CommandTypeMask mask); private: - TraceCallStack& mCallStack; - TestGlAbstraction& mGlAbstraction; + TraceCallStack& mCallStack; + TestGlAbstraction& mGlAbstraction; + std::vector mCommands; };