MythTV  master
mythvideotexturevulkan.cpp
Go to the documentation of this file.
1 // MythTV
2 #include "mythlogging.h"
4 
5 #define LOC QString("VulkanVidTex: ")
6 
7 std::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 {
25  m_frameType = Type;
27  m_valid = false;
28  m_plane = 0;
30 }
31 
33  VkCommandBuffer CommandBuffer,
34  std::vector<MythVideoTextureVulkan*>& Textures)
35 {
36  if (!(Vulkan && Vulkan->IsValidVulkan()))
37  return;
38 
39  VkCommandBuffer cmdbuffer = nullptr;
40  if (!CommandBuffer)
41  {
42  cmdbuffer = Vulkan->Render()->CreateSingleUseCommandBuffer();
43  CommandBuffer = cmdbuffer;
44  }
45 
46  for (auto * texture : Textures)
47  MythVideoTextureVulkan::DeleteTexture(Vulkan, CommandBuffer, texture);
48 
49  if (cmdbuffer)
50  Vulkan->Render()->FinishSingleUseCommandBuffer(cmdbuffer);
51 
52  Textures.clear();
53 }
54 
56  VkCommandBuffer CommandBuffer,
57  MythVideoTextureVulkan* Texture)
58 {
59  if (!(Vulkan && Vulkan->IsValidVulkan() && CommandBuffer && Texture))
60  return;
61 
62  delete Texture;
63 }
64 
65 std::vector<MythVideoTextureVulkan*>
67  VkCommandBuffer CommandBuffer,
68  VideoFrameType Type,
70  QSize Size)
71 {
72  (void)Vulkan;
73  (void)CommandBuffer;
74  (void)Type;
75 
76  std::vector<MythVideoTextureVulkan*> result;
77 
79  if (count < 1)
80  {
81  LOG(VB_GENERAL, LOG_ERR, LOC + "Invalid software frame format");
82  return result;
83  }
84 
85  for (uint plane = 0; plane < count; ++plane)
86  {
87  QSize size = Size;
88  MythVideoTextureVulkan* texture = nullptr;
89  switch (Format)
90  {
91  case FMT_YV12:
92  if (plane > 0)
93  size = QSize(size.width() >> 1, size.height() >> 1);
94  //texture = CreateTexture(Context, size, Target,
95  // QOpenGLTexture::UInt8, r8pixelfmtnorm, r8internalfmt);
96  break;
97  default: break;
98  }
99 
100  if (texture)
101  result.push_back(texture);
102  }
103 
104  return result;
105 }
MythVideoTextureVulkan::DeleteTexture
static void DeleteTexture(MythVulkanObject *Vulkan, VkCommandBuffer CommandBuffer, MythVideoTextureVulkan *Texture)
Definition: mythvideotexturevulkan.cpp:55
MythVulkanObject
Definition: mythrendervulkan.h:29
MythVideoTextureVulkan::m_planeCount
uint m_planeCount
Definition: mythvideotexturevulkan.h:48
MythVideoTextureVulkan::m_frameFormat
VideoFrameType m_frameFormat
Definition: mythvideotexturevulkan.h:46
MythVideoTextureVulkan::CreateSoftwareTextures
static std::vector< MythVideoTextureVulkan * > CreateSoftwareTextures(MythVulkanObject *Vulkan, VkCommandBuffer CommandBuffer, VideoFrameType Type, VideoFrameType Format, QSize Size)
Definition: mythvideotexturevulkan.cpp:66
MythVideoTextureVulkan::m_plane
uint m_plane
Definition: mythvideotexturevulkan.h:47
MythDate::Format
Format
Definition: mythdate.h:15
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:23
MythVideoFrame::HardwareFormat
static bool HardwareFormat(VideoFrameType Type)
Definition: mythframe.h:425
MythRenderVulkan::CreateSingleUseCommandBuffer
VkCommandBuffer CreateSingleUseCommandBuffer(void)
Definition: mythrendervulkan.cpp:611
mythlogging.h
FMT_YV12
@ FMT_YV12
Definition: mythframe.h:24
LOC
#define LOC
Definition: mythvideotexturevulkan.cpp:5
MythVideoTextureVulkan::m_frameType
VideoFrameType m_frameType
Definition: mythvideotexturevulkan.h:45
MythVideoTextureVulkan::CreateTextures
static std::vector< MythVideoTextureVulkan * > CreateTextures(MythVulkanObject *Vulkan, VkCommandBuffer CommandBuffer, VideoFrameType Type, VideoFrameType Format, QSize Size)
Definition: mythvideotexturevulkan.cpp:8
uint
unsigned int uint
Definition: compat.h:144
MythVideoTextureVulkan::MythVideoTextureVulkan
MythVideoTextureVulkan()=default
MythVideoTextureVulkan::m_valid
bool m_valid
Definition: mythvideotexturevulkan.h:44
MythVideoFrame::GetNumPlanes
static uint GetNumPlanes(VideoFrameType Type)
Definition: mythframe.h:214
MythVulkanObject::IsValidVulkan
bool IsValidVulkan() const
Definition: mythrendervulkan.cpp:63
VideoFrameType
VideoFrameType
Definition: mythframe.h:20
mythvideotexturevulkan.h
MythVideoTextureVulkan::DeleteTextures
static void DeleteTextures(MythVulkanObject *Vulkan, VkCommandBuffer CommandBuffer, std::vector< MythVideoTextureVulkan * > &Textures)
Definition: mythvideotexturevulkan.cpp:32
MythRenderVulkan::FinishSingleUseCommandBuffer
void FinishSingleUseCommandBuffer(VkCommandBuffer &Buffer)
Definition: mythrendervulkan.cpp:627
MythVideoTextureVulkan
Definition: mythvideotexturevulkan.h:16
MythVulkanObject::Render
MythRenderVulkan * Render()
Definition: mythrendervulkan.cpp:68