[Tizen] Prepare NativeTexture only once per each frames 37/318237/1
authorEunki, Hong <eunkiki.hong@samsung.com>
Tue, 14 Jan 2025 10:49:28 +0000 (19:49 +0900)
committerEunki, Hong <eunkiki.hong@samsung.com>
Tue, 14 Jan 2025 11:13:55 +0000 (20:13 +0900)
Let we make ensure that GLES::Texture::Prepare() called
only 1 times per each frames.

It will guard to update native texture target multiple times
so EGLImage confused.

Change-Id: Ia243e378a0305e94df3ec444cdbdf22e25dfed7e
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
dali/internal/graphics/gles-impl/gles-graphics-texture.cpp
dali/internal/graphics/gles-impl/gles-graphics-texture.h
dali/internal/graphics/gles-impl/gles-texture-dependency-checker.cpp

index 7471f5c6c6888fd95283c07b062fa2cb23c72b51..9c82d0c9eb7840136d3560fc07dda780f6768468 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2024 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2025 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.
@@ -395,8 +395,9 @@ void Texture::Bind(const TextureBinding& binding) const
 void Texture::Prepare()
 {
   NativeImageInterfacePtr nativeImage = mCreateInfo.nativeImagePtr;
-  if(nativeImage)
+  if(nativeImage && !IsPrepared())
   {
+    mIsPrepared = true;
     nativeImage->PrepareTexture();
   }
 }
index 0d736bb73e73de0b86fcf73052e9b75ca9bf0dda..9947d9bf4f2f7121919154bd73f4933115b0a00b 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_GRAPHICS_GLES_TEXTURE_H
 
 /*
- * Copyright (c) 2024 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2025 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.
@@ -105,9 +105,31 @@ public:
    * and updates as appropriate.
    *
    * Gives the callback a chance to draw to the backing texture.
+   *
+   * @note This function has no effort if we call Prepare() before.
+   *       To make sure that the texture is prepared again, call ResetPrepare().
    */
   void Prepare();
 
+  /**
+   * @brief Makes sure that the texture need to be prepared again
+   */
+  void ResetPrepare()
+  {
+    mIsPrepared = false;
+  }
+
+  /**
+   * @brief Returns whether the texture call prepare or not.
+   * ResetPepare() will make this false again.
+   *
+   * @return True if prepare called. false otherwise.
+   */
+  [[nodiscard]] bool IsPrepared() const
+  {
+    return mIsPrepared;
+  }
+
   /**
    * @brief Returns the GL Target
    * @return the Gl target
@@ -187,6 +209,7 @@ private:
   uint32_t          mDependencyIndex{0xFFFFFFFF};
   void*             mGLOwnerContext{nullptr};
   bool              mIsCompressed{false};
+  bool              mIsPrepared{false};
 };
 
 } // namespace Dali::Graphics::GLES
index 01e7983206cc2489a6377498a4fbe5a8be4e84e5..c6cf7b0933f422e1315e232307d767c43380b5b0 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2024 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2025 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.
@@ -77,6 +77,16 @@ void TextureDependencyChecker::Reset()
     }
     mNativeTextureDependencies[mPreviousNativeTextureDependencyIndex].clear();
 
+    // Reset all native texture's state as prepared.
+    // TODO : Is their any more good place to call this logic?
+    for(auto& nativeTextureDependency : mNativeTextureDependencies[mCurrentNativeTextureDependencyIndex])
+    {
+      for(auto& texture : nativeTextureDependency.textures)
+      {
+        const_cast<GLES::Texture*>(texture)->ResetPrepare();
+      }
+    }
+
     mCurrentNativeTextureDependencyIndex = __sync_fetch_and_xor(&mPreviousNativeTextureDependencyIndex, 1);
   }
 }