Line rendering optimizations #22
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
General optimizations to the Line object rendering pipeline, which is used in Anamnesis for the rendering of the gizmo circles, as well as the skeleton visual in the 3D Pose View. The goal is to minimize rendering overhead as much as possible to minimize stutters and hitches in Anamnesis.
The optimizations are primarily focused on the following aspects:
System.Numericsdata types utilize SIMD-type vector instructions, whereas Media3D ones do not.LineManager, which calculates the view projection matrix once for all lines and reuses it, as opposed to calculating it for each line individually.Here are some before and after comparions:
Before (Character page):
In this case, the gizmo is still rendered in the background.
TryTransformTo2DAncestor- 4.5% of total user code.OnRender- 0.8% of total user code.TryWorldToCameraTransform- 0.3% of total user code.=> Total: ~5.6%
After (Character page):
OnRendering- 0.8% of total user code.UpdateGeometry- 0.04% of total user code.=> Total: ~0.84%
Before (3D Pose View):
In this case, both the gizmo and skeleton are rendered.
TryTransformTo2DAncestor- 9.8% of total user code.OnRender- 2.2% of total user code.TryWorldToCameraTransform- 1.0% of total user code.GetProjectionMatrix- 0.6% of total user code.GetViewMatrix- 0.5% of total user code.GetHomogeneousToViewportTransform- 0.2% of total user code.=> Total: ~14.3%
After (3D Pose View):
UpdateGeometry- 2.2% of total user code.OnRendering- 0.7% of total user code.RebuildGeometry- 0.07% of total user code.=> Total ~2.97%