UNPKG

playcanvas

Version:

Open-source WebGL/WebGPU 3D engine for the web

140 lines (139 loc) 6.2 kB
/** * Persistent per-dispatch resource container for the local compute gsplat renderer. Each dispatch * set holds its own Compute instances (for independent parameter state), tile-dependent * StorageBuffers (sized per resolution), a PrefixSumKernel, and mode-specific output textures. * Splat/entry-dependent buffers (projCache, tileEntries) are shared on the renderer and bound * to these Compute instances via setParameter before each dispatch. * * @ignore */ export class GSplatLocalDispatchSet { /** * @param {GraphicsDevice} device - The graphics device. * @param {boolean} pickMode - Whether this set is for picking. */ constructor(device: GraphicsDevice, pickMode: boolean); /** @type {GraphicsDevice} */ device: GraphicsDevice; /** @type {boolean} */ pickMode: boolean; /** @type {Shader|null} */ _countShader: Shader | null; /** @type {BindGroupFormat|null} */ _countBindGroupFormat: BindGroupFormat | null; /** @type {Compute|null} */ _countCompute: Compute | null; /** @type {Shader|null} */ _countShaderFisheye: Shader | null; /** @type {BindGroupFormat|null} */ _countBindGroupFormatFisheye: BindGroupFormat | null; /** @type {Compute|null} */ _countComputeFisheye: Compute | null; /** @type {Compute} */ placeEntriesCompute: Compute; /** @type {Compute} */ largeSplatCompute: Compute; /** @type {Compute} */ largePlaceEntriesCompute: Compute; /** @type {Compute} */ classifyCompute: Compute; /** @type {Compute} */ sortCompute: Compute; /** @type {Compute} */ bucketSortCompute: Compute; /** @type {Compute} */ copyCompute: Compute; /** @type {Compute} */ chunkSortCompute: Compute; /** @type {Map<string, {shader: Shader, bindGroupFormat: BindGroupFormat, compute: Compute}>} */ _rasterizeVariants: Map<string, { shader: Shader; bindGroupFormat: BindGroupFormat; compute: Compute; }>; /** @type {PrefixSumKernel} */ prefixSumKernel: PrefixSumKernel; /** @type {StorageBuffer|null} */ _tileSplatCountsBuffer: StorageBuffer | null; /** @type {StorageBuffer|null} */ _smallTileListBuffer: StorageBuffer | null; /** @type {StorageBuffer|null} */ _largeTileListBuffer: StorageBuffer | null; /** @type {StorageBuffer|null} */ _largeTileOverflowBasesBuffer: StorageBuffer | null; /** @type {StorageBuffer|null} */ _rasterizeTileListBuffer: StorageBuffer | null; /** @type {StorageBuffer|null} */ _tileListCountsBuffer: StorageBuffer | null; /** @type {StorageBuffer|null} */ _chunkRangesBuffer: StorageBuffer | null; /** @type {StorageBuffer|null} */ _totalChunksBuffer: StorageBuffer | null; /** @type {StorageBuffer|null} */ _chunkSortIndirectBuffer: StorageBuffer | null; /** @type {number} */ _allocatedTileCapacity: number; /** @type {Texture|null} Color mode output */ outputTexture: Texture | null; /** @type {Texture|null} Pick mode: splat ID output (r32uint) */ pickIdTexture: Texture | null; /** @type {Texture|null} Pick mode: depth output (rgba16float) */ pickDepthTexture: Texture | null; /** * Resize mode-specific output textures. * * @param {number} width - Target width in pixels. * @param {number} height - Target height in pixels. */ resizeOutputTextures(width: number, height: number): void; /** * Ensure tile-dependent buffers are large enough for the given tile count. * * @param {number} numTiles - Total number of screen tiles. */ ensureTileBuffers(numTiles: number): void; /** * Returns the cached count Compute for the given fisheye state, lazily creating * the requested variant on first use via the provided factory function. * * @param {boolean} fisheyeEnabled - Whether fisheye is active. * @param {Function} createShaderAndFormat - Factory `(pickMode, fisheye) => { shader, bindGroupFormat }`. * @returns {Compute} The cached Compute instance. */ getCountCompute(fisheyeEnabled: boolean, createShaderAndFormat: Function): Compute; /** * Destroy all cached count shaders, bind group formats, and Compute objects. Called when the * work buffer format changes (invalidating all compiled shaders) and on final set destruction. */ destroyCountResources(): void; /** * Returns the cached rasterize Compute for the given variant key, lazily creating the shader, * bind group format, and Compute on first use. * * @param {boolean} pickMode - Whether to use the pick variant. * @param {boolean} depthTest - Whether to enable depth testing against scene geometry. * @param {string} [fogType] - Fog type string: 'none', 'linear', 'exp', or 'exp2'. * @param {boolean} [heatmap] - Whether to enable heatmap debug visualization. * @returns {Compute} The cached Compute instance. */ getRasterizeCompute(pickMode: boolean, depthTest: boolean, fogType?: string, heatmap?: boolean): Compute; /** * Creates the rasterize shader + bind group format for a given mode. * * @param {boolean} pickMode - Whether to create the pick variant. * @param {boolean} depthTest - Whether to enable depth testing against scene geometry. * @param {string} [fogType] - Fog type string: 'none', 'linear', 'exp', or 'exp2'. * @param {boolean} [heatmap] - Whether to enable heatmap debug visualization. * @returns {{ shader: Shader, bindGroupFormat: BindGroupFormat }} The shader and format. * @private */ private _createRasterizeShaderAndFormat; destroy(): void; } import type { GraphicsDevice } from '../../platform/graphics/graphics-device.js'; import { Shader } from '../../platform/graphics/shader.js'; import { BindGroupFormat } from '../../platform/graphics/bind-group-format.js'; import { Compute } from '../../platform/graphics/compute.js'; import { PrefixSumKernel } from '../graphics/prefix-sum-kernel.js'; import { StorageBuffer } from '../../platform/graphics/storage-buffer.js'; import { Texture } from '../../platform/graphics/texture.js';