From: David Steele Date: Mon, 15 Mar 2021 17:52:18 +0000 (+0000) Subject: Syncing Test harness for Scissor/Viewport X-Git-Tag: graphics-backend-release-1^2~3 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=cc7c738325821be41979913e81fffb961656e0c0;ds=sidebyside Syncing Test harness for Scissor/Viewport Change-Id: I66ef88eef4db358e319f8907c133252b73854e15 --- diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-gl-abstraction.h b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-gl-abstraction.h index 292f8b4..9357803 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-gl-abstraction.h +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-gl-abstraction.h @@ -38,14 +38,15 @@ namespace Dali { - struct UniformData { - std::string name; - Property::Type type; - UniformData( const std::string& name, Property::Type type = Property::Type::NONE) - : name(name), type(type) - {} + std::string name; + Property::Type type; + UniformData(const std::string& name, Property::Type type = Property::Type::NONE) + : name(name), + type(type) + { + } }; class DALI_CORE_API TestGlAbstraction : public Dali::Integration::GlAbstraction @@ -1006,7 +1007,7 @@ public: GetUniformLocation(program, "uLightCameraProjectionMatrix"); GetUniformLocation(program, "uLightCameraViewMatrix"); - for( const auto& uniform : mCustomUniformData ) + for(const auto& uniform : mCustomUniformData) { GetUniformLocation(program, uniform.name.c_str()); } @@ -1217,16 +1218,10 @@ public: out << std::hex << target << ", " << pname << ", " << param; std::string params = out.str(); - out.str(""); - out << std::hex << target; TraceCallStack::NamedParams namedParams; - namedParams["target"] << out.str(); - out.str(""); - out << std::hex << pname; - namedParams["pname"] << out.str(); - out.str(""); - out << std::hex << param; - namedParams["param"] << out.str(); + namedParams["target"] << std::hex << target; + namedParams["pname"] << std::hex << pname; + namedParams["param"] << param; mTexParameterTrace.PushCall("TexParameteri", params, namedParams); } @@ -2553,7 +2548,7 @@ private: typedef std::map ProgramUniformMap; ProgramUniformMap mUniforms; - std::vector mCustomUniformData{}; + std::vector mCustomUniformData{}; template struct ProgramUniformValue : public std::map > diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-buffer.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-buffer.cpp index 22ffcfb..d8a1b1a 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-buffer.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-buffer.cpp @@ -15,10 +15,10 @@ */ #include "test-graphics-buffer.h" -#include "test-graphics-program.h" -#include "test-graphics-reflection.h" #include #include "dali-test-suite-utils.h" +#include "test-graphics-program.h" +#include "test-graphics-reflection.h" namespace Dali { @@ -80,7 +80,7 @@ GLenum TestGraphicsBuffer::GetTarget() return target; } -void TestGraphicsBuffer::BindAsUniformBuffer( const TestGraphicsProgram* program ) const +void TestGraphicsBuffer::BindAsUniformBuffer(const TestGraphicsProgram* program) const { auto* reflection = static_cast(&program->GetReflection()); @@ -89,53 +89,52 @@ void TestGraphicsBuffer::BindAsUniformBuffer( const TestGraphicsProgram* program auto* data = memory.data(); - for( const auto& member : uboInfo.members ) + for(const auto& member : uboInfo.members) { - auto type = reflection->GetMemberType( 0, member.location ); + auto type = reflection->GetMemberType(0, member.location); switch(type) { case Property::VECTOR4: { - auto value = *reinterpret_cast(data+member.offset); - mGl.Uniform4f( member.location, value.x, value.y, value.z, value.w ); + auto value = *reinterpret_cast(data + member.offset); + mGl.Uniform4f(member.location, value.x, value.y, value.z, value.w); break; } case Property::VECTOR3: { - auto value = *reinterpret_cast(data+member.offset); - mGl.Uniform3f( member.location, value.x, value.y, value.z ); + auto value = *reinterpret_cast(data + member.offset); + mGl.Uniform3f(member.location, value.x, value.y, value.z); break; } case Property::VECTOR2: { - auto value = *reinterpret_cast(data+member.offset); - mGl.Uniform2f( member.location, value.x, value.y ); + auto value = *reinterpret_cast(data + member.offset); + mGl.Uniform2f(member.location, value.x, value.y); break; } case Property::FLOAT: { - auto value = *reinterpret_cast(data+member.offset); - fprintf(stderr, "BindAsUniformBuffer: %s, value: %f\n", member.name.c_str(), value); - mGl.Uniform1f( member.location, value ); + auto value = *reinterpret_cast(data + member.offset); + mGl.Uniform1f(member.location, value); break; } case Property::INTEGER: { - auto ptr = reinterpret_cast(data+member.offset); + auto ptr = reinterpret_cast(data + member.offset); auto value = *ptr; - mGl.Uniform1i( member.location, value ); + mGl.Uniform1i(member.location, value); break; } case Property::MATRIX: { - auto value = reinterpret_cast(data+member.offset); - mGl.UniformMatrix4fv( member.location, 1, GL_FALSE, value ); + auto value = reinterpret_cast(data + member.offset); + mGl.UniformMatrix4fv(member.location, 1, GL_FALSE, value); break; } case Property::MATRIX3: { - auto value = reinterpret_cast(data+member.offset); - mGl.UniformMatrix3fv( member.location, 1, GL_FALSE, value ); + auto value = reinterpret_cast(data + member.offset); + mGl.UniformMatrix3fv(member.location, 1, GL_FALSE, value); break; } default: @@ -144,8 +143,6 @@ void TestGraphicsBuffer::BindAsUniformBuffer( const TestGraphicsProgram* program } } } - - } } // namespace Dali diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-buffer.h b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-buffer.h index 64107cf..87c9f87 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-buffer.h +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-buffer.h @@ -40,7 +40,7 @@ public: return true; } - void BindAsUniformBuffer( const TestGraphicsProgram* program ) const; + void BindAsUniformBuffer(const TestGraphicsProgram* program) const; TraceCallStack& mCallStack; TestGlAbstraction& mGl; 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 70f3f0e..ed63416 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 @@ -27,11 +27,11 @@ TestGraphicsCommandBuffer::TestGraphicsCommandBuffer(TraceCallStack& callstack, int TestGraphicsCommandBuffer::GetDrawCallsCount() { int count = 0; - for( auto& cmd : mCommands ) + for(auto& cmd : mCommands) { - if( cmd.type == CommandType::DRAW || - cmd.type == CommandType::DRAW_INDEXED || - cmd.type == CommandType::DRAW_INDEXED_INDIRECT ) + if(cmd.type == CommandType::DRAW || + cmd.type == CommandType::DRAW_INDEXED || + cmd.type == CommandType::DRAW_INDEXED_INDIRECT) { ++count; } @@ -39,18 +39,18 @@ int TestGraphicsCommandBuffer::GetDrawCallsCount() return count; } -void TestGraphicsCommandBuffer::GetStateForDrawCall( int drawCallIndex ) +void TestGraphicsCommandBuffer::GetStateForDrawCall(int drawCallIndex) { - int index = 0; + int index = 0; std::vector mCommandStack{}; - for( auto& cmd : mCommands ) + 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(cmd.type == CommandType::DRAW || + cmd.type == CommandType::DRAW_INDEXED || + cmd.type == CommandType::DRAW_INDEXED_INDIRECT) { - if( index == drawCallIndex ) + if(index == drawCallIndex) { break; } @@ -60,14 +60,14 @@ void TestGraphicsCommandBuffer::GetStateForDrawCall( int drawCallIndex ) } } -std::vector TestGraphicsCommandBuffer::GetCommandsByType( CommandTypeMask mask ) +std::vector TestGraphicsCommandBuffer::GetCommandsByType(CommandTypeMask mask) { std::vector mCommandStack{}; - for( auto& cmd : mCommands ) + for(auto& cmd : mCommands) { - if(uint32_t(cmd.type) == (mask & uint32_t(cmd.type)) ) + if(uint32_t(cmd.type) == (mask & uint32_t(cmd.type))) { - mCommandStack.emplace_back( &cmd ); + mCommandStack.emplace_back(&cmd); } } return mCommandStack; 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..b07166c 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; ///& bindings) override { - printf("BindUniformBuffers: bindings.size(): %lu\n", bindings.size()); - mCommands.emplace_back(); auto& cmd = mCommands.back(); cmd.type = CommandType::BIND_UNIFORM_BUFFER; @@ -433,7 +490,7 @@ 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; @@ -444,8 +501,8 @@ public: } void BeginRenderPass( - Graphics::RenderPass& renderPass, - Graphics::RenderTarget& renderTarget, + Graphics::RenderPass& renderPass, + Graphics::RenderTarget& renderTarget, Graphics::Extent2D renderArea, std::vector clearValues) override { @@ -525,24 +582,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().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().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().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().viewportTest.enable = value; } [[nodiscard]] const std::vector& GetCommands() const @@ -560,17 +649,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; }; 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 f970525..f5f065e 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,18 +463,18 @@ 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]->bindTextures.textureBindings) { - if (binding.texture) + if(binding.texture) { auto texture = Uncast(binding.texture); texture->Bind(binding.binding); - if (binding.sampler) + if(binding.sampler) { auto sampler = Uncast(binding.sampler); - if (sampler) + if(sampler) { sampler->Apply(texture->GetTarget()); } @@ -487,10 +487,10 @@ void TestGraphicsController::SubmitCommandBuffers(const Graphics::SubmitInfo& su // IndexBuffer binding, auto bindIndexBufferCmds = commandBuffer->GetCommandsByType(0 | CommandType::BIND_INDEX_BUFFER); - if (!bindIndexBufferCmds.empty()) + if(!bindIndexBufferCmds.empty()) { - auto &indexBufferBinding = bindIndexBufferCmds[0]->bindIndexBuffer; - if (indexBufferBinding.buffer) + auto& indexBufferBinding = bindIndexBufferCmds[0]->bindIndexBuffer; + if(indexBufferBinding.buffer) { auto buffer = Uncast(indexBufferBinding.buffer); buffer->Bind(); @@ -499,22 +499,54 @@ void TestGraphicsController::SubmitCommandBuffers(const Graphics::SubmitInfo& su // VertexBuffer binding, auto bindVertexBufferCmds = commandBuffer->GetCommandsByType(0 | CommandType::BIND_VERTEX_BUFFERS); - if (!bindVertexBufferCmds.empty()) + if(!bindVertexBufferCmds.empty()) { - for (auto &binding : bindVertexBufferCmds[0]->bindVertexBuffers.vertexBufferBindings) + for(auto& binding : bindVertexBufferCmds[0]->bindVertexBuffers.vertexBufferBindings) { auto graphicsBuffer = binding.buffer; auto vertexBuffer = Uncast(graphicsBuffer); vertexBuffer->Bind(); } } + + bool scissorEnabled = false; + + auto scissorTestList = commandBuffer->GetCommandsByType(0 | CommandType::SET_SCISSOR_TEST); + if(!scissorTestList.empty()) + { + if(scissorTestList[0]->scissorTest.enable) + { + mGl.Enable(GL_SCISSOR_TEST); + scissorEnabled = true; + } + else + { + mGl.Disable(GL_SCISSOR_TEST); + } + } + + auto scissorList = commandBuffer->GetCommandsByType(0 | CommandType::SET_SCISSOR); + if(!scissorList.empty() && scissorEnabled) + { + auto& rect = scissorList[0]->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); + } + + // ignore viewport enable + // Pipeline attribute setup - auto bindPipelineCmds = commandBuffer->GetCommandsByType(0 | CommandType::BIND_PIPELINE); - if (!bindPipelineCmds.empty()) + auto bindPipelineCmds = commandBuffer->GetCommandsByType(0 | CommandType::BIND_PIPELINE); + if(!bindPipelineCmds.empty()) { - auto pipeline = bindPipelineCmds[0]->bindPipeline.pipeline; - auto &vi = pipeline->vertexInputState; - for (auto &attribute : vi.attributes) + auto pipeline = bindPipelineCmds[0]->bindPipeline.pipeline; + auto& vi = pipeline->vertexInputState; + for(auto& attribute : vi.attributes) { mGl.EnableVertexAttribArray(attribute.location); uint32_t attributeOffset = attribute.offset; @@ -525,11 +557,12 @@ void TestGraphicsController::SubmitCommandBuffers(const Graphics::SubmitInfo& su GetGlType(attribute.format), GL_FALSE, // Not normalized stride, - reinterpret_cast(attributeOffset)); + reinterpret_cast(attributeOffset)); } + // Cull face setup - auto &rasterizationState = pipeline->rasterizationState; - if (rasterizationState.cullMode == Graphics::CullMode::NONE) + auto& rasterizationState = pipeline->rasterizationState; + if(rasterizationState.cullMode == Graphics::CullMode::NONE) { mGl.Disable(GL_CULL_FACE); } @@ -544,8 +577,8 @@ void TestGraphicsController::SubmitCommandBuffers(const Graphics::SubmitInfo& su // so it isn't present in the API (and won't have any tests!) // Blending setup - auto &colorBlendState = pipeline->colorBlendState; - if (colorBlendState.blendEnable) + auto& colorBlendState = pipeline->colorBlendState; + if(colorBlendState.blendEnable) { mGl.Enable(GL_BLEND); @@ -553,7 +586,7 @@ void TestGraphicsController::SubmitCommandBuffers(const Graphics::SubmitInfo& su GetBlendFactor(colorBlendState.dstColorBlendFactor), GetBlendFactor(colorBlendState.srcAlphaBlendFactor), GetBlendFactor(colorBlendState.dstAlphaBlendFactor)); - if (colorBlendState.colorBlendOp != colorBlendState.alphaBlendOp) + if(colorBlendState.colorBlendOp != colorBlendState.alphaBlendOp) { mGl.BlendEquationSeparate(GetBlendOp(colorBlendState.colorBlendOp), GetBlendOp(colorBlendState.alphaBlendOp)); } @@ -576,27 +609,27 @@ void TestGraphicsController::SubmitCommandBuffers(const Graphics::SubmitInfo& su // UniformBuffer binding (once we know pipeline) auto bindUniformBuffersCmds = commandBuffer->GetCommandsByType(0 | CommandType::BIND_UNIFORM_BUFFER); - if (!bindUniformBuffersCmds.empty()) + if(!bindUniformBuffersCmds.empty()) { auto buffer = bindUniformBuffersCmds[0]->bindUniformBuffers.standaloneUniformsBufferBinding; // based on reflection, issue gl calls - buffer.buffer->BindAsUniformBuffer( static_cast(pipeline->programState.program) ); + buffer.buffer->BindAsUniformBuffer(static_cast(pipeline->programState.program)); } - auto drawCmds = commandBuffer->GetCommandsByType( 0 | - CommandType::DRAW | - CommandType::DRAW_INDEXED_INDIRECT | - CommandType::DRAW_INDEXED ); + auto drawCmds = commandBuffer->GetCommandsByType(0 | + CommandType::DRAW | + CommandType::DRAW_INDEXED_INDIRECT | + CommandType::DRAW_INDEXED); if(!drawCmds.empty()) { - if (drawCmds[0]->draw.type == DrawCallDescriptor::Type::DRAW_INDEXED ) + if(drawCmds[0]->draw.type == DrawCallDescriptor::Type::DRAW_INDEXED) { mGl.DrawElements(GetTopology(topology), static_cast(drawCmds[0]->draw.drawIndexed.indexCount), GL_UNSIGNED_SHORT, - reinterpret_cast(drawCmds[0]->draw.drawIndexed.firstIndex)); + reinterpret_cast(drawCmds[0]->draw.drawIndexed.firstIndex)); } else { @@ -604,7 +637,7 @@ void TestGraphicsController::SubmitCommandBuffers(const Graphics::SubmitInfo& su } } // attribute clear - for (auto &attribute : vi.attributes) + for(auto& attribute : vi.attributes) { mGl.DisableVertexAttribArray(attribute.location); } @@ -758,7 +791,7 @@ Graphics::UniquePtr TestGraphicsController::CreateProgram(con bool found = true; for(auto& shader : *(programCreateInfo.shaderState)) { - auto graphicsShader = Uncast(shader.shader); + auto graphicsShader = Uncast(shader.shader); std::vector source; source.resize(graphicsShader->mCreateInfo.sourceSize); memcpy(&source[0], graphicsShader->mCreateInfo.sourceData, graphicsShader->mCreateInfo.sourceSize); @@ -779,8 +812,8 @@ Graphics::UniquePtr TestGraphicsController::CreateProgram(con mProgramCache.back().programImpl = new TestGraphicsProgramImpl(mGl, programCreateInfo, mVertexFormats, mCustomUniforms); for(auto& shader : *(programCreateInfo.shaderState)) { - auto graphicsShader = Uncast(shader.shader); - mProgramCache.back().shaders[shader.pipelineStage].resize( graphicsShader->mCreateInfo.sourceSize ); + auto graphicsShader = Uncast(shader.shader); + mProgramCache.back().shaders[shader.pipelineStage].resize(graphicsShader->mCreateInfo.sourceSize); memcpy(&mProgramCache.back().shaders[shader.pipelineStage][0], graphicsShader->mCreateInfo.sourceData, graphicsShader->mCreateInfo.sourceSize); } return Graphics::MakeUnique(mProgramCache.back().programImpl); diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-controller.h b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-controller.h index 14429ef..d70ed3b 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-controller.h +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-controller.h @@ -338,7 +338,7 @@ public: struct ProgramCache { std::map> shaders; - TestGraphicsProgramImpl* programImpl; + TestGraphicsProgramImpl* programImpl; }; std::vector mProgramCache; diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-reflection.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-reflection.cpp index 883eb2d..d59f29f 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-reflection.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-reflection.cpp @@ -18,43 +18,43 @@ #include "test-graphics-shader.h" #include -#include #include +#include namespace Dali { namespace { static const std::vector UNIFORMS = -{ - UniformData("uRendererColor",Property::Type::FLOAT), - UniformData("uCustom", Property::Type::INTEGER), - UniformData("uCustom3", Property::Type::VECTOR3), - UniformData("uFadeColor", Property::Type::VECTOR4), - UniformData("uUniform1", Property::Type::VECTOR4), - UniformData("uUniform2", Property::Type::VECTOR4), - UniformData("uUniform3", Property::Type::VECTOR4), - UniformData("uFadeProgress", Property::Type::FLOAT), - UniformData("uANormalMatrix", Property::Type::MATRIX3), - UniformData("sEffect", Property::Type::FLOAT), - UniformData("sTexture", Property::Type::FLOAT), - UniformData("sTextureRect", Property::Type::FLOAT), - UniformData("sGloss", Property::Type::FLOAT), - UniformData("uColor", Property::Type::VECTOR4), - UniformData("uModelMatrix", Property::Type::MATRIX), - UniformData("uModelView", Property::Type::MATRIX), - UniformData("uMvpMatrix", Property::Type::MATRIX), - UniformData("uNormalMatrix", Property::Type::MATRIX3), - UniformData("uProjection", Property::Type::MATRIX), - UniformData("uSize", Property::Type::VECTOR3), - UniformData("uViewMatrix", Property::Type::MATRIX), - UniformData("uLightCameraProjectionMatrix", Property::Type::MATRIX), - UniformData("uLightCameraViewMatrix", Property::Type::MATRIX), + { + UniformData("uRendererColor", Property::Type::FLOAT), + UniformData("uCustom", Property::Type::INTEGER), + UniformData("uCustom3", Property::Type::VECTOR3), + UniformData("uFadeColor", Property::Type::VECTOR4), + UniformData("uUniform1", Property::Type::VECTOR4), + UniformData("uUniform2", Property::Type::VECTOR4), + UniformData("uUniform3", Property::Type::VECTOR4), + UniformData("uFadeProgress", Property::Type::FLOAT), + UniformData("uANormalMatrix", Property::Type::MATRIX3), + UniformData("sEffect", Property::Type::FLOAT), + UniformData("sTexture", Property::Type::FLOAT), + UniformData("sTextureRect", Property::Type::FLOAT), + UniformData("sGloss", Property::Type::FLOAT), + UniformData("uColor", Property::Type::VECTOR4), + UniformData("uModelMatrix", Property::Type::MATRIX), + UniformData("uModelView", Property::Type::MATRIX), + UniformData("uMvpMatrix", Property::Type::MATRIX), + UniformData("uNormalMatrix", Property::Type::MATRIX3), + UniformData("uProjection", Property::Type::MATRIX), + UniformData("uSize", Property::Type::VECTOR3), + UniformData("uViewMatrix", Property::Type::MATRIX), + UniformData("uLightCameraProjectionMatrix", Property::Type::MATRIX), + UniformData("uLightCameraViewMatrix", Property::Type::MATRIX), }; } TestGraphicsReflection::TestGraphicsReflection(TestGlAbstraction& gl, Property::Array& vfs, const Graphics::ProgramCreateInfo& createInfo, std::vector& customUniforms) - : mGl(gl), - mCustomUniforms(customUniforms) +: mGl(gl), + mCustomUniforms(customUniforms) { for(Property::Array::SizeType i = 0; i < vfs.Count(); ++i) { @@ -72,35 +72,35 @@ TestGraphicsReflection::TestGraphicsReflection(TestGlAbstraction& gl, Property:: } } - mDefaultUniformBlock.name = ""; - mDefaultUniformBlock.members = {}; - mDefaultUniformBlock.binding = 0; - mDefaultUniformBlock.size = 64 * (UNIFORMS.size() + mCustomUniforms.size()); + mDefaultUniformBlock.name = ""; + mDefaultUniformBlock.members = {}; + mDefaultUniformBlock.binding = 0; + mDefaultUniformBlock.size = 64 * (UNIFORMS.size() + mCustomUniforms.size()); mDefaultUniformBlock.descriptorSet = 0; mDefaultUniformBlock.members.clear(); int loc = 0; - for( const auto& data : UNIFORMS ) + for(const auto& data : UNIFORMS) { mDefaultUniformBlock.members.emplace_back(); - auto& item = mDefaultUniformBlock.members.back(); - item.name = data.name; - item.binding = 0; - item.offset = loc*64; - item.location = loc++; - item.bufferIndex = 0; + auto& item = mDefaultUniformBlock.members.back(); + item.name = data.name; + item.binding = 0; + item.offset = loc * 64; + item.location = loc++; + item.bufferIndex = 0; item.uniformClass = Graphics::UniformClass::UNIFORM; } - for( const auto& data : mCustomUniforms ) + for(const auto& data : mCustomUniforms) { fprintf(stderr, "\ncustom uniforms: %s\n", data.name.c_str()); mDefaultUniformBlock.members.emplace_back(); - auto& item = mDefaultUniformBlock.members.back(); - item.name = data.name; - item.binding = 0; - item.offset = loc*64; - item.location = loc++; - item.bufferIndex = 0; + auto& item = mDefaultUniformBlock.members.back(); + item.name = data.name; + item.binding = 0; + item.offset = loc * 64; + item.location = loc++; + item.bufferIndex = 0; item.uniformClass = Graphics::UniformClass::UNIFORM; } @@ -250,7 +250,7 @@ Graphics::ShaderLanguage TestGraphicsReflection::GetLanguage() const return Graphics::ShaderLanguage::GLSL_3_1; } -Dali::Property::Type TestGraphicsReflection::GetMemberType( int blockIndex, int location) const +Dali::Property::Type TestGraphicsReflection::GetMemberType(int blockIndex, int location) const { return location < static_cast(UNIFORMS.size()) ? UNIFORMS[location].type : mCustomUniforms[location - UNIFORMS.size()].type; } diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-reflection.h b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-reflection.h index 9e71989..7af052e 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-reflection.h +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-reflection.h @@ -17,13 +17,12 @@ * limitations under the License. */ -#include #include +#include #include "test-gl-abstraction.h" namespace Dali { - class TestGraphicsReflection : public Graphics::Reflection { public: @@ -57,14 +56,14 @@ public: // Test methods } } - Dali::Property::Type GetMemberType( int blockIndex, int location) const; + Dali::Property::Type GetMemberType(int blockIndex, int location) const; TestGlAbstraction& mGl; mutable std::vector mAttributes; std::vector mCustomUniforms; - Graphics::UniformBlockInfo mDefaultUniformBlock{}; ///< The emulated UBO containing all the standalone uniforms - std::vector mUniformBlocks{}; ///< List of uniform blocks + Graphics::UniformBlockInfo mDefaultUniformBlock{}; ///< The emulated UBO containing all the standalone uniforms + std::vector mUniformBlocks{}; ///< List of uniform blocks }; } // namespace Dali