MythTV master
mythvideovulkan.cpp
Go to the documentation of this file.
1// Qt
2#include <QGuiApplication>
3
4// MythTV
12
13#define LOC QString("VulkanVideo: ")
14
16 MythVideoBounds* Bounds, const MythVideoProfilePtr& VideoProfile, const QString& Profile)
17 : MythVideoGPU(Vulkan->Render(), ColourSpace, Bounds, VideoProfile, Profile),
18 MythVulkanObject(Vulkan)
19{
21 return;
22
23 if (IsValidVulkan())
24 m_valid = true;
25}
26
28{
30}
31
33{
36}
37
38bool MythVideoVulkan::SetupFrameFormat(VideoFrameType InputType, VideoFrameType OutputType, QSize Size, VkCommandBuffer CmdBuffer)
39{
40 LOG(VB_GENERAL, LOG_INFO, LOC +
41 QString("New frame format: %1:%2 %3x%4 -> %6:%7 %8x%9")
44 .arg(m_videoDim.width()).arg(m_videoDim.height())
47 .arg(Size.width()).arg(Size.height()));
48
50
51 m_inputType = InputType;
52 m_outputType = OutputType;
53 m_videoDim = Size;
54
55 // Create textures
59
60 // Create shaders
61
62 // Update video colourspace
63
64 return true;
65}
66
68{
69 if (!(m_valid && IsValidVulkan()))
70 return;
71
72 // Tell the renderer that we are requesting a frame start
74
75 // Signal DIRECTLY to the window to start the frame - which ensures
76 // the event is not delayed and we can start to render immediately.
77 QEvent update(QEvent::UpdateRequest);
78 QGuiApplication::sendEvent(m_vulkanWindow, &update);
79}
80
82{
83 if (!m_valid || !IsValidVulkan() || (Frame->m_type != FMT_NONE))
84 return;
85
86 // No hardware frame support yet
88 {
89 LOG(VB_GENERAL, LOG_ERR, LOC + "Invalid hardware video frame");
90 return;
91 }
92
93 // Sanitise frame
94 if ((Frame->m_width < 1) || (Frame->m_height < 1) || !Frame->m_buffer)
95 {
96 LOG(VB_GENERAL, LOG_ERR, LOC + "Invalid video frame");
97 return;
98 }
99
100 // Can we render this frame format
101 if (!MythVideoFrame::YUVFormat(Frame->m_type))
102 {
103 LOG(VB_GENERAL, LOG_ERR, LOC + "Frame format is not supported");
104 return;
105 }
106
107 VkCommandBuffer cmdbuffer = nullptr;
108
109 // check for input changes
110 if ((Frame->m_width != m_videoDim.width()) || (Frame->m_height != m_videoDim.height()) ||
111 (Frame->m_type != m_inputType))
112 {
113 VideoFrameType frametype = Frame->m_type;
114 QSize size(Frame->m_width, Frame->m_height);
116 if (!SetupFrameFormat(Frame->m_type, frametype, size, cmdbuffer))
117 {
119 return;
120 }
121 }
122
124 m_discontinuityCounter = Frame->m_frameCounter;
125
126 if (!cmdbuffer)
128
129 //MythVideoTexture::UpdateTextures(m_render, Frame, current ? m_inputTextures : m_nextTextures);
130
131 if (VERBOSE_LEVEL_CHECK(VB_GPU, LOG_INFO))
132 m_vulkanRender->BeginDebugRegion(cmdbuffer, "PREPARE_FRAME", MythDebugVulkan::kDebugBlue);
133
134 if (VERBOSE_LEVEL_CHECK(VB_GPU, LOG_INFO))
135 m_vulkanRender->EndDebugRegion(cmdbuffer);
136
138}
139
140void MythVideoVulkan::RenderFrame(MythVideoFrame* /*Frame*/, bool /*TopFieldFirst*/,
141 FrameScanType /*Scan*/, StereoscopicMode /*StereoOverride*/,
142 bool /*DrawBorder*/)
143{
144 if (!(m_valid && IsValidVulkan()))
145 return;
146}
147
149{
150 if (m_valid && IsValidVulkan())
152}
153
154void MythVideoVulkan::ColourSpaceUpdate(bool /*PrimariesChanged*/)
155{
156}
157
158
static const MythVulkan4F kDebugBlue
void FinishSingleUseCommandBuffer(VkCommandBuffer &Buffer)
void EndDebugRegion(VkCommandBuffer CommandBuffer)
VkCommandBuffer CreateSingleUseCommandBuffer(void)
void SetFrameExpected(void)
void BeginDebugRegion(VkCommandBuffer CommandBuffer, const char *Name, MythVulkan4F Color)
MythVideoColourSpace contains a QMatrix4x4 that can convert YCbCr data to RGB.
bool UpdateColourSpace(const MythVideoFrame *Frame)
Set the current colourspace to use.
static QString FormatDescription(VideoFrameType Type)
Definition: mythframe.cpp:368
static bool YUVFormat(VideoFrameType Type)
Definition: mythframe.h:465
static bool HardwareFormat(VideoFrameType Type)
Definition: mythframe.h:424
VideoFrameType m_inputType
Definition: mythvideogpu.h:80
uint64_t m_discontinuityCounter
Definition: mythvideogpu.h:78
QSize m_videoDim
Definition: mythvideogpu.h:83
MythVideoColourSpace * m_videoColourSpace
Definition: mythvideogpu.h:87
VideoFrameType m_outputType
Definition: mythvideogpu.h:81
virtual void ResetFrameFormat()
static void DeleteTextures(MythVulkanObject *Vulkan, VkCommandBuffer CommandBuffer, std::vector< MythVideoTextureVulkan * > &Textures)
static std::vector< MythVideoTextureVulkan * > CreateTextures(MythVulkanObject *Vulkan, VkCommandBuffer CommandBuffer, VideoFrameType Type, VideoFrameType Format, QSize Size)
void StartFrame() override
~MythVideoVulkan() override
void ColourSpaceUpdate(bool) override
bool SetupFrameFormat(VideoFrameType InputType, VideoFrameType OutputType, QSize Size, VkCommandBuffer CmdBuffer)
void RenderFrame(MythVideoFrame *, bool, FrameScanType, StereoscopicMode, bool=false) override
void PrepareFrame(MythVideoFrame *Frame, FrameScanType=kScan_Progressive) override
void ResetFrameFormat() override
MythVideoVulkan(MythVulkanObject *Vulkan, MythVideoColourSpace *ColourSpace, MythVideoBounds *Bounds, const MythVideoProfilePtr &VideoProfile, const QString &Profile)
void EndFrame() override
std::vector< MythVideoTextureVulkan * > m_inputTextures
MythRenderVulkan * m_vulkanRender
MythWindowVulkan * m_vulkanWindow
bool IsValidVulkan() const
VideoFrameType
Definition: mythframe.h:20
@ FMT_NONE
Definition: mythframe.h:21
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
FrameScanType
Definition: videoouttypes.h:95
StereoscopicMode