[Tizen] Reset vertex buffer cache at the end of flush 62/320262/1 accepted/tizen_8.0_unified tizen_8.0 accepted/tizen/8.0/unified/20250227.155236
authorEunki, Hong <eunkiki.hong@samsung.com>
Mon, 24 Feb 2025 13:55:45 +0000 (22:55 +0900)
committerEunki, Hong <eunkiki.hong@samsung.com>
Wed, 26 Feb 2025 02:08:49 +0000 (11:08 +0900)
We only check the internal value of VertexBufferBindingDescriptor.

But if the size of mImpl->mCurrentVertexBufferBindings changed, or cleared,
the vertex buffer's pointer might be same as previos old items.
In this case, we might miss vertex attribute, or VAO relative actions.

To avoid this case, let we clear current binded vertex
whenever if the size of mImpl->mCurrentVertexBufferBindings changed.

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

index 67089b255dcdb41d894abb8da11aea06869434ed..f3d74415255d033250b3deef3fecae364ff72b89 100644 (file)
@@ -580,6 +580,7 @@ void Context::BindVertexBuffers(const GLES::VertexBufferBindingDescriptor* bindi
   if(count > mImpl->mCurrentVertexBufferBindings.size())
   {
     mImpl->mCurrentVertexBufferBindings.resize(count);
+    mImpl->mVertexBuffersChanged = true;
   }
   // Copy only set slots
   auto toIter = mImpl->mCurrentVertexBufferBindings.begin();
@@ -935,6 +936,22 @@ void Context::ClearState()
   mImpl->mCurrentUBOBindings.clear();
 }
 
+void Context::ClearVertexBufferCache()
+{
+  mImpl->mCurrentVertexBufferBindings.clear();
+  mImpl->mVertexBuffersChanged   = true;
+  mImpl->mProgramVAOCurrentState = 0;
+  // Skip below logic at tizen_8.0 since we cannot assume that controller is valid.
+  // if(DALI_LIKELY(!EglGraphicsController::IsShuttingDown()))
+  // {
+  //   if(!(mImpl->mController.GetGLESVersion() >= GLESVersion::GLES_30))
+  //   {
+  //     memset(&mImpl->mGlStateCache.mVertexAttributeCachedState, 0, sizeof(mImpl->mGlStateCache.mVertexAttributeCachedState));
+  //     memset(&mImpl->mGlStateCache.mVertexAttributeCurrentState, 0, sizeof(mImpl->mGlStateCache.mVertexAttributeCurrentState));
+  //   }
+  // }
+}
+
 void Context::ColorMask(bool enabled)
 {
   auto* gl = mImpl->GetGL();
@@ -1250,14 +1267,12 @@ void Context::InvalidateCachedPipeline(GLES::Pipeline* pipeline)
 
             // Do not delete vao now. (Since Context might not be current.)
             mImpl->mDiscardedVAOList.emplace_back(vao);
-            if(mImpl->mProgramVAOCurrentState == vao)
-            {
-              mImpl->mProgramVAOCurrentState = 0u;
-            }
           }
 
           // Clear cached Vertex buffer.
-          mImpl->mCurrentVertexBufferBindings.clear();
+          ClearVertexBufferCache();
+
+          mImpl->mGlStateCache.ResetBufferCache();
 
           mImpl->mProgramVAOMap.erase(iter);
         }
@@ -1330,15 +1345,13 @@ void Context::ResetGLESState()
   mImpl->mCurrentPipeline = nullptr;
   mImpl->mCurrentUBOBindings.clear();
   mImpl->mCurrentTextureBindings.clear();
-  mImpl->mCurrentVertexBufferBindings.clear();
   mImpl->mCurrentRenderTarget = nullptr;
   mImpl->mCurrentRenderPass = nullptr;
-  mImpl->mVertexBuffersChanged = true;
   mImpl->mCurrentIndexBufferBinding = {};
   mImpl->mCurrentSamplerBindings = {};
-  mImpl->mProgramVAOCurrentState = 0;
 
   ClearState();
+  ClearVertexBufferCache();
   mImpl->InitializeGlState();
 }
 
index d6273609f4776cd4901adf2572146b5caeea63f5..ec0d1b0bd7c5b18e7cc1d97ac77d5d983f72c6ca 100644 (file)
@@ -230,6 +230,11 @@ private:
    */
   void ClearState();
 
+  /**
+   * @brief Clear vertex buffer relative caches.
+   */
+  void ClearVertexBufferCache();
+
 private:
   struct Impl;
   std::unique_ptr<Impl> mImpl;