English
Class: SSWebGLTextureCache
Defined in: ssplayer-webgl/src/SSWebGLTextureCache.ts:31
Surface-scoped texture cache: one GPU upload per URL, shared by every player on the same SSSurface.
A WebGLTexture belongs to the context that created it, so the cache is per-context — exactly the scope a Surface owns. Two characters using the same atlas on one surface then cost one upload instead of two, which for a cast of the same character is most of the texture memory they would otherwise take.
Keyed by URL, deliberately not by cell-map hash. The hash the core passes around comes from the cell-map name, so two unrelated .ssab files that both contain a cell map of that name collide on it — and sharing on that key would hand one character another character's atlas. That is not hypothetical at surface scope: ssplayer-tyranoscript puts unrelated characters on one surface, and an overlay puts unrelated projects on one. The URL is the real identity, and the core builds it from the owning .ssab's own directory.
Nothing is refcounted. Cached textures live until the Surface is destroyed, so one player tearing down can never pull a texture out from under another — the trap ssplayer-pixi hit by calling Assets.unload() from destroy(). Embedded (--embedded) and caller-supplied textures never reach the cache; they stay private to their player.
Constructors
Constructor
new SSWebGLTextureCache(
gl):SSWebGLTextureCache
Defined in: ssplayer-webgl/src/SSWebGLTextureCache.ts:37
Parameters
gl
WebGLRenderingContext | WebGL2RenderingContext
Returns
SSWebGLTextureCache
Methods
acquire()
acquire(
url,upload):Promise<SSTextureEntry>
Defined in: ssplayer-webgl/src/SSWebGLTextureCache.ts:40
Upload url once via upload, and reuse it for every later request.
Parameters
url
string
upload
(url) => Promise<SSTextureEntry>
Returns
Promise<SSTextureEntry>
destroy()
destroy():
void
Defined in: ssplayer-webgl/src/SSWebGLTextureCache.ts:75
Delete every cached texture. Only the owning Surface may call this.
Returns
void
invalidate()
invalidate():
void
Defined in: ssplayer-webgl/src/SSWebGLTextureCache.ts:69
Forget everything after a context loss. The handles died with the context so there is nothing to delete — players re-acquire during their own restore, and whichever asks first re-uploads on behalf of the rest.
Returns
void