UNPKG

pixi.js

Version:

<p align="center"> <a href="https://pixijs.com" target="_blank" rel="noopener noreferrer"> <img height="150" src="https://files.pixijs.download/branding/pixijs-logo-transparent-dark.svg?v=1" alt="PixiJS logo"> </a> </p> <br/> <p align="center">

1 lines 2.86 kB
{"version":3,"file":"GpuLimitsSystem.mjs","sources":["../../../../src/rendering/renderers/gpu/GpuLimitsSystem.ts"],"sourcesContent":["import { ExtensionType } from '../../../extensions/Extensions';\nimport { type System } from '../shared/system/System';\nimport { type WebGPURenderer } from './WebGPURenderer';\n\n/**\n * The GpuLimitsSystem provides information about the capabilities and limitations of the underlying GPU.\n * These limits, such as the maximum number of textures that can be used in a shader\n * (`maxTextures`) or the maximum number of textures that can be batched together (`maxBatchableTextures`),\n * are determined by the specific graphics hardware and driver.\n *\n * The values for these limits are not available immediately upon instantiation of the class.\n * They are populated when the WebGPU Device rendering context is successfully initialized and ready,\n * which occurs after the `renderer.init()` method has completed.\n * Attempting to access these properties before the context is ready will result in undefined or default values.\n *\n * This system allows the renderer to adapt its behavior and resource allocation strategies\n * to stay within the supported boundaries of the GPU, ensuring optimal performance and stability.\n * @example\n * ```ts\n * const renderer = new WebGPURenderer();\n * await renderer.init(); // GPU limits are populated after this call\n *\n * console.log(renderer.limits.maxTextures);\n * console.log(renderer.limits.maxBatchableTextures);\n * ```\n * @category rendering\n * @advanced\n */\nexport class GpuLimitsSystem implements System\n{\n /** @ignore */\n public static extension = {\n type: [\n ExtensionType.WebGPUSystem,\n ],\n name: 'limits',\n } as const;\n\n /** The maximum number of textures that can be used by a shader */\n public maxTextures: number;\n /** The maximum number of batchable textures */\n public maxBatchableTextures: number;\n\n private readonly _renderer: WebGPURenderer;\n\n constructor(renderer: WebGPURenderer)\n {\n this._renderer = renderer;\n }\n\n public contextChange(): void\n {\n this.maxTextures = this._renderer.device.gpu.device.limits.maxSampledTexturesPerShaderStage;\n this.maxBatchableTextures = this.maxTextures;\n }\n\n public destroy(): void\n {\n // boom!\n }\n}\n"],"names":[],"mappings":";;;AA4BO,MAAM,eACb,CAAA;AAAA,EAgBI,YAAY,QACZ,EAAA;AACI,IAAA,IAAA,CAAK,SAAY,GAAA,QAAA,CAAA;AAAA,GACrB;AAAA,EAEO,aACP,GAAA;AACI,IAAA,IAAA,CAAK,cAAc,IAAK,CAAA,SAAA,CAAU,MAAO,CAAA,GAAA,CAAI,OAAO,MAAO,CAAA,gCAAA,CAAA;AAC3D,IAAA,IAAA,CAAK,uBAAuB,IAAK,CAAA,WAAA,CAAA;AAAA,GACrC;AAAA,EAEO,OACP,GAAA;AAAA,GAEA;AACJ,CAAA;AAAA;AAhCa,eAAA,CAGK,SAAY,GAAA;AAAA,EACtB,IAAM,EAAA;AAAA,IACF,aAAc,CAAA,YAAA;AAAA,GAClB;AAAA,EACA,IAAM,EAAA,QAAA;AACV,CAAA;;;;"}