MythTV  master
mythdebugvulkan.cpp
Go to the documentation of this file.
1 // MythTV
2 #include "mythlogging.h"
5 
6 #define LOC QString("VulkanMarker: ")
7 
8 MythVulkan4F const MythDebugVulkan::kDebugRed { 1.0, 0.0, 0.0, 1.0 };
9 MythVulkan4F const MythDebugVulkan::kDebugGreen { 0.0, 1.0, 0.0, 1.0 };
10 MythVulkan4F const MythDebugVulkan::kDebugBlue { 0.0, 0.0, 1.0, 1.0 };
11 MythVulkan4F const MythDebugVulkan::kDebugGray { 0.5, 0.5, 0.5, 1.0 };
12 MythVulkan4F const MythDebugVulkan::kDebugBlack { 0.0, 0.0, 0.0, 1.0 };
13 
15 {
16  auto * result = new MythDebugVulkan(Vulkan);
17  if (result && !result->IsValidVulkan())
18  {
19  delete result;
20  result = nullptr;
21  }
22  return result;
23 }
24 
26  : MythVulkanObject(Vulkan)
27 {
28  if (!m_vulkanValid)
29  return;
30 
31  m_vulkanValid = false;
32  if (m_vulkanWindow->supportedDeviceExtensions().contains(VK_EXT_DEBUG_MARKER_EXTENSION_NAME))
33  {
34  m_beginRegion = reinterpret_cast<PFN_vkCmdDebugMarkerBeginEXT>(
35  m_vulkanWindow->vulkanInstance()->getInstanceProcAddr("vkCmdDebugMarkerBeginEXT"));
36  m_endRegion = reinterpret_cast<PFN_vkCmdDebugMarkerEndEXT>(
37  m_vulkanWindow->vulkanInstance()->getInstanceProcAddr("vkCmdDebugMarkerEndEXT"));
38  m_nameObject = reinterpret_cast<PFN_vkDebugMarkerSetObjectNameEXT>(
39  m_vulkanWindow->vulkanInstance()->getInstanceProcAddr("vkDebugMarkerSetObjectNameEXT"));
41  m_vulkanValid = true;
42  else
43  LOG(VB_GENERAL, LOG_INFO, LOC + "Failed to load procs");
44  }
45  else
46  {
47  LOG(VB_GENERAL, LOG_INFO, LOC + "Extension not found");
48  }
49 }
50 
51 void MythDebugVulkan::BeginRegion(VkCommandBuffer CmdBuffer, const char *Name, const MythVulkan4F Color)
52 {
53  VkDebugMarkerMarkerInfoEXT begin =
54  { VK_STRUCTURE_TYPE_DEBUG_MARKER_MARKER_INFO_EXT, nullptr, Name,
55  { Color[0], Color[1], Color[2], Color[3] } };
56  m_beginRegion(CmdBuffer, &begin);
57 }
58 
59 void MythDebugVulkan::EndRegion(VkCommandBuffer CmdBuffer)
60 {
61  m_endRegion(CmdBuffer);
62 }
63 
64 void MythDebugVulkan::NameObject(uint64_t Object, VkDebugReportObjectTypeEXT Type, const char *Name)
65 {
66  VkDebugMarkerObjectNameInfoEXT info { };
67  info.sType = VK_STRUCTURE_TYPE_DEBUG_MARKER_OBJECT_NAME_INFO_EXT;
68  info.objectType = Type;
69  info.object = Object;
70  info.pObjectName = Name;
72 }
mythwindowvulkan.h
mythdebugvulkan.h
MythDebugVulkan
Definition: mythdebugvulkan.h:8
MythVulkanObject
Definition: mythrendervulkan.h:29
MythDebugVulkan::kDebugRed
static const MythVulkan4F kDebugRed
Definition: mythdebugvulkan.h:11
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:23
MythVulkanObject::m_vulkanValid
bool m_vulkanValid
Definition: mythrendervulkan.h:44
MythVulkanObject::m_vulkanDevice
VkDevice m_vulkanDevice
Definition: mythrendervulkan.h:46
MythDebugVulkan::Create
static MythDebugVulkan * Create(MythVulkanObject *Vulkan)
Definition: mythdebugvulkan.cpp:14
MythDebugVulkan::m_nameObject
PFN_vkDebugMarkerSetObjectNameEXT m_nameObject
Definition: mythdebugvulkan.h:29
mythlogging.h
MythDebugVulkan::kDebugGray
static const MythVulkan4F kDebugGray
Definition: mythdebugvulkan.h:14
MythDebugVulkan::m_endRegion
PFN_vkCmdDebugMarkerEndEXT m_endRegion
Definition: mythdebugvulkan.h:28
MythDebugVulkan::BeginRegion
void BeginRegion(VkCommandBuffer CmdBuffer, const char *Name, MythVulkan4F Color)
Definition: mythdebugvulkan.cpp:51
MythDebugVulkan::kDebugBlack
static const MythVulkan4F kDebugBlack
Definition: mythdebugvulkan.h:15
MythDebugVulkan::kDebugBlue
static const MythVulkan4F kDebugBlue
Definition: mythdebugvulkan.h:13
MythVulkan4F
std::array< float, 4 > MythVulkan4F
Definition: mythrendervulkan.h:20
MythDebugVulkan::MythDebugVulkan
MythDebugVulkan(MythVulkanObject *Vulkan)
Definition: mythdebugvulkan.cpp:25
Name
Definition: channelsettings.cpp:46
MythDebugVulkan::kDebugGreen
static const MythVulkan4F kDebugGreen
Definition: mythdebugvulkan.h:12
MythVulkanObject::m_vulkanWindow
MythWindowVulkan * m_vulkanWindow
Definition: mythrendervulkan.h:48
LOC
#define LOC
Definition: mythdebugvulkan.cpp:6
MythDebugVulkan::m_beginRegion
PFN_vkCmdDebugMarkerBeginEXT m_beginRegion
Definition: mythdebugvulkan.h:27
MythDebugVulkan::EndRegion
void EndRegion(VkCommandBuffer CmdBuffer)
Definition: mythdebugvulkan.cpp:59
MythDebugVulkan::NameObject
void NameObject(uint64_t Object, VkDebugReportObjectTypeEXT Type, const char *Name)
Definition: mythdebugvulkan.cpp:64
Color
Definition: graphic.h:6