google / filament

Filament is a real-time physically based rendering engine for Android, iOS, Windows, Linux, macOS, and WebGL2
https://google.github.io/filament/
Apache License 2.0
17.37k stars 1.84k forks source link

gl: simplify how we track bound textures #7785

Closed pixelflinger closed 2 months ago

pixelflinger commented 2 months ago

In opengl it's possible to bind several textures to the same texture unit as long as they're a different target. Until now we were tracking that state. In practice it's not very useful to bind several textures to the same unit (it is a little bit when updating texture data, but not when rendering). With the coming change to a descriptor set API, it is better to have a 1-to-1 mapping between bound textures and texture units.

So with this change, only a single texture can be bound to a texture unit. If another texture in bound to the same unit with a different target, we first unbind the texture from the current target.

There is less state to track, and it allows us to "unbind a texture unit" (whereas before we'd have to iterate through all the possible targets for that unit and unbind all of them).