Vulkan: Add overlay and stats for descriptor set caches.

This adds more overlay widgets for different metrics of descriptor
sets, including for uniforms and for all sets.

Bug: angleproject:6776
Change-Id: If1a053bd711454227e7ccbdb01202a712a5f9787
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3469228
Reviewed-by: Charlie Lao <cclao@google.com>
Auto-Submit: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Yuxin Hu <yuxinhu@google.com>
Commit-Queue: Jamie Madill <jmadill@chromium.org>
This commit is contained in:
Jamie Madill
2022-02-16 13:14:54 -05:00
committed by Angle LUCI CQ
parent 671fcf732d
commit 8ade4c2f7f
8 changed files with 190 additions and 6 deletions

View File

@@ -1,10 +1,10 @@
{
"src/libANGLE/Overlay_autogen.cpp":
"a2908b6154ad1f806df809362df4c4cb",
"ca689b3761eb41124d90e967aa1711ca",
"src/libANGLE/Overlay_autogen.h":
"f3ed231c995dc396bff04873c2dc3355",
"8c7cbdb70508cc5a23b9f44771dc7919",
"src/libANGLE/gen_overlay_widgets.py":
"a28d28499de562d8341464abb2f2bf18",
"src/libANGLE/overlay_widgets.json":
"d6490743be40dc5abdb80f3feee41421"
"1aac61356846ebbb533ab210e1895290"
}

View File

@@ -493,6 +493,37 @@ void AppendWidgetDataHelper::AppendVulkanTextureDescriptorCacheSize(
AppendRunningGraphCommon(widget, imageExtent, textWidget, graphWidget, widgetCounts, format);
}
void AppendWidgetDataHelper::AppendVulkanUniformDescriptorCacheSize(
const overlay::Widget *widget,
const gl::Extents &imageExtent,
TextWidgetData *textWidget,
GraphWidgetData *graphWidget,
OverlayWidgetCounts *widgetCounts)
{
auto format = [](size_t curVal) {
std::ostringstream text;
text << "Total Uniform Descriptor Cache Size: " << curVal;
return text.str();
};
AppendRunningGraphCommon(widget, imageExtent, textWidget, graphWidget, widgetCounts, format);
}
void AppendWidgetDataHelper::AppendVulkanDescriptorCacheSize(const overlay::Widget *widget,
const gl::Extents &imageExtent,
TextWidgetData *textWidget,
GraphWidgetData *graphWidget,
OverlayWidgetCounts *widgetCounts)
{
auto format = [](size_t curVal) {
std::ostringstream text;
text << "Total Descriptor Cache Size: " << curVal;
return text.str();
};
AppendRunningGraphCommon(widget, imageExtent, textWidget, graphWidget, widgetCounts, format);
}
std::ostream &AppendWidgetDataHelper::OutputPerSecond(std::ostream &out,
const overlay::PerSecond *perSecond)
{

View File

@@ -404,6 +404,49 @@ void Overlay::initOverlayWidgets()
}
}
{
RunningGraph *widget = new RunningGraph(60);
{
const int32_t fontSize = GetFontSize(0, kLargeFont);
const int32_t offsetX = 0;
const int32_t offsetY = 450;
const int32_t width = 5 * static_cast<uint32_t>(widget->runningValues.size());
const int32_t height = 100;
widget->type = WidgetType::RunningGraph;
widget->fontSize = fontSize;
widget->coords[0] = offsetX;
widget->coords[1] = offsetY;
widget->coords[2] = offsetX + width;
widget->coords[3] = offsetY + height;
widget->color[0] = 0.0f;
widget->color[1] = 0.78431372549f;
widget->color[2] = 0.725490196078f;
widget->color[3] = 0.78431372549f;
}
mState.mOverlayWidgets[WidgetId::VulkanDescriptorCacheSize].reset(widget);
{
const int32_t fontSize = GetFontSize(kFontMipSmall, kLargeFont);
const int32_t offsetX =
mState.mOverlayWidgets[WidgetId::VulkanDescriptorCacheSize]->coords[0];
const int32_t offsetY =
mState.mOverlayWidgets[WidgetId::VulkanDescriptorCacheSize]->coords[1];
const int32_t width = 90 * (kFontGlyphWidth >> fontSize);
const int32_t height = (kFontGlyphHeight >> fontSize);
widget->description.type = WidgetType::Text;
widget->description.fontSize = fontSize;
widget->description.coords[0] = offsetX;
widget->description.coords[1] = std::max(offsetY - height, 1);
widget->description.coords[2] = offsetX + width;
widget->description.coords[3] = offsetY;
widget->description.color[0] = 0.0f;
widget->description.color[1] = 0.78431372549f;
widget->description.color[2] = 0.294117647059f;
widget->description.color[3] = 1.0f;
}
}
{
RunningGraph *widget = new RunningGraph(60);
{
@@ -446,6 +489,49 @@ void Overlay::initOverlayWidgets()
widget->description.color[3] = 1.0f;
}
}
{
RunningGraph *widget = new RunningGraph(60);
{
const int32_t fontSize = GetFontSize(0, kLargeFont);
const int32_t offsetX = 0;
const int32_t offsetY = 450;
const int32_t width = 5 * static_cast<uint32_t>(widget->runningValues.size());
const int32_t height = 100;
widget->type = WidgetType::RunningGraph;
widget->fontSize = fontSize;
widget->coords[0] = offsetX;
widget->coords[1] = offsetY;
widget->coords[2] = offsetX + width;
widget->coords[3] = offsetY + height;
widget->color[0] = 0.0f;
widget->color[1] = 0.78431372549f;
widget->color[2] = 1.17647058824f;
widget->color[3] = 0.78431372549f;
}
mState.mOverlayWidgets[WidgetId::VulkanUniformDescriptorCacheSize].reset(widget);
{
const int32_t fontSize = GetFontSize(kFontMipSmall, kLargeFont);
const int32_t offsetX =
mState.mOverlayWidgets[WidgetId::VulkanUniformDescriptorCacheSize]->coords[0];
const int32_t offsetY =
mState.mOverlayWidgets[WidgetId::VulkanUniformDescriptorCacheSize]->coords[1];
const int32_t width = 90 * (kFontGlyphWidth >> fontSize);
const int32_t height = (kFontGlyphHeight >> fontSize);
widget->description.type = WidgetType::Text;
widget->description.fontSize = fontSize;
widget->description.coords[0] = offsetX;
widget->description.coords[1] = std::max(offsetY - height, 1);
widget->description.coords[2] = offsetX + width;
widget->description.coords[3] = offsetY;
widget->description.color[0] = 0.0f;
widget->description.color[1] = 0.78431372549f;
widget->description.color[2] = 0.294117647059f;
widget->description.color[3] = 1.0f;
}
}
}
} // namespace gl

View File

@@ -32,8 +32,12 @@ enum class WidgetId
VulkanShaderBufferDSHitRate,
// Buffer Allocations Made By vk::DynamicBuffer.
VulkanDynamicBufferAllocations,
// size of mTextureDescriptorsCache of all ProgramExecutableVk
// Total size of all descriptor set caches
VulkanDescriptorCacheSize,
// Number of cached Texture descriptor sets
VulkanTextureDescriptorCacheSize,
// Number of cached default uniform descriptor sets
VulkanUniformDescriptorCacheSize,
InvalidEnum,
EnumCount = InvalidEnum,
@@ -51,6 +55,8 @@ enum class WidgetId
PROC(VulkanDescriptorSetAllocations) \
PROC(VulkanShaderBufferDSHitRate) \
PROC(VulkanDynamicBufferAllocations) \
PROC(VulkanTextureDescriptorCacheSize)
PROC(VulkanDescriptorCacheSize) \
PROC(VulkanTextureDescriptorCacheSize) \
PROC(VulkanUniformDescriptorCacheSize)
} // namespace gl

View File

@@ -165,9 +165,25 @@
"length": 40
}
},
{
"name": "VulkanDescriptorCacheSize",
"comment": "Total size of all descriptor set caches",
"type": "RunningGraph(60)",
"color": [0, 200, 185, 200],
"coords": [0, 450],
"bar_width": 5,
"height": 100,
"description": {
"color": [0, 200, 75, 255],
"coords": ["VulkanDescriptorCacheSize.left.align",
"VulkanDescriptorCacheSize.top.adjacent"],
"font": "small",
"length": 90
}
},
{
"name": "VulkanTextureDescriptorCacheSize",
"comment": "size of mTextureDescriptorsCache of all ProgramExecutableVk",
"comment": "Number of cached Texture descriptor sets",
"type": "RunningGraph(60)",
"color": [0, 200, 75, 200],
"coords": [0, 450],
@@ -180,6 +196,22 @@
"font": "small",
"length": 90
}
},
{
"name": "VulkanUniformDescriptorCacheSize",
"comment": "Number of cached default uniform descriptor sets",
"type": "RunningGraph(60)",
"color": [0, 200, 300, 200],
"coords": [0, 450],
"bar_width": 5,
"height": 100,
"description": {
"color": [0, 200, 75, 255],
"coords": ["VulkanUniformDescriptorCacheSize.left.align",
"VulkanUniformDescriptorCacheSize.top.adjacent"],
"font": "small",
"length": 90
}
}
]
}

View File

@@ -2233,6 +2233,7 @@ angle::Result ContextVk::handleDirtyDescriptorSetsImpl(CommandBufferT *commandBu
void ContextVk::syncObjectPerfCounters()
{
mPerfCounters.descriptorSetAllocations = 0;
mPerfCounters.descriptorSetCacheTotalSize = 0;
mPerfCounters.uniformsAndXfbDescriptorSetCacheHits = 0;
mPerfCounters.uniformsAndXfbDescriptorSetCacheMisses = 0;
mPerfCounters.uniformsAndXfbDescriptorSetCacheTotalSize = 0;
@@ -2292,6 +2293,17 @@ void ContextVk::syncObjectPerfCounters()
mPerfCounters.shaderBuffersDescriptorSetCacheTotalSize +=
progPerfCounters.descriptorSetCacheSizes[DescriptorSetIndex::ShaderResource];
}
mPerfCounters.descriptorSetCacheTotalSize +=
mPerfCounters.uniformsAndXfbDescriptorSetCacheTotalSize;
mPerfCounters.descriptorSetCacheTotalSize += mPerfCounters.textureDescriptorSetCacheTotalSize;
mPerfCounters.descriptorSetCacheTotalSize +=
mPerfCounters.shaderBuffersDescriptorSetCacheTotalSize;
for (const DriverUniformsDescriptorSet &driverSet : mDriverUniforms)
{
mPerfCounters.descriptorSetCacheTotalSize += driverSet.descriptorSetCache.getSize();
}
}
void ContextVk::updateOverlayOnPresent()
@@ -2371,6 +2383,20 @@ void ContextVk::addOverlayUsedBuffersCount(vk::CommandBufferHelperCommon *comman
textureDescriptorCacheSize->add(mPerfCounters.textureDescriptorSetCacheTotalSize);
textureDescriptorCacheSize->next();
}
{
gl::RunningGraphWidget *uniformDescriptorCacheSize =
overlay->getRunningGraphWidget(gl::WidgetId::VulkanUniformDescriptorCacheSize);
uniformDescriptorCacheSize->add(mPerfCounters.uniformsAndXfbDescriptorSetCacheTotalSize);
uniformDescriptorCacheSize->next();
}
{
gl::RunningGraphWidget *descriptorCacheSize =
overlay->getRunningGraphWidget(gl::WidgetId::VulkanDescriptorCacheSize);
descriptorCacheSize->add(mPerfCounters.descriptorSetCacheTotalSize);
descriptorCacheSize->next();
}
}
angle::Result ContextVk::submitFrame(const vk::Semaphore *signalSemaphore, Serial *submitSerialOut)

View File

@@ -1786,6 +1786,8 @@ class DriverUniformsDescriptorSetCache final
ANGLE_INLINE void clear() { mPayload.clear(); }
size_t getSize() const { return mPayload.size(); }
private:
static constexpr uint32_t kFastMapSize = 16;
angle::FastUnorderedMap<uint32_t, VkDescriptorSet, kFastMapSize> mPayload;

View File

@@ -1261,6 +1261,7 @@ struct PerfCounters
uint32_t stencilAttachmentResolves;
uint32_t readOnlyDepthStencilRenderPasses;
uint32_t descriptorSetAllocations;
uint32_t descriptorSetCacheTotalSize;
uint32_t uniformsAndXfbDescriptorSetCacheHits;
uint32_t uniformsAndXfbDescriptorSetCacheMisses;
uint32_t uniformsAndXfbDescriptorSetCacheTotalSize;