Skip to content

Commit fa75f1f

Browse files
committed
Merge branch 'main' into dev/picking-transparent
2 parents 5a3aff9 + 22db1be commit fa75f1f

File tree

10 files changed

+72
-145
lines changed

10 files changed

+72
-145
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ repositories {
3131
}
3232
3333
dependencies {
34-
implementation 'com.google.android.filament:filament-android:1.54.5'
34+
implementation 'com.google.android.filament:filament-android:1.55.0'
3535
}
3636
```
3737

@@ -51,7 +51,7 @@ Here are all the libraries available in the group `com.google.android.filament`:
5151
iOS projects can use CocoaPods to install the latest release:
5252

5353
```shell
54-
pod 'Filament', '~> 1.54.5'
54+
pod 'Filament', '~> 1.55.0'
5555
```
5656

5757
## Documentation

RELEASE_NOTES.md

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ A new header is inserted each time a *tag* is created.
77
Instead, if you are authoring a PR for the main branch, add your release note to
88
[NEW_RELEASE_NOTES.md](./NEW_RELEASE_NOTES.md).
99

10+
## v1.55.1
11+
12+
1013
## v1.55.0
1114
- Add descriptor sets to describe shader resources. [⚠️ **New Material Version**]
1215

android/gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
GROUP=com.google.android.filament
2-
VERSION_NAME=1.54.5
2+
VERSION_NAME=1.55.0
33

44
POM_DESCRIPTION=Real-time physically based rendering engine for Android.
55

filament/CMakeLists.txt

+7
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,13 @@ else()
607607
-Wover-aligned
608608
-Werror
609609
)
610+
if (CMAKE_CXX_STANDARD EQUAL 20)
611+
# The lambdas for passes in PostProcessManager.cpp capture this
612+
# implicitly in a way that's deprecated in c++20, but can't easily be
613+
# fixed in a way that's backwards compatible with c++17:
614+
# https://www.nextptr.com/tutorial/ta1430524603/capture-this-in-lambda-expression-timeline-of-change
615+
list(APPEND FILAMENT_WARNINGS -Wno-deprecated-this-capture)
616+
endif()
610617
endif()
611618

612619
target_compile_options(${TARGET} PRIVATE

filament/backend/src/vulkan/VulkanHandles.h

+15-16
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,13 @@ struct VulkanDescriptorSet : public VulkanResource, HwDescriptorSet {
135135
using OnRecycle = std::function<void(VulkanDescriptorSet*)>;
136136

137137
VulkanDescriptorSet(VulkanResourceAllocator* allocator, VkDescriptorSet rawSet,
138+
UniformBufferBitmask const& dynamicUboMask,
139+
uint8_t uniqueDynamicUboCount,
138140
OnRecycle&& onRecycleFn)
139141
: VulkanResource(VulkanResourceType::DESCRIPTOR_SET),
140142
vkSet(rawSet),
143+
dynamicUboMask(dynamicUboMask),
144+
uniqueDynamicUboCount(uniqueDynamicUboCount),
141145
mResources(allocator),
142146
mOnRecycleFn(std::move(onRecycleFn)) {}
143147

@@ -147,13 +151,24 @@ struct VulkanDescriptorSet : public VulkanResource, HwDescriptorSet {
147151
}
148152
}
149153

154+
void setOffsets(backend::DescriptorSetOffsetArray&& offsets) noexcept {
155+
mOffsets = std::move(offsets);
156+
}
157+
158+
backend::DescriptorSetOffsetArray const* getOffsets() {
159+
return &mOffsets;
160+
}
161+
150162
void acquire(VulkanTexture* texture);
151163

152164
void acquire(VulkanBufferObject* texture);
153165

154166
VkDescriptorSet const vkSet;
167+
UniformBufferBitmask const dynamicUboMask;
168+
uint8_t const uniqueDynamicUboCount;
155169

156170
private:
171+
backend::DescriptorSetOffsetArray mOffsets;
157172
VulkanAcquireOnlyResourceManager mResources;
158173
OnRecycle mOnRecycleFn;
159174
};
@@ -194,10 +209,6 @@ struct VulkanProgram : public HwProgram, VulkanResource {
194209

195210
inline VkShaderModule getFragmentShader() const { return mInfo->shaders[1]; }
196211

197-
// Get a list of the sampler binding indices so that we don't have to loop through all possible
198-
// samplers.
199-
inline BindingList const& getBindings() const { return mInfo->bindings; }
200-
201212
inline uint32_t getPushConstantRangeCount() const {
202213
return mInfo->pushConstantDescription.getVkRangeCount();
203214
}
@@ -225,22 +236,10 @@ struct VulkanProgram : public HwProgram, VulkanResource {
225236
struct PipelineInfo {
226237
explicit PipelineInfo(backend::Program const& program) noexcept
227238
: pushConstantDescription(program)
228-
#if FVK_ENABLED_DEBUG_SAMPLER_NAME
229-
, bindingToName(MAX_SAMPLER_COUNT, "")
230-
#endif
231239
{}
232240

233-
BindingList bindings;
234-
235241
VkShaderModule shaders[MAX_SHADER_MODULES] = { VK_NULL_HANDLE };
236-
237242
PushConstantDescription pushConstantDescription;
238-
239-
#if FVK_ENABLED_DEBUG_SAMPLER_NAME
240-
// We store the sampler name mapped from binding index (only for debug purposes).
241-
utils::FixedCapacityVector<std::string> bindingToName;
242-
#endif
243-
244243
};
245244

246245
PipelineInfo* mInfo;

filament/backend/src/vulkan/caching/VulkanDescriptorSetManager.cpp

+28-98
Original file line numberDiff line numberDiff line change
@@ -347,70 +347,6 @@ class VulkanDescriptorSetManager::DescriptorSetLayoutManager {
347347
mVkLayouts;
348348
};
349349

350-
class VulkanDescriptorSetManager::DescriptorSetHistory {
351-
private:
352-
using TextureBundle = std::pair<VulkanTexture*, VkImageSubresourceRange>;
353-
354-
public:
355-
DescriptorSetHistory()
356-
: dynamicUboCount(0),
357-
mResources(nullptr) {}
358-
359-
DescriptorSetHistory(UniformBufferBitmask const& dynamicUbo, uint8_t uniqueDynamicUboCount,
360-
VulkanResourceAllocator* allocator, VulkanDescriptorSet* set)
361-
: dynamicUboMask(dynamicUbo),
362-
dynamicUboCount(uniqueDynamicUboCount),
363-
mResources(allocator),
364-
mSet(set),
365-
mBound(false) {
366-
assert_invariant(set);
367-
// initial state is unbound.
368-
unbind();
369-
}
370-
371-
~DescriptorSetHistory() {
372-
if (mSet) {
373-
mResources.clear();
374-
}
375-
}
376-
377-
void setOffsets(backend::DescriptorSetOffsetArray&& offsets) noexcept {
378-
mOffsets = std::move(offsets);
379-
mBound = false;
380-
}
381-
382-
void write(uint8_t binding) noexcept { mBound = false; }
383-
384-
// Ownership will be transfered to the commandbuffer.
385-
void bind(VulkanCommandBuffer* commands, VkPipelineLayout pipelineLayout,
386-
uint8_t index) noexcept {
387-
VkCommandBuffer const cmdbuffer = commands->buffer();
388-
vkCmdBindDescriptorSets(cmdbuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayout, index,
389-
1, &mSet->vkSet, dynamicUboCount, mOffsets.data());
390-
391-
commands->acquire(mSet);
392-
mResources.clear();
393-
mBound = true;
394-
}
395-
396-
void unbind() noexcept {
397-
mResources.acquire(mSet);
398-
mBound = false;
399-
}
400-
401-
bool bound() const noexcept { return mBound; }
402-
403-
UniformBufferBitmask const dynamicUboMask;
404-
uint8_t const dynamicUboCount;
405-
406-
private:
407-
FixedSizeVulkanResourceManager<1> mResources;
408-
VulkanDescriptorSet* mSet = nullptr;
409-
410-
backend::DescriptorSetOffsetArray mOffsets;
411-
bool mBound = false;
412-
};
413-
414350
VulkanDescriptorSetManager::VulkanDescriptorSetManager(VkDevice device,
415351
VulkanResourceAllocator* resourceAllocator)
416352
: mDevice(device),
@@ -423,50 +359,53 @@ VulkanDescriptorSetManager::~VulkanDescriptorSetManager() = default;
423359
void VulkanDescriptorSetManager::terminate() noexcept{
424360
mLayoutManager.reset();
425361
mDescriptorPool.reset();
426-
mHistory.clear();
427362
}
428363

429364
// bind() is not really binding the set but just stashing until we have all the info
430365
// (pipelinelayout).
431366
void VulkanDescriptorSetManager::bind(uint8_t setIndex, VulkanDescriptorSet* set,
432367
backend::DescriptorSetOffsetArray&& offsets) {
433-
auto history = mHistory[set].get();
434-
history->setOffsets(std::move(offsets));
435-
436-
auto lastHistory = mStashedSets[setIndex];
437-
if (lastHistory) {
438-
lastHistory->unbind();
439-
}
440-
mStashedSets[setIndex] = history;
368+
set->setOffsets(std::move(offsets));
369+
mStashedSets[setIndex] = set;
441370
}
442371

443372
void VulkanDescriptorSetManager::commit(VulkanCommandBuffer* commands,
444373
VkPipelineLayout pipelineLayout, DescriptorSetMask const& setMask) {
445-
DescriptorSetHistoryArray& updateSets = mStashedSets;
446-
447374
// setMask indicates the set of descriptor sets the driver wants to bind, curMask is the
448375
// actual set of sets that *needs* to be bound.
449376
DescriptorSetMask curMask = setMask;
450377

378+
auto& updateSets = mStashedSets;
379+
auto& lastBoundSets = mLastBoundInfo.boundSets;
380+
451381
setMask.forEachSetBit([&](size_t index) {
452-
if (!updateSets[index] || updateSets[index]->bound()) {
382+
if (!updateSets[index] || updateSets[index] == lastBoundSets[index]) {
453383
curMask.unset(index);
454384
}
455385
});
456386

457-
BoundInfo nextInfo = {
458-
pipelineLayout,
459-
setMask,
460-
updateSets,
461-
};
462-
if (curMask.none() && mLastBoundInfo == nextInfo) {
387+
if (curMask.none() &&
388+
(mLastBoundInfo.pipelineLayout == pipelineLayout && mLastBoundInfo.setMask == setMask &&
389+
mLastBoundInfo.boundSets == updateSets)) {
463390
return;
464391
}
465392

466393
curMask.forEachSetBit([&updateSets, commands, pipelineLayout](size_t index) {
467-
updateSets[index]->bind(commands, pipelineLayout, index);
394+
// This code actually binds the descriptor sets.
395+
auto set = updateSets[index];
396+
VkCommandBuffer const cmdbuffer = commands->buffer();
397+
vkCmdBindDescriptorSets(cmdbuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayout, index,
398+
1, &set->vkSet, set->uniqueDynamicUboCount, set->getOffsets()->data());
399+
commands->acquire(set);
468400
});
469-
mLastBoundInfo = nextInfo;
401+
402+
mStashedSets = {};
403+
404+
mLastBoundInfo = {
405+
pipelineLayout,
406+
setMask,
407+
updateSets,
408+
};
470409
}
471410

472411
void VulkanDescriptorSetManager::updateBuffer(VulkanDescriptorSet* set, uint8_t binding,
@@ -478,9 +417,8 @@ void VulkanDescriptorSetManager::updateBuffer(VulkanDescriptorSet* set, uint8_t
478417
};
479418

480419
VkDescriptorType type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
481-
auto& history = mHistory[set];
482420

483-
if (history->dynamicUboMask.test(binding)) {
421+
if (set->dynamicUboMask.test(binding)) {
484422
type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC;
485423
}
486424
VkWriteDescriptorSet const descriptorWrite = {
@@ -494,7 +432,6 @@ void VulkanDescriptorSetManager::updateBuffer(VulkanDescriptorSet* set, uint8_t
494432
};
495433
vkUpdateDescriptorSets(mDevice, 1, &descriptorWrite, 0, nullptr);
496434
set->acquire(bufferObject);
497-
history->write(binding);
498435
}
499436

500437
void VulkanDescriptorSetManager::updateSampler(VulkanDescriptorSet* set, uint8_t binding,
@@ -526,7 +463,6 @@ void VulkanDescriptorSetManager::updateSampler(VulkanDescriptorSet* set, uint8_t
526463
};
527464
vkUpdateDescriptorSets(mDevice, 1, &descriptorWrite, 0, nullptr);
528465
set->acquire(texture);
529-
mHistory[set]->write(binding);
530466
}
531467

532468
void VulkanDescriptorSetManager::updateInputAttachment(VulkanDescriptorSet* set,
@@ -539,30 +475,24 @@ void VulkanDescriptorSetManager::createSet(Handle<HwDescriptorSet> handle,
539475
auto const vkSet = mDescriptorPool->obtainSet(layout);
540476
auto const& count = layout->count;
541477
auto const vklayout = layout->getVkLayout();
542-
VulkanDescriptorSet* set = mResourceAllocator->construct<VulkanDescriptorSet>(handle,
543-
mResourceAllocator, vkSet, [vkSet, count, vklayout, this](VulkanDescriptorSet* set) {
478+
mResourceAllocator->construct<VulkanDescriptorSet>(handle, mResourceAllocator, vkSet,
479+
layout->bitmask.dynamicUbo, layout->count.dynamicUbo,
480+
[vkSet, count, vklayout, this](VulkanDescriptorSet* set) {
544481
eraseSetFromHistory(set);
545482
mDescriptorPool->recycle(count, vklayout, vkSet);
546483
});
547-
mHistory[set] = std::make_unique<DescriptorSetHistory>(layout->bitmask.dynamicUbo,
548-
layout->count.dynamicUbo, mResourceAllocator, set);
549484
}
550485

551486
void VulkanDescriptorSetManager::destroySet(Handle<HwDescriptorSet> handle) {
552-
VulkanDescriptorSet* set = mResourceAllocator->handle_cast<VulkanDescriptorSet*>(handle);
553-
eraseSetFromHistory(set);
554487
}
555488

556489
void VulkanDescriptorSetManager::initVkLayout(VulkanDescriptorSetLayout* layout) {
557490
layout->setVkLayout(mLayoutManager->getVkLayout(layout));
558491
}
559492

560493
void VulkanDescriptorSetManager::eraseSetFromHistory(VulkanDescriptorSet* set) {
561-
DescriptorSetHistory* history = mHistory[set].get();
562-
mHistory.erase(set);
563-
564494
for (uint8_t i = 0; i < mStashedSets.size(); ++i) {
565-
if (mStashedSets[i] == history) {
495+
if (mStashedSets[i] == set) {
566496
mStashedSets[i] = nullptr;
567497
}
568498
}

filament/backend/src/vulkan/caching/VulkanDescriptorSetManager.h

+8-25
Original file line numberDiff line numberDiff line change
@@ -74,43 +74,26 @@ class VulkanDescriptorSetManager {
7474
void initVkLayout(VulkanDescriptorSetLayout* layout);
7575

7676
private:
77-
class DescriptorSetHistory;
7877
class DescriptorSetLayoutManager;
7978
class DescriptorInfinitePool;
8079

8180
void eraseSetFromHistory(VulkanDescriptorSet* set);
8281

83-
using DescriptorSetHistoryArray =
84-
std::array<DescriptorSetHistory*, UNIQUE_DESCRIPTOR_SET_COUNT>;
85-
86-
struct BoundInfo {
87-
VkPipelineLayout pipelineLayout = VK_NULL_HANDLE;
88-
DescriptorSetMask setMask;
89-
DescriptorSetHistoryArray boundSets;
90-
91-
bool operator==(BoundInfo const& info) const {
92-
if (pipelineLayout != info.pipelineLayout || setMask != info.setMask) {
93-
return false;
94-
}
95-
bool equal = true;
96-
setMask.forEachSetBit([&](size_t i) {
97-
if (boundSets[i] != info.boundSets[i]) {
98-
equal = false;
99-
}
100-
});
101-
return equal;
102-
}
103-
};
82+
using DescriptorSetArray =
83+
std::array<VulkanDescriptorSet*, UNIQUE_DESCRIPTOR_SET_COUNT>;
10484

10585
VkDevice mDevice;
10686
VulkanResourceAllocator* mResourceAllocator;
10787
std::unique_ptr<DescriptorSetLayoutManager> mLayoutManager;
10888
std::unique_ptr<DescriptorInfinitePool> mDescriptorPool;
10989
std::pair<VulkanAttachment, VkDescriptorImageInfo> mInputAttachment;
110-
std::unordered_map<VulkanDescriptorSet*, std::unique_ptr<DescriptorSetHistory>> mHistory;
111-
DescriptorSetHistoryArray mStashedSets = {};
90+
DescriptorSetArray mStashedSets = {};
11291

113-
BoundInfo mLastBoundInfo;
92+
struct {
93+
VkPipelineLayout pipelineLayout = VK_NULL_HANDLE;
94+
DescriptorSetMask setMask;
95+
DescriptorSetArray boundSets;
96+
} mLastBoundInfo;
11497
};
11598

11699
}// namespace filament::backend

ios/CocoaPods/Filament.podspec

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
Pod::Spec.new do |spec|
22
spec.name = "Filament"
3-
spec.version = "1.54.5"
3+
spec.version = "1.55.0"
44
spec.license = { :type => "Apache 2.0", :file => "LICENSE" }
55
spec.homepage = "https://google.github.io/filament"
66
spec.authors = "Google LLC."
77
spec.summary = "Filament is a real-time physically based rendering engine for Android, iOS, Windows, Linux, macOS, and WASM/WebGL."
88
spec.platform = :ios, "11.0"
9-
spec.source = { :http => "https://github.com/google/filament/releases/download/v1.54.5/filament-v1.54.5-ios.tgz" }
9+
spec.source = { :http => "https://github.com/google/filament/releases/download/v1.55.0/filament-v1.55.0-ios.tgz" }
1010

1111
# Fix linking error with Xcode 12; we do not yet support the simulator on Apple silicon.
1212
spec.pod_target_xcconfig = {

0 commit comments

Comments
 (0)