SpiecsEngine
 
Loading...
Searching...
No Matches
NsightPerfGPUProfilerHUD.h
Go to the documentation of this file.
1/**
2* @file NsightPerfGPUProfilerHUD.h
3* @brief The NsightPerfGPUProfilerHUD Class Definitions.
4* @author Spices
5*/
6
7#pragma once
8#include "Core/Core.h"
9#include "Render/Vulkan/VulkanUtils.h"
10
11#include <NvPerfHudDataModel.h>
12#include <NvPerfHudImPlotRenderer.h>
13#include <NvPerfPeriodicSamplerVulkan.h>
14#include <NvPerfReportGeneratorVulkan.h>
15
16namespace Spices {
17
18 /**
19 * @brief Wrapper of Nvidia Nsight Performance HUD.
20 */
22 {
23 public:
24
25 /**
26 * @brief Constructor Function.
27 * @param[in] state VulkanState.
28 */
30
31 /**
32 * @brief Destructor Function.
33 */
34 virtual ~NsightPerfGPUProfilerHUD() = default;
35
36 /**
37 * @brief Create this.
38 */
39 void Create(VulkanState& state);
40
41 /**
42 * @brief Create this Single Instance.
43 * @param[in] state VulkanState.
44 */
45 static void CreateInstance(VulkanState& state);
46
47 /**
48 * @brief Get this Single Instance.
49 * @return Returns this Single Instance.
50 */
52
53 /**
54 * @brief Initialize ImGui, ImPlot and pass the data model into HUD Renderer.
55 */
56 void InitHUDRenderer();
57
58 /**
59 * @brief Inform the sampler about the frame end, and use the HUD renderer to visualize the populated
60 * data model.
61 */
62 void RenderHUD();
63
64 /**
65 * @brief Set if is needed in session.
66 * @param[in] inSession True if is needed in session.
67 */
68 void SetInSession(bool inSession) { m_IsInSession = inSession; }
69
70 /**
71 * @brief Samples to be periodically fetched and processed by the sampler utility classes. Caveat: If this
72 * is not done, the sampler can fall into an irrecoverable state. Choose maxDecodeLatency to
73 * cover for a large-enough delay. Frame boundaries are recorded so that per-frame values, of e.g.
74 * draw call counts, can be shown as well as per-sample values.
75 */
76 void ConsumeSample();
77
78 /***
79 * @brief Query Device Extensions Requirements.
80 * @param[in] instance VkInstance.
81 * @param[in] physicalDevice VkPhysicalDevice.
82 * @param[in,out] deviceExtensionNames Extensions.
83 */
85 VkInstance instance ,
86 VkPhysicalDevice physicalDevice ,
87 std::vector<const char*>& deviceExtensionNames
88 );
89
90 /**
91 * @brief Query Instance Extension Requirements.
92 * @param[in,out] instanceExtensionNames Extensions.
93 * @param[in] apiVersion Vulkan API Version.
94 */
95 static void QueryInstanceExtensionRequirement(std::vector<const char*>& instanceExtensionNames, uint32_t apiVersion);
96
97 /**
98 * @brief End Sampler Frame.
99 */
100 void EndFrame(VulkanState& state);
101
102 /**
103 * @brief Reset Sampler.
104 */
105 void Reset();
106
107 private:
108
109 /**
110 * @brief Select a SamplingFrequency (Hz) by ImGui::IO.
111 * @return Returns SamplingFrequency.
112 */
113 uint32_t SelectSamplingFrequency() const;
114
115 private:
116
117 /**
118 * @brief VulkanState.
119 */
121
122 /**
123 * @brief This Single Instance.
124 */
126
127 /**
128 * @brief Sampler.
129 */
131
132 /**
133 * @brief HUD data.
134 */
136
137 /**
138 * @brief HUD imgui renderer.
139 */
141
142 /**
143 * @brief True if Decode and Consume failed.
144 */
146
147 /**
148 * @brief True if in a Session.
149 */
151
152 /**
153 * @brief True id HUD is initialized.
154 */
156 };
157
158#define NSIGHTPERF_GPUPROFILERHUD_QUERYDEVICEEXTENSION(...) { ::Spices::NsightPerfGPUProfilerHUD::QueryDeviceExtensionRequirement(__VA_ARGS__); }
159#define NSIGHTPERF_GPUPROFILERHUD_QUERYINSTANCEEXTENSION(...) { ::Spices::NsightPerfGPUProfilerHUD::QueryInstanceExtensionRequirement(__VA_ARGS__); }
160
161#ifdef SPICES_DEBUG
162
163#define NSIGHTPERF_GPUPROFILERHUD_CREATEINSTANCE(...) { ::Spices::NsightPerfGPUProfilerHUD::CreateInstance(__VA_ARGS__); }
164#define NSIGHTPERF_GPUPROFILERHUD_INITHUDRENDERER { ::Spices::NsightPerfGPUProfilerHUD::Get().InitHUDRenderer(); }
165#define NSIGHTPERF_GPUPROFILERHUD_FRAMECONSUME { ::Spices::NsightPerfGPUProfilerHUD::Get().ConsumeSample(); }
166#define NSIGHTPERF_GPUPROFILERHUD_RENDERHUD { ::Spices::NsightPerfGPUProfilerHUD::Get().RenderHUD(); }
167#define NSIGHTPERF_GPUPROFILERHUD_SETINSESSION(...) { ::Spices::NsightPerfGPUProfilerHUD::Get().SetInSession(__VA_ARGS__); }
168#define NSIGHTPERF_GPUPROFILERHUD_ENDFRAME(...) { ::Spices::NsightPerfGPUProfilerHUD::Get().EndFrame(__VA_ARGS__); }
169#define NSIGHTPERF_GPUPROFILERHUD_RESET { ::Spices::NsightPerfGPUProfilerHUD::Get().Reset(); }
170
171#endif
172
173#ifdef SPICES_RELEASE
174
175#define NSIGHTPERF_GPUPROFILERHUD_CREATEINSTANCE(...)
176#define NSIGHTPERF_GPUPROFILERHUD_INITHUDRENDERER
177#define NSIGHTPERF_GPUPROFILERHUD_FRAMECONSUME
178#define NSIGHTPERF_GPUPROFILERHUD_RENDERHUD
179#define NSIGHTPERF_GPUPROFILERHUD_SETINSESSION(...)
180#define NSIGHTPERF_GPUPROFILERHUD_ENDFRAME(...)
181#define NSIGHTPERF_GPUPROFILERHUD_RESET
182
183#endif
184
185}
#define NSPERF_CHECK(val)
#define SPICES_PROFILE_ZONE
nv::perf::sampler::PeriodicSamplerTimeHistoryVulkan m_Sampler
Sampler.
void Create(VulkanState &state)
Create this.
NsightPerfGPUProfilerHUD(VulkanState &state)
Constructor Function.
void RenderHUD()
Inform the sampler about the frame end, and use the HUD renderer to visualize the populated data mode...
bool m_IsReachBufferBound
True if Decode and Consume failed.
void ConsumeSample()
Samples to be periodically fetched and processed by the sampler utility classes. Caveat: If this is n...
void SetInSession(bool inSession)
Set if is needed in session.
void EndFrame(VulkanState &state)
End Sampler Frame.
static void QueryDeviceExtensionRequirement(VkInstance instance, VkPhysicalDevice physicalDevice, std::vector< const char * > &deviceExtensionNames)
virtual ~NsightPerfGPUProfilerHUD()=default
Destructor Function.
static std::shared_ptr< NsightPerfGPUProfilerHUD > m_NsightPerfGPUProfilerHUD
This Single Instance.
static void CreateInstance(VulkanState &state)
Create this Single Instance.
bool m_IsHUDInitialized
True id HUD is initialized.
static void QueryInstanceExtensionRequirement(std::vector< const char * > &instanceExtensionNames, uint32_t apiVersion)
Query Instance Extension Requirements.
uint32_t SelectSamplingFrequency() const
Select a SamplingFrequency (Hz) by ImGui::IO.
void InitHUDRenderer()
Initialize ImGui, ImPlot and pass the data model into HUD Renderer.
nv::perf::hud::HudImPlotRenderer m_HudRenderer
HUD imgui renderer.
static NsightPerfGPUProfilerHUD & Get()
Get this Single Instance.
nv::perf::hud::HudDataModel m_HudDataModel
HUD data.
Wrapper of Nvidia Nsight Performance HUD.
This struct contains all Vulkan object in used global.
Definition VulkanUtils.h:74