3#include <QtGui/qtguiglobal.h>
10#if defined(QGC_HAS_GST_VULKAN_GPU_PATH) && QT_CONFIG(vulkan)
13#include <rhi/qrhi_platform.h>
14#include <vulkan/vulkan.h>
16#include <QtCore/QLoggingCategory>
20#pragma push_macro("slots")
22#include <gst/vulkan/gstvkdevice.h>
23#include <gst/vulkan/gstvkimagememory.h>
24#pragma pop_macro("slots")
35 std::atomic<bool> loggedDeviceMismatch{
false};
36 std::atomic<bool> loggedMultiMemory{
false};
37 std::atomic<bool> loggedNoSync{
false};
42 for (std::atomic<bool>* flag : {&loggedDeviceMismatch, &loggedMultiMemory, &loggedNoSync}) {
43 flag->store(
false, std::memory_order_relaxed);
48static_assert(
sizeof(VulkanDiagnostics) ==
sizeof(
GstHw::MapDiagnostics) + (3 *
sizeof(std::atomic<bool>)),
49 "VulkanDiagnostics::reset() must list every flag");
51VulkanDiagnostics s_diag;
55bool GstVulkanVideoBuffer::validatePlaneHandles()
const
57 return validatePlanes([](GstMemory* mem) {
return mem && gst_is_vulkan_image_memory(mem); });
60QVideoFrameTexturesUPtr GstVulkanVideoBuffer::mapTextures(QRhi& rhi, QVideoFrameTexturesUPtr& )
63 GstBuffer* buffer =
nullptr;
64 if (!checkMapPreconditions(rhi,
static_cast<int>(QRhi::Vulkan), GstVulkanBufLog(), s_diag, buffer)) {
69 if (gst_buffer_n_memory(buffer) != 1) {
71 "Vulkan import: multi-memory buffer not supported; frame not imported");
75 GstMemory* mem0 = gst_buffer_peek_memory(buffer, 0);
76 if (!mem0 || !gst_is_vulkan_image_memory(mem0)) {
79 auto* vkMem =
reinterpret_cast<GstVulkanImageMemory*
>(mem0);
81 const auto* nh =
static_cast<const QRhiVulkanNativeHandles*
>(rhi.nativeHandles());
82 if (!nh || nh->dev == VK_NULL_HANDLE) {
88 if (!vkMem->device || vkMem->device->device != nh->dev) {
92 "Vulkan import: GstVulkanImageMemory VkDevice != QRhi VkDevice; frame not imported");
102 "Vulkan import: no decoder-to-QRhi sync (timeline semaphore); frame not imported");
106constinit const HwPathDescriptor GstHwPaths::kVulkan = {
108 .matches = [](GstMemory* mem) ->
bool {
return gst_is_vulkan_image_memory(mem); },
109 .construct = &GstHwPaths::construct<GstVulkanVideoBuffer>,
110 .resetCaches = [] { s_diag.reset(); },
111 .bridge = &GstVulkanContextBridge::instance,
#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.
QVideoFrameTexturesUPtr fail(HwVideoBufferPath path) noexcept
Records a map failure for path and returns the empty bundle mapTextures() reports it with.
void recordFallbackReason(HwVideoBufferPath attemptedPath, HwFallbackReason reason) noexcept
Per-(path,reason) fallback accounting; lets a bug report show why a path demoted to CPU.
One-shot warning flags per failure cause; paths with extra causes (DMABuf, D3D, IOSurface) derive and...