From d47d7833823c678d8e6cfbe8066b08e4da2b7396 Mon Sep 17 00:00:00 2001 From: Adeel Kazmi Date: Fri, 26 Mar 2021 19:41:52 +0000 Subject: [PATCH] (Automated Tests) Sync Tests Change-Id: Ibf4b75ba259dee161fef22fb45477e2753c527b7 --- .../test-graphics-command-buffer.h | 120 ++++++++++-------- .../test-graphics-controller.cpp | 24 ++-- 2 files changed, 76 insertions(+), 68 deletions(-) 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 b07166c1d1..c10c3f113c 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 @@ -174,50 +174,50 @@ struct Command { 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: @@ -227,22 +227,22 @@ struct Command } case CommandType::SET_SCISSOR: { - scissor.region = rhs.scissor.region; + data.scissor.region = rhs.data.scissor.region; break; } case CommandType::SET_SCISSOR_TEST: { - scissorTest.enable = rhs.scissorTest.enable; + data.scissorTest.enable = rhs.data.scissorTest.enable; break; } case CommandType::SET_VIEWPORT: { - viewport.region = rhs.viewport.region; + data.viewport.region = rhs.data.viewport.region; break; } case CommandType::SET_VIEWPORT_TEST: { - viewportTest.enable = rhs.viewportTest.enable; + data.viewportTest.enable = rhs.data.viewportTest.enable; break; } } @@ -259,50 +259,50 @@ struct Command { 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: @@ -312,22 +312,22 @@ struct Command } case CommandType::SET_SCISSOR: { - scissor.region = rhs.scissor.region; + data.scissor.region = rhs.data.scissor.region; break; } case CommandType::SET_SCISSOR_TEST: { - scissorTest.enable = rhs.scissorTest.enable; + data.scissorTest.enable = rhs.data.scissorTest.enable; break; } case CommandType::SET_VIEWPORT: { - viewport.region = rhs.viewport.region; + data.viewport.region = rhs.data.viewport.region; break; } case CommandType::SET_VIEWPORT_TEST: { - viewportTest.enable = rhs.viewportTest.enable; + data.viewportTest.enable = rhs.data.viewportTest.enable; break; } } @@ -336,8 +336,16 @@ struct Command CommandType type{CommandType::FLUSH}; ///< Type of command - union + union CommandData { + CommandData() + { + } + + ~CommandData() + { + } // do nothing + struct { std::vector textureBindings; @@ -390,7 +398,7 @@ struct Command { bool enable; } viewportTest; - }; + } data; }; class TestGraphicsCommandBuffer : public Graphics::CommandBuffer @@ -407,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()); @@ -427,7 +435,7 @@ public: 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) @@ -461,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", ""); } @@ -493,10 +501,10 @@ public: 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", ""); } @@ -531,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; @@ -549,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; @@ -567,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; @@ -592,8 +600,8 @@ public: mCallStack.PushCall("SetScissor", params.str(), params); mCommands.emplace_back(); - mCommands.back().type = CommandType::SET_SCISSOR; - mCommands.back().scissor.region = value; + mCommands.back().type = CommandType::SET_SCISSOR; + mCommands.back().data.scissor.region = value; } void SetScissorTestEnable(bool value) override @@ -603,8 +611,8 @@ public: mCallStack.PushCall("SetScissorTestEnable", params.str(), params); mCommands.emplace_back(); - mCommands.back().type = CommandType::SET_SCISSOR_TEST; - mCommands.back().scissorTest.enable = value; + mCommands.back().type = CommandType::SET_SCISSOR_TEST; + mCommands.back().data.scissorTest.enable = value; } void SetViewport(Graphics::Viewport value) override @@ -619,8 +627,8 @@ public: mCallStack.PushCall("SetViewport", params.str(), params); mCommands.emplace_back(); - mCommands.back().type = CommandType::SET_VIEWPORT; - mCommands.back().viewport.region = value; + mCommands.back().type = CommandType::SET_VIEWPORT; + mCommands.back().data.viewport.region = value; } void SetViewportEnable(bool value) override @@ -630,8 +638,8 @@ public: mCallStack.PushCall("SetViewportEnable", params.str(), params); mCommands.emplace_back(); - mCommands.back().type = CommandType::SET_VIEWPORT_TEST; - mCommands.back().viewportTest.enable = value; + mCommands.back().type = CommandType::SET_VIEWPORT_TEST; + mCommands.back().data.viewportTest.enable = value; } [[nodiscard]] const std::vector& GetCommands() const diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-controller.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-controller.cpp index f5f065ed69..48d6912ac7 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-controller.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-controller.cpp @@ -463,7 +463,7 @@ void TestGraphicsController::SubmitCommandBuffers(const Graphics::SubmitInfo& su if(!value.empty()) { // must be fixed - for(auto& binding : value[0]->bindTextures.textureBindings) + for(auto& binding : value[0]->data.bindTextures.textureBindings) { if(binding.texture) { @@ -489,7 +489,7 @@ void TestGraphicsController::SubmitCommandBuffers(const Graphics::SubmitInfo& su auto bindIndexBufferCmds = commandBuffer->GetCommandsByType(0 | CommandType::BIND_INDEX_BUFFER); if(!bindIndexBufferCmds.empty()) { - auto& indexBufferBinding = bindIndexBufferCmds[0]->bindIndexBuffer; + auto& indexBufferBinding = bindIndexBufferCmds[0]->data.bindIndexBuffer; if(indexBufferBinding.buffer) { auto buffer = Uncast(indexBufferBinding.buffer); @@ -501,7 +501,7 @@ void TestGraphicsController::SubmitCommandBuffers(const Graphics::SubmitInfo& su auto bindVertexBufferCmds = commandBuffer->GetCommandsByType(0 | CommandType::BIND_VERTEX_BUFFERS); if(!bindVertexBufferCmds.empty()) { - for(auto& binding : bindVertexBufferCmds[0]->bindVertexBuffers.vertexBufferBindings) + for(auto& binding : bindVertexBufferCmds[0]->data.bindVertexBuffers.vertexBufferBindings) { auto graphicsBuffer = binding.buffer; auto vertexBuffer = Uncast(graphicsBuffer); @@ -514,7 +514,7 @@ void TestGraphicsController::SubmitCommandBuffers(const Graphics::SubmitInfo& su auto scissorTestList = commandBuffer->GetCommandsByType(0 | CommandType::SET_SCISSOR_TEST); if(!scissorTestList.empty()) { - if(scissorTestList[0]->scissorTest.enable) + if(scissorTestList[0]->data.scissorTest.enable) { mGl.Enable(GL_SCISSOR_TEST); scissorEnabled = true; @@ -528,14 +528,14 @@ void TestGraphicsController::SubmitCommandBuffers(const Graphics::SubmitInfo& su auto scissorList = commandBuffer->GetCommandsByType(0 | CommandType::SET_SCISSOR); if(!scissorList.empty() && scissorEnabled) { - auto& rect = scissorList[0]->scissor.region; + auto& rect = scissorList[0]->data.scissor.region; mGl.Scissor(rect.x, rect.y, rect.width, rect.height); } auto viewportList = commandBuffer->GetCommandsByType(0 | CommandType::SET_VIEWPORT); if(!viewportList.empty()) { - mGl.Viewport(viewportList[0]->viewport.region.x, viewportList[0]->viewport.region.y, viewportList[0]->viewport.region.width, viewportList[0]->viewport.region.height); + mGl.Viewport(viewportList[0]->data.viewport.region.x, viewportList[0]->data.viewport.region.y, viewportList[0]->data.viewport.region.width, viewportList[0]->data.viewport.region.height); } // ignore viewport enable @@ -544,7 +544,7 @@ void TestGraphicsController::SubmitCommandBuffers(const Graphics::SubmitInfo& su auto bindPipelineCmds = commandBuffer->GetCommandsByType(0 | CommandType::BIND_PIPELINE); if(!bindPipelineCmds.empty()) { - auto pipeline = bindPipelineCmds[0]->bindPipeline.pipeline; + auto pipeline = bindPipelineCmds[0]->data.bindPipeline.pipeline; auto& vi = pipeline->vertexInputState; for(auto& attribute : vi.attributes) { @@ -611,7 +611,7 @@ void TestGraphicsController::SubmitCommandBuffers(const Graphics::SubmitInfo& su auto bindUniformBuffersCmds = commandBuffer->GetCommandsByType(0 | CommandType::BIND_UNIFORM_BUFFER); if(!bindUniformBuffersCmds.empty()) { - auto buffer = bindUniformBuffersCmds[0]->bindUniformBuffers.standaloneUniformsBufferBinding; + auto buffer = bindUniformBuffersCmds[0]->data.bindUniformBuffers.standaloneUniformsBufferBinding; // based on reflection, issue gl calls buffer.buffer->BindAsUniformBuffer(static_cast(pipeline->programState.program)); @@ -624,16 +624,16 @@ void TestGraphicsController::SubmitCommandBuffers(const Graphics::SubmitInfo& su if(!drawCmds.empty()) { - if(drawCmds[0]->draw.type == DrawCallDescriptor::Type::DRAW_INDEXED) + if(drawCmds[0]->data.draw.type == DrawCallDescriptor::Type::DRAW_INDEXED) { mGl.DrawElements(GetTopology(topology), - static_cast(drawCmds[0]->draw.drawIndexed.indexCount), + static_cast(drawCmds[0]->data.draw.drawIndexed.indexCount), GL_UNSIGNED_SHORT, - reinterpret_cast(drawCmds[0]->draw.drawIndexed.firstIndex)); + reinterpret_cast(drawCmds[0]->data.draw.drawIndexed.firstIndex)); } else { - mGl.DrawArrays(GetTopology(topology), 0, drawCmds[0]->draw.draw.vertexCount); + mGl.DrawArrays(GetTopology(topology), 0, drawCmds[0]->data.draw.draw.vertexCount); } } // attribute clear -- 2.34.1