{"version":3,"file":"TextureGCSystem.mjs","sources":["../../../../../src/rendering/renderers/shared/texture/TextureGCSystem.ts"],"sourcesContent":["import { ExtensionType } from '../../../../extensions/Extensions';\nimport { deprecation } from '../../../../utils/logging/deprecation';\nimport { type Renderer } from '../../types';\n\nimport type { System } from '../system/System';\n\n/**\n * Options for the {@link TextureGCSystem}.\n * @category rendering\n * @advanced\n * @deprecated since 8.15.0\n * @see {@link GCSystem}\n */\nexport interface TextureGCSystemOptions\n{\n    /**\n     * If set to true, this will enable the garbage collector on the GPU.\n     * @default true\n     * @deprecated since 8.15.0\n     */\n    textureGCActive: boolean;\n    /**\n     * @deprecated since 8.3.0\n     * @see {@link TextureGCSystemOptions.textureGCMaxIdle}\n     */\n    textureGCAMaxIdle: number;\n    /**\n     * The maximum idle frames before a texture is destroyed by garbage collection.\n     * @default 60 * 60\n     * @deprecated since 8.15.0\n     */\n    textureGCMaxIdle: number;\n    /**\n     * Frames between two garbage collections.\n     * @default 600\n     * @deprecated since 8.15.0\n     */\n    textureGCCheckCountMax: number;\n}\n/**\n * System plugin to the renderer to manage texture garbage collection on the GPU,\n * ensuring that it does not get clogged up with textures that are no longer being used.\n * @category rendering\n * @advanced\n * @deprecated since 8.15.0\n * @see {@link GCSystem}\n */\nexport class TextureGCSystem implements System<TextureGCSystemOptions>\n{\n    /** @ignore */\n    public static extension = {\n        type: [\n            ExtensionType.WebGLSystem,\n            ExtensionType.WebGPUSystem,\n        ],\n        name: 'textureGC',\n    } as const;\n\n    /**\n     * Default options for the TextureGCSystem\n     * @deprecated since 8.15.0\n     */\n    public static defaultOptions: TextureGCSystemOptions = {\n        /**\n         * If set to true, this will enable the garbage collector on the GPU.\n         * @default true\n         */\n        textureGCActive: true,\n        /**\n         * @deprecated since 8.3.0\n         * @see {@link TextureGCSystemOptions.textureGCMaxIdle}\n         */\n        textureGCAMaxIdle: null,\n        /**\n         * The maximum idle frames before a texture is destroyed by garbage collection.\n         * @default 60 * 60\n         */\n        textureGCMaxIdle: 60 * 60,\n        /**\n         * Frames between two garbage collections.\n         * @default 600\n         */\n        textureGCCheckCountMax: 600,\n    };\n\n    /**\n     * Frame count since started.\n     * @readonly\n     * @deprecated since 8.15.0\n     */\n    public get count() { return this._renderer.tick; }\n\n    /**\n     * Frame count since last garbage collection.\n     * @readonly\n     * @deprecated since 8.15.0\n     */\n    public get checkCount() { return this._checkCount; }\n    public set checkCount(value: number)\n    {\n        // #if _DEBUG\n        deprecation('8.15.0', 'TextureGCSystem.run is deprecated, please use the GCSystem instead.');\n        // #endif\n        this._checkCount = value;\n    }\n    private _checkCount: number;\n\n    /**\n     * Maximum idle frames before a texture is destroyed by garbage collection.\n     * @see TextureGCSystem.defaultMaxIdle\n     * @deprecated since 8.15.0\n     */\n    public get maxIdle() { return (this._renderer.gc.maxUnusedTime / 1000) * 60; }\n    public set maxIdle(value: number)\n    {\n        // #if _DEBUG\n        deprecation('8.15.0', 'TextureGCSystem.run is deprecated, please use the GCSystem instead.');\n        // #endif\n        this._renderer.gc.maxUnusedTime = (value / 60) * 1000;\n    }\n\n    /**\n     * Frames between two garbage collections.\n     * @see TextureGCSystem.defaultCheckCountMax\n     * @deprecated since 8.15.0\n     */\n    // eslint-disable-next-line dot-notation\n    public get checkCountMax() { return Math.floor(this._renderer.gc['_frequency'] / 1000); }\n    public set checkCountMax(_value: number)\n    {\n        // #if _DEBUG\n        deprecation('8.15.0', 'TextureGCSystem.run is deprecated, please use the GCSystem instead.');\n        // #endif\n    }\n\n    /**\n     * Current garbage collection mode.\n     * @see TextureGCSystem.defaultMode\n     * @deprecated since 8.15.0\n     */\n    public get active() { return this._renderer.gc.enabled; }\n    public set active(value: boolean)\n    {\n        // #if _DEBUG\n        deprecation('8.15.0', 'TextureGCSystem.run is deprecated, please use the GCSystem instead.');\n        // #endif\n        this._renderer.gc.enabled = value;\n    }\n\n    private _renderer: Renderer;\n\n    /** @param renderer - The renderer this System works for. */\n    constructor(renderer: Renderer)\n    {\n        this._renderer = renderer;\n        this._checkCount = 0;\n    }\n\n    public init(options: TextureGCSystemOptions): void\n    {\n        if (options.textureGCActive !== TextureGCSystem.defaultOptions.textureGCActive)\n        { this.active = options.textureGCActive; }\n        if (options.textureGCMaxIdle !== TextureGCSystem.defaultOptions.textureGCMaxIdle)\n        { this.maxIdle = options.textureGCMaxIdle; }\n        if (options.textureGCCheckCountMax !== TextureGCSystem.defaultOptions.textureGCCheckCountMax)\n        { this.checkCountMax = options.textureGCCheckCountMax; }\n    }\n\n    /**\n     * Checks to see when the last time a texture was used.\n     * If the texture has not been used for a specified amount of time, it will be removed from the GPU.\n     * @deprecated since 8.15.0\n     */\n    public run(): void\n    {\n        // #if _DEBUG\n        deprecation('8.15.0', 'TextureGCSystem.run is deprecated, please use the GCSystem instead.');\n        // #endif\n        this._renderer.gc.run();\n    }\n\n    public destroy(): void\n    {\n        this._renderer = null as any as Renderer;\n    }\n}\n"],"names":[],"mappings":";;;;AA+CO,MAAM,gBAAA,GAAN,MAAM,gBAAA,CACb;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA0CI,IAAW,KAAA,GAAQ;AAAE,IAAA,OAAO,KAAK,SAAA,CAAU,IAAA;AAAA,EAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOjD,IAAW,UAAA,GAAa;AAAE,IAAA,OAAO,IAAA,CAAK,WAAA;AAAA,EAAa;AAAA,EACnD,IAAW,WAAW,KAAA,EACtB;AAEI,IAAA,WAAA,CAAY,UAAU,qEAAqE,CAAA;AAE3F,IAAA,IAAA,CAAK,WAAA,GAAc,KAAA;AAAA,EACvB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,IAAW,OAAA,GAAU;AAAE,IAAA,OAAQ,IAAA,CAAK,SAAA,CAAU,EAAA,CAAG,aAAA,GAAgB,GAAA,GAAQ,EAAA;AAAA,EAAI;AAAA,EAC7E,IAAW,QAAQ,KAAA,EACnB;AAEI,IAAA,WAAA,CAAY,UAAU,qEAAqE,CAAA;AAE3F,IA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