Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit ee4e086

Browse files
timvpGoogleCommit Bot
authored andcommitted
Vulkan: Add descriptor set allocation counters
Add descriptor set allocation counters for the following: - ContextVk - Driver uniform allocations for graphics and compute pipelines. - ProgramExecutableVk - ANGLE driver uniforms - Uniforms - Textures - Other shader resources - UtilsVk - All of the UtilsVk::Function types increment the same counter Each object's counters live within the object itself and the cumulative total is output as part of that object's destruction. On Present, all of the descriptor set counts are collected into a single total which is used to update the overlay each frame. In order to see the cumulative total output for each object, the following GN args must be enabled: is_debug = true angle_enable_perf_counter_output = true To see the descriptor set allocation overlay: ANGLE_OVERLAY=VulkanDescriptorSetAllocations Bug: angleproject:5067 Test: Manual verification with angle_perftests Change-Id: Ie45fda56ade3e68bfba7bf6da9554eb05a02c6b6 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2429487 Commit-Queue: Tim Van Patten <timvp@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Charlie Lao <cclao@google.com>
1 parent 626a418 commit ee4e086

17 files changed

+276
-16
lines changed

BUILD.gn

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,9 @@ config("libANGLE_config") {
606606
if (angle_enable_overlay) {
607607
defines += [ "ANGLE_ENABLE_OVERLAY=1" ]
608608
}
609+
if (angle_enable_perf_counter_output) {
610+
defines += [ "ANGLE_ENABLE_PERF_COUNTER_OUTPUT=1" ]
611+
}
609612
}
610613

611614
angle_source_set("libANGLE_headers") {

gni/angle.gni

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ declare_args() {
131131

132132
# Disable overlay by default
133133
angle_enable_overlay = false
134+
135+
# Disable performance counter output by default
136+
angle_enable_perf_counter_output = false
134137
}
135138

136139
if (!defined(angle_zlib_compression_utils_dir)) {
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"src/libANGLE/Overlay_autogen.cpp":
3-
"6c9c7df59562390505222145c1f32277",
3+
"849f447a220cb0ce00a41f99db179a6b",
44
"src/libANGLE/Overlay_autogen.h":
5-
"03ac72d8286f1f933696fa3dabb75eb1",
5+
"4f29dd0e9c2030b98b396fdf03eaeb29",
66
"src/libANGLE/gen_overlay_widgets.py":
77
"f4395481db010c82af2e2981353e8592",
88
"src/libANGLE/overlay_widgets.json":
9-
"dd9d2a72035e754bbc5f614410e76df1"
9+
"93205f3d9585228428bc62463f478dc6"
1010
}

src/libANGLE/FrameCapture.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2798,7 +2798,7 @@ void CaptureMidExecutionSetup(const gl::Context *context,
27982798
const gl::ResourceMap<gl::Shader, gl::ShaderProgramID> &shaders =
27992799
shadersAndPrograms.getShadersForCapture();
28002800
const gl::ResourceMap<gl::Program, gl::ShaderProgramID> &programs =
2801-
shadersAndPrograms.getProgramsForCapture();
2801+
shadersAndPrograms.getProgramsForCaptureAndPerf();
28022802

28032803
// Capture Program binary state. Use max ID as a temporary shader ID.
28042804
gl::ShaderProgramID tempShaderID = {resourceTracker->getMaxShaderPrograms()};

src/libANGLE/OverlayWidgets.cpp

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -300,10 +300,10 @@ void AppendWidgetDataHelper::AppendRunningHistogramCommon(const overlay::Widget
300300
OverlayWidgetCounts *widgetCounts,
301301
FormatHistogramTitleFunc formatFunc)
302302
{
303-
const overlay::RunningHistogram *secondaryCommandBufferPoolWaste =
303+
const overlay::RunningHistogram *runningHistogram =
304304
static_cast<const overlay::RunningHistogram *>(widget);
305305

306-
std::vector<size_t> histogram = CreateHistogram(secondaryCommandBufferPoolWaste->runningValues);
306+
std::vector<size_t> histogram = CreateHistogram(runningHistogram->runningValues);
307307
auto peakRangeIt = std::max_element(histogram.rbegin(), histogram.rend());
308308
const size_t peakRangeValue = *peakRangeIt;
309309
const int32_t graphHeight = std::abs(widget->coords[3] - widget->coords[1]);
@@ -320,8 +320,8 @@ void AppendWidgetDataHelper::AppendRunningHistogramCommon(const overlay::Widget
320320
size_t maxValueRange = std::distance(maxValueIter, histogram.rend() - 1);
321321

322322
std::string text = formatFunc(peakRange, maxValueRange, histogram.size());
323-
AppendTextCommon(&secondaryCommandBufferPoolWaste->description, imageExtent, text,
324-
textWidget, widgetCounts);
323+
AppendTextCommon(&runningHistogram->description, imageExtent, text, textWidget,
324+
widgetCounts);
325325
}
326326
}
327327

@@ -431,6 +431,21 @@ void AppendWidgetDataHelper::AppendVulkanWriteDescriptorSetCount(const overlay::
431431
AppendRunningGraphCommon(widget, imageExtent, textWidget, graphWidget, widgetCounts, format);
432432
}
433433

434+
void AppendWidgetDataHelper::AppendVulkanDescriptorSetAllocations(const overlay::Widget *widget,
435+
const gl::Extents &imageExtent,
436+
TextWidgetData *textWidget,
437+
GraphWidgetData *graphWidget,
438+
OverlayWidgetCounts *widgetCounts)
439+
{
440+
auto format = [](size_t maxValue) {
441+
std::ostringstream text;
442+
text << "Descriptor Set Allocations (Max: " << maxValue << ")";
443+
return text.str();
444+
};
445+
446+
AppendRunningGraphCommon(widget, imageExtent, textWidget, graphWidget, widgetCounts, format);
447+
}
448+
434449
std::ostream &AppendWidgetDataHelper::OutputPerSecond(std::ostream &out,
435450
const overlay::PerSecond *perSecond)
436451
{

src/libANGLE/Overlay_autogen.cpp

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,49 @@ void Overlay::initOverlayWidgets()
274274
widget->description.color[3] = 1.0f;
275275
}
276276
}
277+
278+
{
279+
RunningGraph *widget = new RunningGraph(60);
280+
{
281+
const int32_t fontSize = GetFontSize(0, kLargeFont);
282+
const int32_t offsetX = -50;
283+
const int32_t offsetY = 250;
284+
const int32_t width = 6 * static_cast<uint32_t>(widget->runningValues.size());
285+
const int32_t height = 100;
286+
287+
widget->type = WidgetType::RunningGraph;
288+
widget->fontSize = fontSize;
289+
widget->coords[0] = offsetX - width;
290+
widget->coords[1] = offsetY;
291+
widget->coords[2] = offsetX;
292+
widget->coords[3] = offsetY + height;
293+
widget->color[0] = 1.0f;
294+
widget->color[1] = 0.0f;
295+
widget->color[2] = 0.294117647059f;
296+
widget->color[3] = 0.78431372549f;
297+
}
298+
mState.mOverlayWidgets[WidgetId::VulkanDescriptorSetAllocations].reset(widget);
299+
{
300+
const int32_t fontSize = GetFontSize(kFontLayerSmall, kLargeFont);
301+
const int32_t offsetX =
302+
mState.mOverlayWidgets[WidgetId::VulkanDescriptorSetAllocations]->coords[0];
303+
const int32_t offsetY =
304+
mState.mOverlayWidgets[WidgetId::VulkanDescriptorSetAllocations]->coords[1];
305+
const int32_t width = 40 * kFontGlyphWidths[fontSize];
306+
const int32_t height = kFontGlyphHeights[fontSize];
307+
308+
widget->description.type = WidgetType::Text;
309+
widget->description.fontSize = fontSize;
310+
widget->description.coords[0] = offsetX;
311+
widget->description.coords[1] = std::max(offsetY - height, 1);
312+
widget->description.coords[2] = std::min(offsetX + width, -1);
313+
widget->description.coords[3] = offsetY;
314+
widget->description.color[0] = 1.0f;
315+
widget->description.color[1] = 0.0f;
316+
widget->description.color[2] = 0.294117647059f;
317+
widget->description.color[3] = 1.0f;
318+
}
319+
}
277320
}
278321

279322
} // namespace gl

src/libANGLE/Overlay_autogen.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ enum class WidgetId
2626
VulkanSecondaryCommandBufferPoolWaste,
2727
// Number of Descriptor Set writes in a frame (Count).
2828
VulkanWriteDescriptorSetCount,
29+
// Descriptor Set Allocations.
30+
VulkanDescriptorSetAllocations,
2931

3032
InvalidEnum,
3133
EnumCount = InvalidEnum,
@@ -39,6 +41,7 @@ enum class WidgetId
3941
PROC(VulkanRenderPassCount) \
4042
PROC(VulkanRenderPassBufferCount) \
4143
PROC(VulkanSecondaryCommandBufferPoolWaste) \
42-
PROC(VulkanWriteDescriptorSetCount)
44+
PROC(VulkanWriteDescriptorSetCount) \
45+
PROC(VulkanDescriptorSetAllocations)
4346

4447
} // namespace gl

src/libANGLE/ResourceManager.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,12 @@ class ShaderProgramManager : public ResourceManagerBase
164164
return mPrograms.query(handle);
165165
}
166166

167-
// For capture only.
167+
// For capture and performance counters only.
168168
const ResourceMap<Shader, ShaderProgramID> &getShadersForCapture() const { return mShaders; }
169-
const ResourceMap<Program, ShaderProgramID> &getProgramsForCapture() const { return mPrograms; }
169+
const ResourceMap<Program, ShaderProgramID> &getProgramsForCaptureAndPerf() const
170+
{
171+
return mPrograms;
172+
}
170173

171174
protected:
172175
~ShaderProgramManager() override;

src/libANGLE/frame_capture_utils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -991,7 +991,7 @@ Result SerializeContext(gl::BinaryOutputStream *bos, const gl::Context *context)
991991
SerializeShader(bos, shaderPtr);
992992
}
993993
const gl::ResourceMap<gl::Program, gl::ShaderProgramID> &programManager =
994-
shaderProgramManager.getProgramsForCapture();
994+
shaderProgramManager.getProgramsForCaptureAndPerf();
995995
for (const auto &program : programManager)
996996
{
997997
gl::Program *programPtr = program.second;

src/libANGLE/overlay_widgets.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,22 @@
116116
"font": "small",
117117
"length": 40
118118
}
119+
},
120+
{
121+
"name": "VulkanDescriptorSetAllocations",
122+
"comment": "Descriptor Set Allocations.",
123+
"type": "RunningGraph(60)",
124+
"color": [255, 0, 75, 200],
125+
"coords": [-50, 250],
126+
"bar_width": 6,
127+
"height": 100,
128+
"description": {
129+
"color": [255, 0, 75, 255],
130+
"coords": ["VulkanDescriptorSetAllocations.left.align",
131+
"VulkanDescriptorSetAllocations.top.adjacent"],
132+
"font": "small",
133+
"length": 40
134+
}
119135
}
120136
]
121137
}

0 commit comments

Comments
 (0)