This fixes a performance regression introduced during state redesign shortly after Wine 5.0.
Some games create a great amount of lights (around 1000 and growing) and touch them quite often. That results in each light being relayed to CS thread before each draw which is taking a great amount of time (performance drop in Nosferatu: The Wrath of Malachi from ~150 fps to ~10-15 at start location; that's with another unrelated regression related to streaming buffer management sorted out).
It is also possible to use bitmasks like for other states, but then with these lights amount even iterating over the full set of lights during stateblock apply leads to noticable performance drop.
With this patchset Nosferatu reaches ~180 fps on the same place (~115 on Windows on the same machine, with the difference being probably due to SWVP).
--
v3: wined3d: Use RB tree for storing lights.
wined3d: Track per light state changes in stateblock.
wined3d: Only set changed.lights if wined3d_light_state_enable_light() changed state.
https://gitlab.winehq.org/wine/wine/-/merge_requests/2833