summaryrefslogtreecommitdiff
path: root/servers/rendering
diff options
context:
space:
mode:
authorAaron Franke <arnfranke@yahoo.com>2021-02-01 21:16:37 -0500
committerAaron Franke <arnfranke@yahoo.com>2021-08-09 14:05:42 -0500
commit84f720966c74d5b37f70e21867e9e3e6a1e44c36 (patch)
tree770bb6c7c266c5266f4de3ceab52e756b55bf440 /servers/rendering
parent78d33a6e24a3977fc3a2c66808d7cbdddd3add11 (diff)
Use doubles for time in many other places
Diffstat (limited to 'servers/rendering')
-rw-r--r--servers/rendering/rasterizer_dummy.h10
-rw-r--r--servers/rendering/renderer_compositor.h2
-rw-r--r--servers/rendering/renderer_rd/renderer_compositor_rd.h4
-rw-r--r--servers/rendering/renderer_rd/renderer_storage_rd.cpp22
-rw-r--r--servers/rendering/renderer_rd/renderer_storage_rd.h20
-rw-r--r--servers/rendering/renderer_storage.h6
-rw-r--r--servers/rendering/rendering_server_default.cpp12
-rw-r--r--servers/rendering/rendering_server_default.h14
8 files changed, 45 insertions, 45 deletions
diff --git a/servers/rendering/rasterizer_dummy.h b/servers/rendering/rasterizer_dummy.h
index b7cf0983af..b2fffca3ea 100644
--- a/servers/rendering/rasterizer_dummy.h
+++ b/servers/rendering/rasterizer_dummy.h
@@ -540,13 +540,13 @@ public:
void particles_emit(RID p_particles, const Transform3D &p_transform, const Vector3 &p_velocity, const Color &p_color, const Color &p_custom, uint32_t p_emit_flags) override {}
void particles_set_emitting(RID p_particles, bool p_emitting) override {}
void particles_set_amount(RID p_particles, int p_amount) override {}
- void particles_set_lifetime(RID p_particles, float p_lifetime) override {}
+ void particles_set_lifetime(RID p_particles, double p_lifetime) override {}
void particles_set_one_shot(RID p_particles, bool p_one_shot) override {}
- void particles_set_pre_process_time(RID p_particles, float p_time) override {}
+ void particles_set_pre_process_time(RID p_particles, double p_time) override {}
void particles_set_explosiveness_ratio(RID p_particles, float p_ratio) override {}
void particles_set_randomness_ratio(RID p_particles, float p_ratio) override {}
void particles_set_custom_aabb(RID p_particles, const AABB &p_aabb) override {}
- void particles_set_speed_scale(RID p_particles, float p_scale) override {}
+ void particles_set_speed_scale(RID p_particles, double p_scale) override {}
void particles_set_use_local_coordinates(RID p_particles, bool p_enable) override {}
void particles_set_process_material(RID p_particles, RID p_material) override {}
void particles_set_fixed_fps(RID p_particles, int p_fps) override {}
@@ -724,7 +724,7 @@ public:
class RasterizerDummy : public RendererCompositor {
private:
uint64_t frame = 1;
- float delta = 0;
+ double delta = 0;
protected:
RasterizerCanvasDummy canvas;
@@ -765,7 +765,7 @@ public:
bool is_low_end() const override { return true; }
uint64_t get_frame_number() const override { return frame; }
- float get_frame_delta_time() const override { return delta; }
+ double get_frame_delta_time() const override { return delta; }
RasterizerDummy() {}
~RasterizerDummy() {}
diff --git a/servers/rendering/renderer_compositor.h b/servers/rendering/renderer_compositor.h
index 5fe9cdffba..6206849b66 100644
--- a/servers/rendering/renderer_compositor.h
+++ b/servers/rendering/renderer_compositor.h
@@ -85,7 +85,7 @@ public:
virtual void end_frame(bool p_swap_buffers) = 0;
virtual void finalize() = 0;
virtual uint64_t get_frame_number() const = 0;
- virtual float get_frame_delta_time() const = 0;
+ virtual double get_frame_delta_time() const = 0;
virtual bool is_low_end() const = 0;
virtual bool is_xr_enabled() const;
diff --git a/servers/rendering/renderer_rd/renderer_compositor_rd.h b/servers/rendering/renderer_rd/renderer_compositor_rd.h
index 15b3b77ed9..8639362da9 100644
--- a/servers/rendering/renderer_rd/renderer_compositor_rd.h
+++ b/servers/rendering/renderer_rd/renderer_compositor_rd.h
@@ -80,7 +80,7 @@ protected:
Map<RID, RID> render_target_descriptors;
double time;
- float delta;
+ double delta;
static uint64_t frame;
@@ -100,7 +100,7 @@ public:
void finalize();
_ALWAYS_INLINE_ uint64_t get_frame_number() const { return frame; }
- _ALWAYS_INLINE_ float get_frame_delta_time() const { return delta; }
+ _ALWAYS_INLINE_ double get_frame_delta_time() const { return delta; }
_ALWAYS_INLINE_ double get_total_time() const { return time; }
static Error is_viable() {
diff --git a/servers/rendering/renderer_rd/renderer_storage_rd.cpp b/servers/rendering/renderer_rd/renderer_storage_rd.cpp
index d5c7db6fd2..5b845cbb88 100644
--- a/servers/rendering/renderer_rd/renderer_storage_rd.cpp
+++ b/servers/rendering/renderer_rd/renderer_storage_rd.cpp
@@ -4091,7 +4091,7 @@ void RendererStorageRD::particles_set_amount(RID p_particles, int p_amount) {
particles->dependency.changed_notify(DEPENDENCY_CHANGED_PARTICLES);
}
-void RendererStorageRD::particles_set_lifetime(RID p_particles, float p_lifetime) {
+void RendererStorageRD::particles_set_lifetime(RID p_particles, double p_lifetime) {
Particles *particles = particles_owner.getornull(p_particles);
ERR_FAIL_COND(!particles);
particles->lifetime = p_lifetime;
@@ -4103,7 +4103,7 @@ void RendererStorageRD::particles_set_one_shot(RID p_particles, bool p_one_shot)
particles->one_shot = p_one_shot;
}
-void RendererStorageRD::particles_set_pre_process_time(RID p_particles, float p_time) {
+void RendererStorageRD::particles_set_pre_process_time(RID p_particles, double p_time) {
Particles *particles = particles_owner.getornull(p_particles);
ERR_FAIL_COND(!particles);
particles->pre_process_time = p_time;
@@ -4126,7 +4126,7 @@ void RendererStorageRD::particles_set_custom_aabb(RID p_particles, const AABB &p
particles->dependency.changed_notify(DEPENDENCY_CHANGED_AABB);
}
-void RendererStorageRD::particles_set_speed_scale(RID p_particles, float p_scale) {
+void RendererStorageRD::particles_set_speed_scale(RID p_particles, double p_scale) {
Particles *particles = particles_owner.getornull(p_particles);
ERR_FAIL_COND(!particles);
@@ -4442,7 +4442,7 @@ void RendererStorageRD::particles_set_canvas_sdf_collision(RID p_particles, bool
particles->sdf_collision_texture = p_texture;
}
-void RendererStorageRD::_particles_process(Particles *p_particles, float p_delta) {
+void RendererStorageRD::_particles_process(Particles *p_particles, double p_delta) {
if (p_particles->particles_material_uniform_set.is_null() || !RD::get_singleton()->uniform_set_is_valid(p_particles->particles_material_uniform_set)) {
Vector<RD::Uniform> uniforms;
@@ -4491,7 +4491,7 @@ void RendererStorageRD::_particles_process(Particles *p_particles, float p_delta
p_particles->particles_material_uniform_set = RD::get_singleton()->uniform_set_create(uniforms, particles_shader.default_shader_rd, 1);
}
- float new_phase = Math::fmod((float)p_particles->phase + (p_delta / p_particles->lifetime) * p_particles->speed_scale, (float)1.0);
+ double new_phase = Math::fmod((double)p_particles->phase + (p_delta / p_particles->lifetime) * p_particles->speed_scale, 1.0);
//move back history (if there is any)
for (uint32_t i = p_particles->frame_history.size() - 1; i > 0; i--) {
@@ -5131,14 +5131,14 @@ void RendererStorageRD::update_particles() {
bool zero_time_scale = Engine::get_singleton()->get_time_scale() <= 0.0;
if (particles->clear && particles->pre_process_time > 0.0) {
- float frame_time;
+ double frame_time;
if (fixed_fps > 0) {
frame_time = 1.0 / fixed_fps;
} else {
frame_time = 1.0 / 30.0;
}
- float todo = particles->pre_process_time;
+ double todo = particles->pre_process_time;
while (todo >= 0) {
_particles_process(particles, frame_time);
@@ -5147,8 +5147,8 @@ void RendererStorageRD::update_particles() {
}
if (fixed_fps > 0) {
- float frame_time;
- float decr;
+ double frame_time;
+ double decr;
if (zero_time_scale) {
frame_time = 0.0;
decr = 1.0 / fixed_fps;
@@ -5156,13 +5156,13 @@ void RendererStorageRD::update_particles() {
frame_time = 1.0 / fixed_fps;
decr = frame_time;
}
- float delta = RendererCompositorRD::singleton->get_frame_delta_time();
+ double delta = RendererCompositorRD::singleton->get_frame_delta_time();
if (delta > 0.1) { //avoid recursive stalls if fps goes below 10
delta = 0.1;
} else if (delta <= 0.0) { //unlikely but..
delta = 0.001;
}
- float todo = particles->frame_remainder + delta;
+ double todo = particles->frame_remainder + delta;
while (todo >= frame_time) {
_particles_process(particles, frame_time);
diff --git a/servers/rendering/renderer_rd/renderer_storage_rd.h b/servers/rendering/renderer_rd/renderer_storage_rd.h
index b290c07705..71c3d8b09a 100644
--- a/servers/rendering/renderer_rd/renderer_storage_rd.h
+++ b/servers/rendering/renderer_rd/renderer_storage_rd.h
@@ -715,12 +715,12 @@ private:
struct Particles {
RS::ParticlesMode mode = RS::PARTICLES_MODE_3D;
bool inactive = true;
- float inactive_time = 0.0;
+ double inactive_time = 0.0;
bool emitting = false;
bool one_shot = false;
int amount = 0;
- float lifetime = 1.0;
- float pre_process_time = 0.0;
+ double lifetime = 1.0;
+ double pre_process_time = 0.0;
float explosiveness = 0.0;
float randomness = 0.0;
bool restart_request = false;
@@ -773,12 +773,12 @@ private:
uint32_t cycle_number = 0;
- float speed_scale = 1.0;
+ double speed_scale = 1.0;
int fixed_fps = 30;
bool interpolate = true;
bool fractional_delta = false;
- float frame_remainder = 0;
+ double frame_remainder = 0;
float collision_base_size = 0.01;
bool clear = true;
@@ -805,14 +805,14 @@ private:
}
};
- void _particles_process(Particles *p_particles, float p_delta);
+ void _particles_process(Particles *p_particles, double p_delta);
void _particles_allocate_emission_buffer(Particles *particles);
void _particles_free_data(Particles *particles);
void _particles_update_buffers(Particles *particles);
struct ParticlesShader {
struct PushConstant {
- float lifetime;
+ double lifetime;
uint32_t clear;
uint32_t total_particles;
uint32_t trail_size;
@@ -2144,13 +2144,13 @@ public:
void particles_set_mode(RID p_particles, RS::ParticlesMode p_mode);
void particles_set_emitting(RID p_particles, bool p_emitting);
void particles_set_amount(RID p_particles, int p_amount);
- void particles_set_lifetime(RID p_particles, float p_lifetime);
+ void particles_set_lifetime(RID p_particles, double p_lifetime);
void particles_set_one_shot(RID p_particles, bool p_one_shot);
- void particles_set_pre_process_time(RID p_particles, float p_time);
+ void particles_set_pre_process_time(RID p_particles, double p_time);
void particles_set_explosiveness_ratio(RID p_particles, float p_ratio);
void particles_set_randomness_ratio(RID p_particles, float p_ratio);
void particles_set_custom_aabb(RID p_particles, const AABB &p_aabb);
- void particles_set_speed_scale(RID p_particles, float p_scale);
+ void particles_set_speed_scale(RID p_particles, double p_scale);
void particles_set_use_local_coordinates(RID p_particles, bool p_enable);
void particles_set_process_material(RID p_particles, RID p_material);
void particles_set_fixed_fps(RID p_particles, int p_fps);
diff --git a/servers/rendering/renderer_storage.h b/servers/rendering/renderer_storage.h
index b9bc349f79..6ffbdbf685 100644
--- a/servers/rendering/renderer_storage.h
+++ b/servers/rendering/renderer_storage.h
@@ -468,13 +468,13 @@ public:
virtual bool particles_get_emitting(RID p_particles) = 0;
virtual void particles_set_amount(RID p_particles, int p_amount) = 0;
- virtual void particles_set_lifetime(RID p_particles, float p_lifetime) = 0;
+ virtual void particles_set_lifetime(RID p_particles, double p_lifetime) = 0;
virtual void particles_set_one_shot(RID p_particles, bool p_one_shot) = 0;
- virtual void particles_set_pre_process_time(RID p_particles, float p_time) = 0;
+ virtual void particles_set_pre_process_time(RID p_particles, double p_time) = 0;
virtual void particles_set_explosiveness_ratio(RID p_particles, float p_ratio) = 0;
virtual void particles_set_randomness_ratio(RID p_particles, float p_ratio) = 0;
virtual void particles_set_custom_aabb(RID p_particles, const AABB &p_aabb) = 0;
- virtual void particles_set_speed_scale(RID p_particles, float p_scale) = 0;
+ virtual void particles_set_speed_scale(RID p_particles, double p_scale) = 0;
virtual void particles_set_use_local_coordinates(RID p_particles, bool p_enable) = 0;
virtual void particles_set_process_material(RID p_particles, RID p_material) = 0;
virtual void particles_set_fixed_fps(RID p_particles, int p_fps) = 0;
diff --git a/servers/rendering/rendering_server_default.cpp b/servers/rendering/rendering_server_default.cpp
index c79dfb1649..bed6ade1f6 100644
--- a/servers/rendering/rendering_server_default.cpp
+++ b/servers/rendering/rendering_server_default.cpp
@@ -134,8 +134,8 @@ void RenderingServerDefault::_draw(bool p_swap_buffers, double frame_step) {
}
if (RSG::storage->capturing_timestamps) {
- new_profile.write[i].gpu_msec = float((time_gpu - base_gpu) / 1000) / 1000.0;
- new_profile.write[i].cpu_msec = float(time_cpu - base_cpu) / 1000.0;
+ new_profile.write[i].gpu_msec = double((time_gpu - base_gpu) / 1000) / 1000.0;
+ new_profile.write[i].cpu_msec = double(time_cpu - base_cpu) / 1000.0;
new_profile.write[i].name = RSG::storage->get_captured_timestamp_name(i);
}
}
@@ -149,7 +149,7 @@ void RenderingServerDefault::_draw(bool p_swap_buffers, double frame_step) {
if (print_frame_profile_ticks_from == 0) {
print_frame_profile_ticks_from = OS::get_singleton()->get_ticks_usec();
}
- float total_time = 0.0;
+ double total_time = 0.0;
for (int i = 0; i < frame_profile.size() - 1; i++) {
String name = frame_profile[i].name;
@@ -157,7 +157,7 @@ void RenderingServerDefault::_draw(bool p_swap_buffers, double frame_step) {
continue;
}
- float time = frame_profile[i + 1].gpu_msec - frame_profile[i].gpu_msec;
+ double time = frame_profile[i + 1].gpu_msec - frame_profile[i].gpu_msec;
if (name[0] != '<' && name[0] != '>') {
if (print_gpu_profile_task_time.has(name)) {
@@ -179,7 +179,7 @@ void RenderingServerDefault::_draw(bool p_swap_buffers, double frame_step) {
float print_threshold = 0.01;
for (OrderedHashMap<String, float>::Element E = print_gpu_profile_task_time.front(); E; E = E.next()) {
- float time = E.value() / float(print_frame_profile_frame_count);
+ double time = E.value() / double(print_frame_profile_frame_count);
if (time > print_threshold) {
print_line("\t-" + E.key() + ": " + rtos(time) + "ms");
}
@@ -193,7 +193,7 @@ void RenderingServerDefault::_draw(bool p_swap_buffers, double frame_step) {
RSG::storage->update_memory_info();
}
-float RenderingServerDefault::get_frame_setup_time_cpu() const {
+double RenderingServerDefault::get_frame_setup_time_cpu() const {
return frame_setup_time;
}
diff --git a/servers/rendering/rendering_server_default.h b/servers/rendering/rendering_server_default.h
index 282b0564da..381f38d80e 100644
--- a/servers/rendering/rendering_server_default.h
+++ b/servers/rendering/rendering_server_default.h
@@ -71,7 +71,7 @@ class RenderingServerDefault : public RenderingServer {
uint64_t frame_profile_frame;
Vector<FrameProfileArea> frame_profile;
- float frame_setup_time = 0;
+ double frame_setup_time = 0;
//for printing
bool print_gpu_profile = false;
@@ -440,13 +440,13 @@ public:
FUNC2(particles_set_emitting, RID, bool)
FUNC1R(bool, particles_get_emitting, RID)
FUNC2(particles_set_amount, RID, int)
- FUNC2(particles_set_lifetime, RID, float)
+ FUNC2(particles_set_lifetime, RID, double)
FUNC2(particles_set_one_shot, RID, bool)
- FUNC2(particles_set_pre_process_time, RID, float)
+ FUNC2(particles_set_pre_process_time, RID, double)
FUNC2(particles_set_explosiveness_ratio, RID, float)
FUNC2(particles_set_randomness_ratio, RID, float)
FUNC2(particles_set_custom_aabb, RID, const AABB &)
- FUNC2(particles_set_speed_scale, RID, float)
+ FUNC2(particles_set_speed_scale, RID, double)
FUNC2(particles_set_use_local_coordinates, RID, bool)
FUNC2(particles_set_process_material, RID, RID)
FUNC2(particles_set_fixed_fps, RID, int)
@@ -574,8 +574,8 @@ public:
FUNC2(viewport_set_debug_draw, RID, ViewportDebugDraw)
FUNC2(viewport_set_measure_render_time, RID, bool)
- FUNC1RC(float, viewport_get_measured_render_time_cpu, RID)
- FUNC1RC(float, viewport_get_measured_render_time_gpu, RID)
+ FUNC1RC(double, viewport_get_measured_render_time_cpu, RID)
+ FUNC1RC(double, viewport_get_measured_render_time_gpu, RID)
FUNC2(call_set_vsync_mode, DisplayServer::VSyncMode, DisplayServer::WindowID)
@@ -890,7 +890,7 @@ public:
/* TESTING */
- virtual float get_frame_setup_time_cpu() const override;
+ virtual double get_frame_setup_time_cpu() const override;
virtual void set_boot_image(const Ref<Image> &p_image, const Color &p_color, bool p_scale, bool p_use_filter = true) override;
virtual void set_default_clear_color(const Color &p_color) override;