From 35eb7f2d6a1f872435dad3a295dc8b93721086aa Mon Sep 17 00:00:00 2001 From: Gustav Lund Date: Wed, 9 May 2018 08:11:43 +0200 Subject: Rasterizers are now in sync with engine The rasterisers (both GLES3 and GLES2) were calculating their own frame delta time This fix lets the rasterizers get the frame delta through the draw call That way any regulations to the frame step from the main script will not cause particle systems to process at a different step than the rest of the Engine. Remove unused rasterizer storage variable frame.prev_tick variable were not used anywhere and has been removed --- servers/visual/rasterizer.h | 2 +- servers/visual/visual_server_raster.cpp | 4 ++-- servers/visual/visual_server_raster.h | 2 +- servers/visual/visual_server_wrap_mt.cpp | 10 +++++----- servers/visual/visual_server_wrap_mt.h | 4 ++-- servers/visual_server.cpp | 4 ++-- servers/visual_server.h | 2 +- 7 files changed, 14 insertions(+), 14 deletions(-) (limited to 'servers') diff --git a/servers/visual/rasterizer.h b/servers/visual/rasterizer.h index 8d8e9e693e..0512b368f5 100644 --- a/servers/visual/rasterizer.h +++ b/servers/visual/rasterizer.h @@ -1069,7 +1069,7 @@ public: virtual void set_boot_image(const Ref &p_image, const Color &p_color, bool p_scale) = 0; virtual void initialize() = 0; - virtual void begin_frame() = 0; + virtual void begin_frame(double frame_step) = 0; virtual void set_current_render_target(RID p_render_target) = 0; virtual void restore_render_target() = 0; virtual void clear_render_target(const Color &p_color) = 0; diff --git a/servers/visual/visual_server_raster.cpp b/servers/visual/visual_server_raster.cpp index fca3126604..34b1f5e697 100644 --- a/servers/visual/visual_server_raster.cpp +++ b/servers/visual/visual_server_raster.cpp @@ -93,11 +93,11 @@ void VisualServerRaster::request_frame_drawn_callback(Object *p_where, const Str frame_drawn_callbacks.push_back(fdc); } -void VisualServerRaster::draw(bool p_swap_buffers) { +void VisualServerRaster::draw(bool p_swap_buffers, double frame_step) { changes = 0; - VSG::rasterizer->begin_frame(); + VSG::rasterizer->begin_frame(frame_step); VSG::scene->update_dirty_instances(); //update scene stuff diff --git a/servers/visual/visual_server_raster.h b/servers/visual/visual_server_raster.h index 8f19de9f8b..c1950c39f5 100644 --- a/servers/visual/visual_server_raster.h +++ b/servers/visual/visual_server_raster.h @@ -652,7 +652,7 @@ public: virtual void request_frame_drawn_callback(Object *p_where, const StringName &p_method, const Variant &p_userdata); - virtual void draw(bool p_swap_buffers); + virtual void draw(bool p_swap_buffers, double frame_step); virtual void sync(); virtual bool has_changed() const; virtual void init(); diff --git a/servers/visual/visual_server_wrap_mt.cpp b/servers/visual/visual_server_wrap_mt.cpp index 094e2794ed..93f3792bdc 100644 --- a/servers/visual/visual_server_wrap_mt.cpp +++ b/servers/visual/visual_server_wrap_mt.cpp @@ -37,11 +37,11 @@ void VisualServerWrapMT::thread_exit() { exit = true; } -void VisualServerWrapMT::thread_draw() { +void VisualServerWrapMT::thread_draw(bool p_swap_buffers, double frame_step) { if (!atomic_decrement(&draw_pending)) { - visual_server->draw(); + visual_server->draw(p_swap_buffers, frame_step); } } @@ -91,15 +91,15 @@ void VisualServerWrapMT::sync() { } } -void VisualServerWrapMT::draw(bool p_swap_buffers) { +void VisualServerWrapMT::draw(bool p_swap_buffers, double frame_step) { if (create_thread) { atomic_increment(&draw_pending); - command_queue.push(this, &VisualServerWrapMT::thread_draw); + command_queue.push(this, &VisualServerWrapMT::thread_draw, p_swap_buffers, frame_step); } else { - visual_server->draw(p_swap_buffers); + visual_server->draw(p_swap_buffers, frame_step); } } diff --git a/servers/visual/visual_server_wrap_mt.h b/servers/visual/visual_server_wrap_mt.h index 19bb58f3ad..ae6aa81ce1 100644 --- a/servers/visual/visual_server_wrap_mt.h +++ b/servers/visual/visual_server_wrap_mt.h @@ -55,7 +55,7 @@ class VisualServerWrapMT : public VisualServer { bool create_thread; uint64_t draw_pending; - void thread_draw(); + void thread_draw(bool p_swap_buffers, double frame_step); void thread_flush(); void thread_exit(); @@ -572,7 +572,7 @@ public: virtual void init(); virtual void finish(); - virtual void draw(bool p_swap_buffers); + virtual void draw(bool p_swap_buffers, double frame_step); virtual void sync(); FUNC0RC(bool, has_changed) diff --git a/servers/visual_server.cpp b/servers/visual_server.cpp index 21745e87a8..6453480342 100644 --- a/servers/visual_server.cpp +++ b/servers/visual_server.cpp @@ -1516,13 +1516,13 @@ Array VisualServer::_mesh_surface_get_skeleton_aabb_bind(RID p_mesh, int p_surfa void VisualServer::_bind_methods() { ClassDB::bind_method(D_METHOD("force_sync"), &VisualServer::sync); - ClassDB::bind_method(D_METHOD("force_draw", "swap_buffers"), &VisualServer::draw, DEFVAL(true)); + ClassDB::bind_method(D_METHOD("force_draw", "swap_buffers", "frame_step"), &VisualServer::draw, DEFVAL(true), DEFVAL(0.0)); // "draw" and "sync" are deprecated duplicates of "force_draw" and "force_sync" // FIXME: Add deprecation messages using GH-4397 once available, and retire // once the warnings have been enabled for a full release cycle ClassDB::bind_method(D_METHOD("sync"), &VisualServer::sync); - ClassDB::bind_method(D_METHOD("draw", "swap_buffers"), &VisualServer::draw, DEFVAL(true)); + ClassDB::bind_method(D_METHOD("draw", "swap_buffers", "frame_step"), &VisualServer::draw, DEFVAL(true), DEFVAL(0.0)); ClassDB::bind_method(D_METHOD("texture_create"), &VisualServer::texture_create); ClassDB::bind_method(D_METHOD("texture_create_from_image", "image", "flags"), &VisualServer::texture_create_from_image, DEFVAL(TEXTURE_FLAGS_DEFAULT)); diff --git a/servers/visual_server.h b/servers/visual_server.h index 65d0f07a43..60fdb26be0 100644 --- a/servers/visual_server.h +++ b/servers/visual_server.h @@ -939,7 +939,7 @@ public: /* EVENT QUEUING */ - virtual void draw(bool p_swap_buffers = true) = 0; + virtual void draw(bool p_swap_buffers = true, double frame_step = 0.0) = 0; virtual void sync() = 0; virtual bool has_changed() const = 0; virtual void init() = 0; -- cgit v1.2.3