-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve 3D Map View movement performance #60246
base: master
Are you sure you want to change the base?
Conversation
Previously the entire camera change was handled on every input event, which led to slowdown and stutters, since we can get ~1000/s such events with common mice. We don't care about intermediate camera states and can only process the last state before rendering.
Previously the average could be computed on every mouse move event. This is a problem, since the loop can be slow, especially on debug builds where nothing gets inlined.
e542b09
to
ee6d434
Compare
🪟 Windows buildsDownload Windows builds of this PR for testing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! 🕺
Tests failed for Qt 6One or more tests failed using the build from commit ee6d434 dem_terrain_filtered_2 (testFilteredDemTerrain)dem_terrain_filtered_2Test failed at testFilteredDemTerrain at tests/src/3d/testqgs3drendering.cpp:1927 Rendered image did not match tests/testdata/control_images/3d/expected_dem_terrain_filtered_2/expected_dem_terrain_filtered_2.png (found 103123 pixels different) depth_retrieve_image (testDepthBuffer)depth_retrieve_imageTest failed at testDepthBuffer at tests/src/3d/testqgs3drendering.cpp:2098 Rendered image did not match tests/testdata/control_images/3d/expected_depth_retrieve_image/expected_depth_retrieve_image.png (found 307008 pixels different) debug_map_1 (testDebugMap)debug_map_1Test failed at testDebugMap at tests/src/3d/testqgs3drendering.cpp:2235 Rendered image did not match tests/testdata/control_images/3d/expected_debug_map_1/qt6/expected_debug_map_1.png (found 3510 pixels different) virtual_pointcloud_3d_overview (testPointCloud3DOverview)virtual_pointcloud_3d_overviewTest failed at testPointCloud3DOverview at tests/src/3d/testqgspointcloud3drendering.cpp:603
The full test report (included comparison of rendered vs expected images) can be found here. Further documentation on the QGIS test infrastructure can be found in the Developer's Guide. |
Tests failed for Qt 5One or more tests failed using the build from commit ee6d434 depth_wheel_action_3 (testDepthBuffer)depth_wheel_action_3Test failed at testDepthBuffer at tests/src/3d/testqgs3drendering.cpp:2148 Rendered image did not match tests/testdata/control_images/3d/expected_depth_wheel_action_3/expected_depth_wheel_action_3.png (found 23775 pixels different) debug_map_2 (testDebugMap)debug_map_2Test failed at testDebugMap at tests/src/3d/testqgs3drendering.cpp:2249 Rendered image did not match tests/testdata/control_images/3d/expected_debug_map_2/expected_debug_map_2.png (found 520 pixels different) virtual_pointcloud_3d_overview (testPointCloud3DOverview)virtual_pointcloud_3d_overviewTest failed at testPointCloud3DOverview at tests/src/3d/testqgspointcloud3drendering.cpp:603
The full test report (included comparison of rendered vs expected images) can be found here. Further documentation on the QGIS test infrastructure can be found in the Developer's Guide. |
Description
This PR improves the performance of the 3D map view, specifically removing some large stutters when moving the camera.
Currently, all work associated with camera movement (incl. finding which chunks should be visible and loading them) is done in the mouse movement event handler. This is an issue, since such events can come 1000 times a second with standard mice. These events accumulate and overrun the main thread, resulting in stutters.
With this PR, I've changed the event handler to only do the necessary event-specific computations, while leaving the rest to be done at the start of the frame.
I've also added some caching to
QgsCameraController::sampleDepthBuffer
, which sometimes computes the average depth over the whole depth buffer. This was also happening on every mouse move event and took >20ms on my machine (though release builds are likely to be faster due to inlining, I haven't checked). In this PR, I've added a cache, so this only happens once per frame.I've also added some new
QgsEventTracing
trace points which were helpful with analysing performance and finding issues.