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