perf: Render ground-aligned particles without sorting#2831
perf: Render ground-aligned particles without sorting#2831stephanmeesters wants to merge 1 commit into
Conversation
|
| Filename | Overview |
|---|---|
| Core/Libraries/Source/WWVegas/WW3D2/pointgr.cpp | Skips back-to-front sorting for non-billboard (ground-aligned) particles by short-circuiting on Billboard == false; logic is sound, minor mixed tabs/spaces in the new comment block. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[PointGroupClass::Render] --> B{Billboard?}
B -- false\nground-aligned --> C[sort = false]
B -- true\nbillboard --> D{DST blend != ZERO?}
D -- false --> C
D -- true --> E{Alpha test disabled?}
E -- false --> C
E -- true --> F{Sorting enabled?}
F -- false --> C
F -- true --> G[sort = true]
C --> H[Regular DX8 draw call\nDYNAMIC_DX8 buffer]
G --> I[Sorting renderer draw call\nDYNAMIC_SORTING buffer]
%%{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[PointGroupClass::Render] --> B{Billboard?}
B -- false\nground-aligned --> C[sort = false]
B -- true\nbillboard --> D{DST blend != ZERO?}
D -- false --> C
D -- true --> E{Alpha test disabled?}
E -- false --> C
E -- true --> F{Sorting enabled?}
F -- false --> C
F -- true --> G[sort = true]
C --> H[Regular DX8 draw call\nDYNAMIC_DX8 buffer]
G --> I[Sorting renderer draw call\nDYNAMIC_SORTING buffer]
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
Core/Libraries/Source/WWVegas/WW3D2/pointgr.cpp:929-932
The new annotation and comment lines use 2-space indentation while the rest of the function body (and every other `// TheSuperHackers @...` annotation in the codebase) uses tabs. This creates mixed indentation within the block.
```suggestion
// TheSuperHackers @perf stephanmeesters 27/06/2026
// Enable sorting if the primitives are translucent and alpha testing is not enabled.
// However, do not apply sorting for ground-aligned (i.e. non-billboard) particles.
// This is for performance reasons and because ground-aligned particles do not generally benefit from back-to-front sorting.
```
Reviews (1): Last reviewed commit: "perf: Render ground-aligned particles wi..." | Re-trigger Greptile
A performance gain (about 8%) could be achieved in a busy scene, see animated gif below, by not sorting particles that are "ground-aligned". (tested in release mode, windowed, stats averaged in 60 secs window)
The reasoning is that ground-aligned particles generally do not have much benefit from back to front sorting, as they are effectively on the ground with nothing behind them, and other nearby ground-aligned particles are at about the same height.
In testing this actually appeared to resolve some rendering issues as ground particles would sometimes cut into nearby particles leaving hard edges (see the before image).
sorting-renderer.webm
Todo