Skip to content

Commit

Permalink
GPU profiling: Count how many descriptors we manage to deduplicate.
Browse files Browse the repository at this point in the history
  • Loading branch information
hrydgard committed Jan 12, 2024
1 parent a8854c9 commit 52d05aa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions Common/GPU/Vulkan/VulkanFrameData.h
Expand Up @@ -29,6 +29,7 @@ struct QueueProfileContext {
double cpuEndTime;
double descWriteTime;
int descriptorsWritten;
int descriptorsDeduped;
#ifdef _DEBUG
int commandCounts[11];
#endif
Expand Down
7 changes: 5 additions & 2 deletions Common/GPU/Vulkan/VulkanRenderManager.cpp
Expand Up @@ -687,7 +687,7 @@ void VulkanRenderManager::BeginFrame(bool enableProfiling, bool enableLogProfile
descUpdateTimeMs_.Update(frameData.profile.descWriteTime * 1000.0);
descUpdateTimeMs_.Format(line, sizeof(line));
str << line;
snprintf(line, sizeof(line), "Descriptors written: %d\n", frameData.profile.descriptorsWritten);
snprintf(line, sizeof(line), "Descriptors written: %d (dedup: %d)\n", frameData.profile.descriptorsWritten, frameData.profile.descriptorsDeduped);
str << line;
snprintf(line, sizeof(line), "Resource deletions: %d\n", vulkan_->GetLastDeleteCount());
str << line;
Expand Down Expand Up @@ -737,6 +737,7 @@ void VulkanRenderManager::BeginFrame(bool enableProfiling, bool enableLogProfile
}

frameData.profile.descriptorsWritten = 0;
frameData.profile.descriptorsDeduped = 0;

// Must be after the fence - this performs deletes.
VLOG("PUSH: BeginFrame %d", curFrame);
Expand Down Expand Up @@ -1747,7 +1748,7 @@ void VKRPipelineLayout::FlushDescSets(VulkanContext *vulkan, int frame, QueuePro
VkDescriptorBufferInfo bufferInfo[MAX_DESC_SET_BINDINGS];

size_t start = data.flushedDescriptors_;
int writeCount = 0;
int writeCount = 0, dedupCount = 0;

for (size_t index = start; index < descSets.size(); index++) {
auto &d = descSets[index];
Expand All @@ -1759,6 +1760,7 @@ void VKRPipelineLayout::FlushDescSets(VulkanContext *vulkan, int frame, QueuePro
if (descSets[index - 1].count == d.count) {
if (!memcmp(descData.data() + d.offset, descData.data() + descSets[index - 1].offset, d.count * sizeof(PackedDescriptor))) {
d.set = descSets[index - 1].set;
dedupCount++;
continue;
}
}
Expand Down Expand Up @@ -1841,4 +1843,5 @@ void VKRPipelineLayout::FlushDescSets(VulkanContext *vulkan, int frame, QueuePro

data.flushedDescriptors_ = (int)descSets.size();
profile->descriptorsWritten += writeCount;
profile->descriptorsDeduped += dedupCount;
}

0 comments on commit 52d05aa

Please sign in to comment.