About Social Code
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSerdar Kocdemir <kocdemir@google.com>2025-06-09 11:19:00 +0000
committerMarge Bot <marge-bot@fdo.invalid>2025-06-26 17:11:41 +0000
commit5fbb3817ba71cbc479d0eb5e06f6800532eee7fa (patch)
treee6aab1d7733f449d0357c36c10dbde4be5ec8281
parentdce282e7d9cdd5d6c24e1c2519a5d402457cd71a (diff)
gfxstream: Small optimization on transformDescriptorSetList
Reduce number of possible allocations and remove unnecessary memory initialization which will be overwritten immediately. Test: dEQP-GLES31.functional.ssbo.layout.* Reviewed-by: Marcin Radomski <dextero@google.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35768>
-rw-r--r--src/gfxstream/guest/vulkan/gfxstream_vk_device.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/gfxstream/guest/vulkan/gfxstream_vk_device.cpp b/src/gfxstream/guest/vulkan/gfxstream_vk_device.cpp
index 3c815724b34..2a943c0ec29 100644
--- a/src/gfxstream/guest/vulkan/gfxstream_vk_device.cpp
+++ b/src/gfxstream/guest/vulkan/gfxstream_vk_device.cpp
@@ -729,6 +729,7 @@ static std::vector<VkWriteDescriptorSet> transformDescriptorSetList(
const VkWriteDescriptorSet* pDescriptorSets, uint32_t descriptorSetCount,
std::vector<std::vector<VkDescriptorBufferInfo>>& bufferInfos) {
std::vector<VkWriteDescriptorSet> outDescriptorSets(descriptorSetCount);
+ bufferInfos.resize(descriptorSetCount);
for (uint32_t i = 0; i < descriptorSetCount; ++i) {
const auto& srcDescriptorSet = pDescriptorSets[i];
const uint32_t descriptorCount = srcDescriptorSet.descriptorCount;
@@ -736,19 +737,20 @@ static std::vector<VkWriteDescriptorSet> transformDescriptorSetList(
VkWriteDescriptorSet& outDescriptorSet = outDescriptorSets[i];
outDescriptorSet = srcDescriptorSet;
- bufferInfos.push_back(std::vector<VkDescriptorBufferInfo>());
- bufferInfos[i].resize(descriptorCount);
- memset(&bufferInfos[i][0], 0, sizeof(VkDescriptorBufferInfo) * descriptorCount);
+ std::vector<VkDescriptorBufferInfo>& bufferInfo = bufferInfos[i];
+ bufferInfo.resize(descriptorCount);
for (uint32_t j = 0; j < descriptorCount; ++j) {
const auto* srcBufferInfo = srcDescriptorSet.pBufferInfo;
if (srcBufferInfo) {
- bufferInfos[i][j] = srcBufferInfo[j];
- bufferInfos[i][j].buffer = VK_NULL_HANDLE;
+ bufferInfo[j] = srcBufferInfo[j];
+ bufferInfo[j].buffer = VK_NULL_HANDLE;
if (vk_descriptor_type_has_descriptor_buffer(srcDescriptorSet.descriptorType) &&
srcBufferInfo[j].buffer) {
VK_FROM_HANDLE(gfxstream_vk_buffer, gfxstreamBuffer, srcBufferInfo[j].buffer);
- bufferInfos[i][j].buffer = gfxstreamBuffer->internal_object;
+ bufferInfo[j].buffer = gfxstreamBuffer->internal_object;
}
+ } else {
+ memset(&bufferInfo[j], 0, sizeof(VkDescriptorBufferInfo));
}
}
outDescriptorSet.pBufferInfo = bufferInfos[i].data();