From aab4c5574b6d63ab5b4a41fa972f5eaa9e6e769a Mon Sep 17 00:00:00 2001 From: Adam Bialogonski Date: Thu, 11 Mar 2021 17:49:29 +0000 Subject: [PATCH] Command union has been named Change-Id: Ic8afdfeac79c74b7ec70abccf9f3d450501e32f8 --- .../test-graphics-command-buffer.h | 80 ++++++++++++---------- .../test-graphics-controller.cpp | 18 ++--- automated-tests/src/dali/utc-Dali-Renderer.cpp | 2 +- 3 files changed, 53 insertions(+), 47 deletions(-) diff --git a/automated-tests/src/dali/dali-test-suite-utils/test-graphics-command-buffer.h b/automated-tests/src/dali/dali-test-suite-utils/test-graphics-command-buffer.h index 1eccb8d..e24d132 100644 --- a/automated-tests/src/dali/dali-test-suite-utils/test-graphics-command-buffer.h +++ b/automated-tests/src/dali/dali-test-suite-utils/test-graphics-command-buffer.h @@ -170,50 +170,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: @@ -235,50 +235,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: @@ -292,8 +292,14 @@ struct Command CommandType type{CommandType::FLUSH}; ///< Type of command - union + union CommandData { + CommandData() + {} + + ~CommandData() + {} // do nothing + struct { std::vector textureBindings; @@ -329,7 +335,7 @@ struct Command struct : public DrawCallDescriptor { } draw; - }; + } data; }; @@ -348,7 +354,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()); @@ -368,7 +374,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) @@ -403,7 +409,7 @@ public: { mCommands.emplace_back(); mCommands.back().type = CommandType::BIND_PIPELINE; - mCommands.back().bindPipeline.pipeline = static_cast(&pipeline); + mCommands.back().data.bindPipeline.pipeline = static_cast(&pipeline); mCallStack.PushCall("BindPipeline", ""); } @@ -411,14 +417,14 @@ public: { mCommands.emplace_back(); mCommands.back().type = CommandType::BIND_TEXTURES; - mCommands.back().bindTextures.textureBindings = std::move(textureBindings); + 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", ""); } @@ -435,9 +441,9 @@ public: { 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().data.bindIndexBuffer.buffer = static_cast(&buffer); + mCommands.back().data.bindIndexBuffer.offset = offset; + mCommands.back().data.bindIndexBuffer.format = format; mCallStack.PushCall("BindIndexBuffer", ""); } @@ -472,7 +478,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; @@ -490,7 +496,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; @@ -508,7 +514,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; diff --git a/automated-tests/src/dali/dali-test-suite-utils/test-graphics-controller.cpp b/automated-tests/src/dali/dali-test-suite-utils/test-graphics-controller.cpp index 782835e..acddb79 100644 --- a/automated-tests/src/dali/dali-test-suite-utils/test-graphics-controller.cpp +++ b/automated-tests/src/dali/dali-test-suite-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); @@ -512,7 +512,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) { @@ -578,7 +578,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) ); @@ -591,16 +591,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 diff --git a/automated-tests/src/dali/utc-Dali-Renderer.cpp b/automated-tests/src/dali/utc-Dali-Renderer.cpp index 667b065..47c641a 100644 --- a/automated-tests/src/dali/utc-Dali-Renderer.cpp +++ b/automated-tests/src/dali/utc-Dali-Renderer.cpp @@ -3653,7 +3653,7 @@ int UtcDaliRendererPreparePipeline(void) TestGraphicsCommandBuffer* cmdBuf = static_cast((submissions[0].cmdBuffer[0])); //auto pipeline = cmdBuf->mPipeline; auto result = cmdBuf->GetCommandsByType( 0 | CommandType::BIND_PIPELINE ); - auto pipeline = result[0]->bindPipeline.pipeline; + auto pipeline = result[0]->data.bindPipeline.pipeline; if(pipeline) { -- 2.7.4