Compare commits

...

3 Commits

Author SHA1 Message Date
Powei Feng
84c9752493 Update MATERIAL_VERSION to 70 2026-03-23 15:22:20 -07:00
Powei Feng
cab8a89346 vk: make fbo eviction time configurable (#9808)
The previous eviction time is too large (40), then causes memory
to bloat over time. We set the default to 3 (as in triple
buffering), but make it a configurable option via VulkanPlatform.

Fixes #9786
2026-03-23 10:12:41 -07:00
Benjamin Doherty
90254338d6 Bump version to 1.70.1 2026-03-10 13:43:25 -07:00
9 changed files with 46 additions and 31 deletions

View File

@@ -31,7 +31,7 @@ repositories {
} }
dependencies { dependencies {
implementation 'com.google.android.filament:filament-android:1.70.0' implementation 'com.google.android.filament:filament-android:1.70.1'
} }
``` ```
@@ -50,7 +50,7 @@ Here are all the libraries available in the group `com.google.android.filament`:
iOS projects can use CocoaPods to install the latest release: iOS projects can use CocoaPods to install the latest release:
```shell ```shell
pod 'Filament', '~> 1.70.0' pod 'Filament', '~> 1.70.1'
``` ```
## Documentation ## Documentation

View File

@@ -1,5 +1,5 @@
GROUP=com.google.android.filament GROUP=com.google.android.filament
VERSION_NAME=1.70.0 VERSION_NAME=1.70.1
POM_DESCRIPTION=Real-time physically based rendering engine for Android. POM_DESCRIPTION=Real-time physically based rendering engine for Android.

View File

@@ -177,6 +177,12 @@ public:
* presentation. Default is true. * presentation. Default is true.
*/ */
bool transitionSwapChainImageLayoutForPresent = true; bool transitionSwapChainImageLayoutForPresent = true;
/**
* The number of frames before an unused framebuffer is evicted from the cache.
* Default is 3.
*/
uint32_t timeBeforeEvictionFbo = 3;
}; };
/** /**

View File

@@ -260,7 +260,8 @@ VulkanDriver::VulkanDriver(VulkanPlatform* platform, VulkanContext& context,
mPipelineCache(*this, mPlatform->getDevice(), mContext), mPipelineCache(*this, mPlatform->getDevice(), mContext),
mStagePool(mAllocator, &mResourceManager, &mCommands, &mContext.getPhysicalDeviceLimits()), mStagePool(mAllocator, &mResourceManager, &mCommands, &mContext.getPhysicalDeviceLimits()),
mBufferCache(mContext, mResourceManager, mAllocator), mBufferCache(mContext, mResourceManager, mAllocator),
mFramebufferCache(mPlatform->getDevice()), mFramebufferCache(mPlatform->getDevice(),
mPlatform->getCustomization().timeBeforeEvictionFbo),
mYcbcrConversionCache(mPlatform->getDevice()), mYcbcrConversionCache(mPlatform->getDevice()),
mSamplerCache(mPlatform->getDevice()), mSamplerCache(mPlatform->getDevice()),
mBlitter(mPlatform->getPhysicalDevice(), &mCommands), mBlitter(mPlatform->getPhysicalDevice(), &mCommands),

View File

@@ -20,6 +20,7 @@
#include "VulkanHandles.h" #include "VulkanHandles.h"
#include "vulkan/utils/Image.h" #include "vulkan/utils/Image.h"
#include <utils/compiler.h>
#include <utils/Panic.h> #include <utils/Panic.h>
// If any VkRenderPass or VkFramebuffer is unused for more than TIME_BEFORE_EVICTION frames, it // If any VkRenderPass or VkFramebuffer is unused for more than TIME_BEFORE_EVICTION frames, it
@@ -62,8 +63,9 @@ bool VulkanFboCache::FboKeyEqualFn::operator()(const FboKey& k1, const FboKey& k
return true; return true;
} }
VulkanFboCache::VulkanFboCache(VkDevice device) VulkanFboCache::VulkanFboCache(VkDevice device, uint32_t timeBeforeEvictionFbo)
: mDevice(device) {} : mDevice(device),
mTimeBeforeEvictionFbo(timeBeforeEvictionFbo) {}
VulkanFboCache::~VulkanFboCache() { VulkanFboCache::~VulkanFboCache() {
FILAMENT_CHECK_POSTCONDITION(mFramebufferCache.empty() && mRenderPassCache.empty()) FILAMENT_CHECK_POSTCONDITION(mFramebufferCache.empty() && mRenderPassCache.empty())
@@ -376,31 +378,36 @@ void VulkanFboCache::gc() noexcept {
FVK_SYSTRACE_START("fbocache::gc"); FVK_SYSTRACE_START("fbocache::gc");
// If this is one of the first few frames, return early to avoid wrapping unsigned integers. // If this is one of the first few frames, return early to avoid wrapping unsigned integers.
if (++mCurrentTime <= TIME_BEFORE_EVICTION) { ++mCurrentTime;
return;
}
const uint32_t evictTime = mCurrentTime - TIME_BEFORE_EVICTION;
for (FboMap::iterator iter = mFramebufferCache.begin(); iter != mFramebufferCache.end(); ) { if (UTILS_UNLIKELY(mCurrentTime > mTimeBeforeEvictionFbo)) {
const FboVal fbo = iter->second; const uint32_t evictTimeFbo = mCurrentTime - mTimeBeforeEvictionFbo;
if (fbo.timestamp < evictTime && fbo.handle) { for (FboMap::iterator iter = mFramebufferCache.begin(); iter != mFramebufferCache.end();) {
mRenderPassRefCount[iter->first.renderPass]--; const FboVal fbo = iter->second;
if (fbo.timestamp < evictTimeFbo && fbo.handle) {
mRenderPassRefCount[iter->first.renderPass]--;
// erase(iterator) returns the iterator to the next element. // erase(iterator) returns the iterator to the next element.
iter = mFramebufferCache.erase(iter); iter = mFramebufferCache.erase(iter);
} else { } else {
++iter; ++iter;
}
} }
} }
for (RenderPassMap::iterator iter = mRenderPassCache.begin(); iter != mRenderPassCache.end(); ) { if (UTILS_UNLIKELY(mCurrentTime > TIME_BEFORE_EVICTION)) {
const VkRenderPass handle = iter->second.handle->getVkRenderPass(); const uint32_t evictTimeRp = mCurrentTime - TIME_BEFORE_EVICTION;
if (iter->second.timestamp < evictTime && handle && mRenderPassRefCount[handle] == 0) { for (RenderPassMap::iterator iter = mRenderPassCache.begin();
// erase(iterator) returns the iterator to the next element. iter != mRenderPassCache.end();) {
iter = mRenderPassCache.erase(iter); const VkRenderPass handle = iter->second.handle->getVkRenderPass();
mRenderPassRefCount.erase(handle); if (iter->second.timestamp < evictTimeRp && handle &&
} else { mRenderPassRefCount[handle] == 0) {
++iter; // erase(iterator) returns the iterator to the next element.
iter = mRenderPassCache.erase(iter);
mRenderPassRefCount.erase(handle);
} else {
++iter;
}
} }
} }

View File

@@ -100,7 +100,7 @@ public:
bool operator()(const FboKey& k1, const FboKey& k2) const; bool operator()(const FboKey& k1, const FboKey& k2) const;
}; };
explicit VulkanFboCache(VkDevice device); explicit VulkanFboCache(VkDevice device, uint32_t timeBeforeEvictionFbo);
~VulkanFboCache(); ~VulkanFboCache();
// Retrieves or creates a VkFramebuffer handle. // Retrieves or creates a VkFramebuffer handle.
@@ -130,6 +130,7 @@ private:
RenderPassMap mRenderPassCache; RenderPassMap mRenderPassCache;
tsl::robin_map<VkRenderPass, uint32_t> mRenderPassRefCount; tsl::robin_map<VkRenderPass, uint32_t> mRenderPassRefCount;
uint32_t mCurrentTime = 0; uint32_t mCurrentTime = 0;
uint32_t mTimeBeforeEvictionFbo;
}; };
} // namespace filament::backend } // namespace filament::backend

View File

@@ -1,12 +1,12 @@
Pod::Spec.new do |spec| Pod::Spec.new do |spec|
spec.name = "Filament" spec.name = "Filament"
spec.version = "1.70.0" spec.version = "1.70.1"
spec.license = { :type => "Apache 2.0", :file => "LICENSE" } spec.license = { :type => "Apache 2.0", :file => "LICENSE" }
spec.homepage = "https://google.github.io/filament" spec.homepage = "https://google.github.io/filament"
spec.authors = "Google LLC." spec.authors = "Google LLC."
spec.summary = "Filament is a real-time physically based rendering engine for Android, iOS, Windows, Linux, macOS, and WASM/WebGL." spec.summary = "Filament is a real-time physically based rendering engine for Android, iOS, Windows, Linux, macOS, and WASM/WebGL."
spec.platform = :ios, "11.0" spec.platform = :ios, "11.0"
spec.source = { :http => "https://github.com/google/filament/releases/download/v1.70.0/filament-v1.70.0-ios.tgz" } spec.source = { :http => "https://github.com/google/filament/releases/download/v1.70.1/filament-v1.70.1-ios.tgz" }
spec.libraries = 'c++' spec.libraries = 'c++'

View File

@@ -28,7 +28,7 @@
namespace filament { namespace filament {
// update this when a new version of filament wouldn't work with older materials // update this when a new version of filament wouldn't work with older materials
static constexpr size_t MATERIAL_VERSION = 69; static constexpr size_t MATERIAL_VERSION = 70;
// Those are the api levels that are used in the source material file (.mat) // Those are the api levels that are used in the source material file (.mat)
// //

View File

@@ -1,6 +1,6 @@
{ {
"name": "filament", "name": "filament",
"version": "1.70.0", "version": "1.70.1",
"description": "Real-time physically based rendering engine", "description": "Real-time physically based rendering engine",
"main": "filament.js", "main": "filament.js",
"module": "filament.js", "module": "filament.js",