Moving CullFace mode and Blending modes to Pipeline 76/253476/3
authorDavid Steele <david.steele@samsung.com>
Tue, 9 Feb 2021 15:36:07 +0000 (15:36 +0000)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Mon, 15 Feb 2021 17:23:47 +0000 (17:23 +0000)
Change-Id: Ieffad68a3db9276a14c7b69427a47d8dc544bd13
Signed-off-by: David Steele <david.steele@samsung.com>
automated-tests/src/dali/dali-test-suite-utils/test-gl-abstraction.h
automated-tests/src/dali/dali-test-suite-utils/test-graphics-controller.cpp
automated-tests/src/dali/utc-Dali-Actor.cpp
automated-tests/src/dali/utc-Dali-Layer.cpp
automated-tests/src/dali/utc-Dali-RenderTask.cpp
automated-tests/src/dali/utc-Dali-Renderer.cpp
automated-tests/src/dali/utc-Dali-Scene.cpp
dali/internal/render/renderers/render-renderer.cpp
dali/internal/render/renderers/render-renderer.h
dali/internal/render/shaders/scene-graph-shader.h

index b414084..5679a01 100644 (file)
@@ -407,10 +407,10 @@ public:
   inline void CullFace(GLenum mode) override
   {
     std::stringstream out;
-    out << mode;
+    out << std::hex << mode;
 
     TraceCallStack::NamedParams namedParams;
-    namedParams["program"] << mode;
+    namedParams["mode"] << std::hex << mode;
 
     mCullFaceTrace.PushCall("CullFace", out.str(), namedParams);
   }
@@ -498,7 +498,7 @@ public:
   inline void DepthFunc(GLenum func) override
   {
     std::stringstream out;
-    out << func;
+    out << std::hex << func;
 
     TraceCallStack::NamedParams namedParams;
     namedParams["func"] << std::hex << func;
@@ -533,7 +533,7 @@ public:
   inline void Disable(GLenum cap) override
   {
     std::stringstream out;
-    out << cap;
+    out << std::hex << cap;
     TraceCallStack::NamedParams namedParams;
     namedParams["cap"] << std::hex << cap;
     mEnableDisableTrace.PushCall("Disable", out.str(), namedParams);
@@ -576,7 +576,7 @@ public:
   inline void Enable(GLenum cap) override
   {
     std::stringstream out;
-    out << cap;
+    out << std::hex << cap;
     TraceCallStack::NamedParams namedParams;
     namedParams["cap"] << std::hex << cap;
     mEnableDisableTrace.PushCall("Enable", out.str(), namedParams);
@@ -631,6 +631,7 @@ public:
 
   inline void FrontFace(GLenum mode) override
   {
+    // do nothing
   }
 
   inline void GenBuffers(GLsizei n, GLuint* buffers) override
index 578285b..a8357c1 100644 (file)
@@ -318,6 +318,125 @@ GLenum GetTopology(Graphics::PrimitiveTopology topology)
   return GL_TRIANGLES;
 }
 
+GLenum GetCullFace(Graphics::CullMode cullMode)
+{
+  switch(cullMode)
+  {
+    case Graphics::CullMode::NONE:
+      return GL_NONE;
+    case Graphics::CullMode::FRONT:
+      return GL_FRONT;
+    case Graphics::CullMode::BACK:
+      return GL_BACK;
+    case Graphics::CullMode::FRONT_AND_BACK:
+      return GL_FRONT_AND_BACK;
+  }
+  return GL_NONE;
+}
+
+GLenum GetFrontFace(Graphics::FrontFace frontFace)
+{
+  if(frontFace == Graphics::FrontFace::CLOCKWISE)
+  {
+    return GL_CW;
+  }
+  return GL_CCW;
+}
+
+GLenum GetBlendFactor(Graphics::BlendFactor blendFactor)
+{
+  GLenum glFactor = GL_ZERO;
+
+  switch(blendFactor)
+  {
+    case Graphics::BlendFactor::ZERO:
+      glFactor = GL_ZERO;
+      break;
+    case Graphics::BlendFactor::ONE:
+      glFactor = GL_ONE;
+      break;
+    case Graphics::BlendFactor::SRC_COLOR:
+      glFactor = GL_SRC_COLOR;
+      break;
+    case Graphics::BlendFactor::ONE_MINUS_SRC_COLOR:
+      glFactor = GL_ONE_MINUS_SRC_COLOR;
+      break;
+    case Graphics::BlendFactor::DST_COLOR:
+      glFactor = GL_DST_COLOR;
+      break;
+    case Graphics::BlendFactor::ONE_MINUS_DST_COLOR:
+      glFactor = GL_ONE_MINUS_DST_COLOR;
+      break;
+    case Graphics::BlendFactor::SRC_ALPHA:
+      glFactor = GL_SRC_ALPHA;
+      break;
+    case Graphics::BlendFactor::ONE_MINUS_SRC_ALPHA:
+      glFactor = GL_ONE_MINUS_SRC_ALPHA;
+      break;
+    case Graphics::BlendFactor::DST_ALPHA:
+      glFactor = GL_DST_ALPHA;
+      break;
+    case Graphics::BlendFactor::ONE_MINUS_DST_ALPHA:
+      glFactor = GL_ONE_MINUS_DST_ALPHA;
+      break;
+    case Graphics::BlendFactor::CONSTANT_COLOR:
+      glFactor = GL_CONSTANT_COLOR;
+      break;
+    case Graphics::BlendFactor::ONE_MINUS_CONSTANT_COLOR:
+      glFactor = GL_ONE_MINUS_CONSTANT_COLOR;
+      break;
+    case Graphics::BlendFactor::CONSTANT_ALPHA:
+      glFactor = GL_CONSTANT_ALPHA;
+      break;
+    case Graphics::BlendFactor::ONE_MINUS_CONSTANT_ALPHA:
+      glFactor = GL_ONE_MINUS_CONSTANT_ALPHA;
+      break;
+    case Graphics::BlendFactor::SRC_ALPHA_SATURATE:
+      glFactor = GL_SRC_ALPHA_SATURATE;
+      break;
+      // GLES doesn't appear to have dual source blending.
+    case Graphics::BlendFactor::SRC1_COLOR:
+      glFactor = GL_SRC_COLOR;
+      break;
+    case Graphics::BlendFactor::ONE_MINUS_SRC1_COLOR:
+      glFactor = GL_ONE_MINUS_SRC_COLOR;
+      break;
+    case Graphics::BlendFactor::SRC1_ALPHA:
+      glFactor = GL_SRC_ALPHA;
+      break;
+    case Graphics::BlendFactor::ONE_MINUS_SRC1_ALPHA:
+      glFactor = GL_ONE_MINUS_SRC_ALPHA;
+      break;
+  }
+  return glFactor;
+}
+
+GLenum GetBlendOp(Graphics::BlendOp blendOp)
+{
+  GLenum op = GL_FUNC_ADD;
+  switch(blendOp)
+  {
+    case Graphics::BlendOp::ADD:
+      op = GL_FUNC_ADD;
+      break;
+    case Graphics::BlendOp::SUBTRACT:
+      op = GL_FUNC_SUBTRACT;
+      break;
+    case Graphics::BlendOp::REVERSE_SUBTRACT:
+      op = GL_FUNC_REVERSE_SUBTRACT;
+      break;
+    case Graphics::BlendOp::MIN:
+      op = GL_MIN;
+      break;
+    case Graphics::BlendOp::MAX:
+      op = GL_MAX;
+      break;
+
+      // @todo Add advanced blend equations
+  }
+  return op;
+}
+
 void TestGraphicsController::SubmitCommandBuffers(const Graphics::SubmitInfo& submitInfo)
 {
   TraceCallStack::NamedParams namedParams;
@@ -381,6 +500,50 @@ void TestGraphicsController::SubmitCommandBuffers(const Graphics::SubmitInfo& su
                               reinterpret_cast<void*>(attributeOffset));
     }
 
+    // Cull face setup
+    auto& rasterizationState = commandBuffer->mPipeline->rasterizationState;
+    if(rasterizationState.cullMode == Graphics::CullMode::NONE)
+    {
+      mGl.Disable(GL_CULL_FACE);
+    }
+    else
+    {
+      mGl.Enable(GL_CULL_FACE);
+      mGl.CullFace(GetCullFace(rasterizationState.cullMode));
+    }
+
+    mGl.FrontFace(GetFrontFace(rasterizationState.frontFace));
+    // We don't modify glPolygonMode in our context/abstraction from GL_FILL (the GL default),
+    // so it isn't present in the API (and won't have any tests!)
+
+    // Blending setup
+    auto& colorBlendState = commandBuffer->mPipeline->colorBlendState;
+    if(colorBlendState.blendEnable)
+    {
+      mGl.Enable(GL_BLEND);
+
+      mGl.BlendFuncSeparate(GetBlendFactor(colorBlendState.srcColorBlendFactor),
+                            GetBlendFactor(colorBlendState.dstColorBlendFactor),
+                            GetBlendFactor(colorBlendState.srcAlphaBlendFactor),
+                            GetBlendFactor(colorBlendState.dstAlphaBlendFactor));
+      if(colorBlendState.colorBlendOp != colorBlendState.alphaBlendOp)
+      {
+        mGl.BlendEquationSeparate(GetBlendOp(colorBlendState.colorBlendOp), GetBlendOp(colorBlendState.alphaBlendOp));
+      }
+      else
+      {
+        mGl.BlendEquation(GetBlendOp(colorBlendState.colorBlendOp));
+      }
+      mGl.BlendColor(colorBlendState.blendConstants[0],
+                     colorBlendState.blendConstants[1],
+                     colorBlendState.blendConstants[2],
+                     colorBlendState.blendConstants[3]);
+    }
+    else
+    {
+      mGl.Disable(GL_BLEND);
+    }
+
     // draw call
     auto topology = commandBuffer->mPipeline->inputAssemblyState.topology;
 
index 1b1e37a..d7ac79b 100644 (file)
@@ -4262,7 +4262,9 @@ int UtcDaliActorPropertyClippingActor(void)
   CheckColorMask(glAbstraction, true);
 
   // Check the stencil buffer was enabled.
-  DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", "2960")); // 2960 is GL_STENCIL_TEST
+  std::ostringstream oss;
+  oss << std::hex << GL_STENCIL_TEST;
+  DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", oss.str()));
 
   // Check the stencil buffer was cleared.
   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("ClearStencil", "0", startIndex));
@@ -4298,7 +4300,9 @@ int UtcDaliActorPropertyClippingActorEnableThenDisable(void)
   CheckColorMask(glAbstraction, true);
 
   // Check the stencil buffer was enabled.
-  DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", "2960")); // 2960 is GL_STENCIL_TEST
+  std::ostringstream oss;
+  oss << std::hex << GL_STENCIL_TEST;
+  DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", oss.str()));
 
   // Check the stencil buffer was cleared.
   DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("ClearStencil", "0", startIndex));
@@ -4315,7 +4319,9 @@ int UtcDaliActorPropertyClippingActorEnableThenDisable(void)
   GenerateTrace(application, enabledDisableTrace, stencilTrace);
 
   // Check the stencil buffer was disabled.
-  DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Disable", "2960")); // 2960 is GL_STENCIL_TEST
+  std::ostringstream stencil;
+  stencil << std::hex << GL_STENCIL_TEST;
+  DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Disable", stencil.str()));
 
   // Ensure all values in stencil-mask are set to 1.
   startIndex = 0u;
@@ -4362,7 +4368,9 @@ int UtcDaliActorPropertyClippingNestedChildren(void)
   CheckColorMask(glAbstraction, true);
 
   // Check the stencil buffer was enabled.
-  DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", "2960")); // 2960 is GL_STENCIL_TEST
+  std::ostringstream oss;
+  oss << std::hex << GL_STENCIL_TEST;
+  DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", oss.str()));
 
   // Perform the test twice, once for 2D layer, and once for 3D.
   for(unsigned int i = 0u; i < 2u; ++i)
@@ -4469,10 +4477,15 @@ int UtcDaliActorPropertyClippingActorDrawOrder(void)
      Note: Correct enable call trace:    StackTrace: Index:0, Function:Enable, ParamList:3042 StackTrace: Index:1, Function:Enable, ParamList:2960 StackTrace: Index:2, Function:Disable, ParamList:2960
            Incorrect enable call trace:  StackTrace: Index:0, Function:Enable, ParamList:3042 StackTrace: Index:1, Function:Enable, ParamList:2960
   */
-  size_t startIndex = 0u;
-  DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", "3042", startIndex));
-  DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", "2960", startIndex)); // 2960 is GL_STENCIL_TEST
-  DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Disable", "2960", startIndex));
+  size_t             startIndex = 0u;
+  std::ostringstream blend;
+  blend << std::hex << GL_BLEND;
+  std::ostringstream stencil;
+  stencil << std::hex << GL_STENCIL_TEST;
+
+  DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", blend.str(), startIndex));
+  DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", stencil.str(), startIndex));
+  DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Disable", stencil.str(), startIndex));
 
   // Swap the clipping actor from top of left branch to top of right branch.
   actors[1].SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED);
@@ -4488,8 +4501,8 @@ int UtcDaliActorPropertyClippingActorDrawOrder(void)
   // Check stencil is enabled but NOT disabled again (as right-hand branch of tree is drawn).
   // This proves the draw order has remained the same.
   startIndex = 0u;
-  DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", "2960", startIndex));
-  DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParamsFromStartIndex("Disable", "2960", startIndex));
+  DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", stencil.str(), startIndex));
+  DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParamsFromStartIndex("Disable", stencil.str(), startIndex));
 
   END_TEST;
 }
@@ -4523,7 +4536,10 @@ int UtcDaliActorPropertyScissorClippingActor(void)
   CheckColorMask(glAbstraction, true);
 
   // Check scissor test was enabled.
-  DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", "3089")); // 3089 = 0xC11 (GL_SCISSOR_TEST)
+
+  std::ostringstream scissor;
+  scissor << std::hex << GL_SCISSOR_TEST;
+  DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
 
   // Check the scissor was set, and the coordinates are correct.
   std::stringstream compareParametersString;
@@ -4584,7 +4600,9 @@ int UtcDaliActorPropertyScissorClippingActorSiblings(void)
   CheckColorMask(glAbstraction, true);
 
   // Check scissor test was enabled.
-  DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", "3089")); // 3089 = 0xC11 (GL_SCISSOR_TEST)
+  std::ostringstream scissor;
+  scissor << std::hex << GL_SCISSOR_TEST;
+  DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
 
   // Check the scissor was set, and the coordinates are correct.
   std::stringstream compareParametersString;
@@ -4663,7 +4681,9 @@ int UtcDaliActorPropertyScissorClippingActorNested01(void)
     CheckColorMask(glAbstraction, true);
 
     // Check scissor test was enabled.
-    DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", "3089")); // 3089 = 0xC11 (GL_SCISSOR_TEST)
+    std::ostringstream scissor;
+    scissor << std::hex << GL_SCISSOR_TEST;
+    DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
 
     // Check the scissor was set, and the coordinates are correct.
     const Vector4&    expectResults(expect[test]);
@@ -4747,7 +4767,9 @@ int UtcDaliActorPropertyScissorClippingActorNested02(void)
   CheckColorMask(glAbstraction, true);
 
   // Check scissor test was enabled.
-  DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", "3089")); // 3089 = 0xC11 (GL_SCISSOR_TEST)
+  std::ostringstream scissor;
+  scissor << std::hex << GL_SCISSOR_TEST;
+  DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
 
   // Check the scissor was set, and the coordinates are correct.
   std::string clipA("0, 500, 480, 200");
@@ -4789,7 +4811,9 @@ int UtcDaliActorPropertyClippingActorWithRendererOverride(void)
   CheckColorMask(glAbstraction, true);
 
   // Check the stencil buffer was not enabled.
-  DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParams("Enable", "2960")); // 2960 is GL_STENCIL_TEST
+  std::ostringstream stencil;
+  stencil << std::hex << GL_STENCIL_TEST;
+  DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParams("Enable", stencil.str()));
 
   // Check stencil functions are not called.
   DALI_TEST_CHECK(!stencilTrace.FindMethod("StencilFunc"));
@@ -4806,7 +4830,9 @@ int UtcDaliActorPropertyClippingActorWithRendererOverride(void)
   GenerateTrace(application, enabledDisableTrace, scissorTrace);
 
   // Check the stencil buffer was not enabled.
-  DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParams("Enable", "3089")); // 3089 = 0xC11 (GL_SCISSOR_TEST)
+  std::ostringstream scissor;
+  scissor << std::hex << GL_SCISSOR_TEST;
+  DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
 
   DALI_TEST_CHECK(!scissorTrace.FindMethod("StencilFunc"));
 
index 8d9dc7e..8b63242 100644 (file)
@@ -765,7 +765,9 @@ int UtcDaliLayer3DSort(void)
   application.Render();
   enabledDisableTrace.Enable(false);
 
-  DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", "2929")); // 2929 is GL_DEPTH_TEST
+  std::ostringstream depth;
+  depth << std::hex << GL_DEPTH_TEST;
+  DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", depth.str()));
 
   END_TEST;
 }
index 0bb0706..0143114 100644 (file)
@@ -3410,7 +3410,9 @@ int UtcDaliRenderTaskClippingMode01(void)
   application.SendNotification();
   application.Render();
 
-  DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", "3089")); // 3089 = 0xC11 (GL_SCISSOR_TEST)
+  std::ostringstream scissor;
+  scissor << std::hex << GL_SCISSOR_TEST;
+  DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
 
   // Check the scissor was set, and the coordinates are correct.
   Vector4           expectResults(position.x, TestApplication::DEFAULT_SURFACE_HEIGHT - size.height - position.y, size.width, size.height); // (100, 500, 200, 200)
@@ -3468,7 +3470,9 @@ int UtcDaliRenderTaskClippingMode02(void)
   application.SendNotification();
   application.Render();
 
-  DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", "3089")); // 3089 = 0xC11 (GL_SCISSOR_TEST)
+  std::ostringstream scissor;
+  scissor << std::hex << GL_SCISSOR_TEST;
+  DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
 
   // Check the scissor was set, and the coordinates are correct.
   Vector4           expectResults(position.x, position.y, size.width, size.height); // (100, 100, 200, 200)
index 57bc25f..6a1306c 100644 (file)
@@ -49,7 +49,7 @@ const BlendEquation::Type DEFAULT_BLEND_EQUATION_ALPHA(BlendEquation::ADD);
 std::string GetStencilTestString(void)
 {
   std::stringstream stream;
-  stream << GL_STENCIL_TEST;
+  stream << std::hex << GL_STENCIL_TEST;
   return stream.str();
 }
 
@@ -60,7 +60,7 @@ std::string GetStencilTestString(void)
 std::string GetDepthTestString(void)
 {
   std::stringstream stream;
-  stream << GL_DEPTH_TEST;
+  stream << std::hex << GL_DEPTH_TEST;
   return stream.str();
 }
 
@@ -477,7 +477,7 @@ int UtcDaliRendererSetGetFaceCullingMode(void)
     DALI_TEST_EQUALS(cullFaceStack.CountMethod("CullFace"), 1, TEST_LOCATION);
 
     std::ostringstream cullModeString;
-    cullModeString << GL_FRONT_AND_BACK;
+    cullModeString << std::hex << GL_FRONT_AND_BACK;
 
     DALI_TEST_CHECK(cullFaceStack.FindMethodAndParams("CullFace", cullModeString.str()));
     cullFace = renderer.GetProperty<int>(Renderer::Property::FACE_CULLING_MODE);
@@ -493,7 +493,7 @@ int UtcDaliRendererSetGetFaceCullingMode(void)
     DALI_TEST_EQUALS(cullFaceStack.CountMethod("CullFace"), 1, TEST_LOCATION);
 
     std::ostringstream cullModeString;
-    cullModeString << GL_BACK;
+    cullModeString << std::hex << GL_BACK;
 
     DALI_TEST_CHECK(cullFaceStack.FindMethodAndParams("CullFace", cullModeString.str()));
     cullFace = renderer.GetProperty<int>(Renderer::Property::FACE_CULLING_MODE);
@@ -509,7 +509,7 @@ int UtcDaliRendererSetGetFaceCullingMode(void)
     DALI_TEST_EQUALS(cullFaceStack.CountMethod("CullFace"), 1, TEST_LOCATION);
 
     std::ostringstream cullModeString;
-    cullModeString << GL_FRONT;
+    cullModeString << std::hex << GL_FRONT;
 
     DALI_TEST_CHECK(cullFaceStack.FindMethodAndParams("CullFace", cullModeString.str()));
     cullFace = renderer.GetProperty<int>(Renderer::Property::FACE_CULLING_MODE);
@@ -837,10 +837,10 @@ int UtcDaliRendererSetBlendMode01(void)
   application.SendNotification();
   application.Render();
 
-  TraceCallStack&    glEnableStack = glAbstraction.GetEnableDisableTrace();
-  std::ostringstream blendStr;
-  blendStr << GL_BLEND;
-  DALI_TEST_CHECK(glEnableStack.FindMethodAndParams("Enable", blendStr.str().c_str()));
+  TraceCallStack&             glEnableStack = glAbstraction.GetEnableDisableTrace();
+  TraceCallStack::NamedParams params;
+  params["cap"] << std::hex << GL_BLEND;
+  DALI_TEST_CHECK(glEnableStack.FindMethodAndParams("Enable", params));
 
   END_TEST;
 }
@@ -870,9 +870,7 @@ int UtcDaliRendererSetBlendMode01b(void)
   application.SendNotification();
   application.Render();
 
-  TraceCallStack&    glEnableStack = glAbstraction.GetEnableDisableTrace();
-  std::ostringstream blendStr;
-  blendStr << GL_BLEND;
+  TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
   DALI_TEST_CHECK(!glEnableStack.FindMethod("Enable"));
 
   DALI_TEST_CHECK(!glAbstraction.GetDrawTrace().FindMethod("DrawElements"));
@@ -904,10 +902,10 @@ int UtcDaliRendererSetBlendMode02(void)
   application.SendNotification();
   application.Render();
 
-  TraceCallStack&    glEnableStack = glAbstraction.GetEnableDisableTrace();
-  std::ostringstream blendStr;
-  blendStr << GL_BLEND;
-  DALI_TEST_CHECK(!glEnableStack.FindMethodAndParams("Enable", blendStr.str().c_str()));
+  TraceCallStack&             glEnableStack = glAbstraction.GetEnableDisableTrace();
+  TraceCallStack::NamedParams params;
+  params["cap"] << std::hex << GL_BLEND;
+  DALI_TEST_CHECK(!glEnableStack.FindMethodAndParams("Enable", params));
 
   END_TEST;
 }
@@ -936,10 +934,10 @@ int UtcDaliRendererSetBlendMode03(void)
   application.SendNotification();
   application.Render();
 
-  TraceCallStack&    glEnableStack = glAbstraction.GetEnableDisableTrace();
-  std::ostringstream blendStr;
-  blendStr << GL_BLEND;
-  DALI_TEST_CHECK(glEnableStack.FindMethodAndParams("Enable", blendStr.str().c_str()));
+  TraceCallStack&             glEnableStack = glAbstraction.GetEnableDisableTrace();
+  TraceCallStack::NamedParams params;
+  params["cap"] << std::hex << GL_BLEND;
+  DALI_TEST_CHECK(glEnableStack.FindMethodAndParams("Enable", params));
 
   END_TEST;
 }
@@ -967,10 +965,11 @@ int UtcDaliRendererSetBlendMode04(void)
   application.SendNotification();
   application.Render();
 
-  TraceCallStack&    glEnableStack = glAbstraction.GetEnableDisableTrace();
-  std::ostringstream blendStr;
-  blendStr << GL_BLEND;
-  DALI_TEST_CHECK(!glEnableStack.FindMethodAndParams("Enable", blendStr.str().c_str()));
+  TraceCallStack&             glEnableStack = glAbstraction.GetEnableDisableTrace();
+  TraceCallStack::NamedParams params;
+  params["cap"] << std::hex << GL_BLEND;
+  DALI_TEST_CHECK(!glEnableStack.FindMethodAndParams("Enable", params));
+  DALI_TEST_CHECK(glEnableStack.FindMethodAndParams("Disable", params));
 
   END_TEST;
 }
@@ -999,10 +998,10 @@ int UtcDaliRendererSetBlendMode04b(void)
   application.SendNotification();
   application.Render();
 
-  TraceCallStack&    glEnableStack = glAbstraction.GetEnableDisableTrace();
-  std::ostringstream blendStr;
-  blendStr << GL_BLEND;
-  DALI_TEST_CHECK(glEnableStack.FindMethodAndParams("Enable", blendStr.str().c_str()));
+  TraceCallStack&             glEnableStack = glAbstraction.GetEnableDisableTrace();
+  TraceCallStack::NamedParams params;
+  params["cap"] << std::hex << GL_BLEND;
+  DALI_TEST_CHECK(glEnableStack.FindMethodAndParams("Enable", params));
 
   END_TEST;
 }
@@ -1031,10 +1030,11 @@ int UtcDaliRendererSetBlendMode04c(void)
   application.SendNotification();
   application.Render();
 
-  TraceCallStack&    glEnableStack = glAbstraction.GetEnableDisableTrace();
-  std::ostringstream blendStr;
-  blendStr << GL_BLEND;
-  DALI_TEST_CHECK(!glEnableStack.FindMethodAndParams("Enable", blendStr.str().c_str()));
+  TraceCallStack&             glEnableStack = glAbstraction.GetEnableDisableTrace();
+  TraceCallStack::NamedParams params;
+  params["cap"] << std::hex << GL_BLEND;
+  DALI_TEST_CHECK(!glEnableStack.FindMethodAndParams("Enable", params));
+  DALI_TEST_CHECK(glEnableStack.FindMethodAndParams("Disable", params));
 
   END_TEST;
 }
@@ -1066,10 +1066,10 @@ int UtcDaliRendererSetBlendMode05(void)
   application.SendNotification();
   application.Render();
 
-  TraceCallStack&    glEnableStack = glAbstraction.GetEnableDisableTrace();
-  std::ostringstream blendStr;
-  blendStr << GL_BLEND;
-  DALI_TEST_CHECK(glEnableStack.FindMethodAndParams("Enable", blendStr.str().c_str()));
+  TraceCallStack&             glEnableStack = glAbstraction.GetEnableDisableTrace();
+  TraceCallStack::NamedParams params;
+  params["cap"] << std::hex << GL_BLEND;
+  DALI_TEST_CHECK(glEnableStack.FindMethodAndParams("Enable", params));
 
   END_TEST;
 }
@@ -1097,10 +1097,10 @@ int UtcDaliRendererSetBlendMode06(void)
   application.SendNotification();
   application.Render();
 
-  TraceCallStack&    glEnableStack = glAbstraction.GetEnableDisableTrace();
-  std::ostringstream blendStr;
-  blendStr << GL_BLEND;
-  DALI_TEST_CHECK(glEnableStack.FindMethodAndParams("Enable", blendStr.str().c_str()));
+  TraceCallStack&             glEnableStack = glAbstraction.GetEnableDisableTrace();
+  TraceCallStack::NamedParams params;
+  params["cap"] << std::hex << GL_BLEND;
+  DALI_TEST_CHECK(glEnableStack.FindMethodAndParams("Enable", params));
 
   END_TEST;
 }
@@ -1131,8 +1131,10 @@ int UtcDaliRendererSetBlendMode07(void)
   application.SendNotification();
   application.Render();
 
-  TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
-  DALI_TEST_CHECK(!glEnableStack.FindMethodAndParams("Enable", "GL_BLEND"));
+  TraceCallStack&             glEnableStack = glAbstraction.GetEnableDisableTrace();
+  TraceCallStack::NamedParams params;
+  params["cap"] << std::hex << GL_BLEND;
+  DALI_TEST_CHECK(!glEnableStack.FindMethodAndParams("Enable", params));
 
   END_TEST;
 }
@@ -1165,10 +1167,10 @@ int UtcDaliRendererSetBlendMode08(void)
     application.SendNotification();
     application.Render();
 
-    TraceCallStack&    glEnableStack = glAbstraction.GetEnableDisableTrace();
-    std::ostringstream blendStr;
-    blendStr << GL_BLEND;
-    DALI_TEST_CHECK(glEnableStack.FindMethodAndParams("Enable", blendStr.str().c_str()));
+    TraceCallStack&             glEnableStack = glAbstraction.GetEnableDisableTrace();
+    TraceCallStack::NamedParams params;
+    params["cap"] << std::hex << GL_BLEND;
+    DALI_TEST_CHECK(glEnableStack.FindMethodAndParams("Enable", params));
   }
 
   END_TEST;
@@ -1202,10 +1204,10 @@ int UtcDaliRendererSetBlendMode08b(void)
     application.SendNotification();
     application.Render();
 
-    TraceCallStack&    glEnableStack = glAbstraction.GetEnableDisableTrace();
-    std::ostringstream blendStr;
-    blendStr << GL_BLEND;
-    DALI_TEST_CHECK(!glEnableStack.FindMethodAndParams("Enable", blendStr.str().c_str()));
+    TraceCallStack&             glEnableStack = glAbstraction.GetEnableDisableTrace();
+    TraceCallStack::NamedParams params;
+    params["cap"] << std::hex << GL_BLEND;
+    DALI_TEST_CHECK(!glEnableStack.FindMethodAndParams("Enable", params));
   }
 
   END_TEST;
@@ -2360,15 +2362,17 @@ int UtcDaliRendererSetDepthFunction(void)
   scene.GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_3D);
   scene.Add(actor);
 
-  TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
-  glAbstraction.EnableEnableDisableCallTrace(true);
-  glAbstraction.EnableDepthFunctionCallTrace(true);
+  TestGlAbstraction& glAbstraction        = application.GetGlAbstraction();
+  TraceCallStack&    glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
+  TraceCallStack&    glDepthFunctionStack = glAbstraction.GetDepthFunctionTrace();
 
-  TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
-  TraceCallStack& glDepthFunctionStack = glAbstraction.GetDepthFunctionTrace();
+  glEnableDisableStack.Enable(true);
+  glDepthFunctionStack.Enable(true);
+  glEnableDisableStack.EnableLogging(true);
+  glDepthFunctionStack.EnableLogging(true);
 
   std::ostringstream depthTestStr;
-  depthTestStr << GL_DEPTH_TEST;
+  depthTestStr << std::hex << GL_DEPTH_TEST;
 
   //GL_NEVER
   {
@@ -2381,7 +2385,7 @@ int UtcDaliRendererSetDepthFunction(void)
 
     DALI_TEST_CHECK(glEnableDisableStack.FindMethodAndParams("Enable", depthTestStr.str().c_str()));
     std::ostringstream depthFunctionStr;
-    depthFunctionStr << GL_NEVER;
+    depthFunctionStr << std::hex << GL_NEVER;
     DALI_TEST_CHECK(glDepthFunctionStack.FindMethodAndParams("DepthFunc", depthFunctionStr.str().c_str()));
   }
 
@@ -2394,7 +2398,7 @@ int UtcDaliRendererSetDepthFunction(void)
     application.Render();
 
     std::ostringstream depthFunctionStr;
-    depthFunctionStr << GL_ALWAYS;
+    depthFunctionStr << std::hex << GL_ALWAYS;
     DALI_TEST_CHECK(glDepthFunctionStack.FindMethodAndParams("DepthFunc", depthFunctionStr.str().c_str()));
   }
 
@@ -2407,7 +2411,7 @@ int UtcDaliRendererSetDepthFunction(void)
     application.Render();
 
     std::ostringstream depthFunctionStr;
-    depthFunctionStr << GL_LESS;
+    depthFunctionStr << std::hex << GL_LESS;
     DALI_TEST_CHECK(glDepthFunctionStack.FindMethodAndParams("DepthFunc", depthFunctionStr.str().c_str()));
   }
 
@@ -2420,7 +2424,7 @@ int UtcDaliRendererSetDepthFunction(void)
     application.Render();
 
     std::ostringstream depthFunctionStr;
-    depthFunctionStr << GL_GREATER;
+    depthFunctionStr << std::hex << GL_GREATER;
     DALI_TEST_CHECK(glDepthFunctionStack.FindMethodAndParams("DepthFunc", depthFunctionStr.str().c_str()));
   }
 
@@ -2433,7 +2437,7 @@ int UtcDaliRendererSetDepthFunction(void)
     application.Render();
 
     std::ostringstream depthFunctionStr;
-    depthFunctionStr << GL_EQUAL;
+    depthFunctionStr << std::hex << GL_EQUAL;
     DALI_TEST_CHECK(glDepthFunctionStack.FindMethodAndParams("DepthFunc", depthFunctionStr.str().c_str()));
   }
 
@@ -2446,7 +2450,7 @@ int UtcDaliRendererSetDepthFunction(void)
     application.Render();
 
     std::ostringstream depthFunctionStr;
-    depthFunctionStr << GL_NOTEQUAL;
+    depthFunctionStr << std::hex << GL_NOTEQUAL;
     DALI_TEST_CHECK(glDepthFunctionStack.FindMethodAndParams("DepthFunc", depthFunctionStr.str().c_str()));
   }
 
@@ -2459,7 +2463,7 @@ int UtcDaliRendererSetDepthFunction(void)
     application.Render();
 
     std::ostringstream depthFunctionStr;
-    depthFunctionStr << GL_LEQUAL;
+    depthFunctionStr << std::hex << GL_LEQUAL;
     DALI_TEST_CHECK(glDepthFunctionStack.FindMethodAndParams("DepthFunc", depthFunctionStr.str().c_str()));
   }
 
@@ -2472,7 +2476,7 @@ int UtcDaliRendererSetDepthFunction(void)
     application.Render();
 
     std::ostringstream depthFunctionStr;
-    depthFunctionStr << GL_GEQUAL;
+    depthFunctionStr << std::hex << GL_GEQUAL;
     DALI_TEST_CHECK(glDepthFunctionStack.FindMethodAndParams("DepthFunc", depthFunctionStr.str().c_str()));
   }
 
@@ -2592,10 +2596,11 @@ int UtcDaliRendererSetDepthTestMode(void)
   TestApplication application;
   tet_infoline("Test setting the DepthTestMode");
 
-  Renderer           renderer      = RendererTestFixture(application);
-  TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
-  glAbstraction.EnableEnableDisableCallTrace(true);
-  TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
+  Renderer           renderer             = RendererTestFixture(application);
+  TestGlAbstraction& glAbstraction        = application.GetGlAbstraction();
+  TraceCallStack&    glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
+  glEnableDisableStack.Enable(true);
+  glEnableDisableStack.EnableLogging(true);
 
   glEnableDisableStack.Reset();
   application.SendNotification();
@@ -2703,12 +2708,14 @@ int UtcDaliRendererCheckStencilDefaults(void)
   TestApplication application;
   tet_infoline("Test the stencil defaults");
 
-  Renderer           renderer      = RendererTestFixture(application);
-  TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
-  glAbstraction.EnableEnableDisableCallTrace(true);
-  glAbstraction.EnableStencilFunctionCallTrace(true);
-  TraceCallStack& glEnableDisableStack   = glAbstraction.GetEnableDisableTrace();
-  TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace();
+  Renderer           renderer               = RendererTestFixture(application);
+  TestGlAbstraction& glAbstraction          = application.GetGlAbstraction();
+  TraceCallStack&    glEnableDisableStack   = glAbstraction.GetEnableDisableTrace();
+  TraceCallStack&    glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace();
+  glEnableDisableStack.Enable(true);
+  glEnableDisableStack.EnableLogging(true);
+  glStencilFunctionStack.Enable(true);
+  glStencilFunctionStack.EnableLogging(true);
 
   ResetDebugAndFlush(application, glEnableDisableStack, glStencilFunctionStack);
 
@@ -2729,12 +2736,14 @@ int UtcDaliRendererSetRenderModeToUseStencilBuffer(void)
   TestApplication application;
   tet_infoline("Test setting the RenderMode to use the stencil buffer");
 
-  Renderer           renderer      = RendererTestFixture(application);
-  TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
-  glAbstraction.EnableEnableDisableCallTrace(true);
-  glAbstraction.EnableStencilFunctionCallTrace(true);
-  TraceCallStack& glEnableDisableStack   = glAbstraction.GetEnableDisableTrace();
-  TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace();
+  Renderer           renderer               = RendererTestFixture(application);
+  TestGlAbstraction& glAbstraction          = application.GetGlAbstraction();
+  TraceCallStack&    glEnableDisableStack   = glAbstraction.GetEnableDisableTrace();
+  TraceCallStack&    glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace();
+  glEnableDisableStack.Enable(true);
+  glEnableDisableStack.EnableLogging(true);
+  glStencilFunctionStack.Enable(true);
+  glStencilFunctionStack.EnableLogging(true);
 
   // Set the StencilFunction to something other than the default, to confirm it is set as a property,
   // but NO GL call has been made while the RenderMode is set to not use the stencil buffer.
@@ -2820,12 +2829,14 @@ int UtcDaliRendererSetStencilFunction(void)
   TestApplication application;
   tet_infoline("Test setting the StencilFunction");
 
-  Renderer           renderer      = RendererTestFixture(application);
-  TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
-  glAbstraction.EnableEnableDisableCallTrace(true);
-  glAbstraction.EnableStencilFunctionCallTrace(true);
-  TraceCallStack& glEnableDisableStack   = glAbstraction.GetEnableDisableTrace();
-  TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace();
+  Renderer           renderer               = RendererTestFixture(application);
+  TestGlAbstraction& glAbstraction          = application.GetGlAbstraction();
+  TraceCallStack&    glEnableDisableStack   = glAbstraction.GetEnableDisableTrace();
+  TraceCallStack&    glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace();
+  glEnableDisableStack.Enable(true);
+  glEnableDisableStack.EnableLogging(true);
+  glStencilFunctionStack.Enable(true);
+  glStencilFunctionStack.EnableLogging(true);
 
   // RenderMode must use the stencil for StencilFunction to operate.
   renderer.SetProperty(Renderer::Property::RENDER_MODE, RenderMode::STENCIL);
@@ -2913,12 +2924,14 @@ int UtcDaliRendererSetStencilOperation(void)
   TestApplication application;
   tet_infoline("Test setting the StencilOperation");
 
-  Renderer           renderer      = RendererTestFixture(application);
-  TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
-  glAbstraction.EnableEnableDisableCallTrace(true);
-  glAbstraction.EnableStencilFunctionCallTrace(true);
-  TraceCallStack& glEnableDisableStack   = glAbstraction.GetEnableDisableTrace();
-  TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace();
+  Renderer           renderer               = RendererTestFixture(application);
+  TestGlAbstraction& glAbstraction          = application.GetGlAbstraction();
+  TraceCallStack&    glEnableDisableStack   = glAbstraction.GetEnableDisableTrace();
+  TraceCallStack&    glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace();
+  glEnableDisableStack.Enable(true);
+  glEnableDisableStack.EnableLogging(true);
+  glStencilFunctionStack.Enable(true);
+  glStencilFunctionStack.EnableLogging(true);
 
   // RenderMode must use the stencil for StencilOperation to operate.
   renderer.SetProperty(Renderer::Property::RENDER_MODE, RenderMode::STENCIL);
@@ -3008,12 +3021,14 @@ int UtcDaliRendererSetStencilMask(void)
   TestApplication application;
   tet_infoline("Test setting the StencilMask");
 
-  Renderer           renderer      = RendererTestFixture(application);
-  TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
-  glAbstraction.EnableEnableDisableCallTrace(true);
-  glAbstraction.EnableStencilFunctionCallTrace(true);
-  TraceCallStack& glEnableDisableStack   = glAbstraction.GetEnableDisableTrace();
-  TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace();
+  Renderer           renderer               = RendererTestFixture(application);
+  TestGlAbstraction& glAbstraction          = application.GetGlAbstraction();
+  TraceCallStack&    glEnableDisableStack   = glAbstraction.GetEnableDisableTrace();
+  TraceCallStack&    glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace();
+  glEnableDisableStack.Enable(true);
+  glEnableDisableStack.EnableLogging(true);
+  glStencilFunctionStack.Enable(true);
+  glStencilFunctionStack.EnableLogging(true);
 
   // RenderMode must use the stencil for StencilMask to operate.
   renderer.SetProperty(Renderer::Property::RENDER_MODE, RenderMode::STENCIL);
@@ -3080,6 +3095,7 @@ int UtcDaliRendererWrongNumberOfTextures(void)
   TraceCallStack&    drawTrace = gl.GetDrawTrace();
   drawTrace.Reset();
   drawTrace.Enable(true);
+  drawTrace.EnableLogging(true);
 
   application.SendNotification();
   application.Render(0);
index f841c9b..474f278 100644 (file)
@@ -1387,7 +1387,9 @@ int UtcDaliSceneEnsureReplacedSurfaceKeepsClearColor(void)
   application.Render();
 
   // Check scissor test was enabled.
-  DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", "3089")); // 3089 = 0xC11 (GL_SCISSOR_TEST)
+  std::ostringstream scissor;
+  scissor << std::hex << GL_SCISSOR_TEST;
+  DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str()));
 
   // Check the scissor was set, and the coordinates are correct.
   DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", "0, 700, 100, 100"));
index 2eb8711..89ea041 100644 (file)
@@ -19,6 +19,7 @@
 #include <dali/internal/render/renderers/render-renderer.h>
 
 // INTERNAL INCLUDES
+#include <dali/graphics-api/graphics-types.h>
 #include <dali/internal/common/image-sampler.h>
 #include <dali/internal/render/common/render-instruction.h>
 #include <dali/internal/render/data-providers/node-data-provider.h>
@@ -163,6 +164,100 @@ Dali::Graphics::VertexInputFormat GetPropertyVertexFormat(Property::Type propert
   return type;
 }
 
+constexpr Graphics::CullMode ConvertCullFace(Dali::FaceCullingMode::Type mode)
+{
+  switch(mode)
+  {
+    case Dali::FaceCullingMode::NONE:
+    {
+      return Graphics::CullMode::NONE;
+    }
+    case Dali::FaceCullingMode::FRONT:
+    {
+      return Graphics::CullMode::FRONT;
+    }
+    case Dali::FaceCullingMode::BACK:
+    {
+      return Graphics::CullMode::BACK;
+    }
+    case Dali::FaceCullingMode::FRONT_AND_BACK:
+    {
+      return Graphics::CullMode::FRONT_AND_BACK;
+    }
+  }
+  return Graphics::CullMode::NONE;
+}
+
+constexpr Graphics::BlendFactor ConvertBlendFactor(BlendFactor::Type blendFactor)
+{
+  switch(blendFactor)
+  {
+    case BlendFactor::ZERO:
+      return Graphics::BlendFactor::ZERO;
+    case BlendFactor::ONE:
+      return Graphics::BlendFactor::ONE;
+    case BlendFactor::SRC_COLOR:
+      return Graphics::BlendFactor::SRC_COLOR;
+    case BlendFactor::ONE_MINUS_SRC_COLOR:
+      return Graphics::BlendFactor::ONE_MINUS_SRC_COLOR;
+    case BlendFactor::SRC_ALPHA:
+      return Graphics::BlendFactor::SRC_ALPHA;
+    case BlendFactor::ONE_MINUS_SRC_ALPHA:
+      return Graphics::BlendFactor::ONE_MINUS_SRC_ALPHA;
+    case BlendFactor::DST_ALPHA:
+      return Graphics::BlendFactor::DST_ALPHA;
+    case BlendFactor::ONE_MINUS_DST_ALPHA:
+      return Graphics::BlendFactor::ONE_MINUS_DST_ALPHA;
+    case BlendFactor::DST_COLOR:
+      return Graphics::BlendFactor::DST_COLOR;
+    case BlendFactor::ONE_MINUS_DST_COLOR:
+      return Graphics::BlendFactor::ONE_MINUS_DST_COLOR;
+    case BlendFactor::SRC_ALPHA_SATURATE:
+      return Graphics::BlendFactor::SRC_ALPHA_SATURATE;
+    case BlendFactor::CONSTANT_COLOR:
+      return Graphics::BlendFactor::CONSTANT_COLOR;
+    case BlendFactor::ONE_MINUS_CONSTANT_COLOR:
+      return Graphics::BlendFactor::ONE_MINUS_CONSTANT_COLOR;
+    case BlendFactor::CONSTANT_ALPHA:
+      return Graphics::BlendFactor::CONSTANT_ALPHA;
+    case BlendFactor::ONE_MINUS_CONSTANT_ALPHA:
+      return Graphics::BlendFactor::ONE_MINUS_CONSTANT_ALPHA;
+  }
+  return Graphics::BlendFactor{};
+}
+
+constexpr Graphics::BlendOp ConvertBlendEquation(DevelBlendEquation::Type blendEquation)
+{
+  switch(blendEquation)
+  {
+    case DevelBlendEquation::ADD:
+      return Graphics::BlendOp::ADD;
+    case DevelBlendEquation::SUBTRACT:
+      return Graphics::BlendOp::SUBTRACT;
+    case DevelBlendEquation::REVERSE_SUBTRACT:
+      return Graphics::BlendOp::REVERSE_SUBTRACT;
+    case DevelBlendEquation::COLOR:
+    case DevelBlendEquation::COLOR_BURN:
+    case DevelBlendEquation::COLOR_DODGE:
+    case DevelBlendEquation::DARKEN:
+    case DevelBlendEquation::DIFFERENCE:
+    case DevelBlendEquation::EXCLUSION:
+    case DevelBlendEquation::HARD_LIGHT:
+    case DevelBlendEquation::HUE:
+    case DevelBlendEquation::LIGHTEN:
+    case DevelBlendEquation::LUMINOSITY:
+    case DevelBlendEquation::MAX:
+    case DevelBlendEquation::MIN:
+    case DevelBlendEquation::MULTIPLY:
+    case DevelBlendEquation::OVERLAY:
+    case DevelBlendEquation::SATURATION:
+    case DevelBlendEquation::SCREEN:
+    case DevelBlendEquation::SOFT_LIGHT:
+      return Graphics::BlendOp{};
+  }
+  return Graphics::BlendOp{};
+}
+
 } // namespace
 
 namespace Render
@@ -239,49 +334,6 @@ void Renderer::SetDrawCommands(Dali::DevelRenderer::DrawCommand* pDrawCommands,
   mDrawCommands.insert(mDrawCommands.end(), pDrawCommands, pDrawCommands + size);
 }
 
-void Renderer::SetBlending(Context& context, bool blend)
-{
-  context.SetBlend(blend);
-  if(blend)
-  {
-    // Blend color is optional and rarely used
-    const Vector4* blendColor = mBlendingOptions.GetBlendColor();
-    if(blendColor)
-    {
-      context.SetCustomBlendColor(*blendColor);
-    }
-    else
-    {
-      context.SetDefaultBlendColor();
-    }
-
-    // Set blend source & destination factors
-    context.BlendFuncSeparate(mBlendingOptions.GetBlendSrcFactorRgb(),
-                              mBlendingOptions.GetBlendDestFactorRgb(),
-                              mBlendingOptions.GetBlendSrcFactorAlpha(),
-                              mBlendingOptions.GetBlendDestFactorAlpha());
-
-    // Set blend equations
-    Dali::DevelBlendEquation::Type rgbEquation   = mBlendingOptions.GetBlendEquationRgb();
-    Dali::DevelBlendEquation::Type alphaEquation = mBlendingOptions.GetBlendEquationAlpha();
-
-    if(mBlendingOptions.IsAdvancedBlendEquationApplied() && mPremultipledAlphaEnabled)
-    {
-      if(rgbEquation != alphaEquation)
-      {
-        DALI_LOG_ERROR("Advanced Blend Equation have to be appried by using BlendEquation.\n");
-      }
-      context.BlendEquation(rgbEquation);
-    }
-    else
-    {
-      context.BlendEquationSeparate(rgbEquation, alphaEquation);
-    }
-  }
-
-  mUpdated = true;
-}
-
 void Renderer::GlContextDestroyed()
 {
   mGeometry->GlContextDestroyed();
@@ -430,7 +482,7 @@ void Renderer::SetUniformFromProperty(BufferIndex bufferIndex, Program& program,
   }
 }
 
-bool Renderer::BindTextures(Context& context, Program& program, Graphics::CommandBuffer& commandBuffer, Vector<Graphics::Texture*>& boundTextures)
+bool Renderer::BindTextures(Program& program, Graphics::CommandBuffer& commandBuffer, Vector<Graphics::Texture*>& boundTextures)
 {
   uint32_t textureUnit = 0;
   bool     result      = true;
@@ -684,44 +736,18 @@ void Renderer::Render(Context&                                             conte
       .SetLevel(Graphics::CommandBufferLevel::SECONDARY),
     nullptr);
 
-  //Set cull face  mode
-  const Dali::Internal::SceneGraph::Camera* cam = instruction.GetCamera();
-  if(cam->GetReflectionUsed())
-  {
-    auto adjFaceCullingMode = mFaceCullingMode;
-    switch(mFaceCullingMode)
-    {
-      case FaceCullingMode::Type::FRONT:
-      {
-        adjFaceCullingMode = FaceCullingMode::Type::BACK;
-        break;
-      }
-      case FaceCullingMode::Type::BACK:
-      {
-        adjFaceCullingMode = FaceCullingMode::Type::FRONT;
-        break;
-      }
-      default:
-      {
-        // nothing to do, leave culling as it is
-      }
-    }
-    context.CullFace(adjFaceCullingMode);
-  }
-  else
+  //Set blending mode
+  if(!mDrawCommands.empty())
   {
-    context.CullFace(mFaceCullingMode);
+    blend = (commands[0]->queue == DevelRenderer::RENDER_QUEUE_OPAQUE ? false : blend);
   }
 
   // Temporarily create a pipeline here - this will be used for transporting
-  // topology and vertex format for now.
-  Graphics::UniquePtr<Graphics::Pipeline> pipeline = PrepareGraphicsPipeline(*program);
+  // topology, vertex format, attrs, rasterization state
+  Graphics::UniquePtr<Graphics::Pipeline> pipeline = PrepareGraphicsPipeline(*program, instruction, blend);
   commandBuffer->BindPipeline(*pipeline.get());
 
-  // Take the program into use so we can send uniforms to it
-  program->Use();
-
-  if(DALI_LIKELY(BindTextures(context, *program, *commandBuffer.get(), boundTextures)))
+  if(DALI_LIKELY(BindTextures(*program, *commandBuffer.get(), boundTextures)))
   {
     // Only set up and draw if we have textures and they are all valid
 
@@ -746,34 +772,21 @@ void Renderer::Render(Context&                                             conte
 
     SetUniforms(bufferIndex, node, size, *program);
 
-    if(mBlendingOptions.IsAdvancedBlendEquationApplied() && mPremultipledAlphaEnabled)
-    {
-      context.BlendBarrier();
-    }
-
     bool drawn = false; // Draw can fail if there are no vertex buffers or they haven't been uploaded yet
                         // @todo We should detect this case much earlier to prevent unnecessary work
 
     //@todo manage mDrawCommands in the same way as above command buffer?!
     if(mDrawCommands.empty())
     {
-      SetBlending(context, blend);
-
       drawn = mGeometry->Draw(*mGraphicsController, *commandBuffer.get(), mIndexedDrawFirstElement, mIndexedDrawElementsCount);
     }
     else
     {
       for(auto& cmd : commands)
       {
-        if(cmd->queue == queueIndex)
-        {
-          //Set blending mode
-          SetBlending(context, cmd->queue == DevelRenderer::RENDER_QUEUE_OPAQUE ? false : blend);
-
-          // @todo This should generate a command buffer per cmd
-          // Tests WILL fail.
-          mGeometry->Draw(*mGraphicsController, *commandBuffer.get(), cmd->firstIndex, cmd->elementCount);
-        }
+        // @todo This should generate a command buffer per cmd
+        // Tests WILL fail. (Temporarily commented out)
+        mGeometry->Draw(*mGraphicsController, *commandBuffer.get(), cmd->firstIndex, cmd->elementCount);
       }
     }
 
@@ -848,7 +861,10 @@ bool Renderer::Updated(BufferIndex bufferIndex, const SceneGraph::NodeDataProvid
   return false;
 }
 
-Graphics::UniquePtr<Graphics::Pipeline> Renderer::PrepareGraphicsPipeline(Program& program)
+Graphics::UniquePtr<Graphics::Pipeline> Renderer::PrepareGraphicsPipeline(
+  Program&                                             program,
+  const Dali::Internal::SceneGraph::RenderInstruction& instruction,
+  bool                                                 blend)
 {
   Graphics::InputAssemblyState inputAssemblyState{};
   Graphics::VertexInputState   vertexInputState{};
@@ -860,6 +876,9 @@ Graphics::UniquePtr<Graphics::Pipeline> Renderer::PrepareGraphicsPipeline(Progra
     mUpdateAttributeLocations = true;
   }
 
+  /**
+   * Bind Attributes
+   */
   uint32_t base = 0;
   for(auto&& vertexBuffer : mGeometry->GetVertexBuffers())
   {
@@ -898,11 +917,112 @@ Graphics::UniquePtr<Graphics::Pipeline> Renderer::PrepareGraphicsPipeline(Progra
   // Get the topology
   inputAssemblyState.SetTopology(mGeometry->GetTopology());
 
+  Graphics::RasterizationState rasterizationState{};
+
+  //Set cull face  mode
+  const Dali::Internal::SceneGraph::Camera* cam = instruction.GetCamera();
+  if(cam->GetReflectionUsed())
+  {
+    auto adjFaceCullingMode = mFaceCullingMode;
+    switch(mFaceCullingMode)
+    {
+      case FaceCullingMode::Type::FRONT:
+      {
+        adjFaceCullingMode = FaceCullingMode::Type::BACK;
+        break;
+      }
+      case FaceCullingMode::Type::BACK:
+      {
+        adjFaceCullingMode = FaceCullingMode::Type::FRONT;
+        break;
+      }
+      default:
+      {
+        // nothing to do, leave culling as it is
+      }
+    }
+    rasterizationState.SetCullMode(ConvertCullFace(adjFaceCullingMode));
+  }
+  else
+  {
+    rasterizationState.SetCullMode(ConvertCullFace(mFaceCullingMode));
+  }
+
+  rasterizationState.SetFrontFace(Graphics::FrontFace::COUNTER_CLOCKWISE);
+
+  /**
+   * Set Polygon mode
+   */
+  switch(mGeometry->GetTopology())
+  {
+    case Graphics::PrimitiveTopology::TRIANGLE_LIST:
+    case Graphics::PrimitiveTopology::TRIANGLE_STRIP:
+    case Graphics::PrimitiveTopology::TRIANGLE_FAN:
+      rasterizationState.SetPolygonMode(Graphics::PolygonMode::FILL);
+      break;
+    case Graphics::PrimitiveTopology::LINE_LIST:
+    case Graphics::PrimitiveTopology::LINE_LOOP:
+    case Graphics::PrimitiveTopology::LINE_STRIP:
+      rasterizationState.SetPolygonMode(Graphics::PolygonMode::LINE);
+      break;
+    case Graphics::PrimitiveTopology::POINT_LIST:
+      rasterizationState.SetPolygonMode(Graphics::PolygonMode::POINT);
+      break;
+  }
+
+  // @todo How to signal a blend barrier is needed?
+  //if(mBlendingOptions.IsAdvancedBlendEquationApplied() && mPremultipledAlphaEnabled)
+  //{
+  //  context.BlendBarrier();
+  //}
+
+  Graphics::ColorBlendState colorBlendState{};
+  colorBlendState.SetBlendEnable(false);
+
+  if(blend)
+  {
+    colorBlendState.SetBlendEnable(true);
+
+    Graphics::BlendOp rgbOp   = ConvertBlendEquation(mBlendingOptions.GetBlendEquationRgb());
+    Graphics::BlendOp alphaOp = ConvertBlendEquation(mBlendingOptions.GetBlendEquationRgb());
+    if(mBlendingOptions.IsAdvancedBlendEquationApplied() && mPremultipledAlphaEnabled)
+    {
+      if(rgbOp != alphaOp)
+      {
+        DALI_LOG_ERROR("Advanced Blend Equation MUST be applied by using BlendEquation.\n");
+        alphaOp = rgbOp;
+      }
+    }
+
+    colorBlendState
+      .SetSrcColorBlendFactor(ConvertBlendFactor(mBlendingOptions.GetBlendSrcFactorRgb()))
+      .SetSrcAlphaBlendFactor(ConvertBlendFactor(mBlendingOptions.GetBlendSrcFactorAlpha()))
+      .SetDstColorBlendFactor(ConvertBlendFactor(mBlendingOptions.GetBlendDestFactorRgb()))
+      .SetDstAlphaBlendFactor(ConvertBlendFactor(mBlendingOptions.GetBlendDestFactorAlpha()))
+      .SetColorBlendOp(rgbOp)
+      .SetAlphaBlendOp(alphaOp);
+
+    // Blend color is optional and rarely used
+    Vector4* blendColor = const_cast<Vector4*>(mBlendingOptions.GetBlendColor());
+    if(blendColor)
+    {
+      colorBlendState.SetBlendConstants(blendColor->AsFloat());
+    }
+  }
+
+  // Take the program into use so we can send uniforms to it
+  // @todo Remove this call entirely!
+  program.Use();
+
+  mUpdated = true;
+
   // Create a new pipeline
   return mGraphicsController->CreatePipeline(
     Graphics::PipelineCreateInfo()
       .SetInputAssemblyState(&inputAssemblyState) // Passed as pointers - shallow copy will break. TOO C LIKE
-      .SetVertexInputState(&vertexInputState),
+      .SetVertexInputState(&vertexInputState)
+      .SetRasterizationState(&rasterizationState)
+      .SetColorBlendState(&colorBlendState),
     nullptr);
 }
 
index faad59c..2e7c049 100644 (file)
@@ -442,12 +442,15 @@ private:
    * @param[in] boundTextures The textures bound for rendering
    * @return False if create or bind failed, true if success.
    */
-  bool BindTextures(Context& context, Program& program, Graphics::CommandBuffer& commandBuffer, Vector<Graphics::Texture*>& boundTextures);
+  bool BindTextures(Program& program, Graphics::CommandBuffer& commandBuffer, Vector<Graphics::Texture*>& boundTextures);
 
   /**
    * Prepare a pipeline for this renderer
    */
-  Graphics::UniquePtr<Graphics::Pipeline> PrepareGraphicsPipeline(Program& program);
+  Graphics::UniquePtr<Graphics::Pipeline> PrepareGraphicsPipeline(
+    Program&                                             program,
+    const Dali::Internal::SceneGraph::RenderInstruction& instruction,
+    bool                                                 blend);
 
 private:
   Graphics::Controller*                        mGraphicsController;
index 6e25894..6a31a43 100644 (file)
@@ -35,6 +35,7 @@ namespace SceneGraph
 {
 class ConnectionObserver;
 class SceneController;
+
 /**
  * A holder class for Program; also enables sharing of uniform properties
  */