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.cpp;h=9f86b991c21c89d7aea90f3de70cee973d171669;hb=abc8459e18c5a7f8730c9493885fd067126520cb;hp=a0dee4ab2e86ed3b207100e5ff6e9044942ecc04;hpb=6c62f5aa91b434193d0fc11b7763ba7286372fc4;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-command-buffer.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-command-buffer.cpp index a0dee4a..9f86b99 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-command-buffer.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-command-buffer.cpp @@ -18,140 +18,146 @@ namespace Dali { -TestGraphicsCommandBuffer::TestGraphicsCommandBuffer(TraceCallStack& callstack, TestGlAbstraction& glAbstraction) -: mCallStack(callstack), - mGlAbstraction(glAbstraction) -{ -} - -void TestGraphicsCommandBuffer::BindVertexBuffers(uint32_t firstBinding, - std::vector buffers, - std::vector offsets) -{ - mVertexBufferBindings.firstBinding = firstBinding; - mVertexBufferBindings.buffers = buffers; // Copy - mVertexBufferBindings.offsets = offsets; // Copy - mCallStack.PushCall("BindVertexBuffers", ""); -} - -void TestGraphicsCommandBuffer::BindUniformBuffers(const std::vector& bindings) -{ - mCallStack.PushCall("BindUniformBuffers", ""); -} - -void TestGraphicsCommandBuffer::BindPipeline(const Graphics::Pipeline& pipeline) -{ - mPipeline = static_cast(const_cast(&pipeline)); - mCallStack.PushCall("BindPipeline", ""); -} - -void TestGraphicsCommandBuffer::BindTextures(std::vector& textureBindings) +std::ostream& operator<<(std::ostream& os, Graphics::StencilOp op) { - mCallStack.PushCall("BindTextures", ""); - for(auto& binding : textureBindings) + switch(op) { - mTextureBindings.push_back(binding); + case Graphics::StencilOp::KEEP: + os << "KEEP"; + return os; + case Graphics::StencilOp::ZERO: + os << "ZERO"; + return os; + case Graphics::StencilOp::REPLACE: + os << "REPLACE"; + return os; + case Graphics::StencilOp::INCREMENT_AND_CLAMP: + os << "INCREMENT_AND_CLAMP"; + return os; + case Graphics::StencilOp::DECREMENT_AND_CLAMP: + os << "DECREMENT_AND_CLAMP"; + return os; + case Graphics::StencilOp::INVERT: + os << "INVERT"; + return os; + case Graphics::StencilOp::INCREMENT_AND_WRAP: + os << "INCREMENT_AND_WRAP"; + return os; + case Graphics::StencilOp::DECREMENT_AND_WRAP: + os << "DECREMENT_AND_WRAP"; + return os; } -} + return os; +}; -void TestGraphicsCommandBuffer::BindSamplers(std::vector& samplerBindings) +std::ostream& operator<<(std::ostream& os, Graphics::CompareOp op) { - mCallStack.PushCall("BindSamplers", ""); -} - -void TestGraphicsCommandBuffer::BindPushConstants(void* data, - uint32_t size, - uint32_t binding) -{ - mCallStack.PushCall("BindPushConstants", ""); -} - -void TestGraphicsCommandBuffer::BindIndexBuffer(const Graphics::Buffer& buffer, - uint32_t offset, - Graphics::Format format) -{ - mIndexBufferBinding.buffer = &buffer; - mIndexBufferBinding.offset = offset; - mIndexBufferBinding.format = format; - mCallStack.PushCall("BindIndexBuffer", ""); -} - -void TestGraphicsCommandBuffer::BeginRenderPass( - Graphics::RenderPass& renderPass, - Graphics::RenderTarget& renderTarget, - Graphics::Extent2D renderArea, - std::vector clearValues) -{ - mCallStack.PushCall("BeginRenderPass", ""); -} - -void TestGraphicsCommandBuffer::EndRenderPass() -{ - mCallStack.PushCall("EndRenderPass", ""); -} - -void TestGraphicsCommandBuffer::Draw( - uint32_t vertexCount, - uint32_t instanceCount, - uint32_t firstVertex, - uint32_t firstInstance) -{ - drawCommand.drawType = Draw::DrawType::Unindexed; - drawCommand.u.unindexedDraw.vertexCount = vertexCount; - drawCommand.u.unindexedDraw.instanceCount = instanceCount; - drawCommand.u.unindexedDraw.firstVertex = firstVertex; - drawCommand.u.unindexedDraw.firstInstance = firstInstance; - mCallStack.PushCall("Draw", ""); -} - -void TestGraphicsCommandBuffer::DrawIndexed( - uint32_t indexCount, - uint32_t instanceCount, - uint32_t firstIndex, - int32_t vertexOffset, - uint32_t firstInstance) -{ - drawCommand.drawType = TestGraphicsCommandBuffer::Draw::DrawType::Indexed; - drawCommand.u.indexedDraw.indexCount = indexCount; - drawCommand.u.indexedDraw.instanceCount = instanceCount; - drawCommand.u.indexedDraw.firstIndex = firstIndex; - drawCommand.u.indexedDraw.vertexOffset = vertexOffset; - drawCommand.u.indexedDraw.firstInstance = firstInstance; - mCallStack.PushCall("DrawIndexed", ""); -} - -void TestGraphicsCommandBuffer::DrawIndexedIndirect( - Graphics::Buffer& buffer, - uint32_t offset, - uint32_t drawCount, - uint32_t stride) -{ - mCallStack.PushCall("DrawIndexedIndirect", ""); -} + switch(op) + { + case Graphics::CompareOp::NEVER: + os << "NEVER"; + return os; + case Graphics::CompareOp::LESS: + os << "LESS"; + return os; + case Graphics::CompareOp::EQUAL: + os << "EQUAL"; + return os; + case Graphics::CompareOp::LESS_OR_EQUAL: + os << "LESS_OR_EQUAL"; + return os; + case Graphics::CompareOp::GREATER: + os << "GREATER"; + return os; + case Graphics::CompareOp::NOT_EQUAL: + os << "NOT_EQUAL"; + return os; + case Graphics::CompareOp::GREATER_OR_EQUAL: + os << "GREATER_OR_EQUAL"; + return os; + case Graphics::CompareOp::ALWAYS: + os << "ALWAYS"; + return os; + } + return os; +}; -void TestGraphicsCommandBuffer::Reset(Graphics::CommandBuffer& commandBuffer) +TestGraphicsCommandBuffer::TestGraphicsCommandBuffer(TraceCallStack& callstack, TestGlAbstraction& glAbstraction) +: mCallStack(callstack), + mGlAbstraction(glAbstraction) { - mCallStack.PushCall("Reset", ""); } -void TestGraphicsCommandBuffer::SetScissor(Graphics::Extent2D value) +int TestGraphicsCommandBuffer::GetDrawCallsCount() { - mCallStack.PushCall("SetScissor", ""); + int count = 0; + for(auto& cmd : mCommands) + { + if(cmd.type == CommandType::DRAW || + cmd.type == CommandType::DRAW_INDEXED || + cmd.type == CommandType::DRAW_INDEXED_INDIRECT) + { + ++count; + } + } + return count; } -void TestGraphicsCommandBuffer::SetScissorTestEnable(bool value) +void TestGraphicsCommandBuffer::GetStateForDrawCall(int drawCallIndex) { - mCallStack.PushCall("SetScissorTestEnable", ""); + int index = 0; + std::vector mCommandStack{}; + for(auto& cmd : mCommands) + { + mCommandStack.push_back(cmd); + if(cmd.type == CommandType::DRAW || + cmd.type == CommandType::DRAW_INDEXED || + cmd.type == CommandType::DRAW_INDEXED_INDIRECT) + { + if(index == drawCallIndex) + { + break; + } + mCommandStack.clear(); + ++index; + } + } } -void TestGraphicsCommandBuffer::SetViewport(Graphics::Viewport value) +std::vector TestGraphicsCommandBuffer::GetCommandsByType(CommandTypeMask mask) const { - mCallStack.PushCall("SetViewport", ""); + std::vector mCommandStack{}; + for(auto& cmd : mCommands) + { + if(uint32_t(cmd.type) == (mask & uint32_t(cmd.type))) + { + mCommandStack.emplace_back(&cmd); + } + } + return mCommandStack; } -void TestGraphicsCommandBuffer::SetViewportEnable(bool value) +std::vector TestGraphicsCommandBuffer::GetChildCommandsByType(CommandTypeMask mask) const { - mCallStack.PushCall("SetViewportEnable", ""); + std::vector mCommandStack{}; + for(auto& cmd : mCommands) + { + if(uint32_t(cmd.type) == (mask & uint32_t(cmd.type))) + { + mCommandStack.emplace_back(&cmd); + } + if(cmd.type == CommandType::EXECUTE_COMMAND_BUFFERS) + { + for(auto secondaryCB : cmd.data.executeCommandBuffers.buffers) + { + for(auto command : secondaryCB->GetChildCommandsByType(mask)) + { + mCommandStack.push_back(command); + } + } + } + } + return mCommandStack; } } // namespace Dali