Improve Performance in Scenes With Many Lights #14
No reviewers
Labels
No Label
Kind/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: SeanOMik/lyra-engine#14
Loading…
Reference in New Issue
No description provided.
Delete Branch "bugfix/many-lights-poor-performance"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
In #5, when tiled forward rendering was first implemented, I wrote a stress test example that spawned 500 point lights in Sponza. This example had poor performance. This pr aimed at fixing it.
The large slow down was not actually the forward+ renderer, but updating the transform buffer and interpolating the transforms of entities! The example originally got around 180fps in release mode. After I improved the performance of updating the transform buffers, it got around 430fps! Improving the transform interpolation improved performance by another 100fps with the example now running around 530fps.
Transform Buffer
Originally the buffer of entity transforms was updated by adding buffer writes to the
wgpu::Queue
. Each transform caused a write to be queued. This is understandably pretty slow when queuing everything up. The improved version writes the transforms to a largeVec
in memory, then after all entities are processed, it sends this buffer to the GPU.Some improvements that can be made:
Transform Interpolation
Interpolating transforms was very slow. I believe it was because all the interpolated transforms were stored in a
HashMap
and retrieved and updated every frame.This was improved by creating an
InterpTransform
component that stored the last transform, and a blending alpha on the entities. These components would be created on newly discovered entities, and updated on entities that already have the components. This solution caused no noticeable impact in performance and worked great. The solution was partially discovered in bevy_mod_interp, with some modifications.Fix for poor performance with many lights.to Improve Performance in Scenes With Many Lights