VOX
A little voxel engine
Loading...
Searching...
No Matches
DebugGui.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "Camera.hpp"
4
5#include "imgui.h"
6
7#include <string>
8#include <mutex>
9#include <atomic>
10#include <array>
11#include <algorithm>
12#include <numeric>
13#include "Tracy.hpp"
14
15template <typename T>
16class Atomic
17{
18
19public:
20
21 Atomic() = default;
22 Atomic(T value) : m_value(value) {}
23
24 T get() const
25 {
26 std::lock_guard lock(m_mutex);
27 return m_value;
28 }
29
30 void set(T value)
31 {
32 std::lock_guard lock(m_mutex);
33 m_value = value;
34 }
35
36 operator T() const
37 {
38 return get();
39 }
40
42 {
43 set(value);
44 return *this;
45 }
46
47private:
48
49 T m_value;
50 mutable std::mutex m_mutex;
51
52};
53
54template <typename T, int N>
56{
57
58public:
59
60 void push(T value)
61 {
62 std::lock_guard lock(m_mutex);
63 m_sum += value;
64 m_sum -= m_history[0];
65 std::shift_left(m_history.begin(), m_history.end(), 1);
66 m_history[N - 1] = value;
67 }
68
69 T average() const
70 {
71 std::lock_guard lock(m_mutex);
72 return m_sum / N;
73 }
74
75 std::unique_lock<std::mutex> lock() const
76 {
77 return std::unique_lock(m_mutex);
78 }
79
80 T * data()
81 {
82 return m_history.data();
83 }
84
85 int size() const
86 {
87 return N;
88 }
89
90private:
91
92 std::array<T, N> m_history;
93 T m_sum = 0;
94 mutable std::mutex m_mutex;
95
96};
97
99{
100
101public:
102
103 static constexpr int NOISE_SIZE = 256;
104
105
106 static inline std::atomic<uint32_t> fps = 0;
107 static inline std::atomic<uint32_t> ups = 0;
108 static inline std::atomic<uint64_t> rendered_triangles = 0;
109 static inline std::atomic<uint64_t> gpu_allocated_memory = 0;
110
113 static inline std::atomic<double> player_velocity;
114 static inline std::atomic<int> looked_face_sky_light;
115 static inline std::atomic<int> looked_face_block_light;
116
117 static inline std::atomic<float> continentalness;
118 static inline std::atomic<float> erosion;
119 static inline std::atomic<float> humidity;
120 static inline std::atomic<float> weirdness;
121 static inline std::atomic<float> PV;
122 static inline std::atomic<float> temperature;
123 static inline std::atomic<bool> isLand;
124 static inline std::atomic<bool> isOcean;
125 static inline std::atomic<uint8_t> biome;
126
127 // Render Thread times
131
132 static inline std::atomic_int32_t chunk_mesh_count = 0;
133
135
138
142
143 static inline std::atomic<double> create_mesh_time;
144
145 static inline std::atomic<size_t> send_buffer_size;
146 static inline std::atomic<size_t> recv_buffer_size;
147
150
151 static inline std::atomic<float> sun_theta = 70.0f;
152 static inline std::atomic<float> earth_radius = 6360000.0f;
153 static inline std::atomic<float> atmosphere_radius = 6420000.0f;
154 static inline std::atomic<float> player_height = 1.0f;
155 static inline Atomic<glm::vec3> beta_rayleigh = glm::vec3(5.8e-6, 13.5e-6, 33.1e-6);
156 static inline Atomic<glm::vec3> beta_mie = glm::vec3(21e-6);
157 static inline std::atomic<float> sun_intensity = 20.0f;
158 static inline std::atomic<float> h_rayleigh = 7994.0f;
159 static inline std::atomic<float> h_mie = 1200.0f;
160 static inline std::atomic<float> g = 0.95f;
161 static inline std::atomic<int> n_samples = 8.0f;
162 static inline std::atomic<int> n_light_samples = 4.0f;
163
164 static inline std::atomic<uint64_t> imgui_texture_id = 0;
165
166 static inline std::atomic<uint64_t> continentalness_texture_id = 0;
167 static inline std::atomic<uint64_t> weirdness_texture_id = 0;
168 static inline std::atomic<uint64_t> temperature_texture_id = 0;
169 static inline std::atomic<uint64_t> PV_texture_id = 0;
170 static inline std::atomic<uint64_t> erosion_texture_id = 0;
171 static inline std::atomic<uint64_t> humidity_texture_id = 0;
172 static inline std::atomic<uint64_t> biome_texture_id = 0;
173};
Definition: DebugGui.hpp:17
Atomic()=default
Atomic(T value)
Definition: DebugGui.hpp:22
void set(T value)
Definition: DebugGui.hpp:30
T get() const
Definition: DebugGui.hpp:24
Atomic< T > & operator=(T value)
Definition: DebugGui.hpp:41
Definition: DebugGui.hpp:99
static std::atomic< float > sun_intensity
Definition: DebugGui.hpp:157
static std::atomic< float > weirdness
Definition: DebugGui.hpp:120
static History< float, 100 > chunk_count_history
Definition: DebugGui.hpp:134
static std::atomic< int > n_samples
Definition: DebugGui.hpp:161
static std::atomic< uint8_t > biome
Definition: DebugGui.hpp:125
static History< float, 100 > cpu_time_history
Definition: DebugGui.hpp:129
static Atomic< glm::vec3 > player_position
Definition: DebugGui.hpp:111
static History< float, 100 > chunk_unload_time_history
Definition: DebugGui.hpp:141
static std::atomic< float > erosion
Definition: DebugGui.hpp:118
static std::atomic< float > atmosphere_radius
Definition: DebugGui.hpp:153
static std::atomic< float > player_height
Definition: DebugGui.hpp:154
static std::atomic< float > humidity
Definition: DebugGui.hpp:119
static std::atomic< size_t > send_buffer_size
Definition: DebugGui.hpp:145
static std::atomic< uint64_t > humidity_texture_id
Definition: DebugGui.hpp:171
static std::atomic< bool > isLand
Definition: DebugGui.hpp:123
static History< float, 1000 > chunk_load_queue_size_history
Definition: DebugGui.hpp:136
static std::atomic< uint64_t > gpu_allocated_memory
Definition: DebugGui.hpp:109
static std::atomic< float > sun_theta
Definition: DebugGui.hpp:151
static std::atomic< int > looked_face_block_light
Definition: DebugGui.hpp:115
static std::atomic< bool > isOcean
Definition: DebugGui.hpp:124
static Atomic< glm::vec3 > beta_mie
Definition: DebugGui.hpp:156
static Atomic< glm::vec3 > beta_rayleigh
Definition: DebugGui.hpp:155
static Atomic< glm::vec3 > player_velocity_vec
Definition: DebugGui.hpp:112
static std::atomic< uint64_t > PV_texture_id
Definition: DebugGui.hpp:169
static std::atomic< uint64_t > weirdness_texture_id
Definition: DebugGui.hpp:167
static std::atomic< int > n_light_samples
Definition: DebugGui.hpp:162
static std::atomic< double > create_mesh_time
Definition: DebugGui.hpp:143
static std::atomic< float > continentalness
Definition: DebugGui.hpp:117
static std::atomic< uint64_t > continentalness_texture_id
Definition: DebugGui.hpp:166
static std::atomic< uint64_t > erosion_texture_id
Definition: DebugGui.hpp:170
static std::atomic< float > h_rayleigh
Definition: DebugGui.hpp:158
static std::atomic< uint64_t > temperature_texture_id
Definition: DebugGui.hpp:168
static std::atomic< int > looked_face_sky_light
Definition: DebugGui.hpp:114
static std::atomic< float > earth_radius
Definition: DebugGui.hpp:152
static std::atomic< uint32_t > ups
Definition: DebugGui.hpp:107
static constexpr int NOISE_SIZE
Definition: DebugGui.hpp:103
static History< size_t, 100 > send_history
Definition: DebugGui.hpp:148
static std::atomic< uint64_t > biome_texture_id
Definition: DebugGui.hpp:172
static std::atomic< float > g
Definition: DebugGui.hpp:160
static std::atomic< size_t > recv_buffer_size
Definition: DebugGui.hpp:146
static History< float, 100 > chunk_render_time_history
Definition: DebugGui.hpp:139
static std::atomic< float > PV
Definition: DebugGui.hpp:121
static std::atomic< uint32_t > fps
Definition: DebugGui.hpp:106
static History< float, 1000 > chunk_unload_queue_size_history
Definition: DebugGui.hpp:137
static History< float, 100 > frame_time_history
Definition: DebugGui.hpp:128
static std::atomic< float > temperature
Definition: DebugGui.hpp:122
static std::atomic< uint64_t > rendered_triangles
Definition: DebugGui.hpp:108
static History< float, 100 > cpu_wait_time_history
Definition: DebugGui.hpp:130
static std::atomic< double > player_velocity
Definition: DebugGui.hpp:113
static std::atomic_int32_t chunk_mesh_count
Definition: DebugGui.hpp:132
static History< float, 100 > chunk_gen_time_history
Definition: DebugGui.hpp:140
static History< size_t, 100 > recv_history
Definition: DebugGui.hpp:149
static std::atomic< float > h_mie
Definition: DebugGui.hpp:159
static std::atomic< uint64_t > imgui_texture_id
Definition: DebugGui.hpp:164
Definition: DebugGui.hpp:56
T * data()
Definition: DebugGui.hpp:80
void push(T value)
Definition: DebugGui.hpp:60
T average() const
Definition: DebugGui.hpp:69
int size() const
Definition: DebugGui.hpp:85
std::unique_lock< std::mutex > lock() const
Definition: DebugGui.hpp:75