3#if defined(QGC_HAS_ANY_GPU_PATH)
7#include <QtCore/QMutex>
9#include <private/qvideotexturehelper_p.h>
19 QVideoFrameFormat::PixelFormat pixelFormat = QVideoFrameFormat::Format_Invalid;
21 QRhiTexture::Flags flags;
28std::array<PreflightMemo, kPathCount> s_memo{};
32namespace GstHwImportPreflight {
34bool canImportTexture(QRhi* rhi, QRhiTexture::Format fmt,
const QSize& size, QRhiTexture::Flags flags)
noexcept
39 if (fmt == QRhiTexture::UnknownFormat) {
42 if (!rhi->isTextureFormatSupported(fmt, flags)) {
45 const int maxDim = rhi->resourceLimit(QRhi::TextureSizeMax);
46 if (maxDim > 0 && (size.width() > maxDim || size.height() > maxDim)) {
52bool canImportPlanes(QRhi* rhi, QVideoFrameFormat::PixelFormat pixelFormat,
const QSize& size,
53 QRhiTexture::Flags flags)
noexcept
58 const auto* desc = QVideoTextureHelper::textureDescription(pixelFormat);
63 using FallbackPolicy = QVideoTextureHelper::TextureDescription::FallbackPolicy;
64 for (
int plane = 0; plane < desc->nplanes; ++plane) {
65 const QRhiTexture::Format fmt = desc->rhiTextureFormat(plane, rhi, FallbackPolicy::Disable);
66 const QSize planeSize = desc->rhiPlaneSize(size, plane, rhi);
67 if (!canImportTexture(rhi, fmt, planeSize, flags)) {
74bool preflightOrRecord(QRhi* rhi,
HwVideoBufferPath path, QVideoFrameFormat::PixelFormat pixelFormat,
75 const QSize& size, QRhiTexture::Flags flags)
noexcept
78 const std::size_t idx =
static_cast<std::size_t
>(path);
79 if (idx < s_memo.size()) {
80 QMutexLocker lock(&s_memoMutex);
81 PreflightMemo& memo = s_memo[idx];
82 if (memo.valid && (memo.rhi == rhi) && (memo.pixelFormat == pixelFormat) && (memo.size == size) &&
83 (memo.flags == flags)) {
86 ok = canImportPlanes(rhi, pixelFormat, size, flags);
87 memo = {rhi, pixelFormat, size, flags, ok,
true};
90 ok = canImportPlanes(rhi, pixelFormat, size, flags);
HwVideoBufferPath
Identifies which GPU path was chosen; used by the adapter to increment the right counter.
void recordFallbackReason(HwVideoBufferPath attemptedPath, HwFallbackReason reason) noexcept
Per-(path,reason) fallback accounting; lets a bug report show why a path demoted to CPU.