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