Limits texture upload buffer to 1MB and flushes upload requests 66/258166/2
authoradam.b <adam.b@samsung.com>
Tue, 11 May 2021 15:10:01 +0000 (16:10 +0100)
committerAdam Bialogonski <adam.b@samsung.com>
Wed, 12 May 2021 15:29:55 +0000 (15:29 +0000)
in case of exceeding the maximum size.

Change-Id: If6ab05dd557afba718be53dd7d114f54eb1263e6

dali/internal/graphics/gles-impl/egl-graphics-controller.cpp
dali/internal/graphics/gles-impl/egl-graphics-controller.h

index 8fe7b73..4ec725d 100644 (file)
@@ -88,6 +88,9 @@ T0* CastObject(T1* apiObject)
   return static_cast<T0*>(apiObject);
 }
 
+// Maximum size of texture upload buffer.
+const uint32_t TEXTURE_UPLOAD_MAX_BUFER_SIZE_MB = 1;
+
 } // namespace
 
 EglGraphicsController::~EglGraphicsController() = default;
@@ -398,6 +401,8 @@ void EglGraphicsController::UpdateTextures(const std::vector<TextureUpdateInfo>&
                   reinterpret_cast<char*>(source.memorySource.memory) + info.srcSize,
                   stagingBuffer);
 
+        mTextureUploadTotalCPUMemoryUsed += info.srcSize;
+
         // store staging buffer
         source.memorySource.memory = stagingBuffer;
         break;
@@ -414,6 +419,13 @@ void EglGraphicsController::UpdateTextures(const std::vector<TextureUpdateInfo>&
       }
     }
   }
+
+  // If upload buffer exceeds maximum size, flush.
+  if( mTextureUploadTotalCPUMemoryUsed > TEXTURE_UPLOAD_MAX_BUFER_SIZE_MB*1024 )
+  {
+    Flush();
+    mTextureUploadTotalCPUMemoryUsed = 0;
+  }
 }
 
 Graphics::UniquePtr<Memory> EglGraphicsController::MapBufferRange(const MapBufferInfo& mapInfo)
index 8317fd8..6886380 100644 (file)
@@ -562,6 +562,8 @@ private:
 
   std::unique_ptr<GLES::PipelineCache> mPipelineCache{nullptr}; ///< Internal pipeline cache
 
+  uint32_t mTextureUploadTotalCPUMemoryUsed {0u};
+
   bool mIsShuttingDown{false}; ///< Indicates whether the controller is shutting down
 };