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