12#if defined(QGC_HAS_GST_DMABUF_GPU_PATH)
14#include <gst/allocators/gstdmabuf.h>
15#include <gst/video/video.h>
18#include <QtCore/QLoggingCategory>
19#include <QtCore/QMutex>
20#include <QtCore/QMutexLocker>
21#include <QtGui/QGuiApplication>
22#include <QtGui/QOpenGLContext>
23#include <QtGui/QOpenGLFunctions>
26#if GST_CHECK_VERSION(1, 24, 0)
27#include <gst/video/video-info-dma.h>
34#include <drm_fourcc.h>
44#if __has_include(<linux/dma-buf.h>)
45#include <linux/dma-buf.h>
47#ifdef DMA_BUF_IOCTL_EXPORT_SYNC_FILE
48#define QGC_HAS_DMABUF_EXPORT_SYNC 1
52#ifndef EGL_ANDROID_native_fence_sync
53#define EGL_SYNC_NATIVE_FENCE_ANDROID 0x3144
54#define EGL_SYNC_NATIVE_FENCE_FD_ANDROID 0x3145
55#define EGL_NO_NATIVE_FENCE_FD_ANDROID -1
67 std::atomic<bool> loggedNoEglContext{
false};
68 std::atomic<bool> loggedLayoutRejected{
false};
69 std::atomic<bool> loggedTiledCpuMap{
false};
70 std::atomic<bool> loggedProducerWaitTimeout{
false};
71 std::atomic<bool> loggedExplicitFence{
false};
72 std::atomic<bool> loggedVulkanSyncRefused{
false};
77 for (std::atomic<bool>* flag : {&loggedNoEglContext, &loggedLayoutRejected, &loggedTiledCpuMap,
78 &loggedProducerWaitTimeout, &loggedExplicitFence, &loggedVulkanSyncRefused}) {
79 flag->store(
false, std::memory_order_relaxed);
84static_assert(
sizeof(DmaBufDiagnostics) ==
sizeof(
GstHw::MapDiagnostics) + (6 *
sizeof(std::atomic<bool>)),
85 "DmaBufDiagnostics::reset() must list every flag");
87DmaBufDiagnostics s_diag;
92std::atomic<bool> s_importDisabled{
false};
98 QVideoFrameFormat::PixelFormat pixelFormat = QVideoFrameFormat::Format_Invalid;
101 friend bool operator==(
const ImportLayout&,
const ImportLayout&) =
default;
106class ImportFailureRuns
110 int noteFailure(
const ImportLayout& layout)
112 const QMutexLocker lock(&_mutex);
113 Run*
run = find(layout);
116 run = std::min_element(_runs.begin(), _runs.end(),
117 [](
const Run& a,
const Run& b) { return a.failures < b.failures; });
118 *
run = {.layout = layout};
120 return ++
run->failures;
123 void noteSuccess(
const ImportLayout& layout)
125 const QMutexLocker lock(&_mutex);
126 if (Run* run = find(layout)) {
133 const QMutexLocker lock(&_mutex);
144 Run* find(
const ImportLayout& layout)
146 const auto run = std::find_if(_runs.begin(), _runs.end(), [&layout](
const Run& candidate) {
147 return (candidate.failures > 0) && (candidate.layout == layout);
149 return (run != _runs.end()) ?
run :
nullptr;
153 std::array<Run, 4> _runs{};
156ImportFailureRuns s_importFailures;
158constexpr const char* kModifiersExt =
"EGL_EXT_image_dma_buf_import_modifiers";
159constexpr const char* kNativeFenceExt =
"EGL_ANDROID_native_fence_sync";
163 if (!s_importDisabled.exchange(
true, std::memory_order_relaxed)) {
165 qCWarning(GstDmaBufLog) << cause <<
"— DMABuf zero-copy disabled until the scene graph is recreated";
171void noteLayoutImportOutcome(
const ImportLayout& layout,
bool tiled, GstDmaBufVideoBuffer::ImportOutcome outcome)
173 using ImportOutcome = GstDmaBufVideoBuffer::ImportOutcome;
175 case ImportOutcome::Imported:
176 s_importFailures.noteSuccess(layout);
178 case ImportOutcome::Unrecoverable:
180 "Qt's DMABuf importer hit EGL_BAD_MATCH (broken EGL/driver combination)");
182 case ImportOutcome::Rejected:
186 case ImportOutcome::NotImportable:
194 if (s_importFailures.noteFailure(layout) >= GstDmaBufVideoBuffer::kMaxConsecutiveImportFailures) {
202quint32 eglfsPackedYuvFourcc(QVideoFrameFormat::PixelFormat format)
204 static const bool isEglfsQPA = QGuiApplication::platformName() == QLatin1String(
"eglfs");
208 if (format == QVideoFrameFormat::Format_YUYV) {
209 return DRM_FORMAT_YUYV;
211 if (format == QVideoFrameFormat::Format_UYVY) {
212 return DRM_FORMAT_UYVY;
217QVideoFrameFormat withPixelFormat(
const QVideoFrameFormat& format, QVideoFrameFormat::PixelFormat pixelFormat)
219 QVideoFrameFormat out(
format.frameSize(), pixelFormat);
220 out.setStreamFrameRate(
format.streamFrameRate());
221 out.setColorRange(
format.colorRange());
222 out.setColorSpace(
format.colorSpace());
223 out.setColorTransfer(
format.colorTransfer());
224 out.setViewport(
format.viewport());
231bool tryExplicitFenceWait(EGLDisplay eglDpy, GstBuffer* buffer)
233#if defined(QGC_HAS_DMABUF_EXPORT_SYNC)
234 if (!GstEglHelpers::displaySupportsExtension(eglDpy, kNativeFenceExt)) {
237 static const auto createSyncKHR =
reinterpret_cast<PFNEGLCREATESYNCKHRPROC
>(eglGetProcAddress(
"eglCreateSyncKHR"));
238 static const auto waitSyncKHR =
reinterpret_cast<PFNEGLWAITSYNCKHRPROC
>(eglGetProcAddress(
"eglWaitSyncKHR"));
239 static const auto destroySyncKHR =
240 reinterpret_cast<PFNEGLDESTROYSYNCKHRPROC
>(eglGetProcAddress(
"eglDestroySyncKHR"));
241 if (!createSyncKHR || !waitSyncKHR || !destroySyncKHR) {
246 for (guint i = 0; i < gst_buffer_n_memory(buffer); ++i) {
247 const int dmaFd = gst_dmabuf_memory_get_fd(gst_buffer_peek_memory(buffer, i));
248 if (dmaFd < 0 || dmaFd == lastFd) {
252 dma_buf_export_sync_file req = {};
253 req.flags = DMA_BUF_SYNC_READ;
255 if (ioctl(dmaFd, DMA_BUF_IOCTL_EXPORT_SYNC_FILE, &req) != 0 || req.fd < 0) {
259 const EGLint attribs[] = {EGL_SYNC_NATIVE_FENCE_FD_ANDROID, req.fd, EGL_NONE};
260 EGLSyncKHR sync = createSyncKHR(eglDpy, EGL_SYNC_NATIVE_FENCE_ANDROID, attribs);
261 if (sync == EGL_NO_SYNC_KHR) {
265 const EGLint waited = waitSyncKHR(eglDpy, sync, 0);
266 destroySyncKHR(eglDpy, sync);
267 if (waited != EGL_TRUE) {
271 if (!s_diag.loggedExplicitFence.exchange(
true, std::memory_order_relaxed)) {
272 qCDebug(GstDmaBufLog) <<
"waiting on the producer's dma-buf fences GPU-side (CPU barrier skipped)";
284constexpr int kProducerWaitTimeoutMs = 100;
290bool waitForProducerWrites(GstBuffer* buffer)
293 for (guint i = 0; i < gst_buffer_n_memory(buffer); ++i) {
294 GstMemory* mem = gst_buffer_peek_memory(buffer, i);
295 const int fd = (mem && gst_is_dmabuf_memory(mem)) ? gst_dmabuf_memory_get_fd(mem) : -1;
296 if (fd < 0 || fd == lastFd) {
300 pollfd pfd = {fd, POLLIN, 0};
303 ret = ::poll(&pfd, 1, kProducerWaitTimeoutMs);
304 }
while (ret < 0 && (errno == EINTR || errno == EAGAIN));
305 const bool writesDone = (ret > 0) && (pfd.revents & POLLIN) && !(pfd.revents & (POLLERR | POLLHUP | POLLNVAL));
307 const int pollError = (ret < 0) ? errno : 0;
310 "dma-buf producer fence wait" << (ret == 0 ?
"timed out" :
"failed") <<
"errno="
311 << pollError <<
"revents=" << Qt::hex << pfd.revents
312 << Qt::dec <<
"— no producer barrier for this frame");
322void waitForProducer(EGLDisplay eglDpy, GstBuffer* buffer)
324 if (!tryExplicitFenceWait(eglDpy, buffer)) {
325 waitForProducerWrites(buffer);
330constexpr int kGpuReadsTimeoutMs = 1000;
332#ifdef QGC_UNITTEST_BUILD
333std::atomic<int> s_gpuFenceForTest{-1};
338int exportGpuFence(EGLDisplay eglDpy)
340#ifdef QGC_UNITTEST_BUILD
341 if (
const int fd = s_gpuFenceForTest.load(std::memory_order_relaxed); fd >= 0) {
345 QOpenGLContext*
const context = QOpenGLContext::currentContext();
346 if (!context || !GstEglHelpers::displaySupportsExtension(eglDpy, kNativeFenceExt)) {
349 using DupNativeFenceFd = EGLint(EGLAPIENTRY*)(EGLDisplay, EGLSyncKHR);
350 static const auto createSyncKHR =
reinterpret_cast<PFNEGLCREATESYNCKHRPROC
>(eglGetProcAddress(
"eglCreateSyncKHR"));
351 static const auto destroySyncKHR =
352 reinterpret_cast<PFNEGLDESTROYSYNCKHRPROC
>(eglGetProcAddress(
"eglDestroySyncKHR"));
353 static const auto dupNativeFenceFd =
354 reinterpret_cast<DupNativeFenceFd
>(eglGetProcAddress(
"eglDupNativeFenceFDANDROID"));
355 if (!createSyncKHR || !destroySyncKHR || !dupNativeFenceFd) {
358 const EGLint attribs[] = {EGL_SYNC_NATIVE_FENCE_FD_ANDROID, EGL_NO_NATIVE_FENCE_FD_ANDROID, EGL_NONE};
359 const EGLSyncKHR sync = createSyncKHR(eglDpy, EGL_SYNC_NATIVE_FENCE_ANDROID, attribs);
360 if (sync == EGL_NO_SYNC_KHR) {
364 context->functions()->glFlush();
365 const int fence = dupNativeFenceFd(eglDpy, sync);
366 destroySyncKHR(eglDpy, sync);
371struct PendingGpuReads
374 GstBuffer* buffer =
nullptr;
378void waitForGpuReads(gpointer data, gpointer )
380 const std::unique_ptr<PendingGpuReads> pending(
static_cast<PendingGpuReads*
>(data));
381 pollfd pfd = {pending->fence, POLLIN, 0};
384 ret = ::poll(&pfd, 1, kGpuReadsTimeoutMs);
385 }
while (ret < 0 && (errno == EINTR || errno == EAGAIN));
386 ::close(pending->fence);
387 gst_buffer_unref(pending->buffer);
394void unrefAfterGpuReads(EGLDisplay eglDpy, GstBuffer* buffer)
398 static GThreadPool*
const waiters = g_thread_pool_new(&waitForGpuReads,
nullptr, -1, FALSE,
nullptr);
399 const int fence = waiters ? exportGpuFence(eglDpy) : -1;
401 gst_buffer_unref(buffer);
405 (void) g_thread_pool_push(waiters,
new PendingGpuReads{.fence = fence, .buffer = buffer},
nullptr);
411bool locatePlanes(GstBuffer* buffer,
const GstVideoInfo& info,
const GstQtDmaBufImport::PlaneFourccs& fourccs,
412 quint64 modifier, std::span<GstQtDmaBufImport::Plane> planes)
414 const GstVideoMeta* vmeta = gst_buffer_get_video_meta(buffer);
415 for (
int i = 0; i < fourccs.count; ++i) {
417 const gsize offset = vmeta ? vmeta->offset[i] : GST_VIDEO_INFO_PLANE_OFFSET(&info, i);
418 const gint stride = vmeta ? vmeta->stride[i] : GST_VIDEO_INFO_PLANE_STRIDE(&info, i);
422 if (!gst_buffer_find_memory(buffer, offset, 1, &memIdx, &length, &skip) || (length != 1)) {
425 GstMemory* mem = gst_buffer_peek_memory(buffer, memIdx);
426 const quint64 fdOffset =
static_cast<quint64
>(mem->offset) + skip;
427 constexpr quint64 kMaxAttrib = (std::numeric_limits<EGLint>::max)();
428 if (!gst_is_dmabuf_memory(mem) || (stride <= 0) || (fdOffset > kMaxAttrib)) {
431 planes[std::size_t(i)] = {.fd = gst_dmabuf_memory_get_fd(mem),
432 .offset =
static_cast<quint32
>(fdOffset),
433 .pitch =
static_cast<quint32
>(stride),
434 .drmFourcc = fourccs.fourcc[std::size_t(i)],
435 .modifier = modifier};
436 if (planes[std::size_t(i)].fd < 0) {
444bool locateImportPlanes(GstBuffer* buffer,
const GstVideoInfo& info,
const GstQtDmaBufImport::PlaneFourccs& fourccs,
445 quint64 modifier, std::span<GstQtDmaBufImport::Plane> planes)
447 if ((fourccs.count != 0) && (fourccs.count ==
int(GST_VIDEO_INFO_N_PLANES(&info))) &&
448 locatePlanes(buffer, info, fourccs, modifier, planes)) {
452 "DMABuf layout not importable (format" << gst_video_format_to_string(GST_VIDEO_INFO_FORMAT(&info))
453 <<
"memories" << gst_buffer_n_memory(buffer)
454 <<
") — CPU fallback");
462GstDmaBufVideoBuffer::GstDmaBufVideoBuffer(GstSample* sample,
const GstVideoInfo& videoInfo,
463 const QVideoFrameFormat& format, EGLDisplay eglDisplay)
465 , _eglDisplay(eglDisplay)
466 , _drmModifier(DRM_FORMAT_MOD_INVALID)
467 , _packedYuvFourcc(eglfsPackedYuvFourcc(
format.pixelFormat()))
471 if (_packedYuvFourcc != 0) {
472 _format = withPixelFormat(_format, QVideoFrameFormat::Format_RGBA8888);
474#if GST_CHECK_VERSION(1, 24, 0)
475 if (GstCaps* caps = gst_sample_get_caps(sample); caps && gst_video_is_dma_drm_caps(caps)) {
476 GstVideoInfoDmaDrm drmInfo = {};
477 gst_video_info_dma_drm_init(&drmInfo);
478 if (gst_video_info_dma_drm_from_caps(&drmInfo, caps)) {
479 _drmModifier = drmInfo.drm_modifier;
490bool GstDmaBufVideoBuffer::isDmaBufFd(
int fd)
noexcept
494 constexpr quint32 kDmaBufFsMagic = 0x444d4142;
495 struct statfs filesystem = {};
496 return (fd >= 0) && (::fstatfs(fd, &filesystem) == 0) &&
497 (
static_cast<quint32
>(filesystem.f_type) == kDmaBufFsMagic);
500bool GstDmaBufVideoBuffer::isTiled() const noexcept
502 return (_drmModifier != DRM_FORMAT_MOD_INVALID) && (_drmModifier != DRM_FORMAT_MOD_LINEAR);
505bool GstDmaBufVideoBuffer::importDisabled() noexcept
507 return s_importDisabled.load(std::memory_order_relaxed);
510void GstDmaBufVideoBuffer::noteImportOutcome(ImportOutcome outcome)
const
512 noteLayoutImportOutcome(
513 {.modifier = _drmModifier, .pixelFormat = _format.pixelFormat(), .size = _format.frameSize()}, isTiled(),
517void GstDmaBufVideoBuffer::resetCachedState() noexcept
519 s_importDisabled.store(
false, std::memory_order_relaxed);
520 s_importFailures.clear();
522#if defined(QGC_HAS_GST_DMABUF_VULKAN_IMPORT)
523 GstDmaBufVulkan::resetCachedState();
533void prepareDmaBufContext(HwVideoBufferContext&)
535 static std::atomic<bool> s_logged{
false};
536 if (!s_logged.exchange(
true, std::memory_order_relaxed)) {
538 qCDebug(GstDmaBufLog) <<
"Qt renders without EGL on" << QGuiApplication::platformName()
539 <<
"— DMABuf frames take the CPU path (xcb: QT_XCB_GL_INTEGRATION=xcb_egl)";
541 qCDebug(GstDmaBufLog) <<
"DMABuf zero-copy available on" << QGuiApplication::platformName();
549bool admitDmaBuf(GstMemory*,
const HwVideoBufferContext& context)
560constinit const HwPathDescriptor GstHwPaths::kDmaBuf = {
562 .matches = [](GstMemory* mem) ->
bool {
return gst_is_dmabuf_memory(mem); },
563 .admits = &admitDmaBuf,
564 .construct = [](GstSample* sample,
const GstVideoInfo& info, QVideoFrameFormat
format,
566 return std::make_unique<GstDmaBufVideoBuffer>(sample, info, format,
567 GstDmaBufVideoBuffer::eglDisplayFor(context));
569 .prepareContext = &prepareDmaBufContext,
570#if defined(QGC_HAS_GST_DMABUF_VULKAN_IMPORT)
571 .probeDevice = &GstDmaBufVulkan::probeDevice,
575 GstDmaBufVideoBuffer::resetCachedState();
576 GstEglHelpers::resetExtensionCache();
580#ifdef QGC_UNITTEST_BUILD
581void GstDmaBufVideoBuffer::recordImportFailureForTest(
bool unrecoverable)
583 noteLayoutImportOutcome({},
false,
584 unrecoverable ? ImportOutcome::Unrecoverable : ImportOutcome::Rejected);
587void GstDmaBufVideoBuffer::noteImportOutcomeForTest(ImportOutcome outcome)
const
589 noteImportOutcome(outcome);
592bool GstDmaBufVideoBuffer::waitForProducerWritesForTest(GstBuffer* buffer)
594 return waitForProducerWrites(buffer);
597void GstDmaBufVideoBuffer::setGpuFenceForTest(
int fd)
599 s_gpuFenceForTest.store(fd, std::memory_order_relaxed);
603bool GstDmaBufVideoBuffer::validatePlaneHandles()
const
605 if (importDisabled()) {
608 const bool planesOk = validatePlanes(
609 [](GstMemory* mem) {
return mem && gst_is_dmabuf_memory(mem) && (gst_dmabuf_memory_get_fd(mem) >= 0); });
613#if defined(QGC_HAS_GST_DMABUF_VULKAN_IMPORT)
616 return GstDmaBufVulkan::canImport(GstQtDmaBufImport::planeFourccs(_format.pixelFormat()), _drmModifier);
621 ((_eglDisplay != EGL_NO_DISPLAY) && GstEglHelpers::displaySupportsExtension(_eglDisplay, kModifiersExt));
624QAbstractVideoBuffer::MapData GstDmaBufVideoBuffer::map(QVideoFrame::MapMode mode)
628 GstDmaBufLog, s_diag.loggedTiledCpuMap,
629 "tiled DMABuf frame has no CPU layout (modifier" << Qt::hex << _drmModifier <<
") — frame not shown");
635QVideoFrameTexturesUPtr GstDmaBufVideoBuffer::mapTextures(QRhi& rhi, QVideoFrameTexturesUPtr& old)
638 if (importDisabled()) {
641 ImportOutcome failure = ImportOutcome::NotImportable;
642 QVideoFrameTexturesUPtr textures = importFrame(rhi, old, failure);
643 noteImportOutcome(textures ? ImportOutcome::Imported : failure);
647QVideoFrameTexturesUPtr GstDmaBufVideoBuffer::importFrame(QRhi& rhi, QVideoFrameTexturesUPtr& old,
648 ImportOutcome& failure)
650#if defined(QGC_HAS_GST_DMABUF_VULKAN_IMPORT)
651 const bool vulkan = (rhi.backend() == QRhi::Vulkan);
653 constexpr bool vulkan =
false;
656 GstBuffer* buffer =
nullptr;
657 if (!checkMapPreconditions(rhi,
static_cast<int>(vulkan ? QRhi::Vulkan : QRhi::OpenGLES2), GstDmaBufLog(), s_diag,
662#if defined(QGC_HAS_GST_DMABUF_VULKAN_IMPORT)
664 return importVulkan(rhi, buffer, old, failure);
667 return importGl(rhi, buffer, failure);
670#if defined(QGC_HAS_GST_DMABUF_VULKAN_IMPORT)
671QVideoFrameTexturesUPtr GstDmaBufVideoBuffer::importVulkan(QRhi& rhi, GstBuffer* buffer, QVideoFrameTexturesUPtr& old,
672 ImportOutcome& failure)
674 const QVideoFrameFormat::PixelFormat pixelFormat = _format.pixelFormat();
675 const GstQtDmaBufImport::PlaneFourccs fourccs = GstQtDmaBufImport::planeFourccs(pixelFormat);
676 std::array<GstQtDmaBufImport::Plane, kMaxPlanes> planes{};
677 if (!locateImportPlanes(buffer, _videoInfo, fourccs, _drmModifier, planes)) {
686 if (!waitForProducerWrites(buffer)) {
690 "Vulkan import refused: producer writes not known complete — CPU fallback");
695 QVideoFrameTexturesUPtr textures =
696 GstDmaBufVulkan::importTextures(*
this, rhi, old, std::span(planes.data(), std::size_t(fourccs.count)),
697 pixelFormat, _format.frameSize(), buffer, rejected);
699 failure = ImportOutcome::Rejected;
705QVideoFrameTexturesUPtr GstDmaBufVideoBuffer::importGl(QRhi& rhi, GstBuffer* buffer, ImportOutcome& failure)
707 const EGLDisplay eglDpy = GstQtDmaBufImport::importDisplay(rhi);
708 if (eglDpy == EGL_NO_DISPLAY) {
710 "Qt's GL context is not EGL or can't bind EGLImages — DMABuf frames take the CPU path");
716 const QVideoFrameFormat::PixelFormat pixelFormat = _format.pixelFormat();
717 GstQtDmaBufImport::PlaneFourccs fourccs = GstQtDmaBufImport::planeFourccs(pixelFormat);
718 if (_packedYuvFourcc != 0) {
719 fourccs = {.fourcc = {_packedYuvFourcc}, .count = 1};
721 const quint64 modifier =
722 ((_drmModifier != DRM_FORMAT_MOD_INVALID) && GstEglHelpers::displaySupportsExtension(eglDpy, kModifiersExt))
724 : GstQtDmaBufImport::kImplicitModifier;
725 std::array<GstQtDmaBufImport::Plane, kMaxPlanes> planes{};
726 if (!locateImportPlanes(buffer, _videoInfo, fourccs, modifier, planes)) {
734 waitForProducer(eglDpy, buffer);
738 std::shared_ptr<void> keepAlive(gst_buffer_ref(buffer),
739 [eglDpy](
void* ref) { unrefAfterGpuReads(eglDpy,
static_cast<GstBuffer*
>(ref)); });
740 GstQtDmaBufImport::ImportResult imported =
741 GstQtDmaBufImport::importTextures(rhi, std::span(planes.data(), std::size_t(fourccs.count)), pixelFormat,
742 _format.frameSize(), std::move(keepAlive));
743 if (!imported.textures) {
744 failure = imported.unrecoverable ? ImportOutcome::Unrecoverable : ImportOutcome::Rejected;
747 if (!s_diag.loggedFirstSuccess.exchange(
true, std::memory_order_relaxed)) {
748 qCDebug(GstDmaBufLog) <<
"First DMABuf import: size=" << _format.frameSize() <<
"format=" << pixelFormat
749 <<
"modifier=" << Qt::hex << modifier;
751 return std::move(imported.textures);
#define QGC_HW_WARN_ONCE(LOGCAT, FLAG,...)
Logs once via qCWarning(LOGCAT) the first time FLAG flips true; subsequent trips are silent.
#define QGC_LOGGING_CATEGORY(name, categoryStr)
RAII timer: records mapTextures() wall time into the path's EWMA on scope exit.
Common base for GStreamer-backed QHwVideoBuffer subclasses.
MapData map(QVideoFrame::MapMode mode) override
bool run(const Environment::BundledRuntime &runtime)
bool preflightOrRecord(QRhi &rhi, HwVideoBufferPath path, QVideoFrameFormat::PixelFormat pixelFormat, const QSize &size, QRhiTexture::Flags flags)
QVideoFrameTexturesUPtr fail(HwVideoBufferPath path) noexcept
Records a map failure for path and returns the empty bundle mapTextures() reports it with.
@ 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.
void recordFallbackReason(HwVideoBufferPath attemptedPath, HwFallbackReason reason) noexcept
Per-(path,reason) fallback accounting; lets a bug report show why a path demoted to CPU.
void record(HwVideoBufferPath path, Counter counter) noexcept
HwFallbackReason
Specific cause a GPU path was rejected for a sample; surfaced as a per-(path,reason) breakdown.
constexpr int kMaxPlanes
Matches GST_VIDEO_MAX_PLANES (gst-video pins it at 4); single source of truth for every per-platform ...
DeviceSnapshot & deviceSnapshot() noexcept
Returns the global snapshot. Atomic fields make individual reads thread-safe.
bool rejected(const Fields &reply, std::string_view command)
One-shot warning flags per failure cause; paths with extra causes (DMABuf, D3D, IOSurface) derive and...