Loading...
Searching...
No Matches
VulkanRhiContext.hpp
Go to the documentation of this file.
1#pragma once
2
25
26#include <score/gfx/Vulkan.hpp>
27
28#if QT_HAS_VULKAN
29
30#include <QtGui/private/qrhivulkan_p.h>
31
32#include <QVulkanInstance>
33
34class QRhi;
35class QVulkanDeviceFunctions;
36
37namespace score::gfx::interop
38{
39
41struct VulkanRhiContext
42{
43 score::gfx::vkinterop::VulkanCtx vk{};
44 QVulkanDeviceFunctions* devFuncs{};
45 VkQueue gfxQueue{VK_NULL_HANDLE};
46 int gfxFamily{-1};
47};
48
52inline bool acquireVulkanRhiContext(QRhi* rhi, VulkanRhiContext& out) noexcept
53{
54 if(!rhi || rhi->backend() != QRhi::Vulkan)
55 return false;
56 auto* h = static_cast<const QRhiVulkanNativeHandles*>(rhi->nativeHandles());
57 QVulkanInstance* qInst = score::gfx::staticVulkanInstance(false);
58 if(!h || !h->dev || !h->physDev || !qInst)
59 return false;
60 out.vk = {qInst->vkInstance(), h->physDev, h->dev, qInst};
61 out.devFuncs = qInst->deviceFunctions(h->dev);
62 out.gfxQueue = h->gfxQueue;
63 out.gfxFamily = h->gfxQueueFamilyIdx;
64 if(!out.devFuncs || !out.gfxQueue || out.gfxFamily < 0)
65 return false;
66 return true;
67}
68
69} // namespace score::gfx::interop
70
71#endif // QT_HAS_VULKAN
Vulkan external-memory image/buffer create + export + import helpers.