MythTV  master
mythvideovulkan.cpp
Go to the documentation of this file.
1 // Qt
2 #include <QGuiApplication>
3 
4 // MythTV
5 #include "mythlogging.h"
11 #include "vulkan/mythvideovulkan.h"
12 
13 #define LOC QString("VulkanVideo: ")
14 
16  MythVideoBounds* Bounds, const QString& Profile)
17  : MythVideoGPU(Vulkan->Render(), ColourSpace, Bounds, Profile),
18  MythVulkanObject(Vulkan)
19 {
20  if (!m_videoColourSpace)
21  return;
22 
23  if (IsValidVulkan())
24  m_valid = true;
25 }
26 
28 {
30 }
31 
33 {
36 }
37 
38 bool 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())
45  .arg(MythVideoFrame::FormatDescription(InputType))
46  .arg(MythVideoFrame::FormatDescription(OutputType))
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
58  m_videoDim);
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::s_DebugBlue);
133 
134  if (VERBOSE_LEVEL_CHECK(VB_GPU, LOG_INFO))
135  m_vulkanRender->EndDebugRegion(cmdbuffer);
136 
138 }
139 
140 void 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 
154 void MythVideoVulkan::ColourSpaceUpdate(bool /*PrimariesChanged*/)
155 {
156 }
157 
158 
MythVideoVulkan::ResetFrameFormat
void ResetFrameFormat() override
Definition: mythvideovulkan.cpp:32
LOC
#define LOC
Definition: mythvideovulkan.cpp:13
MythVideoGPU::m_discontinuityCounter
uint64_t m_discontinuityCounter
Definition: mythvideogpu.h:65
mythwindowvulkan.h
mythdebugvulkan.h
mythvideovulkan.h
MythVulkanObject
Definition: mythrendervulkan.h:29
Frame
Definition: zmdefines.h:94
MythVideoColourSpace::UpdateColourSpace
bool UpdateColourSpace(const MythVideoFrame *Frame)
Set the current colourspace to use.
Definition: mythvideocolourspace.cpp:329
MythVideoGPU::m_videoColourSpace
MythVideoColourSpace * m_videoColourSpace
Definition: mythvideogpu.h:74
arg
arg(title).arg(filename).arg(doDelete))
FrameScanType
FrameScanType
Definition: videoouttypes.h:95
MythVideoTextureVulkan::CreateTextures
static vector< MythVideoTextureVulkan * > CreateTextures(MythVulkanObject *Vulkan, VkCommandBuffer CommandBuffer, VideoFrameType Type, VideoFrameType Format, QSize Size)
Definition: mythvideotexturevulkan.cpp:7
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:23
MythVideoTextureVulkan::DeleteTextures
static void DeleteTextures(MythVulkanObject *Vulkan, VkCommandBuffer CommandBuffer, vector< MythVideoTextureVulkan * > &Textures)
Definition: mythvideotexturevulkan.cpp:31
MythVideoFrame::HardwareFormat
static bool HardwareFormat(VideoFrameType Type)
Definition: mythframe.h:408
MythVideoVulkan::SetupFrameFormat
bool SetupFrameFormat(VideoFrameType InputType, VideoFrameType OutputType, QSize Size, VkCommandBuffer CmdBuffer)
Definition: mythvideovulkan.cpp:38
MythRenderVulkan::CreateSingleUseCommandBuffer
VkCommandBuffer CreateSingleUseCommandBuffer(void)
Definition: mythrendervulkan.cpp:611
MythVideoVulkan::RenderFrame
void RenderFrame(MythVideoFrame *, bool, FrameScanType, StereoscopicMode, bool=false) override
Definition: mythvideovulkan.cpp:140
mythpaintervulkan.h
MythVideoGPU::m_videoDim
QSize m_videoDim
Definition: mythvideogpu.h:70
FMT_NONE
@ FMT_NONE
Definition: mythframe.h:17
MythVideoGPU
Definition: mythvideogpu.h:16
MythVideoVulkan::~MythVideoVulkan
~MythVideoVulkan() override
Definition: mythvideovulkan.cpp:27
MythVideoVulkan::ColourSpaceUpdate
void ColourSpaceUpdate(bool) override
Definition: mythvideovulkan.cpp:154
MythVideoFrame::YUVFormat
static bool YUVFormat(VideoFrameType Type)
Definition: mythframe.h:449
MythRenderVulkan::BeginDebugRegion
void BeginDebugRegion(VkCommandBuffer CommandBuffer, const char *Name, MythVulkan4F Color)
Definition: mythrendervulkan.cpp:526
MythVulkanObject::m_vulkanRender
MythRenderVulkan * m_vulkanRender
Definition: mythrendervulkan.h:44
mythlogging.h
MythVideoVulkan::StartFrame
void StartFrame() override
Definition: mythvideovulkan.cpp:67
MythVideoVulkan::PrepareFrame
void PrepareFrame(MythVideoFrame *Frame, FrameScanType=kScan_Progressive) override
Definition: mythvideovulkan.cpp:81
MythVideoVulkan::MythVideoVulkan
MythVideoVulkan(MythVulkanObject *Vulkan, MythVideoColourSpace *ColourSpace, MythVideoBounds *Bounds, const QString &Profile)
Definition: mythvideovulkan.cpp:15
MythRenderVulkan::SetFrameExpected
void SetFrameExpected(void)
Definition: mythrendervulkan.cpp:298
MythVideoGPU::m_outputType
VideoFrameType m_outputType
Definition: mythvideogpu.h:68
MythVideoBounds
Definition: mythvideobounds.h:24
MythVideoVulkan::EndFrame
void EndFrame() override
Definition: mythvideovulkan.cpp:148
StereoscopicMode
StereoscopicMode
Definition: videoouttypes.h:135
MythVideoVulkan::m_inputTextures
vector< MythVideoTextureVulkan * > m_inputTextures
Definition: mythvideovulkan.h:42
MythRenderVulkan::EndDebugRegion
void EndDebugRegion(VkCommandBuffer CommandBuffer)
Definition: mythrendervulkan.cpp:533
VERBOSE_LEVEL_CHECK
#define VERBOSE_LEVEL_CHECK(_MASK_, _LEVEL_)
Definition: mythlogging.h:14
MythVideoFrame::FormatDescription
static QString FormatDescription(VideoFrameType Type)
Definition: mythframe.cpp:363
MythRenderVulkan::EndFrame
void EndFrame(void)
Definition: mythrendervulkan.cpp:355
MythDebugVulkan::s_DebugBlue
static const MythVulkan4F s_DebugBlue
Definition: mythdebugvulkan.h:13
MythVulkanObject::m_vulkanWindow
MythWindowVulkan * m_vulkanWindow
Definition: mythrendervulkan.h:47
mythvideoshadersvulkan.h
MythVulkanObject::IsValidVulkan
bool IsValidVulkan() const
Definition: mythrendervulkan.cpp:63
MythVideoGPU::m_valid
bool m_valid
Definition: mythvideogpu.h:80
MythVideoGPU::ResetFrameFormat
virtual void ResetFrameFormat()
Definition: mythvideogpu.cpp:80
VideoFrameType
VideoFrameType
Definition: mythframe.h:16
mythvideotexturevulkan.h
MythVideoFrame
Definition: mythframe.h:83
MythRenderVulkan::FinishSingleUseCommandBuffer
void FinishSingleUseCommandBuffer(VkCommandBuffer &Buffer)
Definition: mythrendervulkan.cpp:627
MythVideoColourSpace
MythVideoColourSpace contains a QMatrix4x4 that can convert YCbCr data to RGB.
Definition: mythvideocolourspace.h:21
MythVideoGPU::m_inputType
VideoFrameType m_inputType
Definition: mythvideogpu.h:67