MythTV master
mythvideotexturevulkan.cpp
Go to the documentation of this file.
1// MythTV
4
5#define LOC QString("VulkanVidTex: ")
6
7std::vector<MythVideoTextureVulkan*>
9 VkCommandBuffer CommandBuffer,
10 VideoFrameType Type,
12 QSize Size)
13{
14 if (!Vulkan || !Vulkan->IsValidVulkan() || Size.isEmpty())
15 return std::vector<MythVideoTextureVulkan*>{};
16
18 return std::vector<MythVideoTextureVulkan*>{};
19
20 return CreateSoftwareTextures(Vulkan, CommandBuffer, Type, Format, Size);
21}
22
24 [[maybe_unused]] VideoFrameType Format)
25#if 0
26 : m_frameType(Type),
27 m_frameFormat(Format),
29#endif
30{
31}
32
34 VkCommandBuffer CommandBuffer,
35 std::vector<MythVideoTextureVulkan*>& Textures)
36{
37 if (!(Vulkan && Vulkan->IsValidVulkan()))
38 return;
39
40 VkCommandBuffer cmdbuffer = nullptr;
41 if (!CommandBuffer)
42 {
43 cmdbuffer = Vulkan->Render()->CreateSingleUseCommandBuffer();
44 CommandBuffer = cmdbuffer;
45 }
46
47 for (auto * texture : Textures)
48 MythVideoTextureVulkan::DeleteTexture(Vulkan, CommandBuffer, texture);
49
50 if (cmdbuffer)
51 Vulkan->Render()->FinishSingleUseCommandBuffer(cmdbuffer);
52
53 Textures.clear();
54}
55
57 VkCommandBuffer CommandBuffer,
59{
60 if (!(Vulkan && Vulkan->IsValidVulkan() && CommandBuffer && Texture))
61 return;
62
63 delete Texture;
64}
65
66std::vector<MythVideoTextureVulkan*>
68 [[maybe_unused]] VkCommandBuffer CommandBuffer,
69 [[maybe_unused]] VideoFrameType Type,
71 QSize Size)
72{
73 std::vector<MythVideoTextureVulkan*> result;
74
76 if (count < 1)
77 {
78 LOG(VB_GENERAL, LOG_ERR, LOC + "Invalid software frame format");
79 return result;
80 }
81
82 for (uint plane = 0; plane < count; ++plane)
83 {
84 QSize size = Size;
85 MythVideoTextureVulkan* texture = nullptr;
86 switch (Format)
87 {
88 case FMT_YV12:
89 if (plane > 0)
90 size = QSize(size.width() >> 1, size.height() >> 1);
91 //texture = CreateTexture(Context, size, Target,
92 // QOpenGLTexture::UInt8, r8pixelfmtnorm, r8internalfmt);
93 break;
94 default: break;
95 }
96
97 if (texture)
98 result.push_back(texture);
99 }
100
101 return result;
102}
void FinishSingleUseCommandBuffer(VkCommandBuffer &Buffer)
VkCommandBuffer CreateSingleUseCommandBuffer(void)
static uint GetNumPlanes(VideoFrameType Type)
Definition: mythframe.h:213
static bool HardwareFormat(VideoFrameType Type)
Definition: mythframe.h:424
static void DeleteTextures(MythVulkanObject *Vulkan, VkCommandBuffer CommandBuffer, std::vector< MythVideoTextureVulkan * > &Textures)
static void DeleteTexture(MythVulkanObject *Vulkan, VkCommandBuffer CommandBuffer, MythVideoTextureVulkan *Texture)
MythVideoTextureVulkan()=default
static std::vector< MythVideoTextureVulkan * > CreateTextures(MythVulkanObject *Vulkan, VkCommandBuffer CommandBuffer, VideoFrameType Type, VideoFrameType Format, QSize Size)
static std::vector< MythVideoTextureVulkan * > CreateSoftwareTextures(MythVulkanObject *Vulkan, VkCommandBuffer CommandBuffer, VideoFrameType Type, VideoFrameType Format, QSize Size)
MythRenderVulkan * Render()
bool IsValidVulkan() const
unsigned int uint
Definition: freesurround.h:24
VideoFrameType
Definition: mythframe.h:20
@ FMT_YV12
Definition: mythframe.h:23
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:39
#define LOC