export type ScratchTarget = { /** * - The texture the mip levels are rendered to. */ texture: Texture; /** * - Its framebuffer, null until created. */ framebuffer: WebGLFramebuffer | null; }; /** * Generates the mipmaps of 2D textures with the Gaussian filter of {@link MIPMAPFILTER_GAUSSIAN}, * which WebGL's own mipmap generation does not provide. A texture cannot be rendered to while it * is sampled, and limiting the levels it is sampled from makes the level rendered to an incomplete * attachment. So each mip level is rendered from the previous one into a scratch texture, and then * blitted into the texture. * * @ignore */ export class WebglMipmapRenderer { /** * @param {WebglGraphicsDevice} device - The WebGL graphics device. */ constructor(device: WebglGraphicsDevice); /** * @type {WebglGraphicsDevice} * @private */ private _device; /** * @type {Shader|null} * @private */ private _shader; /** * @type {ScopeId|null} * @private */ private _sourceId; /** * @type {ScopeId|null} * @private */ private _sourceLevelId; /** * The texel size and the mip level of the level sampled. * * @private */ private _sourceLevel; /** * The scratch targets, one per texture format, each as large as the largest first mip level * it was used for. * * @type {Map} * @private */ private _scratch; /** * The framebuffer the mip levels of the texture are attached to, to be blitted to. * * @type {WebGLFramebuffer|null} * @private */ private _levelFramebuffer; /** * The WebGL textures whose mip levels were allocated. The levels of a texture are only defined * once WebGL generates them, and a level which is not defined cannot be blitted to. * * @type {WeakSet} * @private */ private _allocated; destroy(): void; /** * Forgets the framebuffers, which are gone with the lost context. The shader and the scratch * textures are restored by the device. */ loseContext(): void; /** * @param {ScratchTarget} scratch - The scratch target to destroy. * @private */ private _destroyScratch; /** * Returns the shader, creating it on first call. * * @returns {Shader} The shader. * @private */ private _getShader; /** * Returns the scratch target for the first mip level of the texture, creating or growing it as * needed, with its framebuffer. * * @param {Texture} texture - The texture. * @returns {ScratchTarget} The scratch target. * @private */ private _getScratch; /** * Generates the mip levels of a 2D texture from its top level. * * @param {Texture} texture - The texture. */ generate(texture: Texture): void; } import { Texture } from '../texture.js'; import type { WebglGraphicsDevice } from './webgl-graphics-device.js';