/*
- * 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.
bool Buffer::TryRecycle(const Graphics::BufferCreateInfo& createInfo, Graphics::EglGraphicsController& controller)
{
- // Compare whether specs are same and the buffer is allocated
- mSetForGLRecycling = false;
+ if(DALI_UNLIKELY(EglGraphicsController::IsShuttingDown()))
+ {
+ // Cannot recycle buffer if shutting down.
+ return false;
+ }
// if different buffer spec, we need new buffer
if(!(createInfo.size == mCreateInfo.size &&
// Make sure the buffer will be reinitialized
controller.AddBuffer(*this);
- mSetForGLRecycling = true;
+ ++mSetForGLRecyclingCount;
return true;
}
bool Buffer::InitializeResource()
{
+ // Fast-skip multiple initialize resource
+ if(DALI_UNLIKELY(mSetForGLRecyclingCount > 1u))
+ {
+ --mSetForGLRecyclingCount;
+ return true;
+ }
+
// CPU allocated uniform buffer is a special "compatibility" mode
// for older GLES
if(mCpuAllocated && !mTransient)
}
// make sure recycling mode is disabled after (re)initializing resource
- mSetForGLRecycling = false;
+ if(mSetForGLRecyclingCount)
+ {
+ --mSetForGLRecyclingCount;
+ }
return true;
}
const auto allocators = GetCreateInfo().allocationCallbacks;
// Early out if we recycle the buffer
- if(mBufferPtr && mSetForGLRecycling)
+ if(mBufferPtr && mSetForGLRecyclingCount)
{
return;
}
}
// If mBufferId is already set and we recycling the buffer (orphaning)
- if(!mSetForGLRecycling && !mBufferId)
+ if(!mSetForGLRecyclingCount && !mBufferId)
{
gl->GenBuffers(1, &mBufferId);
}
#define DALI_GRAPHICS_GLES_BUFFER_H
/*
- * Copyright (c) 2023 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.
bool mCpuAllocated{false};
bool mTransient{false};
- bool mSetForGLRecycling{false}; ///< If flag set true the buffer will recycle
+ uint32_t mSetForGLRecyclingCount{0u}; ///< If value is not zero, the buffer will recycle
};
} // namespace GLES
} // namespace Dali::Graphics