Do not render if bounded sample texture don't have GraphicsObject 55/294755/7
authorEunki, Hong <eunkiki.hong@samsung.com>
Mon, 26 Jun 2023 05:44:07 +0000 (14:44 +0900)
committerEunki Hong <eunkiki.hong@samsung.com>
Mon, 10 Jul 2023 01:47:57 +0000 (10:47 +0900)
Let make Renderer doesn't rendering if bounded texture is
not prepared. Let we apply commands only if all textureSet are
ready to be rendered.

Change-Id: Ie425308eb1cb1fb2939dc4742932057b5626221f
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
automated-tests/src/dali-internal/utc-Dali-Internal-PipelineCache.cpp
automated-tests/src/dali/utc-Dali-CameraActor.cpp
automated-tests/src/dali/utc-Dali-Layer.cpp
automated-tests/src/dali/utc-Dali-Renderer.cpp
automated-tests/src/dali/utc-Dali-Texture.cpp
dali/internal/render/common/render-algorithms.cpp
dali/internal/render/common/render-algorithms.h
dali/internal/render/common/render-manager.cpp
dali/internal/render/renderers/render-renderer.cpp
dali/internal/render/renderers/render-renderer.h

index 8f186e2..4880940 100644 (file)
@@ -88,7 +88,7 @@ int UtcDaliCorePipelineCacheTest(void)
   Geometry   geometry   = CreateQuadGeometry();
   Shader     shader     = Shader::New("vertexSrc", "fragmentSrc");
   TextureSet textureSet = TextureSet::New();
-  Texture    image      = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 50, 50);
+  Texture    image      = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 50, 50);
 
   textureSet.SetTexture(0u, image);
   Renderer renderer = Renderer::New(geometry, shader);
index 28159af..d741721 100644 (file)
@@ -1521,7 +1521,7 @@ int UtcDaliCameraActorReadProjectionMatrix(void)
   application.Render(0);
   application.Render();
   application.SendNotification();
-  Texture image = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 4u, 4u);
+  Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 4u, 4u);
   Actor   actor = CreateRenderableActor(image, RENDER_SHADOW_VERTEX_SOURCE, RENDER_SHADOW_FRAGMENT_SOURCE);
   actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
   application.GetScene().Add(actor);
index 8b63242..a681a25 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -703,7 +703,7 @@ int UtcDaliLayerClippingGLCalls(void)
   layer.SetProperty(Layer::Property::CLIPPING_BOX, testBox);
 
   // Add at least one renderable actor so the GL calls are actually made
-  Texture img   = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 1, 1);
+  Texture img   = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 1, 1);
   Actor   actor = CreateRenderableActor(img);
   scene.Add(actor);
 
@@ -731,7 +731,7 @@ int UtcDaliLayerBehaviour(void)
 
 Actor CreateActor(bool withAlpha)
 {
-  Texture texture = Texture::New(TextureType::TEXTURE_2D, withAlpha ? Pixel::Format::RGBA8888 : Pixel::Format::RGB888, 1u, 1u);
+  Texture texture = CreateTexture(TextureType::TEXTURE_2D, withAlpha ? Pixel::Format::RGBA8888 : Pixel::Format::RGB888, 1u, 1u);
 
   Actor actor = CreateRenderableActor(texture);
   actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
index 9a2d967..0ccc460 100644 (file)
@@ -1086,7 +1086,7 @@ int UtcDaliRendererSetBlendMode05(void)
   tet_infoline("Test setting the blend mode to auto with an opaque color and an image with an alpha channel renders with blending enabled");
 
   Geometry geometry = CreateQuadGeometry();
-  Texture  image    = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 40, 40);
+  Texture  image    = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 40, 40);
 
   Shader     shader     = CreateShader();
   TextureSet textureSet = CreateTextureSet(image);
@@ -1359,7 +1359,7 @@ int UtcDaliRendererSetBlendColor(void)
   Geometry   geometry   = CreateQuadGeometry();
   Shader     shader     = Shader::New("vertexSrc", "fragmentSrc");
   TextureSet textureSet = TextureSet::New();
-  Texture    image      = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 50, 50);
+  Texture    image      = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 50, 50);
   textureSet.SetTexture(0u, image);
   Renderer renderer = Renderer::New(geometry, shader);
   renderer.SetTextures(textureSet);
@@ -1722,7 +1722,7 @@ int UtcDaliRendererUniformMapPrecendence01(void)
 
   tet_infoline("Test the uniform map precedence is applied properly");
 
-  Texture image = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 64, 64);
+  Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 64, 64);
 
   Shader     shader     = Shader::New("VertexSource", "FragmentSource");
   TextureSet textureSet = CreateTextureSet(image);
@@ -1779,7 +1779,7 @@ int UtcDaliRendererUniformMapPrecendence02(void)
 
   tet_infoline("Test the uniform map precedence is applied properly");
 
-  Texture image = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 64, 64);
+  Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 64, 64);
 
   Shader     shader     = Shader::New("VertexSource", "FragmentSource");
   TextureSet textureSet = CreateTextureSet(image);
@@ -1836,7 +1836,7 @@ int UtcDaliRendererUniformMapPrecendence03(void)
 
   tet_infoline("Test the uniform map precedence is applied properly");
 
-  Texture image = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 64, 64);
+  Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 64, 64);
 
   Shader     shader     = Shader::New("VertexSource", "FragmentSource");
   TextureSet textureSet = CreateTextureSet(image);
@@ -1874,7 +1874,7 @@ int UtcDaliRendererUniformMapMultipleUniforms01(void)
 
   tet_infoline("Test the uniform maps are collected from all objects (same type)");
 
-  Texture image = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 64, 64);
+  Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 64, 64);
 
   Shader     shader     = Shader::New("VertexSource", "FragmentSource");
   TextureSet textureSet = CreateTextureSet(image);
@@ -1921,7 +1921,7 @@ int UtcDaliRendererUniformMapMultipleUniforms02(void)
 
   tet_infoline("Test the uniform maps are collected from all objects (different types)");
 
-  Texture image = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 64, 64);
+  Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 64, 64);
 
   Shader     shader     = Shader::New("VertexSource", "FragmentSource");
   TextureSet textureSet = CreateTextureSet(image);
@@ -3250,7 +3250,7 @@ int UtcDaliRendererWrongNumberOfTextures(void)
 
   //Create a TextureSet with 4 textures (One more texture in the texture set than active samplers)
   //@note Shaders in the test suit have 3 active samplers. See TestGlAbstraction::GetActiveUniform()
-  Texture    texture    = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 64u, 64u);
+  Texture    texture    = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 64u, 64u);
   TextureSet textureSet = CreateTextureSet();
   textureSet.SetTexture(0, texture);
   textureSet.SetTexture(1, texture);
index c817afa..443bbb0 100644 (file)
@@ -1426,7 +1426,7 @@ int utcDaliTexturePartialUpdate01(void)
 
   uint32_t   width(4);
   uint32_t   height(4);
-  Texture    texture    = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
+  Texture    texture    = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
   TextureSet textureSet = TextureSet::New();
   textureSet.SetTexture(0u, texture);
   renderer.SetTextures(textureSet);
@@ -1513,8 +1513,8 @@ int utcDaliTexturePartialUpdate02(void)
 
   uint32_t   width(4);
   uint32_t   height(4);
-  Texture    texture1   = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
-  Texture    texture2   = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
+  Texture    texture1   = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
+  Texture    texture2   = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
   TextureSet textureSet = TextureSet::New();
   textureSet.SetTexture(0u, texture1);
   renderer.SetTextures(textureSet);
index 13dfcc4..ad580cf 100644 (file)
@@ -586,7 +586,6 @@ inline void RenderAlgorithms::ProcessRenderList(const RenderList&
                                                 const Matrix&                       projectionMatrix,
                                                 Integration::DepthBufferAvailable   depthBufferAvailable,
                                                 Integration::StencilBufferAvailable stencilBufferAvailable,
-                                                Vector<Graphics::Texture*>&         boundTextures,
                                                 const RenderInstruction&            instruction,
                                                 const Rect<int32_t>&                viewport,
                                                 const Rect<int>&                    rootClippingRect,
@@ -697,7 +696,7 @@ inline void RenderAlgorithms::ProcessRenderList(const RenderList&
         for(auto queue = 0u; queue < MAX_QUEUE; ++queue)
         {
           // Render the item. It will write into the command buffer everything it has to render
-          item.mRenderer->Render(secondaryCommandBuffer, bufferIndex, *item.mNode, item.mModelMatrix, item.mModelViewMatrix, viewMatrix, projectionMatrix, item.mSize, !item.mIsOpaque, boundTextures, instruction, queue);
+          item.mRenderer->Render(secondaryCommandBuffer, bufferIndex, *item.mNode, item.mModelMatrix, item.mModelViewMatrix, viewMatrix, projectionMatrix, item.mSize, !item.mIsOpaque, instruction, queue);
         }
       }
     }
@@ -740,7 +739,6 @@ void RenderAlgorithms::ProcessRenderInstruction(const RenderInstruction&
                                                 BufferIndex                         bufferIndex,
                                                 Integration::DepthBufferAvailable   depthBufferAvailable,
                                                 Integration::StencilBufferAvailable stencilBufferAvailable,
-                                                Vector<Graphics::Texture*>&         boundTextures,
                                                 const Rect<int32_t>&                viewport,
                                                 const Rect<int>&                    rootClippingRect,
                                                 int                                 orientation,
@@ -773,7 +771,6 @@ void RenderAlgorithms::ProcessRenderInstruction(const RenderInstruction&
                           *projectionMatrix,
                           depthBufferAvailable,
                           stencilBufferAvailable,
-                          boundTextures,
                           instruction, //added for reflection effect
                           viewport,
                           rootClippingRect,
index 4639811..04b2fe6 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_RENDER_ALGORITHMS_H
 
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -57,7 +57,6 @@ public:
    * @param[in] bufferIndex            The current render buffer index (previous update buffer)
    * @param[in] depthBufferAvailable   Whether the depth buffer is available
    * @param[in] stencilBufferAvailable Whether the stencil buffer is available
-   * @param[in] boundTextures          The textures bound for rendering
    * @param[in] viewport               The viewport for drawing
    * @param[in] rootClippingRect       The clipping rectangle
    * @param[in] orientation            The Scene's surface orientation.
@@ -67,7 +66,6 @@ public:
                                 BufferIndex                          bufferIndex,
                                 Integration::DepthBufferAvailable    depthBufferAvailable,
                                 Integration::StencilBufferAvailable  stencilBufferAvailable,
-                                Vector<Graphics::Texture*>&          boundTextures,
                                 const Rect<int32_t>&                 viewport,
                                 const Rect<int>&                     rootClippingRect,
                                 int                                  orientation,
@@ -123,7 +121,7 @@ private:
     const Dali::Internal::SceneGraph::RenderItem&        item,
     Graphics::CommandBuffer&                             commandBuffer,
     const Dali::Internal::SceneGraph::RenderInstruction& instruction,
-    int orientation);
+    int                                                  orientation);
 
   /**
    * @brief Set up the clipping based on the specified clipping settings.
@@ -153,7 +151,6 @@ private:
    * @param[in] projectionMatrix       The projection matrix from the appropriate camera.
    * @param[in] depthBufferAvailable   Whether the depth buffer is available
    * @param[in] stencilBufferAvailable Whether the stencil buffer is available
-   * @param[in] boundTextures          The textures bound for rendering
    * @param[in] viewport               The Viewport
    * @param[in] rootClippingRect       The root clipping rectangle
    * @param[in] orientation            The Scene's surface orientation
@@ -165,7 +162,6 @@ private:
                                 const Matrix&                                        projectionMatrix,
                                 Integration::DepthBufferAvailable                    depthBufferAvailable,
                                 Integration::StencilBufferAvailable                  stencilBufferAvailable,
-                                Vector<Graphics::Texture*>&                          boundTextures,
                                 const Dali::Internal::SceneGraph::RenderInstruction& instruction, // in the case of reflection, things like CullFace need to be adjusted for reflection world
                                 const Rect<int32_t>&                                 viewport,
                                 const Rect<int>&                                     rootClippingRect,
index adb9ba0..7907982 100644 (file)
@@ -203,7 +203,6 @@ struct RenderManager::Impl
   Integration::PartialUpdateAvailable partialUpdateAvailable; ///< Whether the partial update is available
 
   std::unique_ptr<Dali::ThreadPool> threadPool;        ///< The thread pool
-  Vector<Graphics::Texture*>        boundTextures;     ///< The textures bound for rendering
   Vector<Render::TextureKey>        updatedTextures{}; ///< The updated texture list
 
   uint32_t    frameCount{0u};                                                    ///< The current frame count
@@ -1050,15 +1049,11 @@ void RenderManager::RenderScene(Integration::RenderStatus& status, Integration::
                                     float(viewportRect.width),
                                     float(viewportRect.height)});
 
-    // Clear the list of bound textures
-    mImpl->boundTextures.Clear();
-
     mImpl->renderAlgorithms.ProcessRenderInstruction(
       instruction,
       mImpl->renderBufferIndex,
       depthBufferAvailable,
       stencilBufferAvailable,
-      mImpl->boundTextures,
       viewportRect,
       clippingRect,
       surfaceOrientation,
index 3c8e4af..60f3a53 100644 (file)
@@ -280,7 +280,7 @@ void Renderer::SetDrawCommands(Dali::DevelRenderer::DrawCommand* pDrawCommands,
   mDrawCommands.insert(mDrawCommands.end(), pDrawCommands, pDrawCommands + size);
 }
 
-void Renderer::BindTextures(Graphics::CommandBuffer& commandBuffer, Vector<Graphics::Texture*>& boundTextures)
+bool Renderer::BindTextures(Graphics::CommandBuffer& commandBuffer)
 {
   uint32_t textureUnit = 0;
 
@@ -307,12 +307,16 @@ void Renderer::BindTextures(Graphics::CommandBuffer& commandBuffer, Vector<Graph
                                                                               : nullptr)
                                                             : nullptr;
 
-        boundTextures.PushBack(graphicsTexture);
         const Graphics::TextureBinding textureBinding{graphicsTexture, graphicsSampler, textureUnit};
         textureBindings.push_back(textureBinding);
 
         ++textureUnit;
       }
+      else
+      {
+        // Texture is not prepared yet. We should not render now.
+        return false;
+      }
     }
   }
 
@@ -320,6 +324,8 @@ void Renderer::BindTextures(Graphics::CommandBuffer& commandBuffer, Vector<Graph
   {
     commandBuffer.BindTextures(textureBindings);
   }
+
+  return true;
 }
 
 void Renderer::SetFaceCullingMode(FaceCullingMode::Type mode)
@@ -543,7 +549,6 @@ bool Renderer::Render(Graphics::CommandBuffer&                             comma
                       const Matrix&                                        projectionMatrix,
                       const Vector3&                                       size,
                       bool                                                 blend,
-                      Vector<Graphics::Texture*>&                          boundTextures,
                       const Dali::Internal::SceneGraph::RenderInstruction& instruction,
                       uint32_t                                             queueIndex)
 {
@@ -626,6 +631,12 @@ bool Renderer::Render(Graphics::CommandBuffer&                             comma
 
   bool drawn = false;
 
+  // Check all textures are prepared first.
+  if(!BindTextures(commandBuffer))
+  {
+    return drawn;
+  }
+
   // We should have a shader here (as only RenderCallback has no shader, and that's been early out)
   Program* program = PrepareProgram(instruction);
   if(program)
@@ -634,7 +645,6 @@ bool Renderer::Render(Graphics::CommandBuffer&                             comma
     auto& pipeline = PrepareGraphicsPipeline(*program, instruction, node, blend);
 
     commandBuffer.BindPipeline(pipeline);
-    BindTextures(commandBuffer, boundTextures);
 
     if(queueIndex == 0)
     {
index 5af3bb7..a348bb4 100644 (file)
@@ -405,7 +405,6 @@ public:
    * @param[in] projectionMatrix The projection matrix.
    * @param[in] size Size of the render item
    * @param[in] blend If true, blending is enabled
-   * @param[in] boundTextures The textures bound for rendering
    * @param[in] instruction. for use case like reflection where CullFace needs to be adjusted
    *
    * @return True if commands have been added to the command buffer
@@ -419,7 +418,6 @@ public:
               const Matrix&                                        projectionMatrix,
               const Vector3&                                       size,
               bool                                                 blend,
-              Vector<Graphics::Texture*>&                          boundTextures,
               const Dali::Internal::SceneGraph::RenderInstruction& instruction,
               uint32_t                                             queueIndex);
 
@@ -557,9 +555,10 @@ private:
   /**
    * Bind the textures and setup the samplers
    * @param[in] commandBuffer The command buffer to record binding into
-   * @param[in] boundTextures The textures bound for rendering
+   *
+   * @return True if all textures are bounded successfully. False otherwise.
    */
-  void BindTextures(Graphics::CommandBuffer& commandBuffer, Vector<Graphics::Texture*>& boundTextures);
+  bool BindTextures(Graphics::CommandBuffer& commandBuffer);
 
   /**
    * Prepare a pipeline for this renderer.