perf(sortingrenderer): Skip z-sorting for nodes without bounding info in SortingRenderer#2854
Conversation
32f4bd8 to
29a4c0b
Compare
|
| Filename | Overview |
|---|---|
| Core/Libraries/Source/WWVegas/WW3D2/sortingrenderer.cpp | Introduces a separate unsorted_list for nodes with no bounding sphere (radius <= 0), bypassing insertion sort and splicing them into the sorted list at the Z=0 boundary in Flush(). Also removes the now-unused bounding_sphere member from SortingNodeStruct. Deinit() correctly cleans up the new list. One minor style nit: radius check uses 0.0 (double) instead of 0.0f (float). |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["Insert_Triangles(bounding_sphere, ...)"] --> B{"Radius <= 0?"}
B -- Yes --> C["transformed_center = (0,0,0)\nunsorted_list.push_back(state)"]
B -- No --> D["Compute world*view\ntransform center"]
D --> E["Insert_To_Sorted_List(state)\n(descending Z order)"]
F["Flush()"] --> G["Advance iterator past\nZ > 0 elements in sorted_list"]
G --> H["sorted_list.splice(node, unsorted_list)\n(particles land at Z=0 boundary)"]
H --> I["Process sorted_list front-to-back\n(painter's algorithm)"]
J["Deinit()"] --> K["Delete all nodes in sorted_list"]
K --> L["Delete all nodes in unsorted_list"]
L --> M["Delete all nodes in clean_list"]
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
A["Insert_Triangles(bounding_sphere, ...)"] --> B{"Radius <= 0?"}
B -- Yes --> C["transformed_center = (0,0,0)\nunsorted_list.push_back(state)"]
B -- No --> D["Compute world*view\ntransform center"]
D --> E["Insert_To_Sorted_List(state)\n(descending Z order)"]
F["Flush()"] --> G["Advance iterator past\nZ > 0 elements in sorted_list"]
G --> H["sorted_list.splice(node, unsorted_list)\n(particles land at Z=0 boundary)"]
H --> I["Process sorted_list front-to-back\n(painter's algorithm)"]
J["Deinit()"] --> K["Delete all nodes in sorted_list"]
K --> L["Delete all nodes in unsorted_list"]
L --> M["Delete all nodes in clean_list"]
Reviews (3): Last reviewed commit: "Check for <=0 sphere radius, rename list..." | Re-trigger Greptile
In the sorting renderer there are two stages in sorting:
SphereClassas bounding information) using a transformed Z coordinateMesh nodes that require sorting usually are inserted with the bounding information, while particles nodes are inserted without the bounding information (a zero sphere).
Because all of the particles nodes have no bounding info, they have a transformed object coordinate of Z=0.0, which means they can't be sorted among themselves, and slow down the insertion sort of objects.
The change in this PR is to keep a separate list of these unsortable nodes, and splice them in later at the correct position of the sorted list. Also
state->bounding_spherewent unused and was cleaned up.Observed a FPS gain of about 4-5% in a busy scene.
Todo