Only call cmd::BindTextures if there are valid textures 89/253489/1
authorDavid Steele <david.steele@samsung.com>
Thu, 11 Feb 2021 12:41:51 +0000 (12:41 +0000)
committerDavid Steele <david.steele@samsung.com>
Thu, 11 Feb 2021 13:05:46 +0000 (13:05 +0000)
Added test case to check the command buffer

Change-Id: I7ec40ae45dec4a2a4ca8f5d809ddf822d4c2c842

automated-tests/src/dali/dali-test-suite-utils/test-graphics-command-buffer.h
automated-tests/src/dali/utc-Dali-Renderer.cpp
dali/internal/render/renderers/render-renderer.cpp

index bd6c83a..49c0990 100644 (file)
@@ -89,7 +89,7 @@ public:
   void SetViewportEnable(bool value);
 
 public:
-  TraceCallStack     mCallStack;
+  TraceCallStack&    mCallStack;
   TestGlAbstraction& mGlAbstraction;
 
   std::vector<Graphics::TextureBinding> mTextureBindings;
index 0e2adb4..5136c4c 100644 (file)
@@ -3540,3 +3540,43 @@ int UtcDaliRendererGetShaderNegative(void)
   }
   END_TEST;
 }
+
+int UtcDaliRendererCheckTextureBindingP(void)
+{
+  TestApplication application;
+
+  tet_infoline("Test adding draw commands to the renderer");
+
+  TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
+  glAbstraction.EnableEnableDisableCallTrace(true);
+
+  Geometry geometry = CreateQuadGeometry();
+  Shader   shader   = Shader::New("vertexSrc", "fragmentSrc");
+  Renderer renderer = Renderer::New(geometry, shader);
+
+  renderer.SetProperty(Renderer::Property::BLEND_MODE, Dali::BlendMode::ON);
+  Actor actor = Actor::New();
+  actor.AddRenderer(renderer);
+  actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
+  actor.SetProperty(Actor::Property::COLOR, Vector4(1.0f, 0.0f, 1.0f, 1.0f));
+  application.GetScene().Add(actor);
+
+  TestGraphicsController& graphics        = application.GetGraphicsController();
+  TraceCallStack&         cmdBufCallstack = graphics.mCommandBufferCallStack;
+  cmdBufCallstack.Enable(true);
+
+  application.SendNotification();
+  application.Render();
+
+  DALI_TEST_CHECK(!cmdBufCallstack.FindMethod("BindTextures"));
+
+  Texture    image0      = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGB888, 64, 64);
+  TextureSet textureSet0 = CreateTextureSet(image0);
+  renderer.SetTextures(textureSet0);
+
+  application.SendNotification();
+  application.Render();
+
+  DALI_TEST_CHECK(cmdBufCallstack.FindMethod("BindTextures"));
+  END_TEST;
+}
index 767a11d..fd3bbab 100644 (file)
@@ -397,7 +397,10 @@ bool Renderer::BindTextures(Context& context, Program& program, Graphics::Comman
     }
   }
 
-  commandBuffer.BindTextures(textureBindings);
+  if(textureBindings.size() > 0)
+  {
+    commandBuffer.BindTextures(textureBindings);
+  }
 
   return result;
 }