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