MythTV master
mythvideooutputvulkan.cpp
Go to the documentation of this file.
1// MythTV
8
9#include "osd.h"
12
13#define LOC QString("VidOutVulkan: ")
14
16{
17 QStringList safe(VULKAN_RENDERER);
18
19 (*Options.safe_renderers)["dummy"].append(safe);
20 (*Options.safe_renderers)["ffmpeg"].append(safe);
21
22 for (auto & decoder : *Options.decoders)
23 if (decoder.endsWith("-dec"))
24 (*Options.safe_renderers)[decoder].append(safe);
25
26 Options.renderers->append(VULKAN_RENDERER);
27 Options.priorities->insert(VULKAN_RENDERER, 75);
28}
29
31{
32 QStringList allowed;
33
34 if (MythRenderVulkan::GetVulkanRender() == nullptr)
35 return allowed;
36
37 if (codec_sw_copy(CodecId))
38 {
39 allowed << VULKAN_RENDERER;
40 return allowed;
41 }
42
43 return allowed;
44}
45
47 MythPainterVulkan* Painter, MythDisplay* MDisplay,
48 const MythVideoProfilePtr& VideoProfile, QString& Profile)
49 : MythVideoOutputGPU(MainWindow, Render, Painter, MDisplay, VideoProfile, Profile),
50 MythVulkanObject(Render)
51{
52 static VideoFrameTypes s_vulkanRenderFormats =
53 {
59 };
60
61 m_renderFormats = &s_vulkanRenderFormats;
62 if (IsValidVulkan())
63 {
64 m_video = new MythVideoVulkan(this, &m_videoColourSpace, this, m_videoProfile, QString {});
65 if (m_video && !m_video->IsValid())
66 {
67 LOG(VB_GENERAL, LOG_ERR, LOC + "Failed to create valid Vulkan video");
68 delete m_video;
69 m_video = nullptr;
70 }
71 }
72
73 if (!(IsValidVulkan() && m_painter && m_video))
74 LOG(VB_GENERAL, LOG_ERR, LOC + "Failed to initialise Vulkan video output");
75}
76
77bool MythVideoOutputVulkan::Init(const QSize VideoDim, const QSize VideoDispDim,
78 float Aspect, const QRect DisplayVisibleRect, MythCodecID CodecId)
79{
80 if (!(IsValidVulkan() && m_painter && m_video))
81 {
82 LOG(VB_GENERAL, LOG_ERR, LOC + "Fatal error");
83 return false;
84 }
85
87 {
88 LOG(VB_GENERAL, LOG_ERR, LOC + "Cannot initialise from this thread");
89 return false;
90 }
91
92 return MythVideoOutputGPU::Init(VideoDim, VideoDispDim, Aspect, DisplayVisibleRect, CodecId);
93}
94
96{
98}
99
101{
102 if (!(IsValidVulkan() && m_video))
103 return;
104
105 // input changes need to be handled in ProcessFrame
107 return;
108
109 // Start the frame...
111
112 if (VERBOSE_LEVEL_CHECK(VB_GPU, LOG_INFO))
113 {
114 m_vulkanRender->BeginDebugRegion(m_vulkanWindow->currentCommandBuffer(),
115 "RENDER_FRAME", MythDebugVulkan::kDebugBlue);
116 }
117
118 // Actual render
120}
121
123{
124 if (!(IsValidVulkan()))
125 return;
126
127 if (VERBOSE_LEVEL_CHECK(VB_GPU, LOG_INFO))
128 m_vulkanRender->EndDebugRegion(m_vulkanWindow->currentCommandBuffer());
129}
130
132{
133 if (m_video)
134 m_video->EndFrame();
135}
static const MythVulkan4F kDebugBlue
static MythRenderVulkan * GetVulkanRender(void)
void EndDebugRegion(VkCommandBuffer CommandBuffer)
void BeginDebugRegion(VkCommandBuffer CommandBuffer, const char *Name, MythVulkan4F Color)
bool IsValid() const
virtual void StartFrame()=0
virtual void EndFrame()=0
Common code shared between GPU accelerated sub-classes (e.g. OpenGL)
MythCodecID m_newCodecId
void PrepareFrame(MythVideoFrame *Frame, FrameScanType Scan) override
MythPainterGPU * m_painter
bool Init(QSize VideoDim, QSize VideoDispDim, float Aspect, QRect DisplayVisibleRect, MythCodecID CodecId) override
void RenderFrame(MythVideoFrame *Frame, FrameScanType Scan) override
MythVideoGPU * m_video
void PrepareFrame(MythVideoFrame *Frame, FrameScanType Scan) override
bool Init(QSize VideoDim, QSize VideoDispDim, float Aspect, QRect DisplayVisibleRect, MythCodecID CodecId) override
void RenderFrame(MythVideoFrame *Frame, FrameScanType Scan) override
MythVideoOutputVulkan(MythMainWindow *MainWindow, MythRenderVulkan *Render, MythPainterVulkan *Painter, MythDisplay *Display, const MythVideoProfilePtr &VideoProfile, QString &Profile)
static void GetRenderOptions(RenderOptions &Options)
static QStringList GetAllowedRenderers(MythCodecID CodecId)
MythVideoColourSpace m_videoColourSpace
Definition: mythvideoout.h:94
MythVideoProfilePtr m_videoProfile
Definition: mythvideoout.h:100
const VideoFrameTypes * m_renderFormats
Definition: mythvideoout.h:106
MythRenderVulkan * m_vulkanRender
MythWindowVulkan * m_vulkanWindow
bool IsValidVulkan() const
MythCodecID
Definition: mythcodecid.h:14
@ kCodec_NONE
Definition: mythcodecid.h:17
static bool codec_sw_copy(MythCodecID id)
Definition: mythcodecid.h:374
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
std::vector< VideoFrameType > VideoFrameTypes
Definition: mythframe.h:82
@ FMT_YUV420P9
Definition: mythframe.h:24
@ FMT_YUV444P
Definition: mythframe.h:43
@ FMT_YUV420P14
Definition: mythframe.h:27
@ FMT_YUV420P12
Definition: mythframe.h:26
@ FMT_YUV422P10
Definition: mythframe.h:38
@ FMT_YUV444P16
Definition: mythframe.h:48
@ FMT_YUV422P9
Definition: mythframe.h:37
@ FMT_YUV422P14
Definition: mythframe.h:40
@ FMT_YV12
Definition: mythframe.h:23
@ FMT_P016
Definition: mythframe.h:54
@ FMT_YUV444P12
Definition: mythframe.h:46
@ FMT_YUV444P9
Definition: mythframe.h:44
@ FMT_YUV444P10
Definition: mythframe.h:45
@ FMT_YUV422P
Definition: mythframe.h:36
@ FMT_YUV422P16
Definition: mythframe.h:41
@ FMT_YUV420P10
Definition: mythframe.h:25
@ FMT_YUV420P16
Definition: mythframe.h:28
@ FMT_P010
Definition: mythframe.h:53
@ FMT_NV12
Definition: mythframe.h:52
@ FMT_YUV444P14
Definition: mythframe.h:47
@ FMT_YUV422P12
Definition: mythframe.h:39
static bool VERBOSE_LEVEL_CHECK(uint64_t mask, LogLevel_t level)
Definition: mythlogging.h:29
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:39
std::shared_ptr< MythVideoProfile > MythVideoProfilePtr
Definition: mythvideogpu.h:18
#define LOC
#define VULKAN_RENDERER
QStringList * decoders
QStringList * renderers
QMap< QString, QStringList > * safe_renderers
QMap< QString, uint > * priorities
FrameScanType
Definition: videoouttypes.h:95