Skip to content

Conversation

@vinsentli
Copy link
Contributor

No description provided.

Copy link
Contributor

@corporateshark corporateshark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please post your benchmarking results with and without this approach.

VkDevice device_ = VK_NULL_HANDLE;
VkDescriptorPool pool_ = VK_NULL_HANDLE;
uint32_t dsetCursor_ = 0;
std::vector<VkDescriptorSet> allocedDSet_;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about a hash table descriptor set contentVkDescriptorSet?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still thinking about it.

VkDescriptorPool pool_ = VK_NULL_HANDLE;
uint32_t dsetCursor_ = 0;
std::vector<VkDescriptorSet> allocedDSet_;
bool isNewPool_ = true; //is a new created pool or an old cached pool
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to cache descriptors from old pools?

Also, a space after // is missing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I add a new filed allocatedDSet in ExtinctDescriptorPool to cache descriptors from old pools.

@vinsentli
Copy link
Contributor Author

before:
Clipboard_Screenshot_1768053985

after:
Clipboard_Screenshot_1768054024

ivkAllocateDescriptorSet(), switchToNewDescriptorPool() have disappeared.

@corporateshark
Copy link
Contributor

ivkAllocateDescriptorSet(), switchToNewDescriptorPool() have disappeared.

This looks very promising. Any numeric perf improvement values you've got?

I'll test it on my side as well.

@meta-codesync
Copy link

meta-codesync bot commented Jan 13, 2026

@corporateshark has imported this pull request. If you are a Meta employee, you can view this in D90555194.

VK_ASSERT(ivkAllocateDescriptorSet(&ctx_.vf_, device_, pool_, dsl_, &dset));
allocatedDSet_.emplace_back(dset);
} else {
dset = allocatedDSet_[dsetCursor_++];
Copy link
Contributor

@corporateshark corporateshark Jan 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potential out-of-bounds access when reusing a descriptor pool. When a pool is reused (line 277), allocatedDSet_ is restored from the extinct pool, but numRemainingDSetsInPool_ is always reset to kNumDSetsPerPool (64) at line 266. If the pool was previously switched before all 64 descriptor sets were allocated, allocatedDSet_ will have fewer than 64 elements. Subsequent calls to getNextDescriptorSet() could then access allocatedDSet_[dsetCursor_++] at line 257 beyond the vector's bounds. Consider either: (1) setting numRemainingDSetsInPool_ based on the actual size of the restored allocatedDSet_ vector, or (2) ensuring that pools always have exactly kNumDSetsPerPool descriptor sets allocated before being marked as extinct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants