Hash :
6de7ee52
Author :
Date :
2020-05-25T17:00:01
Clean up overlay RenderPass count reporting. This fixes the trace perf test to accurately report how many RPs in each frame. Instead of counting the RPs on a flush we now count only on a swap call. This won't work for offscreen surfaces which is fine - the overlay doesn't really have the same use for offscreen rendering. Also ignores the first frame in graph data so we can ignore the first setup frame in the trace tests. Also skips the redundant extra "flush" call that would generate an empty space in the RP graph. Gives a cleaner measurement for optimizing the XFB RP count. Bug: angleproject:4622 Change-Id: I5762c500cdb216700247095984ae62b4f8741602 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2215309 Reviewed-by: Tim Van Patten <timvp@google.com> Commit-Queue: Jamie Madill <jmadill@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206
//
// Copyright 2019 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// OverlayWidgets.h:
// Defines the Overlay* widget classes and corresponding enums.
//
#ifndef LIBANGLE_OVERLAYWIDGETS_H_
#define LIBANGLE_OVERLAYWIDGETS_H_
#include "common/angleutils.h"
namespace gl
{
class Overlay;
class OverlayState;
namespace overlay_impl
{
class AppendWidgetDataHelper;
}
enum class WidgetType
{
// Text types:
// A total count of some event.
Count,
// A single line of ASCII text. Retains content until changed.
Text,
// A per-second value.
PerSecond,
// Graph types:
// A graph of the last N values.
RunningGraph,
// A histogram of the last N values (values between 0 and 1).
RunningHistogram,
InvalidEnum,
EnumCount = InvalidEnum,
};
enum class WidgetId
{
// Front-end widgets:
// Frames per second (PerSecond).
FPS,
// Vulkan backend:
// Last validation error (Text).
VulkanLastValidationMessage,
// Number of validation errors and warnings (Count).
VulkanValidationMessageCount,
// Number of RenderPasses in a frame (RunningGraph).
VulkanRenderPassCount,
// Secondary Command Buffer pool memory waste (RunningHistogram).
VulkanSecondaryCommandBufferPoolWaste,
InvalidEnum,
EnumCount = InvalidEnum,
};
namespace overlay
{
class Widget
{
public:
virtual ~Widget() {}
protected:
WidgetType type;
// Whether this item should be drawn.
bool enabled = false;
// For text items, size of the font. This is a value in [0, overlay::kFontCount) which
// determines the font size to use.
int fontSize;
// The area covered by the item, predetermined by the overlay class. Negative values
// indicate offset from the left/bottom of the image.
int32_t coords[4];
float color[4];
friend class gl::Overlay;
friend class gl::OverlayState;
friend class overlay_impl::AppendWidgetDataHelper;
};
class Count : public Widget
{
public:
~Count() override {}
void add(size_t n) { count += n; }
void reset() { count = 0; }
protected:
size_t count = 0;
friend class gl::Overlay;
friend class overlay_impl::AppendWidgetDataHelper;
};
class PerSecond : public Count
{
public:
~PerSecond() override {}
protected:
size_t lastPerSecondCount = 0;
friend class gl::Overlay;
friend class overlay_impl::AppendWidgetDataHelper;
};
class Text : public Widget
{
public:
~Text() override {}
void set(std::string &&str) { text = std::move(str); }
protected:
std::string text;
friend class overlay_impl::AppendWidgetDataHelper;
};
class RunningGraph : public Widget
{
public:
// Out of line constructor to satisfy chromium-style.
RunningGraph(size_t n);
~RunningGraph() override;
void add(size_t n)
{
if (!ignoreFirstValue)
{
runningValues[lastValueIndex] += n;
}
}
void next()
{
if (ignoreFirstValue)
{
ignoreFirstValue = false;
}
else
{
lastValueIndex = (lastValueIndex + 1) % runningValues.size();
runningValues[lastValueIndex] = 0;
}
}
protected:
std::vector<size_t> runningValues;
size_t lastValueIndex = 0;
Text description;
bool ignoreFirstValue = true;
friend class gl::Overlay;
friend class gl::OverlayState;
friend class overlay_impl::AppendWidgetDataHelper;
};
class RunningHistogram : public RunningGraph
{
public:
RunningHistogram(size_t n) : RunningGraph(n) {}
~RunningHistogram() override {}
void set(float n)
{
ASSERT(n >= 0.0f && n <= 1.0f);
size_t rank =
n == 1.0f ? runningValues.size() - 1 : static_cast<size_t>(n * runningValues.size());
runningValues[lastValueIndex] = rank;
}
};
// If overlay is disabled, all the above classes would be replaced with Dummy, turning them into
// noop.
class Dummy
{
public:
void reset() const {}
template <typename T>
void set(T) const
{}
template <typename T>
void add(T) const
{}
void next() const {}
};
} // namespace overlay
} // namespace gl
#endif // LIBANGLE_OVERLAYWIDGETS_H_