Commit 11207393 by Jamie Madill Committed by Commit Bot

Vulkan: Add an overlay counter for descriptor writes.

Note: currently the trace test shows about 1000 descriptor set writes per frame in NBA2k20. Bug: angleproject:4911 Change-Id: Id50d05fe405249c80a38dbbe3c96e7bd8c66cbc4 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2333398 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarTim Van Patten <timvp@google.com>
parent 22e6fc03
{ {
"src/libANGLE/Overlay_autogen.cpp": "src/libANGLE/Overlay_autogen.cpp":
"b0d9803f2db7b962a53d4d8857a63fbc", "7d26b524a7547a19410ea7de72f17b6e",
"src/libANGLE/gen_overlay_widgets.py": "src/libANGLE/gen_overlay_widgets.py":
"07252fbde304fd48559ae07f8f920a08", "07252fbde304fd48559ae07f8f920a08",
"src/libANGLE/overlay_widgets.json": "src/libANGLE/overlay_widgets.json":
"13629734c314cc88c485cb27527913f3" "2d1804eb11e4f3ea214e80bf2e63c0df"
} }
\ No newline at end of file
...@@ -28,6 +28,7 @@ constexpr std::pair<const char *, WidgetId> kWidgetNames[] = { ...@@ -28,6 +28,7 @@ constexpr std::pair<const char *, WidgetId> kWidgetNames[] = {
{"VulkanValidationMessageCount", WidgetId::VulkanValidationMessageCount}, {"VulkanValidationMessageCount", WidgetId::VulkanValidationMessageCount},
{"VulkanRenderPassCount", WidgetId::VulkanRenderPassCount}, {"VulkanRenderPassCount", WidgetId::VulkanRenderPassCount},
{"VulkanSecondaryCommandBufferPoolWaste", WidgetId::VulkanSecondaryCommandBufferPoolWaste}, {"VulkanSecondaryCommandBufferPoolWaste", WidgetId::VulkanSecondaryCommandBufferPoolWaste},
{"VulkanWriteDescriptorSetCount", WidgetId::VulkanWriteDescriptorSetCount},
}; };
} // namespace } // namespace
......
...@@ -215,6 +215,11 @@ class AppendWidgetDataHelper ...@@ -215,6 +215,11 @@ class AppendWidgetDataHelper
TextWidgetData *textWidget, TextWidgetData *textWidget,
GraphWidgetData *graphWidget, GraphWidgetData *graphWidget,
OverlayWidgetCounts *widgetCounts); OverlayWidgetCounts *widgetCounts);
static void AppendVulkanWriteDescriptorSetCount(const overlay::Widget *widget,
const gl::Extents &imageExtent,
TextWidgetData *textWidget,
GraphWidgetData *graphWidget,
OverlayWidgetCounts *widgetCounts);
private: private:
static std::ostream &OutputPerSecond(std::ostream &out, const overlay::PerSecond *perSecond); static std::ostream &OutputPerSecond(std::ostream &out, const overlay::PerSecond *perSecond);
...@@ -398,6 +403,34 @@ void AppendWidgetDataHelper::AppendVulkanSecondaryCommandBufferPoolWaste( ...@@ -398,6 +403,34 @@ void AppendWidgetDataHelper::AppendVulkanSecondaryCommandBufferPoolWaste(
} }
} }
void AppendWidgetDataHelper::AppendVulkanWriteDescriptorSetCount(const overlay::Widget *widget,
const gl::Extents &imageExtent,
TextWidgetData *textWidget,
GraphWidgetData *graphWidget,
OverlayWidgetCounts *widgetCounts)
{
const overlay::RunningGraph *writeDescriptorSetCount =
static_cast<const overlay::RunningGraph *>(widget);
const size_t maxValue = *std::max_element(writeDescriptorSetCount->runningValues.begin(),
writeDescriptorSetCount->runningValues.end());
const int32_t graphHeight = std::abs(widget->coords[3] - widget->coords[1]);
const float graphScale = static_cast<float>(graphHeight) / maxValue;
AppendGraphCommon(widget, imageExtent, writeDescriptorSetCount->runningValues,
writeDescriptorSetCount->lastValueIndex + 1, graphScale, graphWidget,
widgetCounts);
if ((*widgetCounts)[WidgetInternalType::Text] <
kWidgetInternalTypeMaxWidgets[WidgetInternalType::Text])
{
std::ostringstream text;
text << "WriteDescriptorSet Count (Max: " << maxValue << ")";
AppendTextCommon(&writeDescriptorSetCount->description, imageExtent, text.str(), textWidget,
widgetCounts);
}
}
std::ostream &AppendWidgetDataHelper::OutputPerSecond(std::ostream &out, std::ostream &AppendWidgetDataHelper::OutputPerSecond(std::ostream &out,
const overlay::PerSecond *perSecond) const overlay::PerSecond *perSecond)
{ {
...@@ -427,6 +460,8 @@ constexpr angle::PackedEnumMap<WidgetId, AppendWidgetDataFunc> kWidgetIdToAppend ...@@ -427,6 +460,8 @@ constexpr angle::PackedEnumMap<WidgetId, AppendWidgetDataFunc> kWidgetIdToAppend
overlay_impl::AppendWidgetDataHelper::AppendVulkanRenderPassCount}, overlay_impl::AppendWidgetDataHelper::AppendVulkanRenderPassCount},
{WidgetId::VulkanSecondaryCommandBufferPoolWaste, {WidgetId::VulkanSecondaryCommandBufferPoolWaste,
overlay_impl::AppendWidgetDataHelper::AppendVulkanSecondaryCommandBufferPoolWaste}, overlay_impl::AppendWidgetDataHelper::AppendVulkanSecondaryCommandBufferPoolWaste},
{WidgetId::VulkanWriteDescriptorSetCount,
overlay_impl::AppendWidgetDataHelper::AppendVulkanWriteDescriptorSetCount},
}; };
} }
......
...@@ -20,7 +20,7 @@ class OverlayState; ...@@ -20,7 +20,7 @@ class OverlayState;
namespace overlay_impl namespace overlay_impl
{ {
class AppendWidgetDataHelper; class AppendWidgetDataHelper;
} } // namespace overlay_impl
enum class WidgetType enum class WidgetType
{ {
...@@ -61,6 +61,8 @@ enum class WidgetId ...@@ -61,6 +61,8 @@ enum class WidgetId
VulkanRenderPassCount, VulkanRenderPassCount,
// Secondary Command Buffer pool memory waste (RunningHistogram). // Secondary Command Buffer pool memory waste (RunningHistogram).
VulkanSecondaryCommandBufferPoolWaste, VulkanSecondaryCommandBufferPoolWaste,
// Number of Descriptor Set writes in a frame (RunningGraph).
VulkanWriteDescriptorSetCount,
InvalidEnum, InvalidEnum,
EnumCount = InvalidEnum, EnumCount = InvalidEnum,
......
...@@ -188,6 +188,49 @@ void Overlay::initOverlayWidgets() ...@@ -188,6 +188,49 @@ void Overlay::initOverlayWidgets()
widget->description.color[3] = 1.0; widget->description.color[3] = 1.0;
} }
} }
{
RunningGraph *widget = new RunningGraph(60);
{
const int32_t fontSize = GetFontSize(0, kLargeFont);
const int32_t offsetX = 10;
const int32_t offsetY = 220;
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.294117647059;
widget->color[1] = 0.78431372549;
widget->color[2] = 0.0;
widget->color[3] = 0.78431372549;
}
mState.mOverlayWidgets[WidgetId::VulkanWriteDescriptorSetCount].reset(widget);
{
const int32_t fontSize = GetFontSize(kFontLayerSmall, kLargeFont);
const int32_t offsetX =
mState.mOverlayWidgets[WidgetId::VulkanWriteDescriptorSetCount]->coords[0];
const int32_t offsetY =
mState.mOverlayWidgets[WidgetId::VulkanWriteDescriptorSetCount]->coords[1];
const int32_t width = 40 * kFontGlyphWidths[fontSize];
const int32_t height = kFontGlyphHeights[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.294117647059;
widget->description.color[1] = 0.78431372549;
widget->description.color[2] = 0.0;
widget->description.color[3] = 1.0;
}
}
} }
} // namespace gl } // namespace gl
...@@ -80,6 +80,20 @@ ...@@ -80,6 +80,20 @@
"font": "small", "font": "small",
"length": 40 "length": 40
} }
},
{
"name": "VulkanWriteDescriptorSetCount",
"type": "RunningGraph(60)",
"color": [75, 200, 0, 200],
"coords": [10, 220],
"bar_width": 5,
"height": 100,
"description": {
"color": [75, 200, 0, 255],
"coords": ["VulkanWriteDescriptorSetCount.left.align", "VulkanWriteDescriptorSetCount.top.adjacent"],
"font": "small",
"length": 40
}
} }
] ]
} }
...@@ -657,6 +657,7 @@ ContextVk::ContextVk(const gl::State &state, gl::ErrorSet *errorSet, RendererVk ...@@ -657,6 +657,7 @@ ContextVk::ContextVk(const gl::State &state, gl::ErrorSet *errorSet, RendererVk
mGpuEventTimestampOrigin(0), mGpuEventTimestampOrigin(0),
mPrimaryBufferCounter(0), mPrimaryBufferCounter(0),
mRenderPassCounter(0), mRenderPassCounter(0),
mWriteDescriptorSetCounter(0),
mContextPriority(renderer->getDriverPriority(GetContextPriority(state))), mContextPriority(renderer->getDriverPriority(GetContextPriority(state))),
mCurrentIndirectBuffer(nullptr), mCurrentIndirectBuffer(nullptr),
mShareGroupVk(vk::GetImpl(state.getShareGroup())) mShareGroupVk(vk::GetImpl(state.getShareGroup()))
...@@ -1620,10 +1621,21 @@ angle::Result ContextVk::handleDirtyDescriptorSets(const gl::Context *context, ...@@ -1620,10 +1621,21 @@ angle::Result ContextVk::handleDirtyDescriptorSets(const gl::Context *context,
void ContextVk::updateOverlayOnPresent() void ContextVk::updateOverlayOnPresent()
{ {
// Update overlay if active. // Update overlay if active.
gl::RunningGraphWidget *renderPassCount = {
mState.getOverlay()->getRunningGraphWidget(gl::WidgetId::VulkanRenderPassCount); gl::RunningGraphWidget *renderPassCount =
renderPassCount->add(mRenderPassCommands->getAndResetCounter()); mState.getOverlay()->getRunningGraphWidget(gl::WidgetId::VulkanRenderPassCount);
renderPassCount->next(); renderPassCount->add(mRenderPassCommands->getAndResetCounter());
renderPassCount->next();
}
{
gl::RunningGraphWidget *writeDescriptorSetCount =
mState.getOverlay()->getRunningGraphWidget(gl::WidgetId::VulkanWriteDescriptorSetCount);
writeDescriptorSetCount->add(mWriteDescriptorSetCounter);
writeDescriptorSetCount->next();
mWriteDescriptorSetCounter = 0;
}
} }
angle::Result ContextVk::submitFrame(const VkSubmitInfo &submitInfo, angle::Result ContextVk::submitFrame(const VkSubmitInfo &submitInfo,
...@@ -4039,7 +4051,9 @@ angle::Result ContextVk::flushImpl(const vk::Semaphore *signalSemaphore) ...@@ -4039,7 +4051,9 @@ angle::Result ContextVk::flushImpl(const vk::Semaphore *signalSemaphore)
ANGLE_TRY(startPrimaryCommandBuffer()); ANGLE_TRY(startPrimaryCommandBuffer());
mRenderPassCounter = 0; mRenderPassCounter = 0;
mWriteDescriptorSetCounter = 0;
mWaitSemaphores.clear(); mWaitSemaphores.clear();
mWaitSemaphoreStageMasks.clear(); mWaitSemaphoreStageMasks.clear();
...@@ -4742,6 +4756,8 @@ VkDescriptorImageInfo *ContextVk::allocDescriptorImageInfos(size_t count) ...@@ -4742,6 +4756,8 @@ VkDescriptorImageInfo *ContextVk::allocDescriptorImageInfos(size_t count)
VkWriteDescriptorSet *ContextVk::allocWriteDescriptorSets(size_t count) VkWriteDescriptorSet *ContextVk::allocWriteDescriptorSets(size_t count)
{ {
mWriteDescriptorSetCounter += count;
size_t oldSize = mWriteDescriptorSets.size(); size_t oldSize = mWriteDescriptorSets.size();
size_t newSize = oldSize + count; size_t newSize = oldSize + count;
mWriteDescriptorSets.resize(newSize); mWriteDescriptorSets.resize(newSize);
......
...@@ -590,6 +590,7 @@ class ContextVk : public ContextImpl, public vk::Context ...@@ -590,6 +590,7 @@ class ContextVk : public ContextImpl, public vk::Context
vk::DynamicBuffer *getStagingBufferStorage() { return &mStagingBufferStorage; } vk::DynamicBuffer *getStagingBufferStorage() { return &mStagingBufferStorage; }
uint32_t getRenderPassCounter() const { return mRenderPassCounter; } uint32_t getRenderPassCounter() const { return mRenderPassCounter; }
uint32_t getWriteDescriptorSetCounter() const { return mWriteDescriptorSetCounter; }
private: private:
// Dirty bits. // Dirty bits.
...@@ -1041,6 +1042,7 @@ class ContextVk : public ContextImpl, public vk::Context ...@@ -1041,6 +1042,7 @@ class ContextVk : public ContextImpl, public vk::Context
// Used to count events for tracing. // Used to count events for tracing.
uint32_t mPrimaryBufferCounter; uint32_t mPrimaryBufferCounter;
uint32_t mRenderPassCounter; uint32_t mRenderPassCounter;
uint32_t mWriteDescriptorSetCounter;
gl::State::DirtyBits mPipelineDirtyBitsMask; gl::State::DirtyBits mPipelineDirtyBitsMask;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment