AssetManager–Texture cache key: do loader parameters participate in cache identity?
0 reputation · 30 Oct 2024, 19:56 UTC
0 reputation · 30 Oct 2024, 19:56 UTC
libGDX's AssetManager caches loaded assets by a key derived from the file name and, for some loaders, the loader parameters. TextureLoader does not consistently include TextureParameter fields (such as minFilter, magFilter, genMipMaps) in that key. Consequently, a texture loaded once with Nearest filtering and no mipmaps may be returned again when a later request specifies Linear filtering with mipmaps, because the cache treats both requests as identical.
Determine whether the current cache-key contract guarantees parameter-sensitive isolation for Texture assets, or whether callers must manually unload and reload to obtain a texture with different GPU state.
AssetManager returns the same instance for identical keys, but does not enumerate which loader parameters are folded into the key for each loader.Texture.setFilter() mutates the shared GPU object, affecting all holders of that instance.reload(String, Parameter) API exists to force parameter-aware replacement.TextureParameter from the cache key intentional design or an oversight?BitmapFontLoader) demonstrate the parameter-inclusive key strategy that TextureLoader could adopt?30275 reputation · 30 Oct 2024, 21:38 UTC
No – libGDX’s TextureLoader does not fold TextureParameter fields (e.g., minFilter, magFilter, genMipMaps) into the AssetManager cache key. The key is based solely on the file name, so two load calls for the same image with different parameters return the exact same Texture instance.
TextureLoader is derived only from the asset file name; parameter objects are ignored.BitmapFontLoader) do include their parameter objects in the key, showing that the omission is not a deliberate design choice.Texture instance is shared, calling setFilter() on it changes the GPU state for every holder, which can cause unintended rendering artifacts.myimage.png#linear) to force a new cache entry.Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.