Hash :
4b381f41
Author :
Date :
2022-04-08T09:20:45
Vulkan: Fix descriptorSet perf counter values. Some counters were getting reset in multiple places, which could result in queries returning zero counts. Fix this by consolidating per-frame counter resets. Also updates how we compute cache hit/miss counters. This results in correct and consistent counts for cache accesses. Also includes a fix to not update the overlay when there are no enabled widgets. Also does away with some of the object- specific perf counters that were made to track descriptor set allocations. Bug: angleproject:6776 Change-Id: I769c715986defc50f0cfd0d997c338d34174e9f0 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3573389 Reviewed-by: Charlie Lao <cclao@google.com> Reviewed-by: Yuxin Hu <yuxinhu@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
//
// 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.
//
// Overlay.h:
// Defines the Overlay class that handles overlay widgets.
//
#ifndef LIBANGLE_OVERLAY_H_
#define LIBANGLE_OVERLAY_H_
#include "common/PackedEnums.h"
#include "common/angleutils.h"
#include "libANGLE/Error.h"
#include "libANGLE/OverlayWidgets.h"
#include "libANGLE/angletypes.h"
namespace rx
{
class OverlayImpl;
class GLImplFactory;
} // namespace rx
namespace gl
{
class Context;
class OverlayState : angle::NonCopyable
{
public:
OverlayState();
~OverlayState();
size_t getWidgetCoordinatesBufferSize() const;
size_t getTextWidgetsBufferSize() const;
size_t getGraphWidgetsBufferSize() const;
const uint8_t *getFontData() const;
void fillWidgetData(const gl::Extents &imageExtents,
uint8_t *textData,
uint8_t *graphData,
uint32_t *activeTextWidgetCountOut,
uint32_t *activeGraphWidgetCountOut) const;
uint32_t getEnabledWidgetCount() const { return mEnabledWidgetCount; }
private:
friend class Overlay;
uint32_t mEnabledWidgetCount;
angle::PackedEnumMap<WidgetId, std::unique_ptr<overlay::Widget>> mOverlayWidgets;
};
class Overlay : angle::NonCopyable
{
public:
Overlay(rx::GLImplFactory *implFactory);
~Overlay();
void init();
void destroy(const gl::Context *context);
void onSwap() const;
overlay::Text *getTextWidget(WidgetId id) const
{
return getWidgetAs<overlay::Text, WidgetType::Text>(id);
}
overlay::Count *getCountWidget(WidgetId id) const
{
return getWidgetAs<overlay::Count, WidgetType::Count>(id);
}
overlay::PerSecond *getPerSecondWidget(WidgetId id) const
{
return getWidgetAs<overlay::PerSecond, WidgetType::PerSecond>(id);
}
overlay::RunningGraph *getRunningGraphWidget(WidgetId id) const
{
return getWidgetAs<overlay::RunningGraph, WidgetType::RunningGraph>(id);
}
overlay::RunningHistogram *getRunningHistogramWidget(WidgetId id) const
{
return getWidgetAs<overlay::RunningHistogram, WidgetType::RunningHistogram>(id);
}
rx::OverlayImpl *getImplementation() const { return mImplementation.get(); }
bool isEnabled() const
{
return mImplementation != nullptr && mState.getEnabledWidgetCount() > 0;
}
private:
template <typename Widget, WidgetType Type>
Widget *getWidgetAs(WidgetId id) const
{
ASSERT(mState.mOverlayWidgets[id] != nullptr);
ASSERT(mState.mOverlayWidgets[id]->type == Type);
return rx::GetAs<Widget>(mState.mOverlayWidgets[id].get());
}
void initOverlayWidgets();
void enableOverlayWidgetsFromEnvironment();
// Time tracking for PerSecond items.
mutable double mLastPerSecondUpdate;
OverlayState mState;
std::unique_ptr<rx::OverlayImpl> mImplementation;
};
class MockOverlay
{
public:
MockOverlay(rx::GLImplFactory *implFactory);
~MockOverlay();
void init() {}
void destroy(const Context *context) {}
void onSwap() const {}
const overlay::Mock *getTextWidget(WidgetId id) const { return &mMock; }
const overlay::Mock *getCountWidget(WidgetId id) const { return &mMock; }
const overlay::Mock *getPerSecondWidget(WidgetId id) const { return &mMock; }
const overlay::Mock *getRunningGraphWidget(WidgetId id) const { return &mMock; }
const overlay::Mock *getRunningHistogramWidget(WidgetId id) const { return &mMock; }
bool isEnabled() const { return false; }
private:
overlay::Mock mMock;
};
#if ANGLE_ENABLE_OVERLAY
using OverlayType = Overlay;
using CountWidget = overlay::Count;
using PerSecondWidget = overlay::PerSecond;
using RunningGraphWidget = overlay::RunningGraph;
using RunningHistogramWidget = overlay::RunningHistogram;
using TextWidget = overlay::Text;
#else // !ANGLE_ENABLE_OVERLAY
using OverlayType = MockOverlay;
using CountWidget = const overlay::Mock;
using PerSecondWidget = const overlay::Mock;
using RunningGraphWidget = const overlay::Mock;
using RunningHistogramWidget = const overlay::Mock;
using TextWidget = const overlay::Mock;
#endif // ANGLE_ENABLE_OVERLAY
} // namespace gl
#endif // LIBANGLE_OVERLAY_H_