Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
Profiler.h
Go to the documentation of this file.
1/*
2Copyright (c) 2018 DIVIDE-Studio
3Copyright (c) 2009 Ionut Cava
4
5This file is part of DIVIDE Framework.
6
7Permission is hereby granted, free of charge, to any person obtaining a copy
8of this software
9and associated documentation files (the "Software"), to deal in the Software
10without restriction,
11including without limitation the rights to use, copy, modify, merge, publish,
12distribute, sublicense,
13and/or sell copies of the Software, and to permit persons to whom the
14Software is furnished to do so,
15subject to the following conditions:
16
17The above copyright notice and this permission notice shall be included in
18all copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21IMPLIED,
22INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
23PARTICULAR PURPOSE AND NONINFRINGEMENT.
24IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
25DAMAGES OR OTHER LIABILITY,
26WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
27IN CONNECTION WITH THE SOFTWARE
28OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
30*/
31
32#pragma once
33#ifndef DVD_PROFILER_H_
34#define DVD_PROFILER_H_
35
36#include "config.h"
37
38#include <optick.h>
39
40namespace Divide
41{
42class Application;
43
44namespace Profiler
45{
46namespace detail
47{
49};
50
51void Initialise();
52void RegisterApp(Application* app);
53void Shutdown();
54void OnThreadStart(std::string_view threadName);
55void OnThreadStop();
56
57
58namespace Category
59{
60 constexpr Optick::Category::Type Graphics = Optick::Category::Rendering;
61 constexpr Optick::Category::Type Sound = Optick::Category::Audio;
62 constexpr Optick::Category::Type Physics = Optick::Category::Physics;
63 constexpr Optick::Category::Type GameLogic = Optick::Category::GameLogic;
64 constexpr Optick::Category::Type GUI = Optick::Category::UI;
65 constexpr Optick::Category::Type Streaming = Optick::Category::Streaming;
66 constexpr Optick::Category::Type Scene = Optick::Category::Scene;
67 constexpr Optick::Category::Type Threading = Optick::Category::Wait;
68 constexpr Optick::Category::Type IO = Optick::Category::IO;
69};
70
71enum class State : U8
72{
73 STARTED = 0u,
74 STOPPED,
75 COUNT
76};
77
78bool OnProfilerStateChanged( const Profiler::State state );
79
80}; //namespace Profiler
81
82}; //namespace Divide
83
84// static_assert(true, "") added at the end to force require a semicolon after the macros
85
86#define PROFILE_SCOPE(NAME, CATEGORY) OPTICK_EVENT(NAME, CATEGORY); static_assert(true, "")
87#define PROFILE_SCOPE_AUTO(CATEGORY) OPTICK_EVENT(OPTICK_FUNC, CATEGORY); static_assert(true, "")
88#define PROFILE_TAG(NAME, ...) OPTICK_TAG( NAME, __VA_ARGS__ ); static_assert(true, "")
89#define PROFILE_FRAME(NAME) NO_DESTROY OPTICK_FRAME( NAME ); static_assert(true, "")
90
91
92#if 1
93
94#define PROFILE_VK_INIT(DEVICES, PHYSICAL_DEVICES, CMD_QUEUES, CMD_QUEUES_FAMILY, NUM_CMD_QUEUS, FUNCTIONS) OPTICK_GPU_INIT_VULKAN(DEVICES, PHYSICAL_DEVICES, CMD_QUEUES, CMD_QUEUES_FAMILY, NUM_CMD_QUEUS, FUNCTIONS); static_assert(true, "")
95#define PROFILE_VK_PRESENT(SWAP_CHAIN) OPTICK_GPU_FLIP(SWAP_CHAIN); static_assert(true, "")
96
97#define PROFILE_VK_EVENT_AUTO() OPTICK_GPU_EVENT(OPTICK_FUNC); static_assert(true, "")
98#define PROFILE_VK_EVENT(NAME) OPTICK_GPU_EVENT(NAME); static_assert(true, "")
99#define PROFILE_VK_EVENT_AND_CONTEX(NAME, BUFFER) OPTICK_GPU_CONTEXT(BUFFER) \
100 PROFILE_VK_EVENT(NAME); static_assert(true, "")
101#define PROFILE_VK_EVENT_AUTO_AND_CONTEX(BUFFER) PROFILE_VK_EVENT_AND_CONTEX(OPTICK_FUNC, BUFFER); static_assert(true, "")
102
103#else
104
105#define PROFILE_VK_INIT(DEVICES, PHYSICAL_DEVICES, CMD_QUEUES, CMD_QUEUES_FAMILY, NUM_CMD_QUEUS, FUNCTIONS) static_assert(true, "")
106#define PROFILE_VK_PRESENT(SWAP_CHAIN) static_assert(true, "")
107
108#define PROFILE_VK_EVENT_AUTO() PROFILE_SCOPE_AUTO(Profiler::Category::Graphics ); static_assert(true, "")
109#define PROFILE_VK_EVENT(NAME) PROFILE_SCOPE(NAME, Profiler::Category::Graphics ); static_assert(true, "")
110#define PROFILE_VK_EVENT_AND_CONTEX(NAME, BUFFER) PROFILE_VK_EVENT(NAME); static_assert(true, "")
111#define PROFILE_VK_EVENT_AUTO_AND_CONTEX(BUFFER) PROFILE_VK_EVENT_AUTO(); static_assert(true, "")
112
113#endif
114
115#endif //DVD_PROFILER_H_
Class that provides an interface between our framework and the OS (start/stop, display support,...
Definition: Application.h:97
Graphical User Interface.
Definition: GUI.h:81
constexpr bool ENABLE_FUNCTION_PROFILING
Enable function level profiling.
Definition: config.h:87
constexpr Optick::Category::Type Sound
Definition: Profiler.h:61
constexpr Optick::Category::Type Physics
Definition: Profiler.h:62
constexpr Optick::Category::Type Streaming
Definition: Profiler.h:65
constexpr Optick::Category::Type IO
Definition: Profiler.h:68
constexpr Optick::Category::Type Threading
Definition: Profiler.h:67
constexpr Optick::Category::Type GameLogic
Definition: Profiler.h:63
constexpr Optick::Category::Type Graphics
Definition: Profiler.h:60
constexpr bool enabled
Definition: Profiler.h:48
bool OnProfilerStateChanged(const Profiler::State state)
Definition: Profiler.cpp:13
void OnThreadStart(std::string_view threadName)
Definition: Profiler.cpp:76
void RegisterApp(Application *app)
Definition: Profiler.cpp:37
void OnThreadStop()
Definition: Profiler.cpp:83
void Initialise()
Definition: Profiler.cpp:42
Handle console commands that start with a forward slash.
Definition: AIProcessor.cpp:7
uint8_t U8