Skip to content

Commit

Permalink
Vulkan: Let XFB's BufferHelper keep SharedDescriptorSetCacheKey
Browse files Browse the repository at this point in the history
instead of BufferBlock. Unlike uniform buffers which uses
VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, the descriptorSet for
transform feedback buffers also have the buffer offset baked in, so it
is not helpful to use BufferBlock's serial in the cache key.  This CL
changes to use BufferHelper's serial for cache key. With this we can
also let BufferHelper keep the SharedDescriptorSetCacheKey instead of
store it in the BufferBlock. In the case that BufferHelper gets
destroyed and recreated, the SharedDescriptorSetCacheKey will also get
destroyed. Right now because we cache BufferBlock serial, the
SharedDescriptorSetCacheKey will not be destroyed even though
BufferHelper is destroyed and there is very rare case that it can be
reused, thus causing BufferBlock's SharedDescriptorSetCacheKey queue
keep increasing, which causes perf issue.

Bug: b/384839847
Change-Id: I76b8f0d56486079740cca302e8b14a04a6e24074
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6115111
Reviewed-by: mohan maiya <m.maiya@samsung.com>
Commit-Queue: Yuxin Hu <yuxinhu@google.com>
Auto-Submit: Charlie Lao <cclao@google.com>
Reviewed-by: Yuxin Hu <yuxinhu@google.com>
  • Loading branch information
cclao authored and Angle LUCI CQ committed Dec 23, 2024
1 parent 501f07a commit 711b2c3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
10 changes: 2 additions & 8 deletions src/libANGLE/renderer/vulkan/TransformFeedbackVk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,6 @@ void TransformFeedbackVk::updateTransformFeedbackDescriptorDesc(
vk::DescriptorSetDescBuilder *builder) const
{
size_t xfbBufferCount = executable.getTransformFeedbackBufferCount();

for (uint32_t bufferIndex = 0; bufferIndex < xfbBufferCount; ++bufferIndex)
{
if (mBufferHelpers[bufferIndex] && activeUnpaused)
Expand All @@ -291,14 +290,9 @@ void TransformFeedbackVk::onNewDescriptorSet(const gl::ProgramExecutable &execut
size_t xfbBufferCount = executable.getTransformFeedbackBufferCount();
for (uint32_t bufferIndex = 0; bufferIndex < xfbBufferCount; ++bufferIndex)
{
const gl::OffsetBindingPointer<gl::Buffer> &binding = mState.getIndexedBuffer(bufferIndex);
if (binding.get())
if (mBufferHelpers[bufferIndex])
{
BufferVk *bufferVk = vk::GetImpl(binding.get());
if (bufferVk->getBuffer().valid())
{
bufferVk->getBuffer().getBufferBlock()->onNewDescriptorSet(sharedCacheKey);
}
mBufferHelpers[bufferIndex]->onNewDescriptorSet(sharedCacheKey);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/libANGLE/renderer/vulkan/vk_cache_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6292,7 +6292,7 @@ void DescriptorSetDescBuilder::updateTransformFeedbackBuffer(

uint32_t infoIndex = writeDescriptorDescs[baseBinding].descriptorInfoIndex + xfbBufferIndex;
DescriptorInfoDesc &infoDesc = mDesc.getInfoDesc(infoIndex);
infoDesc.samplerOrBufferSerial = bufferHelper.getBlockSerial().getValue();
infoDesc.samplerOrBufferSerial = bufferHelper.getBufferSerial().getValue();
SetBitField(infoDesc.imageViewSerialOrOffset, alignedOffset);
SetBitField(infoDesc.imageLayoutOrRange, adjustedRange);
infoDesc.imageSubresourceRange = 0;
Expand Down

0 comments on commit 711b2c3

Please sign in to comment.