mirror of
https://github.com/love2d/love.git
synced 2026-08-15 15:51:12 +02:00
2db9bfad11
Fixes two problems: (1) Overwriting externs with the same name and (2) not using unused texture units properly.
1) Sending two different images to two different effects using the same extern name would use the same image for both effects, e.g.:
effect_1:send('img', img_1)
effect_2:send('img', img_2) -- also changes img to point to img_2 in effect_1!
Fixed by localizing the name -> texture unit mapping for each pixel effect.
2) When a pixel effect was destroyed, the allocated texture units were not marked as being available again. Fixed by having a vector<bool> marking the free units instead of just a counter how many units are in use.
Still problematic: Sending more than GL_MAX_TEXTURE_IMAGE_UNITS (>= 16, depending on the implementation) images/canvases *in total* to pixel effects. Effects could hold references to used *texture-ids* and bind/unbind them dynamically on a effect switch. Con: Introduces additional complexity when switching effects. However, benchmarks by Alexander Szpakowski have shown the performance loss is negligible.