Improve handling of motion vectors for multimesh instances.

Fixes #67287. There was a subtle error where due to how enabling motion vectors for multi-meshes was handled, only the first instance would have a valid transforms buffer and the rest would point to an invalid buffer. This change moves over the responsibility of enabling motion vectors only when changes happen to the individual 3D transforms or the entire buffer itself. It also fixes an unnecessary download of the existing buffer that'd get overwritten by the current cache if it exists. Another fix is handling the case where the buffer was not set, and enabling motion vectors would not cause the buffer to be recreated correctly.
This commit is contained in:
Dario 2023-08-08 09:46:06 -03:00
parent f7bc653cbe
commit 5155870d64
5 changed files with 47 additions and 26 deletions

View file

@ -198,6 +198,8 @@ public:
int total_vertices_drawn = 0;
int total_draw_calls_used = 0;
int num_viewports_with_motion_vectors = 0;
private:
Vector<Viewport *> _sort_active_viewports();
void _viewport_set_size(Viewport *p_viewport, int p_width, int p_height, uint32_t p_view_count);
@ -302,6 +304,7 @@ public:
int get_total_objects_drawn() const;
int get_total_primitives_drawn() const;
int get_total_draw_calls_used() const;
int get_num_viewports_with_motion_vectors() const;
// Workaround for setting this on thread.
void call_set_vsync_mode(DisplayServer::VSyncMode p_mode, DisplayServer::WindowID p_window);