sandbox
Loading...
Searching...
No Matches
profiler.hpp
1// SPDX-License-Identifier: MIT
2#ifndef LIBSBX_GRAPHICS_PROFILER_HPP_
3#define LIBSBX_GRAPHICS_PROFILER_HPP_
4
5#if defined(SBX_PROFILING_ENABLED)
6
7#include <vulkan/vulkan.h>
8
9#include <tracy/Tracy.hpp>
10#include <tracy/TracyC.h>
11#include <tracy/TracyVulkan.hpp>
12
13#include <libsbx/graphics/devices/physical_device.hpp>
14#include <libsbx/graphics/devices/logical_device.hpp>
15
16namespace sbx::graphics::detail {
17
18auto register_gpu_context(const queue::type type, const char* name, std::uint16_t size, const physical_device& physical_device, const logical_device& logical_device) -> void;
19
20auto destroy_gpu_contexts() -> void;
21
22auto gpu_context(const queue::type queue) noexcept -> TracyVkCtx;
23
24} // namespace sbx::graphics::detail
25
26#define SBX_PROFILE_GPU_CONTEXT_CREATE(type, name, name_size, physical_device, logical_device) \
27 sbx::graphics::detail::register_gpu_context(type, name, name_size, physical_device, logical_device)
28
29#define SBX_PROFILE_GPU_CONTEXT_DESTROY() \
30 sbx::graphics::detail::destroy_gpu_contexts()
31
32#define SBX_PROFILE_GPU_COLLECT(command_buffer) \
33 TracyVkCollect(sbx::graphics::detail::gpu_context(command_buffer.type()), command_buffer)
34
35#define SBX_PROFILE_GPU_SCOPE(command_buffer, name) \
36 TracyVkZone(sbx::graphics::detail::gpu_context(command_buffer.type()), command_buffer, name)
37
38#define SBX_PROFILE_GPU_SCOPE_COLORED(command_buffer, name, color) \
39 TracyVkZoneC(sbx::graphics::detail::gpu_context(command_buffer.type()), command_buffer, name, color)
40
41#else
42
43#define SBX_PROFILE_GPU_CONTEXT_CREATE(type, name, name_size, physical_device, logical_device) static_cast<void>(0)
44#define SBX_PROFILE_GPU_CONTEXT_DESTROY() static_cast<void>(0)
45#define SBX_PROFILE_GPU_COLLECT(command_buffer) static_cast<void>(0)
46#define SBX_PROFILE_GPU_SCOPE(command_buffer, name) static_cast<void>(0)
47#define SBX_PROFILE_GPU_SCOPE_COLORED(command_buffer, name, color) static_cast<void>(0)
48
49#endif
50
51#endif // LIBSBX_GRAPHICS_PROFILER_HPP_