3#include <QtGui/qtguiglobal.h>
10#if defined(QGC_HAS_GST_VULKAN_GPU_PATH) && QT_CONFIG(vulkan)
12#include <QtCore/QLoggingCategory>
13#include <QtCore/QSize>
14#include <private/qvideotexturehelper_p.h>
16#include <rhi/qrhi_platform.h>
17#include <vulkan/vulkan.h>
21#pragma push_macro("slots")
23#include <gst/vulkan/gstvkdevice.h>
24#include <gst/vulkan/gstvkimagememory.h>
25#pragma pop_macro("slots")
36std::atomic<bool> s_loggedDeviceMismatch{
false};
37std::atomic<bool> s_loggedMultiMemory{
false};
38std::atomic<bool> s_loggedSyncFallback{
false};
39std::atomic<bool> s_loggedFirstSuccess{
false};
43GstVulkanVideoBuffer::GstVulkanVideoBuffer(GstSample* sample,
const GstVideoInfo& videoInfo,
44 const QVideoFrameFormat& format)
48bool GstVulkanVideoBuffer::validatePlaneHandles()
const
50 return validatePlanes([](GstMemory* mem) {
return mem && gst_is_vulkan_image_memory(mem); });
53QVideoFrameTexturesUPtr GstVulkanVideoBuffer::mapTextures(QRhi& rhi, QVideoFrameTexturesUPtr& )
56 if (!rhi.thread()->isCurrentThread()) {
60 GstBuffer* buffer =
nullptr;
61 if (!checkMapPreconditions(rhi,
static_cast<int>(QRhi::Vulkan), GstVulkanBufLog(), s_diag, buffer)) {
66 if (gst_buffer_n_memory(buffer) != 1) {
68 "Vulkan import: multi-memory buffer not supported — CPU fallback");
72 GstMemory* mem0 = gst_buffer_peek_memory(buffer, 0);
73 if (!mem0 || !gst_is_vulkan_image_memory(mem0)) {
76 auto* vkMem =
reinterpret_cast<GstVulkanImageMemory*
>(mem0);
78 const auto* nh =
static_cast<const QRhiVulkanNativeHandles*
>(rhi.nativeHandles());
79 if (!nh || nh->dev == VK_NULL_HANDLE) {
86 if (!vkMem->device || vkMem->device->device != nh->dev) {
90 "Vulkan import: GstVulkanImageMemory VkDevice != QRhi VkDevice — CPU fallback");
99 constexpr bool kVulkanSyncImplemented =
false;
100 if constexpr (!kVulkanSyncImplemented) {
104 "Vulkan import: decoder sync unimplemented (no timeline semaphore) — CPU fallback");
108 const VkImage image = vkMem->image;
109 const int layout =
static_cast<int>(vkMem->barrier.image_layout);
110 if (image == VK_NULL_HANDLE) {
116 _format.frameSize())) {
120 auto textures = std::make_unique<GstVulkanBorrowedFrameTextures>(&rhi, _format.frameSize(), _format.pixelFormat(),
122 if (!textures->texture(0)) {
126 "Vulkan import: QRhiTexture::createFrom(VkImage) failed — CPU fallback");
130 logFirstSuccess(s_loggedFirstSuccess, GstVulkanBufLog(),
"Vulkan", _format.frameSize(), _format.pixelFormat(), 1);
131 textures->setSourceSample(takeSample());
#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.
void recordFallbackReason(HwVideoBufferPath attemptedPath, HwFallbackReason reason) noexcept
Per-(path,reason) fallback accounting; lets a bug report show why a path demoted to CPU.
constexpr int kMaxPlanes
Matches GST_VIDEO_MAX_PLANES (gst-video pins it at 4); single source of truth for every per-platform ...
One-shot warning flags per failure cause; paths with extra causes (D3D, IOSurface) derive and add mem...