Syncing Test harness for Scissor/Viewport 12/255312/1
authorDavid Steele <david.steele@samsung.com>
Mon, 15 Mar 2021 17:52:18 +0000 (17:52 +0000)
committerDavid Steele <david.steele@samsung.com>
Tue, 16 Mar 2021 11:16:39 +0000 (11:16 +0000)
Change-Id: I66ef88eef4db358e319f8907c133252b73854e15

automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-gl-abstraction.h
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-buffer.cpp
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-buffer.h
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-command-buffer.cpp
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-command-buffer.h
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-controller.cpp
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-controller.h
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-reflection.cpp
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-reflection.h

index 292f8b4..9357803 100644 (file)
 
 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<GLuint, UniformIDMap> ProgramUniformMap;
   ProgramUniformMap                      mUniforms;
 
-  std::vector<UniformData>               mCustomUniformData{};
+  std::vector<UniformData> mCustomUniformData{};
 
   template<typename T>
   struct ProgramUniformValue : public std::map<GLuint, std::map<GLint, T> >
index 22ffcfb..d8a1b1a 100644 (file)
  */
 
 #include "test-graphics-buffer.h"
-#include "test-graphics-program.h"
-#include "test-graphics-reflection.h"
 #include <sstream>
 #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<const TestGraphicsReflection*>(&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<const Dali::Vector4*>(data+member.offset);
-        mGl.Uniform4f( member.location, value.x, value.y, value.z, value.w );
+        auto value = *reinterpret_cast<const Dali::Vector4*>(data + member.offset);
+        mGl.Uniform4f(member.location, value.x, value.y, value.z, value.w);
         break;
       }
       case Property::VECTOR3:
       {
-        auto value = *reinterpret_cast<const Dali::Vector3*>(data+member.offset);
-        mGl.Uniform3f( member.location, value.x, value.y, value.z );
+        auto value = *reinterpret_cast<const Dali::Vector3*>(data + member.offset);
+        mGl.Uniform3f(member.location, value.x, value.y, value.z);
         break;
       }
       case Property::VECTOR2:
       {
-        auto value = *reinterpret_cast<const Dali::Vector2*>(data+member.offset);
-        mGl.Uniform2f( member.location, value.x, value.y );
+        auto value = *reinterpret_cast<const Dali::Vector2*>(data + member.offset);
+        mGl.Uniform2f(member.location, value.x, value.y);
         break;
       }
       case Property::FLOAT:
       {
-        auto value = *reinterpret_cast<const float*>(data+member.offset);
-        fprintf(stderr, "BindAsUniformBuffer: %s, value: %f\n", member.name.c_str(), value);
-        mGl.Uniform1f( member.location, value );
+        auto value = *reinterpret_cast<const float*>(data + member.offset);
+        mGl.Uniform1f(member.location, value);
         break;
       }
       case Property::INTEGER:
       {
-        auto ptr = reinterpret_cast<const GLint*>(data+member.offset);
+        auto ptr   = reinterpret_cast<const GLint*>(data + member.offset);
         auto value = *ptr;
-        mGl.Uniform1i( member.location, value );
+        mGl.Uniform1i(member.location, value);
         break;
       }
       case Property::MATRIX:
       {
-        auto value = reinterpret_cast<const float*>(data+member.offset);
-        mGl.UniformMatrix4fv( member.location, 1, GL_FALSE, value );
+        auto value = reinterpret_cast<const float*>(data + member.offset);
+        mGl.UniformMatrix4fv(member.location, 1, GL_FALSE, value);
         break;
       }
       case Property::MATRIX3:
       {
-        auto value = reinterpret_cast<const float*>(data+member.offset);
-        mGl.UniformMatrix3fv( member.location, 1, GL_FALSE, value );
+        auto value = reinterpret_cast<const float*>(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
index 64107cf..87c9f87 100644 (file)
@@ -40,7 +40,7 @@ public:
     return true;
   }
 
-  void BindAsUniformBuffer( const TestGraphicsProgram* program ) const;
+  void BindAsUniformBuffer(const TestGraphicsProgram* program) const;
 
   TraceCallStack&            mCallStack;
   TestGlAbstraction&         mGl;
index 70f3f0e..ed63416 100644 (file)
@@ -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<Command> 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<Command*> TestGraphicsCommandBuffer::GetCommandsByType( CommandTypeMask mask )
+std::vector<Command*> TestGraphicsCommandBuffer::GetCommandsByType(CommandTypeMask mask)
 {
   std::vector<Command*> 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;
index b4cb9b0..b07166c 100644 (file)
@@ -24,8 +24,8 @@
 #include <cstdint>
 #include <vector>
 #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; ///<true if UBO is emulated for old gfx API
+  uint32_t                  binding{0u};
+  uint32_t                  offset{0u};
+  bool                      emulated; ///<true if UBO is emulated for old gfx API
 };
 
 /**
@@ -140,9 +144,9 @@ struct DrawCallDescriptor
     struct
     {
       const TestGraphicsBuffer* buffer;
-      uint32_t            offset;
-      uint32_t            drawCount;
-      uint32_t            stride;
+      uint32_t                  offset;
+      uint32_t                  drawCount;
+      uint32_t                  stride;
     } drawIndexedIndirect;
   };
 };
@@ -221,12 +225,32 @@ struct Command
         // Nothing to do
         break;
       }
+      case CommandType::SET_SCISSOR:
+      {
+        scissor.region = rhs.scissor.region;
+        break;
+      }
+      case CommandType::SET_SCISSOR_TEST:
+      {
+        scissorTest.enable = rhs.scissorTest.enable;
+        break;
+      }
+      case CommandType::SET_VIEWPORT:
+      {
+        viewport.region = rhs.viewport.region;
+        break;
+      }
+      case CommandType::SET_VIEWPORT_TEST:
+      {
+        viewportTest.enable = rhs.viewportTest.enable;
+        break;
+      }
     }
     type = rhs.type;
   }
 
   /**
-   * @brief Copy constructor
+   * @brief move constructor
    * @param[in] rhs Command
    */
   Command(Command&& rhs) noexcept
@@ -286,6 +310,26 @@ struct Command
         // Nothing to do
         break;
       }
+      case CommandType::SET_SCISSOR:
+      {
+        scissor.region = rhs.scissor.region;
+        break;
+      }
+      case CommandType::SET_SCISSOR_TEST:
+      {
+        scissorTest.enable = rhs.scissorTest.enable;
+        break;
+      }
+      case CommandType::SET_VIEWPORT:
+      {
+        viewport.region = rhs.viewport.region;
+        break;
+      }
+      case CommandType::SET_VIEWPORT_TEST:
+      {
+        viewportTest.enable = rhs.viewportTest.enable;
+        break;
+      }
     }
     type = rhs.type;
   }
@@ -329,17 +373,32 @@ struct Command
     struct : public DrawCallDescriptor
     {
     } draw;
+
+    struct
+    {
+      Graphics::Rect2D region;
+    } scissor;
+    struct
+    {
+      bool enable;
+    } scissorTest;
+    struct
+    {
+      Graphics::Viewport region;
+    } viewport;
+    struct
+    {
+      bool enable;
+    } viewportTest;
   };
 };
 
-
 class TestGraphicsCommandBuffer : public Graphics::CommandBuffer
 {
 public:
   TestGraphicsCommandBuffer(TraceCallStack& callstack, TestGlAbstraction& glAbstraction);
   ~TestGraphicsCommandBuffer()
   {
-
   }
 
   void BindVertexBuffers(uint32_t                             firstBinding,
@@ -365,8 +424,6 @@ public:
 
   void BindUniformBuffers(const std::vector<Graphics::UniformBufferBinding>& 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<Graphics::ClearValue> 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<Command>& 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<Command*> GetCommandsByType( CommandTypeMask mask );
-
+  std::vector<Command*> GetCommandsByType(CommandTypeMask mask);
 
 private:
-  TraceCallStack&                       mCallStack;
-  TestGlAbstraction&                    mGlAbstraction;
+  TraceCallStack&    mCallStack;
+  TestGlAbstraction& mGlAbstraction;
+
   std::vector<Command> mCommands;
 };
 
index f970525..f5f065e 100644 (file)
@@ -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<TestGraphicsTexture>(binding.texture);
 
           texture->Bind(binding.binding);
 
-          if (binding.sampler)
+          if(binding.sampler)
           {
             auto sampler = Uncast<TestGraphicsSampler>(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)
+      autoindexBufferBinding = bindIndexBufferCmds[0]->bindIndexBuffer;
+      if(indexBufferBinding.buffer)
       {
         auto buffer = Uncast<TestGraphicsBuffer>(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<TestGraphicsBuffer>(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<void *>(attributeOffset));
+                                reinterpret_cast<void*>(attributeOffset));
       }
+
       // Cull face setup
-      auto &rasterizationState = pipeline->rasterizationState;
-      if (rasterizationState.cullMode == Graphics::CullMode::NONE)
+      autorasterizationState = 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)
+      autocolorBlendState = 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<const TestGraphicsProgram*>(pipeline->programState.program) );
+        buffer.buffer->BindAsUniformBuffer(static_cast<const TestGraphicsProgram*>(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<GLsizei>(drawCmds[0]->draw.drawIndexed.indexCount),
                            GL_UNSIGNED_SHORT,
-                           reinterpret_cast<void *>(drawCmds[0]->draw.drawIndexed.firstIndex));
+                           reinterpret_cast<void*>(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<Graphics::Program> TestGraphicsController::CreateProgram(con
     bool found = true;
     for(auto& shader : *(programCreateInfo.shaderState))
     {
-      auto graphicsShader = Uncast<TestGraphicsShader>(shader.shader);
+      auto                 graphicsShader = Uncast<TestGraphicsShader>(shader.shader);
       std::vector<uint8_t> source;
       source.resize(graphicsShader->mCreateInfo.sourceSize);
       memcpy(&source[0], graphicsShader->mCreateInfo.sourceData, graphicsShader->mCreateInfo.sourceSize);
@@ -779,8 +812,8 @@ Graphics::UniquePtr<Graphics::Program> TestGraphicsController::CreateProgram(con
   mProgramCache.back().programImpl = new TestGraphicsProgramImpl(mGl, programCreateInfo, mVertexFormats, mCustomUniforms);
   for(auto& shader : *(programCreateInfo.shaderState))
   {
-    auto graphicsShader                                = Uncast<TestGraphicsShader>(shader.shader);
-    mProgramCache.back().shaders[shader.pipelineStage].resize( graphicsShader->mCreateInfo.sourceSize );
+    auto graphicsShader = Uncast<TestGraphicsShader>(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<TestGraphicsProgram>(mProgramCache.back().programImpl);
index 14429ef..d70ed3b 100644 (file)
@@ -338,7 +338,7 @@ public:
   struct ProgramCache
   {
     std::map<Graphics::PipelineStage, std::vector<uint8_t>> shaders;
-    TestGraphicsProgramImpl* programImpl;
+    TestGraphicsProgramImpl*                                programImpl;
   };
   std::vector<ProgramCache> mProgramCache;
 
index 883eb2d..d59f29f 100644 (file)
 #include "test-graphics-shader.h"
 
 #include <dali/public-api/object/property-map.h>
-#include <vector>
 #include <string>
+#include <vector>
 namespace Dali
 {
 namespace
 {
 static const std::vector<UniformData> 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<UniformData>& 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<int>(UNIFORMS.size()) ? UNIFORMS[location].type : mCustomUniforms[location - UNIFORMS.size()].type;
 }
index 9e71989..7af052e 100644 (file)
  * limitations under the License.
  */
 
-#include <dali/graphics-api/graphics-reflection.h>
 #include <dali/graphics-api/graphics-program-create-info.h>
+#include <dali/graphics-api/graphics-reflection.h>
 #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<std::string> mAttributes;
   std::vector<UniformData>         mCustomUniforms;
 
-  Graphics::UniformBlockInfo              mDefaultUniformBlock{};       ///< The emulated UBO containing all the standalone uniforms
-  std::vector<Graphics::UniformBlockInfo> mUniformBlocks{};             ///< List of uniform blocks
+  Graphics::UniformBlockInfo              mDefaultUniformBlock{}; ///< The emulated UBO containing all the standalone uniforms
+  std::vector<Graphics::UniformBlockInfo> mUniformBlocks{};       ///< List of uniform blocks
 };
 
 } // namespace Dali