ID:2537175
 
Resolved
Applying a transform or color matrix in the layer filter was more detrimental to performance than it needed to be, due to creating a temporary surface. This will still be done if the original surface needs to be expanded, but in all other cases it will use the existing surface.
BYOND Version:513
Operating System:Windows 10 Home 64-bit
Web Browser:Chrome 79.0.3945.88
Applies to:Dream Seeker
Status: Resolved (513.1507)

This issue has been resolved.
Descriptive Problem Summary:
Putting too many (~15) layer filters on an object causes massive massive lag, so bad that my mouse cursor is frozen.

Numbered Steps to Reproduce Problem:
1. Try to put a bunch of layer filters on an object
2. Watch as your game starts having lag spikes and lag and you can't even open task manager to kill BYOND.

Code Snippet (if applicable) to Reproduce Problem:
var/list/L = list()
for(var/I in 1 to 15)
L += filter(type = "layer", icon = prob(50) ? 'lighting_gradient.dmi' : 'lighting_triangle.dmi', transform = transform_triangle(rand(-100,100),rand(-100,100),rand(-100,100),rand(-100,100),rand(-100,100),rand(-100,100)), blend_mode = BLEND_ADD)
filters = L


Expected Results:
not lagging to shit, and having them all display.

Actual Results:
lags to shit, and they don't display if there are too many

Does the problem occur:
Every time? Or how often?
In other games?
In other user accounts?
On other computers?

When does the problem NOT occur?
when there aren't a bunch of filters.

Did the problem NOT occur in any earlier versions? If so, what was the last version that worked? (Visit http://www.byond.com/download/build to download old versions for testing.)

Workarounds:
use overlays instead I guess

There might be a better way for me to combine these. The layer filter will try to simply draw on the same temporary surface already in use if it can, but will create a new one if need be. It might be possible to chain a few together and avoid the creation of excess temporary surfaces, especially if they're all overlaying. The logic might be tricky, though.
Well, just 15 layers is causing absolutely insane lag spikes when applied.
Another thing I should report is that this lag doesn't happen *at all* if there are no transforms (and hot damn is this fast as shit if there are no transforms, I can have 1000 layer filters and get 60 fps)
Yeah, that makes sense. The transform is triggering the need for another temporary surface but I think that's something I can probably avoid having to worry about.
Lummox JR resolved issue with message:
Applying a transform or color matrix in the layer filter was more detrimental to performance than it needed to be, due to creating a temporary surface. This will still be done if the original surface needs to be expanded, but in all other cases it will use the existing surface.