releaseTexture method

  1. @override
void releaseTexture(
  1. TextureHandle texture
)
override

Gives one back, rather than waiting for the whole device to go.

GraphicsDevice.dispose was the only release primitive there was, and that is not enough for a renderer that reallocates. A window resize remakes six or seven full-screen targets and empties this pool of every spec it holds; changing one shadow setting remakes two atlases that are 75 MB each at the default tile. All of it was dropped rather than freed. Where the collector is what frees a texture that is correct and this method has nothing to do — but on WebGL2 a WebGLTexture the driver holds is not a GC artefact, and nothing reclaims it unless something calls gl.deleteTexture. A browser window dragged a few dozen times was enough to show it.

A no-op is a correct implementation where dropping the last reference already frees, and is expected to say so rather than be left blank.

Afterwards the handle is spent. Releasing one twice, or one this allocator never made, is a caller mistake that a backend may refuse.

Nothing here says the GPU has stopped reading. That is the caller's to know — see the frames-in-flight ring in the engine's renderer, which is what keeps a target from being freed while a pass still samples it.

Implementation

@override
void releaseTexture(TextureHandle texture) => releasedTextures.add(texture);