QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
GstHwPathTelemetry.h
Go to the documentation of this file.
1#pragma once
2
3#include <array>
4
5#include <QtCore/QElapsedTimer>
6#include <QtCore/qglobal.h>
7
8#include "GstHwTypes.h"
9
13namespace GstHwPathTelemetry {
14
27
42
43void record(HwVideoBufferPath path, Counter counter) noexcept;
44
46void recordMapDuration(HwVideoBufferPath path, qint64 nsecs) noexcept;
47quint64 peekMapDurationUsEwma(HwVideoBufferPath path) noexcept;
48
51{
52public:
53 explicit ScopedMapTimer(HwVideoBufferPath path) noexcept
54 : _path(path)
55 {
56 _timer.start();
57 }
58
59 ~ScopedMapTimer() noexcept { recordMapDuration(_path, _timer.nsecsElapsed()); }
60
63
64private:
66 QElapsedTimer _timer;
67};
68
70void recordFallbackReason(HwVideoBufferPath attemptedPath, HwFallbackReason reason) noexcept;
71
74{
75 std::array<std::array<quint64, std::size_t(Counter::Count)>, GstHw::kPathCount> counters{};
76 std::array<std::array<quint64, std::size_t(HwFallbackReason::Count)>, GstHw::kPathCount> fallbackReasons{};
77
78 quint64 count(HwVideoBufferPath path, Counter counter) const noexcept
79 {
80 return counters[std::size_t(path)][std::size_t(counter)];
81 }
82
83 quint64 count(HwVideoBufferPath path, HwFallbackReason reason) const noexcept
84 {
85 return fallbackReasons[std::size_t(path)][std::size_t(reason)];
86 }
87};
88
89Snapshot snapshot() noexcept;
90
91} // namespace GstHwPathTelemetry
HwVideoBufferPath
GPU zero-copy path a frame is imported through; None means the frame takes the CPU path.
Definition GstHwTypes.h:7
ScopedMapTimer(HwVideoBufferPath path) noexcept
ScopedMapTimer & operator=(const ScopedMapTimer &)=delete
ScopedMapTimer(const ScopedMapTimer &)=delete
Counter
Per-path event counts.
@ GpuWaits
GPU-side waits on the producer's writes before sampling a frame.
@ CpuWaits
CPU-blocking waits on the producer's writes before sampling a frame.
@ MapFailures
mapTextures() returned an invalid bundle (GPU import failed).
@ TextureReuse
Prior frame's QRhiTexture wrappers reused (decoder pool returned same native handle).
void recordFallbackReason(HwVideoBufferPath attemptedPath, HwFallbackReason reason) noexcept
Per-(path,reason) fallback accounting; lets a bug report show why a path demoted to CPU.
void recordMapDuration(HwVideoBufferPath path, qint64 nsecs) noexcept
Per-path mapTextures() wall-time, fed into an EWMA; peek returns the smoothed value in microseconds.
void record(HwVideoBufferPath path, Counter counter) noexcept
quint64 peekMapDurationUsEwma(HwVideoBufferPath path) noexcept
Snapshot snapshot() noexcept
HwFallbackReason
Specific cause a GPU path was rejected for a sample; surfaced as a per-(path,reason) breakdown.
constexpr std::size_t kPathCount
Definition GstHwTypes.h:33
Every counter and fallback reason at one instant; a reader's baseline for counts since then.
std::array< std::array< quint64, std::size_t(HwFallbackReason::Count)>, GstHw::kPathCount > fallbackReasons
quint64 count(HwVideoBufferPath path, Counter counter) const noexcept
quint64 count(HwVideoBufferPath path, HwFallbackReason reason) const noexcept
std::array< std::array< quint64, std::size_t(Counter::Count)>, GstHw::kPathCount > counters