MythTV  master
mythvertexbuffervulkan.cpp
Go to the documentation of this file.
1 // MythTV
2 #include "mythlogging.h"
4 
5 #define LOC QString("VulkanBuf: ")
6 
8 {
9  auto* result = new MythBufferVulkan(Vulkan, Size);
10  if (result && !result->IsValidVulkan())
11  {
12  delete result;
13  result = nullptr;
14  }
15  return result;
16 }
17 
19  : MythVulkanObject(Vulkan),
20  m_bufferSize(Size)
21 {
22  if (m_vulkanValid && m_vulkanRender->CreateBuffer(Size, VK_BUFFER_USAGE_TRANSFER_SRC_BIT,
23  VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
25  {
26  if (m_vulkanRender->CreateBuffer(Size, VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_VERTEX_BUFFER_BIT,
27  VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
29  {
30  m_vulkanValid = m_vulkanFuncs->vkMapMemory(m_vulkanDevice, m_stagingMemory, 0, Size, 0, &m_mappedMemory) == VK_SUCCESS;
31  }
32  }
33 }
34 
36 {
37  if (m_vulkanValid)
38  {
39  m_vulkanFuncs->vkDestroyBuffer(m_vulkanDevice, m_stagingBuffer, nullptr);
40  m_vulkanFuncs->vkFreeMemory(m_vulkanDevice, m_stagingMemory, nullptr);
41  m_vulkanFuncs->vkDestroyBuffer(m_vulkanDevice, m_buffer, nullptr);
42  m_vulkanFuncs->vkFreeMemory(m_vulkanDevice, m_bufferMemory, nullptr);
43  }
44 }
45 
46 VkBuffer MythBufferVulkan::GetBuffer(void) const
47 {
48  return m_buffer;
49 }
50 
52 {
53  return m_mappedMemory;
54 }
55 
56 void MythBufferVulkan::Update(VkCommandBuffer CommandBuffer)
57 {
59 }
60 
62 {
63  auto* result = new MythVertexBufferVulkan(Vulkan, Size);
64  if (result && !result->IsValidVulkan())
65  {
66  delete result;
67  result = nullptr;
68  }
69  return result;
70 }
71 
73  : MythBufferVulkan(Vulkan, Size)
74 {
75 }
76 
77 void MythVertexBufferVulkan::Update(const QRect Source, const QRect Dest,
78  int Alpha, int Rotation, VkCommandBuffer CommandBuffer)
79 {
81  m_source = Source;
82  m_dest = Dest;
83  m_alpha = Alpha;
84  m_rotation = Rotation;
85 }
86 
87 bool MythVertexBufferVulkan::NeedsUpdate(const QRect Source, const QRect Dest, int Alpha, int Rotation)
88 {
89  return !((m_source == Source) && (m_dest == Dest) && (m_alpha == Alpha) && (m_rotation == Rotation));
90 }
MythVertexBufferVulkan::Update
void Update(QRect Source, QRect Dest, int Alpha, int Rotation, VkCommandBuffer CommandBuffer=nullptr)
Definition: mythvertexbuffervulkan.cpp:77
Source
static QString Source(const QNetworkRequest &request)
Definition: netstream.cpp:144
MythVertexBufferVulkan::NeedsUpdate
bool NeedsUpdate(QRect Source, QRect Dest, int Alpha, int Rotation)
Definition: mythvertexbuffervulkan.cpp:87
MythBufferVulkan::m_stagingMemory
VkDeviceMemory m_stagingMemory
Definition: mythvertexbuffervulkan.h:24
MythRenderVulkan::CopyBuffer
void CopyBuffer(VkBuffer Src, VkBuffer Dst, VkDeviceSize Size, VkCommandBuffer CommandBuffer=nullptr)
Definition: mythrendervulkan.cpp:433
MythBufferVulkan::m_mappedMemory
void * m_mappedMemory
Definition: mythvertexbuffervulkan.h:25
MythVertexBufferVulkan::MythVertexBufferVulkan
MythVertexBufferVulkan(MythVulkanObject *Vulkan, VkDeviceSize Size)
Definition: mythvertexbuffervulkan.cpp:72
MythVulkanObject
Definition: mythrendervulkan.h:29
MythBufferVulkan::m_stagingBuffer
VkBuffer m_stagingBuffer
Definition: mythvertexbuffervulkan.h:23
MythVertexBufferVulkan
Definition: mythvertexbuffervulkan.h:31
MythBufferVulkan::MythBufferVulkan
MythBufferVulkan(MythVulkanObject *Vulkan, VkDeviceSize Size)
Definition: mythvertexbuffervulkan.cpp:18
MythVertexBufferVulkan::m_alpha
int m_alpha
Definition: mythvertexbuffervulkan.h:47
MythBufferVulkan::GetBuffer
VkBuffer GetBuffer() const
Definition: mythvertexbuffervulkan.cpp:46
MythVulkanObject::m_vulkanValid
bool m_vulkanValid
Definition: mythrendervulkan.h:44
MythBufferVulkan::m_buffer
VkBuffer m_buffer
Definition: mythvertexbuffervulkan.h:21
MythVulkanObject::m_vulkanDevice
VkDevice m_vulkanDevice
Definition: mythrendervulkan.h:46
MythVulkanObject::m_vulkanRender
MythRenderVulkan * m_vulkanRender
Definition: mythrendervulkan.h:45
mythlogging.h
MythBufferVulkan::~MythBufferVulkan
virtual ~MythBufferVulkan()
Definition: mythvertexbuffervulkan.cpp:35
Source
Definition: channelsettings.cpp:68
MythVertexBufferVulkan::Create
static MythVertexBufferVulkan * Create(MythVulkanObject *Vulkan, VkDeviceSize Size)
Definition: mythvertexbuffervulkan.cpp:61
mythvertexbuffervulkan.h
MythBufferVulkan::Create
static MythBufferVulkan * Create(MythVulkanObject *Vulkan, VkDeviceSize Size)
Definition: mythvertexbuffervulkan.cpp:7
MythVulkanObject::m_vulkanFuncs
QVulkanDeviceFunctions * m_vulkanFuncs
Definition: mythrendervulkan.h:47
MythBufferVulkan::m_bufferMemory
VkDeviceMemory m_bufferMemory
Definition: mythvertexbuffervulkan.h:22
MythBufferVulkan::Update
void Update(VkCommandBuffer CommandBuffer=nullptr)
Definition: mythvertexbuffervulkan.cpp:56
MythVertexBufferVulkan::m_source
QRect m_source
Definition: mythvertexbuffervulkan.h:44
MythBufferVulkan::m_bufferSize
VkDeviceSize m_bufferSize
Definition: mythvertexbuffervulkan.h:20
MythVertexBufferVulkan::m_dest
QRect m_dest
Definition: mythvertexbuffervulkan.h:45
MythVertexBufferVulkan::m_rotation
int m_rotation
Definition: mythvertexbuffervulkan.h:46
MythRenderVulkan::CreateBuffer
bool CreateBuffer(VkDeviceSize Size, VkBufferUsageFlags Usage, VkMemoryPropertyFlags Properties, VkBuffer &Buffer, VkDeviceMemory &Memory)
Definition: mythrendervulkan.cpp:450
MythBufferVulkan::GetMappedMemory
void * GetMappedMemory() const
Definition: mythvertexbuffervulkan.cpp:51
MythBufferVulkan
Definition: mythvertexbuffervulkan.h:7