570e99774936a721d63c108ddbe0d131958fbc956afbf5311fd84e668eccb687.json 412 KB

1
  1. {"ast":null,"code":"import _asyncToGenerator from \"F:/workspace/202226701027/huinongbao-app/node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js\";\n/* eslint-disable babylonjs/available */\nimport { Logger } from \"../Misc/logger.js\";\nimport { ThinWebGPUEngine } from \"./thinWebGPUEngine.js\";\nimport { Color4 } from \"../Maths/math.js\";\nimport { InternalTexture } from \"../Materials/Textures/internalTexture.js\";\nimport { Effect } from \"../Materials/effect.js\";\n\n// eslint-disable-next-line @typescript-eslint/naming-convention\nimport * as WebGPUConstants from \"./WebGPU/webgpuConstants.js\";\nimport { VertexBuffer } from \"../Buffers/buffer.js\";\nimport { WebGPUPipelineContext } from \"./WebGPU/webgpuPipelineContext.js\";\nimport { WebGPUShaderProcessorGLSL } from \"./WebGPU/webgpuShaderProcessorsGLSL.js\";\nimport { WebGPUShaderProcessorWGSL } from \"./WebGPU/webgpuShaderProcessorsWGSL.js\";\nimport { WebGPUShaderProcessingContext } from \"./WebGPU/webgpuShaderProcessingContext.js\";\nimport { Tools } from \"../Misc/tools.js\";\nimport { WebGPUTextureHelper } from \"./WebGPU/webgpuTextureHelper.js\";\nimport { WebGPUTextureManager } from \"./WebGPU/webgpuTextureManager.js\";\nimport { AbstractEngine } from \"./abstractEngine.js\";\nimport { WebGPUBufferManager } from \"./WebGPU/webgpuBufferManager.js\";\nimport { WebGPUHardwareTexture } from \"./WebGPU/webgpuHardwareTexture.js\";\nimport { UniformBuffer } from \"../Materials/uniformBuffer.js\";\nimport { WebGPUCacheSampler } from \"./WebGPU/webgpuCacheSampler.js\";\nimport { WebGPUCacheRenderPipelineTree } from \"./WebGPU/webgpuCacheRenderPipelineTree.js\";\nimport { WebGPUStencilStateComposer } from \"./WebGPU/webgpuStencilStateComposer.js\";\nimport { WebGPUDepthCullingState } from \"./WebGPU/webgpuDepthCullingState.js\";\nimport { WebGPUMaterialContext } from \"./WebGPU/webgpuMaterialContext.js\";\nimport { WebGPUDrawContext } from \"./WebGPU/webgpuDrawContext.js\";\nimport { WebGPUCacheBindGroups } from \"./WebGPU/webgpuCacheBindGroups.js\";\nimport { WebGPUClearQuad } from \"./WebGPU/webgpuClearQuad.js\";\nimport { WebGPURenderItemBlendColor, WebGPURenderItemScissor, WebGPURenderItemStencilRef, WebGPURenderItemViewport, WebGPUBundleList } from \"./WebGPU/webgpuBundleList.js\";\nimport { WebGPUTimestampQuery } from \"./WebGPU/webgpuTimestampQuery.js\";\nimport { WebGPUOcclusionQuery } from \"./WebGPU/webgpuOcclusionQuery.js\";\nimport { ShaderCodeInliner } from \"./Processors/shaderCodeInliner.js\";\nimport { WebGPUTintWASM } from \"./WebGPU/webgpuTintWASM.js\";\nimport { WebGPUShaderProcessor } from \"./WebGPU/webgpuShaderProcessor.js\";\nimport { WebGPUSnapshotRendering } from \"./WebGPU/webgpuSnapshotRendering.js\";\nimport \"../Buffers/buffer.align.js\";\nimport { SphericalPolynomial } from \"../Maths/sphericalPolynomial.js\";\nimport { PerformanceMonitor } from \"../Misc/performanceMonitor.js\";\nimport { CreateImageBitmapFromSource, ExitFullscreen, ExitPointerlock, GetFontOffset, RequestFullscreen, RequestPointerlock, ResizeImageBitmap, _CommonDispose, _CommonInit } from \"./engine.common.js\";\nimport { IsWrapper } from \"../Materials/drawWrapper.functions.js\";\nimport { PerfCounter } from \"../Misc/perfCounter.js\";\nimport \"./AbstractEngine/abstractEngine.loadingScreen.js\";\nimport \"./AbstractEngine/abstractEngine.dom.js\";\nimport \"./AbstractEngine/abstractEngine.states.js\";\nimport \"./AbstractEngine/abstractEngine.renderPass.js\";\nimport \"../Audio/audioEngine.js\";\nimport { resetCachedPipeline } from \"../Materials/effect.functions.js\";\nimport { WebGPUExternalTexture } from \"./WebGPU/webgpuExternalTexture.js\";\nimport \"./WebGPU/Extensions/engine.alpha.js\";\nimport \"./WebGPU/Extensions/engine.rawTexture.js\";\nimport \"./WebGPU/Extensions/engine.readTexture.js\";\nimport \"./WebGPU/Extensions/engine.cubeTexture.js\";\nimport \"./WebGPU/Extensions/engine.renderTarget.js\";\nimport \"./WebGPU/Extensions/engine.renderTargetTexture.js\";\nimport \"./WebGPU/Extensions/engine.renderTargetCube.js\";\nimport \"./WebGPU/Extensions/engine.query.js\";\nconst viewDescriptorSwapChainAntialiasing = {\n label: `TextureView_SwapChain_ResolveTarget`,\n dimension: \"2d\" /* WebGPUConstants.TextureDimension.E2d */,\n format: undefined,\n // will be updated with the right value\n mipLevelCount: 1,\n arrayLayerCount: 1\n};\nconst viewDescriptorSwapChain = {\n label: `TextureView_SwapChain`,\n dimension: \"2d\" /* WebGPUConstants.TextureDimension.E2d */,\n format: undefined,\n // will be updated with the right value\n mipLevelCount: 1,\n arrayLayerCount: 1\n};\nconst tempColor4 = new Color4();\n/**\n * The web GPU engine class provides support for WebGPU version of babylon.js.\n * @since 5.0.0\n */\nexport class WebGPUEngine extends ThinWebGPUEngine {\n /**\n * Gets or sets the snapshot rendering mode\n */\n get snapshotRenderingMode() {\n return this._snapshotRendering.mode;\n }\n set snapshotRenderingMode(mode) {\n this._snapshotRendering.mode = mode;\n }\n /**\n * Creates a new snapshot at the next frame using the current snapshotRenderingMode\n */\n snapshotRenderingReset() {\n this._snapshotRendering.reset();\n }\n /**\n * Enables or disables the snapshot rendering mode\n * Note that the WebGL engine does not support snapshot rendering so setting the value won't have any effect for this engine\n */\n get snapshotRendering() {\n return this._snapshotRendering.enabled;\n }\n set snapshotRendering(activate) {\n this._snapshotRendering.enabled = activate;\n }\n /**\n * Sets this to true to disable the cache for the samplers. You should do it only for testing purpose!\n */\n get disableCacheSamplers() {\n return this._cacheSampler ? this._cacheSampler.disabled : false;\n }\n set disableCacheSamplers(disable) {\n if (this._cacheSampler) {\n this._cacheSampler.disabled = disable;\n }\n }\n /**\n * Sets this to true to disable the cache for the render pipelines. You should do it only for testing purpose!\n */\n get disableCacheRenderPipelines() {\n return this._cacheRenderPipeline ? this._cacheRenderPipeline.disabled : false;\n }\n set disableCacheRenderPipelines(disable) {\n if (this._cacheRenderPipeline) {\n this._cacheRenderPipeline.disabled = disable;\n }\n }\n /**\n * Sets this to true to disable the cache for the bind groups. You should do it only for testing purpose!\n */\n get disableCacheBindGroups() {\n return this._cacheBindGroups ? this._cacheBindGroups.disabled : false;\n }\n set disableCacheBindGroups(disable) {\n if (this._cacheBindGroups) {\n this._cacheBindGroups.disabled = disable;\n }\n }\n /**\n * Gets a boolean indicating if all created effects are ready\n * @returns true if all effects are ready\n */\n areAllEffectsReady() {\n return true;\n }\n /**\n * Get Font size information\n * @param font font name\n * @returns an object containing ascent, height and descent\n */\n getFontOffset(font) {\n return GetFontOffset(font);\n }\n /**\n * Gets a Promise<boolean> indicating if the engine can be instantiated (ie. if a WebGPU context can be found)\n */\n static get IsSupportedAsync() {\n return !navigator.gpu ? Promise.resolve(false) : navigator.gpu.requestAdapter().then(adapter => !!adapter, () => false).catch(() => false);\n }\n /**\n * Not supported by WebGPU, you should call IsSupportedAsync instead!\n */\n static get IsSupported() {\n Logger.Warn(\"You must call IsSupportedAsync for WebGPU!\");\n return false;\n }\n /**\n * Gets a boolean indicating that the engine supports uniform buffers\n */\n get supportsUniformBuffers() {\n return true;\n }\n /** Gets the supported extensions by the WebGPU adapter */\n get supportedExtensions() {\n return this._adapterSupportedExtensions;\n }\n /** Gets the currently enabled extensions on the WebGPU device */\n get enabledExtensions() {\n return this._deviceEnabledExtensions;\n }\n /** Gets the supported limits by the WebGPU adapter */\n get supportedLimits() {\n return this._adapterSupportedLimits;\n }\n /** Gets the current limits of the WebGPU device */\n get currentLimits() {\n return this._deviceLimits;\n }\n /**\n * Returns a string describing the current engine\n */\n get description() {\n const description = this.name + this.version;\n return description;\n }\n /**\n * Returns the version of the engine\n */\n get version() {\n return 1;\n }\n /**\n * Gets an object containing information about the current engine context\n * @returns an object containing the vendor, the renderer and the version of the current engine context\n */\n getInfo() {\n return {\n vendor: this._adapterInfo.vendor || \"unknown vendor\",\n renderer: this._adapterInfo.architecture || \"unknown renderer\",\n version: this._adapterInfo.description || \"unknown version\"\n };\n }\n /**\n * (WebGPU only) True (default) to be in compatibility mode, meaning rendering all existing scenes without artifacts (same rendering than WebGL).\n * Setting the property to false will improve performances but may not work in some scenes if some precautions are not taken.\n * See https://doc.babylonjs.com/setup/support/webGPU/webGPUOptimization/webGPUNonCompatibilityMode for more details\n */\n get compatibilityMode() {\n return this._compatibilityMode;\n }\n set compatibilityMode(mode) {\n this._compatibilityMode = mode;\n }\n /** @internal */\n get currentSampleCount() {\n return this._currentRenderTarget ? this._currentRenderTarget.samples : this._mainPassSampleCount;\n }\n /**\n * Create a new instance of the gpu engine asynchronously\n * @param canvas Defines the canvas to use to display the result\n * @param options Defines the options passed to the engine to create the GPU context dependencies\n * @returns a promise that resolves with the created engine\n */\n static CreateAsync(canvas, options = {}) {\n const engine = new WebGPUEngine(canvas, options);\n return new Promise(resolve => {\n engine.initAsync(options.glslangOptions, options.twgslOptions).then(() => resolve(engine));\n });\n }\n /**\n * Create a new instance of the gpu engine.\n * @param canvas Defines the canvas to use to display the result\n * @param options Defines the options passed to the engine to create the GPU context dependencies\n */\n constructor(canvas, options = {}) {\n var _options$antialias, _options$enableGPUDeb;\n super((_options$antialias = options.antialias) !== null && _options$antialias !== void 0 ? _options$antialias : true, options);\n /** A unique id to identify this instance */\n this.uniqueId = -1;\n // Page Life cycle and constants\n this._uploadEncoderDescriptor = {\n label: \"upload\"\n };\n this._renderEncoderDescriptor = {\n label: \"render\"\n };\n /** @internal */\n this._clearDepthValue = 1;\n /** @internal */\n this._clearReverseDepthValue = 0;\n /** @internal */\n this._clearStencilValue = 0;\n this._defaultSampleCount = 4; // Only supported value for now.\n this._glslang = null;\n this._tintWASM = null;\n this._glslangAndTintAreFullyLoaded = false;\n this._adapterInfo = {\n vendor: \"\",\n architecture: \"\",\n device: \"\",\n description: \"\"\n };\n /** @internal */\n this._compiledComputeEffects = {};\n /** @internal */\n this._counters = {\n numEnableEffects: 0,\n numEnableDrawWrapper: 0,\n numBundleCreationNonCompatMode: 0,\n numBundleReuseNonCompatMode: 0\n };\n /**\n * Counters from last frame\n */\n this.countersLastFrame = {\n numEnableEffects: 0,\n numEnableDrawWrapper: 0,\n numBundleCreationNonCompatMode: 0,\n numBundleReuseNonCompatMode: 0\n };\n /**\n * Max number of uncaptured error messages to log\n */\n this.numMaxUncapturedErrors = 20;\n /**\n * Gets the list of created scenes\n */\n this.scenes = [];\n /** @internal */\n this._virtualScenes = new Array();\n this._commandBuffers = [null, null];\n // Frame Buffer Life Cycle (recreated for each render target pass)\n this._mainRenderPassWrapper = {\n renderPassDescriptor: null,\n colorAttachmentViewDescriptor: null,\n depthAttachmentViewDescriptor: null,\n colorAttachmentGPUTextures: [],\n depthTextureFormat: undefined\n };\n this._rttRenderPassWrapper = {\n renderPassDescriptor: null,\n colorAttachmentViewDescriptor: null,\n depthAttachmentViewDescriptor: null,\n colorAttachmentGPUTextures: [],\n depthTextureFormat: undefined\n };\n /** @internal */\n this._pendingDebugCommands = [];\n this._currentOverrideVertexBuffers = null;\n this._currentIndexBuffer = null;\n this._colorWriteLocal = true;\n this._forceEnableEffect = false;\n /**\n * Indicates if the z range in NDC space is 0..1 (value: true) or -1..1 (value: false)\n */\n this.isNDCHalfZRange = true;\n /**\n * Indicates that the origin of the texture/framebuffer space is the bottom left corner. If false, the origin is top left\n */\n this.hasOriginBottomLeft = false;\n //------------------------------------------------------------------------------\n // Initialization\n //------------------------------------------------------------------------------\n this._workingGlslangAndTintPromise = null;\n //------------------------------------------------------------------------------\n // Dynamic WebGPU States\n //------------------------------------------------------------------------------\n // index 0 is for main render pass, 1 for RTT render pass\n this._viewportsCurrent = {\n x: 0,\n y: 0,\n w: 0,\n h: 0\n };\n this._scissorsCurrent = {\n x: 0,\n y: 0,\n w: 0,\n h: 0\n };\n this._scissorCached = {\n x: 0,\n y: 0,\n z: 0,\n w: 0\n };\n this._stencilRefsCurrent = -1;\n this._blendColorsCurrent = [null, null, null, null];\n this._performanceMonitor = new PerformanceMonitor();\n this._name = \"WebGPU\";\n this._drawCalls = new PerfCounter();\n options.deviceDescriptor = options.deviceDescriptor || {};\n options.enableGPUDebugMarkers = (_options$enableGPUDeb = options.enableGPUDebugMarkers) !== null && _options$enableGPUDeb !== void 0 ? _options$enableGPUDeb : false;\n Logger.Log(`Babylon.js v${AbstractEngine.Version} - ${this.description} engine`);\n if (!navigator.gpu) {\n Logger.Error(\"WebGPU is not supported by your browser.\");\n return;\n }\n options.swapChainFormat = options.swapChainFormat || navigator.gpu.getPreferredCanvasFormat();\n this._isWebGPU = true;\n this._shaderPlatformName = \"WEBGPU\";\n this._renderingCanvas = canvas;\n this._options = options;\n this._mainPassSampleCount = options.antialias ? this._defaultSampleCount : 1;\n if (navigator && navigator.userAgent) {\n this._setupMobileChecks();\n }\n this._sharedInit(this._renderingCanvas);\n this._shaderProcessor = new WebGPUShaderProcessorGLSL();\n this._shaderProcessorWGSL = new WebGPUShaderProcessorWGSL();\n }\n /**\n * Load the glslang and tintWASM libraries and prepare them for use.\n * @returns a promise that resolves when the engine is ready to use the glslang and tintWASM\n */\n prepareGlslangAndTintAsync() {\n if (!this._workingGlslangAndTintPromise) {\n this._workingGlslangAndTintPromise = new Promise(resolve => {\n var _this$_glslangOptions, _this$_options;\n this._initGlslang((_this$_glslangOptions = this._glslangOptions) !== null && _this$_glslangOptions !== void 0 ? _this$_glslangOptions : (_this$_options = this._options) === null || _this$_options === void 0 ? void 0 : _this$_options.glslangOptions).then(glslang => {\n var _this$_twgslOptions, _this$_options2;\n this._glslang = glslang;\n this._tintWASM = new WebGPUTintWASM();\n this._tintWASM.initTwgsl((_this$_twgslOptions = this._twgslOptions) !== null && _this$_twgslOptions !== void 0 ? _this$_twgslOptions : (_this$_options2 = this._options) === null || _this$_options2 === void 0 ? void 0 : _this$_options2.twgslOptions).then(() => {\n this._glslangAndTintAreFullyLoaded = true;\n resolve();\n });\n });\n });\n }\n return this._workingGlslangAndTintPromise;\n }\n /**\n * Initializes the WebGPU context and dependencies.\n * @param glslangOptions Defines the GLSLang compiler options if necessary\n * @param twgslOptions Defines the Twgsl compiler options if necessary\n * @returns a promise notifying the readiness of the engine.\n */\n initAsync(glslangOptions, twgslOptions) {\n var _this = this;\n this.uniqueId = WebGPUEngine._InstanceId++;\n this._glslangOptions = glslangOptions;\n this._twgslOptions = twgslOptions;\n return navigator.gpu.requestAdapter(this._options).then(adapter => {\n if (!adapter) {\n // eslint-disable-next-line no-throw-literal\n throw \"Could not retrieve a WebGPU adapter (adapter is null).\";\n } else {\n var _this$_adapter$featur, _this$_options$device, _deviceDescriptor$req;\n this._adapter = adapter;\n this._adapterSupportedExtensions = [];\n (_this$_adapter$featur = this._adapter.features) === null || _this$_adapter$featur === void 0 || _this$_adapter$featur.forEach(feature => this._adapterSupportedExtensions.push(feature));\n this._adapterSupportedLimits = this._adapter.limits;\n this._adapterInfo = this._adapter.info;\n const deviceDescriptor = (_this$_options$device = this._options.deviceDescriptor) !== null && _this$_options$device !== void 0 ? _this$_options$device : {};\n const requiredFeatures = (_deviceDescriptor$req = deviceDescriptor === null || deviceDescriptor === void 0 ? void 0 : deviceDescriptor.requiredFeatures) !== null && _deviceDescriptor$req !== void 0 ? _deviceDescriptor$req : this._options.enableAllFeatures ? this._adapterSupportedExtensions : undefined;\n if (requiredFeatures) {\n const requestedExtensions = requiredFeatures;\n const validExtensions = [];\n for (const extension of requestedExtensions) {\n if (this._adapterSupportedExtensions.indexOf(extension) !== -1) {\n validExtensions.push(extension);\n }\n }\n deviceDescriptor.requiredFeatures = validExtensions;\n }\n if (this._options.setMaximumLimits && !deviceDescriptor.requiredLimits) {\n deviceDescriptor.requiredLimits = {};\n for (const name in this._adapterSupportedLimits) {\n if (name === \"minSubgroupSize\" || name === \"maxSubgroupSize\") {\n // Chrome exposes these limits in \"webgpu developer\" mode, but these can't be set on the device.\n continue;\n }\n deviceDescriptor.requiredLimits[name] = this._adapterSupportedLimits[name];\n }\n }\n deviceDescriptor.label = `BabylonWebGPUDevice${this.uniqueId}`;\n return this._adapter.requestDevice(deviceDescriptor);\n }\n }).then(device => {\n var _this$_device$feature;\n this._device = device;\n this._deviceEnabledExtensions = [];\n (_this$_device$feature = this._device.features) === null || _this$_device$feature === void 0 || _this$_device$feature.forEach(feature => this._deviceEnabledExtensions.push(feature));\n this._deviceLimits = device.limits;\n let numUncapturedErrors = -1;\n this._device.addEventListener(\"uncapturederror\", event => {\n if (++numUncapturedErrors < this.numMaxUncapturedErrors) {\n Logger.Warn(`WebGPU uncaptured error (${numUncapturedErrors + 1}): ${event.error} - ${event.error.message}`);\n } else if (numUncapturedErrors++ === this.numMaxUncapturedErrors) {\n Logger.Warn(`WebGPU uncaptured error: too many warnings (${this.numMaxUncapturedErrors}), no more warnings will be reported to the console for this engine.`);\n }\n });\n if (!this._doNotHandleContextLost) {\n var _this$_device$lost;\n (_this$_device$lost = this._device.lost) === null || _this$_device$lost === void 0 || _this$_device$lost.then(info => {\n if (this._isDisposed) {\n return;\n }\n this._contextWasLost = true;\n Logger.Warn(\"WebGPU context lost. \" + info);\n this.onContextLostObservable.notifyObservers(this);\n this._restoreEngineAfterContextLost( /*#__PURE__*/_asyncToGenerator(function* () {\n var _this$_glslangOptions2, _this$_options3, _this$_twgslOptions2, _this$_options4;\n const snapshotRenderingMode = _this.snapshotRenderingMode;\n const snapshotRendering = _this.snapshotRendering;\n const disableCacheSamplers = _this.disableCacheSamplers;\n const disableCacheRenderPipelines = _this.disableCacheRenderPipelines;\n const disableCacheBindGroups = _this.disableCacheBindGroups;\n const enableGPUTimingMeasurements = _this.enableGPUTimingMeasurements;\n yield _this.initAsync((_this$_glslangOptions2 = _this._glslangOptions) !== null && _this$_glslangOptions2 !== void 0 ? _this$_glslangOptions2 : (_this$_options3 = _this._options) === null || _this$_options3 === void 0 ? void 0 : _this$_options3.glslangOptions, (_this$_twgslOptions2 = _this._twgslOptions) !== null && _this$_twgslOptions2 !== void 0 ? _this$_twgslOptions2 : (_this$_options4 = _this._options) === null || _this$_options4 === void 0 ? void 0 : _this$_options4.twgslOptions);\n _this.snapshotRenderingMode = snapshotRenderingMode;\n _this.snapshotRendering = snapshotRendering;\n _this.disableCacheSamplers = disableCacheSamplers;\n _this.disableCacheRenderPipelines = disableCacheRenderPipelines;\n _this.disableCacheBindGroups = disableCacheBindGroups;\n _this.enableGPUTimingMeasurements = enableGPUTimingMeasurements;\n _this._currentRenderPass = null;\n }));\n });\n }\n }).then(() => {\n this._initializeLimits();\n this._bufferManager = new WebGPUBufferManager(this, this._device);\n this._textureHelper = new WebGPUTextureManager(this, this._device, this._bufferManager, this._deviceEnabledExtensions);\n this._cacheSampler = new WebGPUCacheSampler(this._device);\n this._cacheBindGroups = new WebGPUCacheBindGroups(this._device, this._cacheSampler, this);\n this._timestampQuery = new WebGPUTimestampQuery(this, this._device, this._bufferManager);\n this._occlusionQuery = this._device.createQuerySet ? new WebGPUOcclusionQuery(this, this._device, this._bufferManager) : undefined;\n this._bundleList = new WebGPUBundleList(this._device);\n this._snapshotRendering = new WebGPUSnapshotRendering(this, this._snapshotRenderingMode, this._bundleList);\n this._ubInvertY = this._bufferManager.createBuffer(new Float32Array([-1, 0]), WebGPUConstants.BufferUsage.Uniform | WebGPUConstants.BufferUsage.CopyDst, \"UBInvertY\");\n this._ubDontInvertY = this._bufferManager.createBuffer(new Float32Array([1, 0]), WebGPUConstants.BufferUsage.Uniform | WebGPUConstants.BufferUsage.CopyDst, \"UBDontInvertY\");\n if (this.dbgVerboseLogsForFirstFrames) {\n if (this._count === undefined) {\n this._count = 0;\n Logger.Log([\"%c frame #\" + this._count + \" - begin\", \"background: #ffff00\"]);\n }\n }\n this._uploadEncoder = this._device.createCommandEncoder(this._uploadEncoderDescriptor);\n this._renderEncoder = this._device.createCommandEncoder(this._renderEncoderDescriptor);\n this._emptyVertexBuffer = new VertexBuffer(this, [0], \"\", {\n stride: 1,\n offset: 0,\n size: 1,\n label: \"EmptyVertexBuffer\"\n });\n this._cacheRenderPipeline = new WebGPUCacheRenderPipelineTree(this._device, this._emptyVertexBuffer);\n this._depthCullingState = new WebGPUDepthCullingState(this._cacheRenderPipeline);\n this._stencilStateComposer = new WebGPUStencilStateComposer(this._cacheRenderPipeline);\n this._stencilStateComposer.stencilGlobal = this._stencilState;\n this._depthCullingState.depthTest = true;\n this._depthCullingState.depthFunc = 515;\n this._depthCullingState.depthMask = true;\n this._textureHelper.setCommandEncoder(this._uploadEncoder);\n this._clearQuad = new WebGPUClearQuad(this._device, this, this._emptyVertexBuffer);\n this._defaultDrawContext = this.createDrawContext();\n this._currentDrawContext = this._defaultDrawContext;\n this._defaultMaterialContext = this.createMaterialContext();\n this._currentMaterialContext = this._defaultMaterialContext;\n this._initializeContextAndSwapChain();\n this._initializeMainAttachments();\n this.resize();\n }).catch(e => {\n Logger.Error(\"A fatal error occurred during WebGPU creation/initialization.\");\n throw e;\n });\n }\n _initGlslang(glslangOptions) {\n glslangOptions = glslangOptions || {};\n glslangOptions = {\n ...WebGPUEngine._GlslangDefaultOptions,\n ...glslangOptions\n };\n if (glslangOptions.glslang) {\n return Promise.resolve(glslangOptions.glslang);\n }\n if (self.glslang) {\n return self.glslang(glslangOptions.wasmPath);\n }\n if (glslangOptions.jsPath && glslangOptions.wasmPath) {\n return Tools.LoadBabylonScriptAsync(glslangOptions.jsPath).then(() => {\n return self.glslang(Tools.GetBabylonScriptURL(glslangOptions.wasmPath));\n });\n }\n return Promise.reject(\"gslang is not available.\");\n }\n _initializeLimits() {\n // Init caps\n // TODO WEBGPU Real Capability check once limits will be working.\n this._caps = {\n maxTexturesImageUnits: this._deviceLimits.maxSampledTexturesPerShaderStage,\n maxVertexTextureImageUnits: this._deviceLimits.maxSampledTexturesPerShaderStage,\n maxCombinedTexturesImageUnits: this._deviceLimits.maxSampledTexturesPerShaderStage * 2,\n maxTextureSize: this._deviceLimits.maxTextureDimension2D,\n maxCubemapTextureSize: this._deviceLimits.maxTextureDimension2D,\n maxRenderTextureSize: this._deviceLimits.maxTextureDimension2D,\n maxVertexAttribs: this._deviceLimits.maxVertexAttributes,\n maxDrawBuffers: 8,\n maxVaryingVectors: this._deviceLimits.maxInterStageShaderVariables,\n maxFragmentUniformVectors: Math.floor(this._deviceLimits.maxUniformBufferBindingSize / 4),\n maxVertexUniformVectors: Math.floor(this._deviceLimits.maxUniformBufferBindingSize / 4),\n standardDerivatives: true,\n astc: this._deviceEnabledExtensions.indexOf(\"texture-compression-astc\" /* WebGPUConstants.FeatureName.TextureCompressionASTC */) >= 0 ? true : undefined,\n s3tc: this._deviceEnabledExtensions.indexOf(\"texture-compression-bc\" /* WebGPUConstants.FeatureName.TextureCompressionBC */) >= 0 ? true : undefined,\n pvrtc: null,\n etc1: null,\n etc2: this._deviceEnabledExtensions.indexOf(\"texture-compression-etc2\" /* WebGPUConstants.FeatureName.TextureCompressionETC2 */) >= 0 ? true : undefined,\n bptc: this._deviceEnabledExtensions.indexOf(\"texture-compression-bc\" /* WebGPUConstants.FeatureName.TextureCompressionBC */) >= 0 ? true : undefined,\n maxAnisotropy: 16,\n // Most implementations support maxAnisotropy values in range between 1 and 16, inclusive. The used value of maxAnisotropy will be clamped to the maximum value that the platform supports.\n uintIndices: true,\n fragmentDepthSupported: true,\n highPrecisionShaderSupported: true,\n colorBufferFloat: true,\n supportFloatTexturesResolve: false,\n // See https://github.com/gpuweb/gpuweb/issues/3844\n rg11b10ufColorRenderable: this._deviceEnabledExtensions.indexOf(\"rg11b10ufloat-renderable\" /* WebGPUConstants.FeatureName.RG11B10UFloatRenderable */) >= 0,\n textureFloat: true,\n textureFloatLinearFiltering: this._deviceEnabledExtensions.indexOf(\"float32-filterable\" /* WebGPUConstants.FeatureName.Float32Filterable */) >= 0,\n textureFloatRender: true,\n textureHalfFloat: true,\n textureHalfFloatLinearFiltering: true,\n textureHalfFloatRender: true,\n textureLOD: true,\n texelFetch: true,\n drawBuffersExtension: true,\n depthTextureExtension: true,\n vertexArrayObject: false,\n instancedArrays: true,\n timerQuery: typeof BigUint64Array !== \"undefined\" && this._deviceEnabledExtensions.indexOf(\"timestamp-query\" /* WebGPUConstants.FeatureName.TimestampQuery */) !== -1 ? true : undefined,\n supportOcclusionQuery: typeof BigUint64Array !== \"undefined\",\n canUseTimestampForTimerQuery: true,\n multiview: false,\n oculusMultiview: false,\n parallelShaderCompile: undefined,\n blendMinMax: true,\n maxMSAASamples: 4,\n // the spec only supports values of 1 and 4\n canUseGLInstanceID: true,\n canUseGLVertexID: true,\n supportComputeShaders: true,\n supportSRGBBuffers: true,\n supportTransformFeedbacks: false,\n textureMaxLevel: true,\n texture2DArrayMaxLayerCount: this._deviceLimits.maxTextureArrayLayers,\n disableMorphTargetTexture: false,\n textureNorm16: false // in the works: https://github.com/gpuweb/gpuweb/issues/3001\n };\n this._features = {\n forceBitmapOverHTMLImageElement: true,\n supportRenderAndCopyToLodForFloatTextures: true,\n supportDepthStencilTexture: true,\n supportShadowSamplers: true,\n uniformBufferHardCheckMatrix: false,\n allowTexturePrefiltering: true,\n trackUbosInFrame: true,\n checkUbosContentBeforeUpload: true,\n supportCSM: true,\n basisNeedsPOT: false,\n support3DTextures: true,\n needTypeSuffixInShaderConstants: true,\n supportMSAA: true,\n supportSSAO2: true,\n supportIBLShadows: true,\n supportExtendedTextureFormats: true,\n supportSwitchCaseInShader: true,\n supportSyncTextureRead: false,\n needsInvertingBitmap: false,\n useUBOBindingCache: false,\n needShaderCodeInlining: true,\n needToAlwaysBindUniformBuffers: true,\n supportRenderPasses: true,\n supportSpriteInstancing: true,\n forceVertexBufferStrideAndOffsetMultiple4Bytes: true,\n _checkNonFloatVertexBuffersDontRecreatePipelineContext: true,\n _collectUbosUpdatedInFrame: false\n };\n }\n _initializeContextAndSwapChain() {\n if (!this._renderingCanvas) {\n // eslint-disable-next-line no-throw-literal\n throw \"The rendering canvas has not been set!\";\n }\n this._context = this._renderingCanvas.getContext(\"webgpu\");\n this._configureContext();\n this._colorFormat = this._options.swapChainFormat;\n this._mainRenderPassWrapper.colorAttachmentGPUTextures = [new WebGPUHardwareTexture(this)];\n this._mainRenderPassWrapper.colorAttachmentGPUTextures[0].format = this._colorFormat;\n this._setColorFormat(this._mainRenderPassWrapper);\n }\n // Set default values as WebGL with depth and stencil attachment for the broadest Compat.\n _initializeMainAttachments() {\n if (!this._bufferManager) {\n return;\n }\n this.flushFramebuffer();\n this._mainTextureExtends = {\n width: this.getRenderWidth(true),\n height: this.getRenderHeight(true),\n depthOrArrayLayers: 1\n };\n const bufferDataUpdate = new Float32Array([this.getRenderHeight(true)]);\n this._bufferManager.setSubData(this._ubInvertY, 4, bufferDataUpdate);\n this._bufferManager.setSubData(this._ubDontInvertY, 4, bufferDataUpdate);\n let mainColorAttachments;\n if (this._options.antialias) {\n const mainTextureDescriptor = {\n label: `Texture_MainColor_${this._mainTextureExtends.width}x${this._mainTextureExtends.height}_antialiasing`,\n size: this._mainTextureExtends,\n mipLevelCount: 1,\n sampleCount: this._mainPassSampleCount,\n dimension: \"2d\" /* WebGPUConstants.TextureDimension.E2d */,\n format: this._options.swapChainFormat,\n usage: 16 /* WebGPUConstants.TextureUsage.RenderAttachment */\n };\n if (this._mainTexture) {\n this._textureHelper.releaseTexture(this._mainTexture);\n }\n this._mainTexture = this._device.createTexture(mainTextureDescriptor);\n mainColorAttachments = [{\n view: this._mainTexture.createView({\n label: \"TextureView_MainColor_antialiasing\",\n dimension: \"2d\" /* WebGPUConstants.TextureDimension.E2d */,\n format: this._options.swapChainFormat,\n mipLevelCount: 1,\n arrayLayerCount: 1\n }),\n clearValue: new Color4(0, 0, 0, 1),\n loadOp: \"clear\" /* WebGPUConstants.LoadOp.Clear */,\n storeOp: \"store\" /* WebGPUConstants.StoreOp.Store */ // don't use StoreOp.Discard, else using several cameras with different viewports or using scissors will fail because we call beginRenderPass / endPass several times for the same color attachment!\n }];\n } else {\n mainColorAttachments = [{\n view: undefined,\n clearValue: new Color4(0, 0, 0, 1),\n loadOp: \"clear\" /* WebGPUConstants.LoadOp.Clear */,\n storeOp: \"store\" /* WebGPUConstants.StoreOp.Store */\n }];\n }\n this._mainRenderPassWrapper.depthTextureFormat = this.isStencilEnable ? \"depth24plus-stencil8\" /* WebGPUConstants.TextureFormat.Depth24PlusStencil8 */ : \"depth32float\" /* WebGPUConstants.TextureFormat.Depth32Float */;\n this._setDepthTextureFormat(this._mainRenderPassWrapper);\n this._setColorFormat(this._mainRenderPassWrapper);\n const depthTextureDescriptor = {\n label: `Texture_MainDepthStencil_${this._mainTextureExtends.width}x${this._mainTextureExtends.height}`,\n size: this._mainTextureExtends,\n mipLevelCount: 1,\n sampleCount: this._mainPassSampleCount,\n dimension: \"2d\" /* WebGPUConstants.TextureDimension.E2d */,\n format: this._mainRenderPassWrapper.depthTextureFormat,\n usage: 16 /* WebGPUConstants.TextureUsage.RenderAttachment */\n };\n if (this._depthTexture) {\n this._textureHelper.releaseTexture(this._depthTexture);\n }\n this._depthTexture = this._device.createTexture(depthTextureDescriptor);\n const mainDepthAttachment = {\n view: this._depthTexture.createView({\n label: `TextureView_MainDepthStencil_${this._mainTextureExtends.width}x${this._mainTextureExtends.height}`,\n dimension: \"2d\" /* WebGPUConstants.TextureDimension.E2d */,\n format: this._depthTexture.format,\n mipLevelCount: 1,\n arrayLayerCount: 1\n }),\n depthClearValue: this._clearDepthValue,\n depthLoadOp: \"clear\" /* WebGPUConstants.LoadOp.Clear */,\n depthStoreOp: \"store\" /* WebGPUConstants.StoreOp.Store */,\n stencilClearValue: this._clearStencilValue,\n stencilLoadOp: !this.isStencilEnable ? undefined : \"clear\" /* WebGPUConstants.LoadOp.Clear */,\n stencilStoreOp: !this.isStencilEnable ? undefined : \"store\" /* WebGPUConstants.StoreOp.Store */\n };\n this._mainRenderPassWrapper.renderPassDescriptor = {\n label: \"MainRenderPass\",\n colorAttachments: mainColorAttachments,\n depthStencilAttachment: mainDepthAttachment\n };\n }\n /**\n * Shared initialization across engines types.\n * @param canvas The canvas associated with this instance of the engine.\n */\n _sharedInit(canvas) {\n super._sharedInit(canvas);\n _CommonInit(this, canvas, this._creationOptions);\n }\n _configureContext() {\n this._context.configure({\n device: this._device,\n format: this._options.swapChainFormat,\n usage: 16 /* WebGPUConstants.TextureUsage.RenderAttachment */ | 1 /* WebGPUConstants.TextureUsage.CopySrc */,\n alphaMode: this.premultipliedAlpha ? \"premultiplied\" /* WebGPUConstants.CanvasAlphaMode.Premultiplied */ : \"opaque\" /* WebGPUConstants.CanvasAlphaMode.Opaque */\n });\n }\n /**\n * Resize an image and returns the image data as an uint8array\n * @param image image to resize\n * @param bufferWidth destination buffer width\n * @param bufferHeight destination buffer height\n * @returns an uint8array containing RGBA values of bufferWidth * bufferHeight size\n */\n resizeImageBitmap(image, bufferWidth, bufferHeight) {\n return ResizeImageBitmap(this, image, bufferWidth, bufferHeight);\n }\n /**\n * Engine abstraction for loading and creating an image bitmap from a given source string.\n * @param imageSource source to load the image from.\n * @param options An object that sets options for the image's extraction.\n * @returns ImageBitmap\n */\n _createImageBitmapFromSource(imageSource, options) {\n return CreateImageBitmapFromSource(this, imageSource, options);\n }\n /**\n * Toggle full screen mode\n * @param requestPointerLock defines if a pointer lock should be requested from the user\n */\n switchFullscreen(requestPointerLock) {\n if (this.isFullscreen) {\n this.exitFullscreen();\n } else {\n this.enterFullscreen(requestPointerLock);\n }\n }\n /**\n * Enters full screen mode\n * @param requestPointerLock defines if a pointer lock should be requested from the user\n */\n enterFullscreen(requestPointerLock) {\n if (!this.isFullscreen) {\n this._pointerLockRequested = requestPointerLock;\n if (this._renderingCanvas) {\n RequestFullscreen(this._renderingCanvas);\n }\n }\n }\n /**\n * Exits full screen mode\n */\n exitFullscreen() {\n if (this.isFullscreen) {\n ExitFullscreen();\n }\n }\n /**\n * Enters Pointerlock mode\n */\n enterPointerlock() {\n if (this._renderingCanvas) {\n RequestPointerlock(this._renderingCanvas);\n }\n }\n /**\n * Exits Pointerlock mode\n */\n exitPointerlock() {\n ExitPointerlock();\n }\n _rebuildBuffers() {\n super._rebuildBuffers();\n for (const storageBuffer of this._storageBuffers) {\n // The buffer can already be rebuilt by the call to _rebuildGeometries(), which recreates the storage buffers for the ComputeShaderParticleSystem\n if (storageBuffer.getBuffer().engineId !== this.uniqueId) {\n storageBuffer._rebuild();\n }\n }\n }\n _restoreEngineAfterContextLost(initEngine) {\n WebGPUCacheRenderPipelineTree.ResetCache();\n WebGPUCacheBindGroups.ResetCache();\n // Clear the draw wrappers and material contexts\n const cleanScenes = scenes => {\n for (const scene of scenes) {\n for (const mesh of scene.meshes) {\n const subMeshes = mesh.subMeshes;\n if (!subMeshes) {\n continue;\n }\n for (const subMesh of subMeshes) {\n subMesh._drawWrappers = [];\n }\n }\n for (const material of scene.materials) {\n var _material$_materialCo;\n (_material$_materialCo = material._materialContext) === null || _material$_materialCo === void 0 || _material$_materialCo.reset();\n }\n }\n };\n cleanScenes(this.scenes);\n cleanScenes(this._virtualScenes);\n // The leftOver uniform buffers are removed from the list because they will be recreated when we rebuild the effects\n const uboList = [];\n for (const uniformBuffer of this._uniformBuffers) {\n if (uniformBuffer.name.indexOf(\"leftOver\") < 0) {\n uboList.push(uniformBuffer);\n }\n }\n this._uniformBuffers = uboList;\n super._restoreEngineAfterContextLost(initEngine);\n }\n /**\n * Force a specific size of the canvas\n * @param width defines the new canvas' width\n * @param height defines the new canvas' height\n * @param forceSetSize true to force setting the sizes of the underlying canvas\n * @returns true if the size was changed\n */\n setSize(width, height, forceSetSize = false) {\n if (!super.setSize(width, height, forceSetSize)) {\n return false;\n }\n if (this.dbgVerboseLogsForFirstFrames) {\n if (this._count === undefined) {\n this._count = 0;\n }\n if (!this._count || this._count < this.dbgVerboseLogsNumFrames) {\n Logger.Log([\"frame #\" + this._count + \" - setSize -\", width, height]);\n }\n }\n this._initializeMainAttachments();\n if (this.snapshotRendering) {\n // reset snapshot rendering so that the next frame will record a new list of bundles\n this.snapshotRenderingReset();\n }\n return true;\n }\n /**\n * @internal\n */\n _getShaderProcessor(shaderLanguage) {\n if (shaderLanguage === 1 /* ShaderLanguage.WGSL */) {\n return this._shaderProcessorWGSL;\n }\n return this._shaderProcessor;\n }\n /**\n * @internal\n */\n _getShaderProcessingContext(shaderLanguage, pureMode) {\n return new WebGPUShaderProcessingContext(shaderLanguage, pureMode);\n }\n _getCurrentRenderPass() {\n if (this._currentRenderTarget && !this._currentRenderPass) {\n // delayed creation of the render target pass, but we now need to create it as we are requested the render pass\n this._startRenderTargetRenderPass(this._currentRenderTarget, false, null, false, false);\n } else if (!this._currentRenderPass) {\n this._startMainRenderPass(false);\n }\n return this._currentRenderPass;\n }\n /** @internal */\n _getCurrentRenderPassWrapper() {\n return this._currentRenderTarget ? this._rttRenderPassWrapper : this._mainRenderPassWrapper;\n }\n //------------------------------------------------------------------------------\n // Static Pipeline WebGPU States\n //------------------------------------------------------------------------------\n /** @internal */\n applyStates() {\n this._stencilStateComposer.apply();\n this._cacheRenderPipeline.setAlphaBlendEnabled(this._alphaState.alphaBlend);\n }\n /**\n * Force the entire cache to be cleared\n * You should not have to use this function unless your engine needs to share the WebGPU context with another engine\n * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)\n */\n wipeCaches(bruteForce) {\n if (this.preventCacheWipeBetweenFrames && !bruteForce) {\n return;\n }\n //this._currentEffect = null; // can't reset _currentEffect, else some crashes can occur (for eg in ProceduralTexture which calls bindFrameBuffer (which calls wipeCaches) after having called enableEffect and before drawing into the texture)\n // _forceEnableEffect = true assumes the role of _currentEffect = null\n this._forceEnableEffect = true;\n this._currentIndexBuffer = null;\n this._currentOverrideVertexBuffers = null;\n this._cacheRenderPipeline.setBuffers(null, null, null);\n if (bruteForce) {\n this._stencilStateComposer.reset();\n this._depthCullingState.reset();\n this._depthCullingState.depthFunc = 515;\n this._alphaState.reset();\n this._alphaMode = 1;\n this._alphaEquation = 0;\n this._cacheRenderPipeline.setAlphaBlendFactors(this._alphaState._blendFunctionParameters, this._alphaState._blendEquationParameters);\n this._cacheRenderPipeline.setAlphaBlendEnabled(false);\n this.setColorWrite(true);\n }\n this._cachedVertexBuffers = null;\n this._cachedIndexBuffer = null;\n this._cachedEffectForVertexBuffers = null;\n }\n /**\n * Enable or disable color writing\n * @param enable defines the state to set\n */\n setColorWrite(enable) {\n this._colorWriteLocal = enable;\n this._cacheRenderPipeline.setWriteMask(enable ? 0xf : 0);\n }\n /**\n * Gets a boolean indicating if color writing is enabled\n * @returns the current color writing state\n */\n getColorWrite() {\n return this._colorWriteLocal;\n }\n _mustUpdateViewport() {\n const x = this._viewportCached.x,\n y = this._viewportCached.y,\n w = this._viewportCached.z,\n h = this._viewportCached.w;\n const update = this._viewportsCurrent.x !== x || this._viewportsCurrent.y !== y || this._viewportsCurrent.w !== w || this._viewportsCurrent.h !== h;\n if (update) {\n this._viewportsCurrent.x = this._viewportCached.x;\n this._viewportsCurrent.y = this._viewportCached.y;\n this._viewportsCurrent.w = this._viewportCached.z;\n this._viewportsCurrent.h = this._viewportCached.w;\n }\n return update;\n }\n _applyViewport(bundleList) {\n const x = Math.floor(this._viewportCached.x);\n const w = Math.floor(this._viewportCached.z);\n const h = Math.floor(this._viewportCached.w);\n let y = Math.floor(this._viewportCached.y);\n if (!this._currentRenderTarget) {\n y = this.getRenderHeight(true) - y - h;\n }\n if (bundleList) {\n bundleList.addItem(new WebGPURenderItemViewport(x, y, w, h));\n } else {\n this._getCurrentRenderPass().setViewport(x, y, w, h, 0, 1);\n }\n if (this.dbgVerboseLogsForFirstFrames) {\n if (this._count === undefined) {\n this._count = 0;\n }\n if (!this._count || this._count < this.dbgVerboseLogsNumFrames) {\n Logger.Log([\"frame #\" + this._count + \" - viewport applied - (\", this._viewportCached.x, this._viewportCached.y, this._viewportCached.z, this._viewportCached.w, \") current pass is main pass=\" + this._currentPassIsMainPass()]);\n }\n }\n }\n /**\n * @internal\n */\n _viewport(x, y, width, height) {\n this._viewportCached.x = x;\n this._viewportCached.y = y;\n this._viewportCached.z = width;\n this._viewportCached.w = height;\n }\n _mustUpdateScissor() {\n const x = this._scissorCached.x,\n y = this._scissorCached.y,\n w = this._scissorCached.z,\n h = this._scissorCached.w;\n const update = this._scissorsCurrent.x !== x || this._scissorsCurrent.y !== y || this._scissorsCurrent.w !== w || this._scissorsCurrent.h !== h;\n if (update) {\n this._scissorsCurrent.x = this._scissorCached.x;\n this._scissorsCurrent.y = this._scissorCached.y;\n this._scissorsCurrent.w = this._scissorCached.z;\n this._scissorsCurrent.h = this._scissorCached.w;\n }\n return update;\n }\n _applyScissor(bundleList) {\n const y = this._currentRenderTarget ? this._scissorCached.y : this.getRenderHeight() - this._scissorCached.w - this._scissorCached.y;\n if (bundleList) {\n bundleList.addItem(new WebGPURenderItemScissor(this._scissorCached.x, y, this._scissorCached.z, this._scissorCached.w));\n } else {\n this._getCurrentRenderPass().setScissorRect(this._scissorCached.x, y, this._scissorCached.z, this._scissorCached.w);\n }\n if (this.dbgVerboseLogsForFirstFrames) {\n if (this._count === undefined) {\n this._count = 0;\n }\n if (!this._count || this._count < this.dbgVerboseLogsNumFrames) {\n Logger.Log([\"frame #\" + this._count + \" - scissor applied - (\", this._scissorCached.x, this._scissorCached.y, this._scissorCached.z, this._scissorCached.w, \") current pass is main pass=\" + this._currentPassIsMainPass()]);\n }\n }\n }\n _scissorIsActive() {\n return this._scissorCached.x !== 0 || this._scissorCached.y !== 0 || this._scissorCached.z !== 0 || this._scissorCached.w !== 0;\n }\n enableScissor(x, y, width, height) {\n this._scissorCached.x = x;\n this._scissorCached.y = y;\n this._scissorCached.z = width;\n this._scissorCached.w = height;\n }\n disableScissor() {\n this._scissorCached.x = this._scissorCached.y = this._scissorCached.z = this._scissorCached.w = 0;\n this._scissorsCurrent.x = this._scissorsCurrent.y = this._scissorsCurrent.w = this._scissorsCurrent.h = 0;\n }\n _mustUpdateStencilRef() {\n const update = this._stencilStateComposer.funcRef !== this._stencilRefsCurrent;\n if (update) {\n this._stencilRefsCurrent = this._stencilStateComposer.funcRef;\n }\n return update;\n }\n _applyStencilRef(bundleList) {\n if (bundleList) {\n var _this$_stencilStateCo;\n bundleList.addItem(new WebGPURenderItemStencilRef((_this$_stencilStateCo = this._stencilStateComposer.funcRef) !== null && _this$_stencilStateCo !== void 0 ? _this$_stencilStateCo : 0));\n } else {\n var _this$_stencilStateCo2;\n this._getCurrentRenderPass().setStencilReference((_this$_stencilStateCo2 = this._stencilStateComposer.funcRef) !== null && _this$_stencilStateCo2 !== void 0 ? _this$_stencilStateCo2 : 0);\n }\n }\n _mustUpdateBlendColor() {\n const colorBlend = this._alphaState._blendConstants;\n const update = colorBlend[0] !== this._blendColorsCurrent[0] || colorBlend[1] !== this._blendColorsCurrent[1] || colorBlend[2] !== this._blendColorsCurrent[2] || colorBlend[3] !== this._blendColorsCurrent[3];\n if (update) {\n this._blendColorsCurrent[0] = colorBlend[0];\n this._blendColorsCurrent[1] = colorBlend[1];\n this._blendColorsCurrent[2] = colorBlend[2];\n this._blendColorsCurrent[3] = colorBlend[3];\n }\n return update;\n }\n _applyBlendColor(bundleList) {\n if (bundleList) {\n bundleList.addItem(new WebGPURenderItemBlendColor(this._alphaState._blendConstants.slice()));\n } else {\n this._getCurrentRenderPass().setBlendConstant(this._alphaState._blendConstants);\n }\n }\n _resetRenderPassStates() {\n this._viewportsCurrent.x = this._viewportsCurrent.y = this._viewportsCurrent.w = this._viewportsCurrent.h = 0;\n this._scissorsCurrent.x = this._scissorsCurrent.y = this._scissorsCurrent.w = this._scissorsCurrent.h = 0;\n this._stencilRefsCurrent = -1;\n this._blendColorsCurrent[0] = this._blendColorsCurrent[1] = this._blendColorsCurrent[2] = this._blendColorsCurrent[3] = null;\n }\n /**\n * Clear the current render buffer or the current render target (if any is set up)\n * @param color defines the color to use\n * @param backBuffer defines if the back buffer must be cleared\n * @param depth defines if the depth buffer must be cleared\n * @param stencil defines if the stencil buffer must be cleared\n */\n clear(color, backBuffer, depth, stencil = false) {\n // Some PGs are using color3...\n if (color && color.a === undefined) {\n color.a = 1;\n }\n const hasScissor = this._scissorIsActive();\n if (this.dbgVerboseLogsForFirstFrames) {\n if (this._count === undefined) {\n this._count = 0;\n }\n if (!this._count || this._count < this.dbgVerboseLogsNumFrames) {\n Logger.Log([\"frame #\" + this._count + \" - clear - backBuffer=\", backBuffer, \" depth=\", depth, \" stencil=\", stencil, \" scissor is active=\", hasScissor]);\n }\n }\n // We need to recreate the render pass so that the new parameters for clear color / depth / stencil are taken into account\n if (this._currentRenderTarget) {\n if (hasScissor) {\n if (!this._currentRenderPass) {\n this._startRenderTargetRenderPass(this._currentRenderTarget, false, backBuffer ? color : null, depth, stencil);\n }\n this._applyScissor(!this.compatibilityMode ? this._bundleList : null);\n this._clearFullQuad(backBuffer ? color : null, depth, stencil);\n } else {\n if (this._currentRenderPass) {\n this._endCurrentRenderPass();\n }\n this._startRenderTargetRenderPass(this._currentRenderTarget, true, backBuffer ? color : null, depth, stencil);\n }\n } else {\n if (!this._currentRenderPass || !hasScissor) {\n this._startMainRenderPass(!hasScissor, backBuffer ? color : null, depth, stencil);\n }\n if (hasScissor) {\n this._applyScissor(!this.compatibilityMode ? this._bundleList : null);\n this._clearFullQuad(backBuffer ? color : null, depth, stencil);\n }\n }\n }\n _clearFullQuad(clearColor, clearDepth, clearStencil) {\n var _this$_cacheRenderPip, _this$_cacheRenderPip2;\n const renderPass = !this.compatibilityMode ? null : this._getCurrentRenderPass();\n this._clearQuad.setColorFormat(this._colorFormat);\n this._clearQuad.setDepthStencilFormat(this._depthTextureFormat);\n this._clearQuad.setMRTAttachments((_this$_cacheRenderPip = this._cacheRenderPipeline.mrtAttachments) !== null && _this$_cacheRenderPip !== void 0 ? _this$_cacheRenderPip : [], (_this$_cacheRenderPip2 = this._cacheRenderPipeline.mrtTextureArray) !== null && _this$_cacheRenderPip2 !== void 0 ? _this$_cacheRenderPip2 : [], this._cacheRenderPipeline.mrtTextureCount);\n if (!this.compatibilityMode) {\n this._bundleList.addItem(new WebGPURenderItemStencilRef(this._clearStencilValue));\n } else {\n renderPass.setStencilReference(this._clearStencilValue);\n }\n const bundle = this._clearQuad.clear(renderPass, clearColor, clearDepth, clearStencil, this.currentSampleCount);\n if (!this.compatibilityMode) {\n this._bundleList.addBundle(bundle);\n this._applyStencilRef(this._bundleList);\n this._reportDrawCall();\n } else {\n this._applyStencilRef(null);\n }\n }\n //------------------------------------------------------------------------------\n // Vertex/Index/Storage Buffers\n //------------------------------------------------------------------------------\n /**\n * Creates a vertex buffer\n * @param data the data or the size for the vertex buffer\n * @param _updatable whether the buffer should be created as updatable\n * @param label defines the label of the buffer (for debug purpose)\n * @returns the new buffer\n */\n createVertexBuffer(data, _updatable, label) {\n let view;\n if (data instanceof Array) {\n view = new Float32Array(data);\n } else if (data instanceof ArrayBuffer) {\n view = new Uint8Array(data);\n } else {\n view = data;\n }\n const dataBuffer = this._bufferManager.createBuffer(view, WebGPUConstants.BufferUsage.Vertex | WebGPUConstants.BufferUsage.CopyDst, label);\n return dataBuffer;\n }\n /**\n * Creates a vertex buffer\n * @param data the data for the dynamic vertex buffer\n * @param label defines the label of the buffer (for debug purpose)\n * @returns the new buffer\n */\n createDynamicVertexBuffer(data, label) {\n return this.createVertexBuffer(data, undefined, label);\n }\n /**\n * Creates a new index buffer\n * @param indices defines the content of the index buffer\n * @param _updatable defines if the index buffer must be updatable\n * @param label defines the label of the buffer (for debug purpose)\n * @returns a new buffer\n */\n createIndexBuffer(indices, _updatable, label) {\n let is32Bits = true;\n let view;\n if (indices instanceof Uint32Array || indices instanceof Int32Array) {\n view = indices;\n } else if (indices instanceof Uint16Array) {\n view = indices;\n is32Bits = false;\n } else {\n if (indices.length > 65535) {\n view = new Uint32Array(indices);\n } else {\n view = new Uint16Array(indices);\n is32Bits = false;\n }\n }\n const dataBuffer = this._bufferManager.createBuffer(view, WebGPUConstants.BufferUsage.Index | WebGPUConstants.BufferUsage.CopyDst, label);\n dataBuffer.is32Bits = is32Bits;\n return dataBuffer;\n }\n /**\n * Update a dynamic index buffer\n * @param indexBuffer defines the target index buffer\n * @param indices defines the data to update\n * @param offset defines the offset in the target index buffer where update should start\n */\n updateDynamicIndexBuffer(indexBuffer, indices, offset = 0) {\n const gpuBuffer = indexBuffer;\n let view;\n if (indexBuffer.is32Bits) {\n view = indices instanceof Uint32Array ? indices : new Uint32Array(indices);\n } else {\n view = indices instanceof Uint16Array ? indices : new Uint16Array(indices);\n }\n this._bufferManager.setSubData(gpuBuffer, offset, view);\n }\n /**\n * Updates a dynamic vertex buffer.\n * @param vertexBuffer the vertex buffer to update\n * @param data the data used to update the vertex buffer\n * @param byteOffset the byte offset of the data\n * @param byteLength the byte length of the data\n */\n updateDynamicVertexBuffer(vertexBuffer, data, byteOffset, byteLength) {\n const dataBuffer = vertexBuffer;\n if (byteOffset === undefined) {\n byteOffset = 0;\n }\n let view;\n if (byteLength === undefined) {\n if (data instanceof Array) {\n view = new Float32Array(data);\n } else if (data instanceof ArrayBuffer) {\n view = new Uint8Array(data);\n } else {\n view = data;\n }\n byteLength = view.byteLength;\n } else {\n if (data instanceof Array) {\n view = new Float32Array(data);\n } else if (data instanceof ArrayBuffer) {\n view = new Uint8Array(data);\n } else {\n view = data;\n }\n }\n this._bufferManager.setSubData(dataBuffer, byteOffset, view, 0, byteLength);\n }\n /**\n * @internal\n */\n _createBuffer(data, creationFlags, label) {\n let view;\n if (data instanceof Array) {\n view = new Float32Array(data);\n } else if (data instanceof ArrayBuffer) {\n view = new Uint8Array(data);\n } else {\n view = data;\n }\n let flags = 0;\n if (creationFlags & 1) {\n flags |= WebGPUConstants.BufferUsage.CopySrc;\n }\n if (creationFlags & 2) {\n flags |= WebGPUConstants.BufferUsage.CopyDst;\n }\n if (creationFlags & 4) {\n flags |= WebGPUConstants.BufferUsage.Uniform;\n }\n if (creationFlags & 8) {\n flags |= WebGPUConstants.BufferUsage.Vertex;\n }\n if (creationFlags & 16) {\n flags |= WebGPUConstants.BufferUsage.Index;\n }\n if (creationFlags & 32) {\n flags |= WebGPUConstants.BufferUsage.Storage;\n }\n if (creationFlags & 64) {\n flags |= WebGPUConstants.BufferUsage.Indirect;\n }\n return this._bufferManager.createBuffer(view, flags, label);\n }\n /**\n * @internal\n */\n bindBuffersDirectly() {\n // eslint-disable-next-line no-throw-literal\n throw \"Not implemented on WebGPU\";\n }\n /**\n * @internal\n */\n updateAndBindInstancesBuffer() {\n // eslint-disable-next-line no-throw-literal\n throw \"Not implemented on WebGPU\";\n }\n /**\n * Unbind all instance attributes\n */\n unbindInstanceAttributes() {\n // Does nothing\n }\n /**\n * Bind a list of vertex buffers with the engine\n * @param vertexBuffers defines the list of vertex buffers to bind\n * @param indexBuffer defines the index buffer to bind\n * @param effect defines the effect associated with the vertex buffers\n * @param overrideVertexBuffers defines optional list of avertex buffers that overrides the entries in vertexBuffers\n */\n bindBuffers(vertexBuffers, indexBuffer, effect, overrideVertexBuffers) {\n this._currentIndexBuffer = indexBuffer;\n this._currentOverrideVertexBuffers = overrideVertexBuffers !== null && overrideVertexBuffers !== void 0 ? overrideVertexBuffers : null;\n this._cacheRenderPipeline.setBuffers(vertexBuffers, indexBuffer, this._currentOverrideVertexBuffers);\n }\n /**\n * @internal\n */\n _releaseBuffer(buffer) {\n return this._bufferManager.releaseBuffer(buffer);\n }\n //------------------------------------------------------------------------------\n // Uniform Buffers\n //------------------------------------------------------------------------------\n /**\n * Create an uniform buffer\n * @see https://doc.babylonjs.com/setup/support/webGL2#uniform-buffer-objets\n * @param elements defines the content of the uniform buffer\n * @param label defines a name for the buffer (for debugging purpose)\n * @returns the webGL uniform buffer\n */\n createUniformBuffer(elements, label) {\n let view;\n if (elements instanceof Array) {\n view = new Float32Array(elements);\n } else {\n view = elements;\n }\n const dataBuffer = this._bufferManager.createBuffer(view, WebGPUConstants.BufferUsage.Uniform | WebGPUConstants.BufferUsage.CopyDst, label);\n return dataBuffer;\n }\n /**\n * Create a dynamic uniform buffer (no different from a non dynamic uniform buffer in WebGPU)\n * @see https://doc.babylonjs.com/setup/support/webGL2#uniform-buffer-objets\n * @param elements defines the content of the uniform buffer\n * @param label defines a name for the buffer (for debugging purpose)\n * @returns the webGL uniform buffer\n */\n createDynamicUniformBuffer(elements, label) {\n return this.createUniformBuffer(elements, label);\n }\n /**\n * Update an existing uniform buffer\n * @see https://doc.babylonjs.com/setup/support/webGL2#uniform-buffer-objets\n * @param uniformBuffer defines the target uniform buffer\n * @param elements defines the content to update\n * @param offset defines the offset in the uniform buffer where update should start\n * @param count defines the size of the data to update\n */\n updateUniformBuffer(uniformBuffer, elements, offset, count) {\n if (offset === undefined) {\n offset = 0;\n }\n const dataBuffer = uniformBuffer;\n let view;\n if (count === undefined) {\n if (elements instanceof Float32Array) {\n view = elements;\n } else {\n view = new Float32Array(elements);\n }\n count = view.byteLength;\n } else {\n if (elements instanceof Float32Array) {\n view = elements;\n } else {\n view = new Float32Array(elements);\n }\n }\n this._bufferManager.setSubData(dataBuffer, offset, view, 0, count);\n }\n /**\n * Bind a buffer to the current draw context\n * @param buffer defines the buffer to bind\n * @param _location not used in WebGPU\n * @param name Name of the uniform variable to bind\n */\n bindUniformBufferBase(buffer, _location, name) {\n this._currentDrawContext.setBuffer(name, buffer);\n }\n /**\n * Unused in WebGPU\n */\n bindUniformBlock() {}\n //------------------------------------------------------------------------------\n // Effects\n //------------------------------------------------------------------------------\n /**\n * Create a new effect (used to store vertex/fragment shaders)\n * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)\n * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object\n * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use\n * @param samplers defines an array of string used to represent textures\n * @param defines defines the string containing the defines to use to compile the shaders\n * @param fallbacks defines the list of potential fallbacks to use if shader compilation fails\n * @param onCompiled defines a function to call when the effect creation is successful\n * @param onError defines a function to call when the effect creation has failed\n * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)\n * @param shaderLanguage the language the shader is written in (default: GLSL)\n * @param extraInitializationsAsync additional async code to run before preparing the effect\n * @returns the new Effect\n */\n createEffect(baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, defines, fallbacks, onCompiled, onError, indexParameters, shaderLanguage = 0 /* ShaderLanguage.GLSL */, extraInitializationsAsync) {\n var _ref2, _attributesNamesOrOpt, _attributesNamesOrOpt2;\n const vertex = typeof baseName === \"string\" ? baseName : baseName.vertexToken || baseName.vertexSource || baseName.vertexElement || baseName.vertex;\n const fragment = typeof baseName === \"string\" ? baseName : baseName.fragmentToken || baseName.fragmentSource || baseName.fragmentElement || baseName.fragment;\n const globalDefines = this._getGlobalDefines();\n let fullDefines = (_ref2 = defines !== null && defines !== void 0 ? defines : attributesNamesOrOptions.defines) !== null && _ref2 !== void 0 ? _ref2 : \"\";\n if (globalDefines) {\n fullDefines += \"\\n\" + globalDefines;\n }\n const name = vertex + \"+\" + fragment + \"@\" + fullDefines;\n if (this._compiledEffects[name]) {\n const compiledEffect = this._compiledEffects[name];\n if (onCompiled && compiledEffect.isReady()) {\n onCompiled(compiledEffect);\n }\n compiledEffect._refCount++;\n return compiledEffect;\n }\n const effect = new Effect(baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, this, defines, fallbacks, onCompiled, onError, indexParameters, name, (_attributesNamesOrOpt = attributesNamesOrOptions.shaderLanguage) !== null && _attributesNamesOrOpt !== void 0 ? _attributesNamesOrOpt : shaderLanguage, (_attributesNamesOrOpt2 = attributesNamesOrOptions.extraInitializationsAsync) !== null && _attributesNamesOrOpt2 !== void 0 ? _attributesNamesOrOpt2 : extraInitializationsAsync);\n this._compiledEffects[name] = effect;\n return effect;\n }\n _compileRawShaderToSpirV(source, type) {\n return this._glslang.compileGLSL(source, type);\n }\n _compileShaderToSpirV(source, type, defines, shaderVersion) {\n return this._compileRawShaderToSpirV(shaderVersion + (defines ? defines + \"\\n\" : \"\") + source, type);\n }\n _getWGSLShader(source, type, defines) {\n if (defines) {\n defines = \"//\" + defines.split(\"\\n\").join(\"\\n//\") + \"\\n\";\n } else {\n defines = \"\";\n }\n return defines + source;\n }\n _createPipelineStageDescriptor(vertexShader, fragmentShader, shaderLanguage, disableUniformityAnalysisInVertex, disableUniformityAnalysisInFragment) {\n if (this._tintWASM && shaderLanguage === 0 /* ShaderLanguage.GLSL */) {\n vertexShader = this._tintWASM.convertSpirV2WGSL(vertexShader, disableUniformityAnalysisInVertex);\n fragmentShader = this._tintWASM.convertSpirV2WGSL(fragmentShader, disableUniformityAnalysisInFragment);\n }\n return {\n vertexStage: {\n module: this._device.createShaderModule({\n label: \"vertex\",\n code: vertexShader\n }),\n entryPoint: \"main\"\n },\n fragmentStage: {\n module: this._device.createShaderModule({\n label: \"fragment\",\n code: fragmentShader\n }),\n entryPoint: \"main\"\n }\n };\n }\n _compileRawPipelineStageDescriptor(vertexCode, fragmentCode, shaderLanguage) {\n const disableUniformityAnalysisInVertex = vertexCode.indexOf(`#define DISABLE_UNIFORMITY_ANALYSIS`) >= 0;\n const disableUniformityAnalysisInFragment = fragmentCode.indexOf(`#define DISABLE_UNIFORMITY_ANALYSIS`) >= 0;\n const vertexShader = shaderLanguage === 0 /* ShaderLanguage.GLSL */ ? this._compileRawShaderToSpirV(vertexCode, \"vertex\") : vertexCode;\n const fragmentShader = shaderLanguage === 0 /* ShaderLanguage.GLSL */ ? this._compileRawShaderToSpirV(fragmentCode, \"fragment\") : fragmentCode;\n return this._createPipelineStageDescriptor(vertexShader, fragmentShader, shaderLanguage, disableUniformityAnalysisInVertex, disableUniformityAnalysisInFragment);\n }\n _compilePipelineStageDescriptor(vertexCode, fragmentCode, defines, shaderLanguage) {\n this.onBeforeShaderCompilationObservable.notifyObservers(this);\n const disableUniformityAnalysisInVertex = vertexCode.indexOf(`#define DISABLE_UNIFORMITY_ANALYSIS`) >= 0;\n const disableUniformityAnalysisInFragment = fragmentCode.indexOf(`#define DISABLE_UNIFORMITY_ANALYSIS`) >= 0;\n const shaderVersion = \"#version 450\\n\";\n const vertexShader = shaderLanguage === 0 /* ShaderLanguage.GLSL */ ? this._compileShaderToSpirV(vertexCode, \"vertex\", defines, shaderVersion) : this._getWGSLShader(vertexCode, \"vertex\", defines);\n const fragmentShader = shaderLanguage === 0 /* ShaderLanguage.GLSL */ ? this._compileShaderToSpirV(fragmentCode, \"fragment\", defines, shaderVersion) : this._getWGSLShader(fragmentCode, \"fragment\", defines);\n const program = this._createPipelineStageDescriptor(vertexShader, fragmentShader, shaderLanguage, disableUniformityAnalysisInVertex, disableUniformityAnalysisInFragment);\n this.onAfterShaderCompilationObservable.notifyObservers(this);\n return program;\n }\n /**\n * @internal\n */\n createRawShaderProgram() {\n // eslint-disable-next-line no-throw-literal\n throw \"Not available on WebGPU\";\n }\n /**\n * @internal\n */\n createShaderProgram() {\n // eslint-disable-next-line no-throw-literal\n throw \"Not available on WebGPU\";\n }\n /**\n * Inline functions in shader code that are marked to be inlined\n * @param code code to inline\n * @returns inlined code\n */\n inlineShaderCode(code) {\n const sci = new ShaderCodeInliner(code);\n sci.debug = false;\n sci.processCode();\n return sci.code;\n }\n /**\n * Creates a new pipeline context\n * @param shaderProcessingContext defines the shader processing context used during the processing if available\n * @returns the new pipeline\n */\n createPipelineContext(shaderProcessingContext) {\n return new WebGPUPipelineContext(shaderProcessingContext, this);\n }\n /**\n * Creates a new material context\n * @returns the new context\n */\n createMaterialContext() {\n return new WebGPUMaterialContext();\n }\n /**\n * Creates a new draw context\n * @returns the new context\n */\n createDrawContext() {\n return new WebGPUDrawContext(this._bufferManager);\n }\n /**\n * @internal\n */\n _preparePipelineContext(pipelineContext, vertexSourceCode, fragmentSourceCode, createAsRaw, rawVertexSourceCode, rawFragmentSourceCode, _rebuildRebind, defines, _transformFeedbackVaryings, _key, onReady) {\n var _this2 = this;\n return _asyncToGenerator(function* () {\n const webGpuContext = pipelineContext;\n const shaderLanguage = webGpuContext.shaderProcessingContext.shaderLanguage;\n if (shaderLanguage === 0 /* ShaderLanguage.GLSL */ && !_this2._glslangAndTintAreFullyLoaded) {\n yield _this2.prepareGlslangAndTintAsync();\n }\n if (_this2.dbgShowShaderCode) {\n Logger.Log([\"defines\", defines]);\n Logger.Log(vertexSourceCode);\n Logger.Log(fragmentSourceCode);\n Logger.Log(\"***********************************************\");\n }\n webGpuContext.sources = {\n fragment: fragmentSourceCode,\n vertex: vertexSourceCode,\n rawVertex: rawVertexSourceCode,\n rawFragment: rawFragmentSourceCode\n };\n if (createAsRaw) {\n webGpuContext.stages = _this2._compileRawPipelineStageDescriptor(vertexSourceCode, fragmentSourceCode, shaderLanguage);\n } else {\n webGpuContext.stages = _this2._compilePipelineStageDescriptor(vertexSourceCode, fragmentSourceCode, defines, shaderLanguage);\n }\n onReady();\n })();\n }\n /**\n * Gets the list of active attributes for a given WebGPU program\n * @param pipelineContext defines the pipeline context to use\n * @param attributesNames defines the list of attribute names to get\n * @returns an array of indices indicating the offset of each attribute\n */\n getAttributes(pipelineContext, attributesNames) {\n const results = new Array(attributesNames.length);\n const gpuPipelineContext = pipelineContext;\n for (let i = 0; i < attributesNames.length; i++) {\n const attributeName = attributesNames[i];\n const attributeLocation = gpuPipelineContext.shaderProcessingContext.availableAttributes[attributeName];\n if (attributeLocation === undefined) {\n continue;\n }\n results[i] = attributeLocation;\n }\n return results;\n }\n /**\n * Activates an effect, making it the current one (ie. the one used for rendering)\n * @param effect defines the effect to activate\n */\n enableEffect(effect) {\n if (!effect) {\n return;\n }\n if (!IsWrapper(effect)) {\n this._currentEffect = effect;\n this._currentMaterialContext = this._defaultMaterialContext;\n this._currentDrawContext = this._defaultDrawContext;\n this._counters.numEnableEffects++;\n if (this.dbgLogIfNotDrawWrapper) {\n Logger.Warn(`enableEffect has been called with an Effect and not a Wrapper! effect.uniqueId=${effect.uniqueId}, effect.name=${effect.name}, effect.name.vertex=${typeof effect.name === \"string\" ? \"\" : effect.name.vertex}, effect.name.fragment=${typeof effect.name === \"string\" ? \"\" : effect.name.fragment}`, 10);\n }\n } else if (!effect.effect || effect.effect === this._currentEffect && effect.materialContext === this._currentMaterialContext && effect.drawContext === this._currentDrawContext && !this._forceEnableEffect) {\n if (!effect.effect && this.dbgShowEmptyEnableEffectCalls) {\n Logger.Log([\"drawWrapper=\", effect]);\n // eslint-disable-next-line no-throw-literal\n throw \"Invalid call to enableEffect: the effect property is empty!\";\n }\n return;\n } else {\n this._currentEffect = effect.effect;\n this._currentMaterialContext = effect.materialContext;\n this._currentDrawContext = effect.drawContext;\n this._counters.numEnableDrawWrapper++;\n if (!this._currentMaterialContext) {\n Logger.Log([\"drawWrapper=\", effect]);\n // eslint-disable-next-line no-throw-literal\n throw `Invalid call to enableEffect: the materialContext property is empty!`;\n }\n }\n this._stencilStateComposer.stencilMaterial = undefined;\n this._forceEnableEffect = false;\n if (this._currentEffect.onBind) {\n this._currentEffect.onBind(this._currentEffect);\n }\n if (this._currentEffect._onBindObservable) {\n this._currentEffect._onBindObservable.notifyObservers(this._currentEffect);\n }\n }\n /**\n * @internal\n */\n _releaseEffect(effect) {\n if (this._compiledEffects[effect._key]) {\n delete this._compiledEffects[effect._key];\n this._deletePipelineContext(effect.getPipelineContext());\n }\n }\n /**\n * Force the engine to release all cached effects. This means that next effect compilation will have to be done completely even if a similar effect was already compiled\n */\n releaseEffects() {\n for (const name in this._compiledEffects) {\n const webGPUPipelineContext = this._compiledEffects[name].getPipelineContext();\n this._deletePipelineContext(webGPUPipelineContext);\n }\n this._compiledEffects = {};\n }\n _deletePipelineContext(pipelineContext) {\n const webgpuPipelineContext = pipelineContext;\n if (webgpuPipelineContext) {\n resetCachedPipeline(webgpuPipelineContext);\n }\n }\n //------------------------------------------------------------------------------\n // Textures\n //------------------------------------------------------------------------------\n /**\n * Gets a boolean indicating that only power of 2 textures are supported\n * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them\n */\n get needPOTTextures() {\n return false;\n }\n /** @internal */\n _createHardwareTexture() {\n return new WebGPUHardwareTexture(this);\n }\n /**\n * @internal\n */\n _releaseTexture(texture) {\n const index = this._internalTexturesCache.indexOf(texture);\n if (index !== -1) {\n this._internalTexturesCache.splice(index, 1);\n }\n this._textureHelper.releaseTexture(texture);\n }\n /**\n * @internal\n */\n _getRGBABufferInternalSizedFormat() {\n return 5;\n }\n updateTextureComparisonFunction(texture, comparisonFunction) {\n texture._comparisonFunction = comparisonFunction;\n }\n /**\n * Creates an internal texture without binding it to a framebuffer\n * @internal\n * @param size defines the size of the texture\n * @param options defines the options used to create the texture\n * @param delayGPUTextureCreation true to delay the texture creation the first time it is really needed. false to create it right away\n * @param source source type of the texture\n * @returns a new internal texture\n */\n _createInternalTexture(size, options, delayGPUTextureCreation = true, source = 0 /* InternalTextureSource.Unknown */) {\n const fullOptions = {};\n if (options !== undefined && typeof options === \"object\") {\n var _options$samples, _options$creationFlag, _options$useSRGBBuffe;\n fullOptions.generateMipMaps = options.generateMipMaps;\n fullOptions.createMipMaps = options.createMipMaps;\n fullOptions.type = options.type === undefined ? 0 : options.type;\n fullOptions.samplingMode = options.samplingMode === undefined ? 3 : options.samplingMode;\n fullOptions.format = options.format === undefined ? 5 : options.format;\n fullOptions.samples = (_options$samples = options.samples) !== null && _options$samples !== void 0 ? _options$samples : 1;\n fullOptions.creationFlags = (_options$creationFlag = options.creationFlags) !== null && _options$creationFlag !== void 0 ? _options$creationFlag : 0;\n fullOptions.useSRGBBuffer = (_options$useSRGBBuffe = options.useSRGBBuffer) !== null && _options$useSRGBBuffe !== void 0 ? _options$useSRGBBuffe : false;\n fullOptions.label = options.label;\n } else {\n fullOptions.generateMipMaps = options;\n fullOptions.type = 0;\n fullOptions.samplingMode = 3;\n fullOptions.format = 5;\n fullOptions.samples = 1;\n fullOptions.creationFlags = 0;\n fullOptions.useSRGBBuffer = false;\n }\n if (fullOptions.type === 1 && !this._caps.textureFloatLinearFiltering) {\n fullOptions.samplingMode = 1;\n } else if (fullOptions.type === 2 && !this._caps.textureHalfFloatLinearFiltering) {\n fullOptions.samplingMode = 1;\n }\n if (fullOptions.type === 1 && !this._caps.textureFloat) {\n fullOptions.type = 0;\n Logger.Warn(\"Float textures are not supported. Type forced to TEXTURETYPE_UNSIGNED_BYTE\");\n }\n const texture = new InternalTexture(this, source);\n const width = size.width || size;\n const height = size.height || size;\n const depth = size.depth || 0;\n const layers = size.layers || 0;\n texture.baseWidth = width;\n texture.baseHeight = height;\n texture.width = width;\n texture.height = height;\n texture.depth = depth || layers;\n texture.isReady = true;\n texture.samples = fullOptions.samples;\n texture.generateMipMaps = !!fullOptions.generateMipMaps;\n texture.samplingMode = fullOptions.samplingMode;\n texture.type = fullOptions.type;\n texture.format = fullOptions.format;\n texture.is2DArray = layers > 0;\n texture.is3D = depth > 0;\n texture._cachedWrapU = 0;\n texture._cachedWrapV = 0;\n texture._useSRGBBuffer = fullOptions.useSRGBBuffer;\n texture.label = fullOptions.label;\n this._internalTexturesCache.push(texture);\n if (!delayGPUTextureCreation) {\n const createMipMapsOnly = !fullOptions.generateMipMaps && fullOptions.createMipMaps;\n if (createMipMapsOnly) {\n // So that the call to createGPUTextureForInternalTexture creates the mipmaps\n texture.generateMipMaps = true;\n }\n this._textureHelper.createGPUTextureForInternalTexture(texture, width, height, layers || 1, fullOptions.creationFlags);\n if (createMipMapsOnly) {\n // So that we don't automatically generate mipmaps when the render target is unbound\n texture.generateMipMaps = false;\n }\n }\n return texture;\n }\n /**\n * Usually called from Texture.ts.\n * Passed information to create a hardware texture\n * @param url defines a value which contains one of the following:\n * * A conventional http URL, e.g. 'http://...' or 'file://...'\n * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'\n * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'\n * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file\n * @param invertY when true, image is flipped when loaded. You probably want true. Certain compressed textures may invert this if their default is inverted (eg. ktx)\n * @param scene needed for loading to the correct scene\n * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)\n * @param onLoad optional callback to be called upon successful completion\n * @param onError optional callback to be called upon failure\n * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), HTMLImageElement (image format), or a Blob\n * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities\n * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures\n * @param forcedExtension defines the extension to use to pick the right loader\n * @param mimeType defines an optional mime type\n * @param loaderOptions options to be passed to the loader\n * @param creationFlags specific flags to use when creating the texture (1 for storage textures, for eg)\n * @param useSRGBBuffer defines if the texture must be loaded in a sRGB GPU buffer (if supported by the GPU).\n * @returns a InternalTexture for assignment back into BABYLON.Texture\n */\n createTexture(url, noMipmap, invertY, scene, samplingMode = 3, onLoad = null, onError = null, buffer = null, fallback = null, format = null, forcedExtension = null, mimeType, loaderOptions, creationFlags, useSRGBBuffer) {\n return this._createTextureBase(url, noMipmap, invertY, scene, samplingMode, onLoad, onError, (texture, extension, scene, img, invertY, noMipmap, isCompressed, processFunction) => {\n var _texture$_hardwareTex;\n const imageBitmap = img; // we will never get an HTMLImageElement in WebGPU\n texture.baseWidth = imageBitmap.width;\n texture.baseHeight = imageBitmap.height;\n texture.width = imageBitmap.width;\n texture.height = imageBitmap.height;\n texture.format = texture.format !== -1 ? texture.format : format !== null && format !== void 0 ? format : 5;\n texture.type = texture.type !== -1 ? texture.type : 0;\n texture._creationFlags = creationFlags !== null && creationFlags !== void 0 ? creationFlags : 0;\n processFunction(texture.width, texture.height, imageBitmap, extension, texture, () => {});\n if (!((_texture$_hardwareTex = texture._hardwareTexture) !== null && _texture$_hardwareTex !== void 0 && _texture$_hardwareTex.underlyingResource)) {\n // the texture could have been created before reaching this point so don't recreate it if already existing\n const gpuTextureWrapper = this._textureHelper.createGPUTextureForInternalTexture(texture, imageBitmap.width, imageBitmap.height, undefined, creationFlags);\n if (WebGPUTextureHelper.IsImageBitmap(imageBitmap)) {\n this._textureHelper.updateTexture(imageBitmap, texture, imageBitmap.width, imageBitmap.height, texture.depth, gpuTextureWrapper.format, 0, 0, invertY, false, 0, 0);\n if (!noMipmap && !isCompressed) {\n this._generateMipmaps(texture, this._uploadEncoder);\n }\n }\n } else if (!noMipmap && !isCompressed) {\n this._generateMipmaps(texture, this._uploadEncoder);\n }\n if (scene) {\n scene.removePendingData(texture);\n }\n texture.isReady = true;\n texture.onLoadedObservable.notifyObservers(texture);\n texture.onLoadedObservable.clear();\n }, () => false, buffer, fallback, format, forcedExtension, mimeType, loaderOptions, useSRGBBuffer);\n }\n /**\n * Wraps an external web gpu texture in a Babylon texture.\n * @param texture defines the external texture\n * @returns the babylon internal texture\n */\n wrapWebGPUTexture(texture) {\n const hardwareTexture = new WebGPUHardwareTexture(this, texture);\n const internalTexture = new InternalTexture(this, 0 /* InternalTextureSource.Unknown */, true);\n internalTexture._hardwareTexture = hardwareTexture;\n internalTexture.isReady = true;\n return internalTexture;\n }\n // eslint-disable-next-line jsdoc/require-returns-check\n /**\n * Wraps an external web gl texture in a Babylon texture.\n * @returns the babylon internal texture\n */\n wrapWebGLTexture() {\n throw new Error(\"wrapWebGLTexture is not supported, use wrapWebGPUTexture instead.\");\n }\n /**\n * @internal\n */\n _getUseSRGBBuffer(useSRGBBuffer, _noMipmap) {\n return useSRGBBuffer && this._caps.supportSRGBBuffers;\n }\n /**\n * @internal\n */\n _unpackFlipY(value) {}\n /**\n * Update the sampling mode of a given texture\n * @param samplingMode defines the required sampling mode\n * @param texture defines the texture to update\n * @param generateMipMaps defines whether to generate mipmaps for the texture\n */\n updateTextureSamplingMode(samplingMode, texture, generateMipMaps = false) {\n if (generateMipMaps) {\n texture.generateMipMaps = true;\n this._generateMipmaps(texture);\n }\n texture.samplingMode = samplingMode;\n }\n /**\n * Update the sampling mode of a given texture\n * @param texture defines the texture to update\n * @param wrapU defines the texture wrap mode of the u coordinates\n * @param wrapV defines the texture wrap mode of the v coordinates\n * @param wrapR defines the texture wrap mode of the r coordinates\n */\n updateTextureWrappingMode(texture, wrapU, wrapV = null, wrapR = null) {\n if (wrapU !== null) {\n texture._cachedWrapU = wrapU;\n }\n if (wrapV !== null) {\n texture._cachedWrapV = wrapV;\n }\n if ((texture.is2DArray || texture.is3D) && wrapR !== null) {\n texture._cachedWrapR = wrapR;\n }\n }\n /**\n * Update the dimensions of a texture\n * @param texture texture to update\n * @param width new width of the texture\n * @param height new height of the texture\n * @param depth new depth of the texture\n */\n updateTextureDimensions(texture, width, height, depth = 1) {\n if (!texture._hardwareTexture) {\n // the gpu texture is not created yet, so when it is it will be created with the right dimensions\n return;\n }\n if (texture.width === width && texture.height === height && texture.depth === depth) {\n return;\n }\n const additionalUsages = texture._hardwareTexture.textureAdditionalUsages;\n texture._hardwareTexture.release(); // don't defer the releasing! Else we will release at the end of this frame the gpu texture we are about to create in the next line...\n this._textureHelper.createGPUTextureForInternalTexture(texture, width, height, depth, additionalUsages);\n }\n /**\n * @internal\n */\n _setInternalTexture(name, texture, baseName) {\n var _baseName;\n baseName = (_baseName = baseName) !== null && _baseName !== void 0 ? _baseName : name;\n if (this._currentEffect) {\n const webgpuPipelineContext = this._currentEffect._pipelineContext;\n const availableTexture = webgpuPipelineContext.shaderProcessingContext.availableTextures[baseName];\n this._currentMaterialContext.setTexture(name, texture);\n if (availableTexture && availableTexture.autoBindSampler) {\n const samplerName = baseName + `Sampler`;\n this._currentMaterialContext.setSampler(samplerName, texture); // we can safely cast to InternalTexture because ExternalTexture always has autoBindSampler = false\n }\n }\n }\n /**\n * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)\n * @param rootUrl defines the url where the file to load is located\n * @param scene defines the current scene\n * @param lodScale defines scale to apply to the mip map selection\n * @param lodOffset defines offset to apply to the mip map selection\n * @param onLoad defines an optional callback raised when the texture is loaded\n * @param onError defines an optional callback raised if there is an issue to load the texture\n * @param format defines the format of the data\n * @param forcedExtension defines the extension to use to pick the right loader\n * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture\n * @returns the cube texture as an InternalTexture\n */\n createPrefilteredCubeTexture(rootUrl, scene, lodScale, lodOffset, onLoad = null, onError = null, format, forcedExtension = null, createPolynomials = true) {\n const callback = loadData => {\n if (!loadData) {\n if (onLoad) {\n onLoad(null);\n }\n return;\n }\n const texture = loadData.texture;\n if (!createPolynomials) {\n texture._sphericalPolynomial = new SphericalPolynomial();\n } else if (loadData.info.sphericalPolynomial) {\n texture._sphericalPolynomial = loadData.info.sphericalPolynomial;\n }\n texture._source = 9 /* InternalTextureSource.CubePrefiltered */;\n if (onLoad) {\n onLoad(texture);\n }\n };\n return this.createCubeTexture(rootUrl, scene, null, false, callback, onError, format, forcedExtension, createPolynomials, lodScale, lodOffset);\n }\n /**\n * Sets a texture to the according uniform.\n * @param channel The texture channel\n * @param unused unused parameter\n * @param texture The texture to apply\n * @param name The name of the uniform in the effect\n */\n setTexture(channel, unused, texture, name) {\n this._setTexture(channel, texture, false, false, name, name);\n }\n /**\n * Sets an array of texture to the WebGPU context\n * @param channel defines the channel where the texture array must be set\n * @param unused unused parameter\n * @param textures defines the array of textures to bind\n * @param name name of the channel\n */\n setTextureArray(channel, unused, textures, name) {\n for (let index = 0; index < textures.length; index++) {\n this._setTexture(-1, textures[index], true, false, name + index.toString(), name);\n }\n }\n /**\n * @internal\n */\n _setTexture(channel, texture,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n isPartOfTextureArray = false, depthStencilTexture = false, name = \"\", baseName) {\n var _baseName2;\n // name == baseName for a texture that is not part of a texture array\n // Else, name is something like 'myTexture0' / 'myTexture1' / ... and baseName is 'myTexture'\n // baseName is used to look up the texture in the shaderProcessingContext.availableTextures map\n // name is used to look up the texture in the _currentMaterialContext.textures map\n baseName = (_baseName2 = baseName) !== null && _baseName2 !== void 0 ? _baseName2 : name;\n if (this._currentEffect) {\n if (!texture) {\n this._currentMaterialContext.setTexture(name, null);\n return false;\n }\n // Video\n if (texture.video) {\n texture.update();\n } else if (texture.delayLoadState === 4) {\n // Delay loading\n texture.delayLoad();\n return false;\n }\n let internalTexture = null;\n if (depthStencilTexture) {\n internalTexture = texture.depthStencilTexture;\n } else if (texture.isReady()) {\n internalTexture = texture.getInternalTexture();\n } else if (texture.isCube) {\n internalTexture = this.emptyCubeTexture;\n } else if (texture.is3D) {\n internalTexture = this.emptyTexture3D;\n } else if (texture.is2DArray) {\n internalTexture = this.emptyTexture2DArray;\n } else {\n internalTexture = this.emptyTexture;\n }\n if (internalTexture && !internalTexture.isMultiview) {\n // CUBIC_MODE and SKYBOX_MODE both require CLAMP_TO_EDGE. All other modes use REPEAT.\n if (internalTexture.isCube && internalTexture._cachedCoordinatesMode !== texture.coordinatesMode) {\n internalTexture._cachedCoordinatesMode = texture.coordinatesMode;\n const textureWrapMode = texture.coordinatesMode !== 3 && texture.coordinatesMode !== 5 ? 1 : 0;\n texture.wrapU = textureWrapMode;\n texture.wrapV = textureWrapMode;\n }\n internalTexture._cachedWrapU = texture.wrapU;\n internalTexture._cachedWrapV = texture.wrapV;\n if (internalTexture.is3D) {\n internalTexture._cachedWrapR = texture.wrapR;\n }\n this._setAnisotropicLevel(0, internalTexture, texture.anisotropicFilteringLevel);\n }\n this._setInternalTexture(name, internalTexture, baseName);\n } else {\n if (this.dbgVerboseLogsForFirstFrames) {\n if (this._count === undefined) {\n this._count = 0;\n }\n if (!this._count || this._count < this.dbgVerboseLogsNumFrames) {\n Logger.Log([\"frame #\" + this._count + \" - _setTexture called with a null _currentEffect! texture=\", texture]);\n }\n }\n }\n return true;\n }\n /**\n * @internal\n */\n _setAnisotropicLevel(target, internalTexture, anisotropicFilteringLevel) {\n if (internalTexture._cachedAnisotropicFilteringLevel !== anisotropicFilteringLevel) {\n internalTexture._cachedAnisotropicFilteringLevel = Math.min(anisotropicFilteringLevel, this._caps.maxAnisotropy);\n }\n }\n /**\n * @internal\n */\n _bindTexture(channel, texture, name) {\n if (channel === undefined) {\n return;\n }\n this._setInternalTexture(name, texture);\n }\n /**\n * Generates the mipmaps for a texture\n * @param texture texture to generate the mipmaps for\n */\n generateMipmaps(texture) {\n this._generateMipmaps(texture);\n }\n /**\n * Update a portion of an internal texture\n * @param texture defines the texture to update\n * @param imageData defines the data to store into the texture\n * @param xOffset defines the x coordinates of the update rectangle\n * @param yOffset defines the y coordinates of the update rectangle\n * @param width defines the width of the update rectangle\n * @param height defines the height of the update rectangle\n * @param faceIndex defines the face index if texture is a cube (0 by default)\n * @param lod defines the lod level to update (0 by default)\n * @param generateMipMaps defines whether to generate mipmaps or not\n */\n updateTextureData(texture, imageData, xOffset, yOffset, width, height, faceIndex = 0, lod = 0, generateMipMaps = false) {\n var _texture$_hardwareTex2;\n let gpuTextureWrapper = texture._hardwareTexture;\n if (!((_texture$_hardwareTex2 = texture._hardwareTexture) !== null && _texture$_hardwareTex2 !== void 0 && _texture$_hardwareTex2.underlyingResource)) {\n gpuTextureWrapper = this._textureHelper.createGPUTextureForInternalTexture(texture);\n }\n const data = new Uint8Array(imageData.buffer, imageData.byteOffset, imageData.byteLength);\n this._textureHelper.updateTexture(data, texture, width, height, texture.depth, gpuTextureWrapper.format, faceIndex, lod, texture.invertY, false, xOffset, yOffset);\n if (generateMipMaps) {\n this._generateMipmaps(texture);\n }\n }\n /**\n * @internal\n */\n _uploadCompressedDataToTextureDirectly(texture, internalFormat, width, height, imageData, faceIndex = 0, lod = 0) {\n var _texture$_hardwareTex3;\n let gpuTextureWrapper = texture._hardwareTexture;\n if (!((_texture$_hardwareTex3 = texture._hardwareTexture) !== null && _texture$_hardwareTex3 !== void 0 && _texture$_hardwareTex3.underlyingResource)) {\n texture.format = internalFormat;\n gpuTextureWrapper = this._textureHelper.createGPUTextureForInternalTexture(texture, width, height);\n }\n const data = new Uint8Array(imageData.buffer, imageData.byteOffset, imageData.byteLength);\n this._textureHelper.updateTexture(data, texture, width, height, texture.depth, gpuTextureWrapper.format, faceIndex, lod, false, false, 0, 0);\n }\n /**\n * @internal\n */\n _uploadDataToTextureDirectly(texture, imageData, faceIndex = 0, lod = 0, babylonInternalFormat, useTextureWidthAndHeight = false) {\n var _texture$_hardwareTex4;\n const lodMaxWidth = Math.round(Math.log(texture.width) * Math.LOG2E);\n const lodMaxHeight = Math.round(Math.log(texture.height) * Math.LOG2E);\n const width = useTextureWidthAndHeight ? texture.width : Math.pow(2, Math.max(lodMaxWidth - lod, 0));\n const height = useTextureWidthAndHeight ? texture.height : Math.pow(2, Math.max(lodMaxHeight - lod, 0));\n let gpuTextureWrapper = texture._hardwareTexture;\n if (!((_texture$_hardwareTex4 = texture._hardwareTexture) !== null && _texture$_hardwareTex4 !== void 0 && _texture$_hardwareTex4.underlyingResource)) {\n gpuTextureWrapper = this._textureHelper.createGPUTextureForInternalTexture(texture, width, height);\n }\n const data = new Uint8Array(imageData.buffer, imageData.byteOffset, imageData.byteLength);\n this._textureHelper.updateTexture(data, texture, width, height, texture.depth, gpuTextureWrapper.format, faceIndex, lod, texture.invertY, false, 0, 0);\n }\n /**\n * @internal\n */\n _uploadArrayBufferViewToTexture(texture, imageData, faceIndex = 0, lod = 0) {\n this._uploadDataToTextureDirectly(texture, imageData, faceIndex, lod);\n }\n /**\n * @internal\n */\n _uploadImageToTexture(texture, image, faceIndex = 0, lod = 0) {\n var _texture$_hardwareTex5;\n let gpuTextureWrapper = texture._hardwareTexture;\n if (!((_texture$_hardwareTex5 = texture._hardwareTexture) !== null && _texture$_hardwareTex5 !== void 0 && _texture$_hardwareTex5.underlyingResource)) {\n gpuTextureWrapper = this._textureHelper.createGPUTextureForInternalTexture(texture);\n }\n if (image instanceof HTMLImageElement) {\n // eslint-disable-next-line no-throw-literal\n throw \"WebGPU engine: HTMLImageElement not supported in _uploadImageToTexture!\";\n }\n const bitmap = image; // in WebGPU we will always get an ImageBitmap, not an HTMLImageElement\n const width = Math.ceil(texture.width / (1 << lod));\n const height = Math.ceil(texture.height / (1 << lod));\n this._textureHelper.updateTexture(bitmap, texture, width, height, texture.depth, gpuTextureWrapper.format, faceIndex, lod, texture.invertY, false, 0, 0);\n }\n /**\n * Reads pixels from the current frame buffer. Please note that this function can be slow\n * @param x defines the x coordinate of the rectangle where pixels must be read\n * @param y defines the y coordinate of the rectangle where pixels must be read\n * @param width defines the width of the rectangle where pixels must be read\n * @param height defines the height of the rectangle where pixels must be read\n * @param hasAlpha defines whether the output should have alpha or not (defaults to true)\n * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels\n * @returns a ArrayBufferView promise (Uint8Array) containing RGBA colors\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n readPixels(x, y, width, height, hasAlpha = true, flushRenderer = true) {\n const renderPassWrapper = this._getCurrentRenderPassWrapper();\n const hardwareTexture = renderPassWrapper.colorAttachmentGPUTextures[0];\n if (!hardwareTexture) {\n // we are calling readPixels for a render pass with no color texture bound\n return Promise.resolve(new Uint8Array(0));\n }\n const gpuTexture = hardwareTexture.underlyingResource;\n const gpuTextureFormat = hardwareTexture.format;\n if (!gpuTexture) {\n // we are calling readPixels before startMainRenderPass has been called and no RTT is bound, so swapChainTexture is not setup yet!\n return Promise.resolve(new Uint8Array(0));\n }\n if (flushRenderer) {\n this.flushFramebuffer();\n }\n return this._textureHelper.readPixels(gpuTexture, x, y, width, height, gpuTextureFormat);\n }\n //------------------------------------------------------------------------------\n // Frame management\n //------------------------------------------------------------------------------\n _measureFps() {\n this._performanceMonitor.sampleFrame();\n this._fps = this._performanceMonitor.averageFPS;\n this._deltaTime = this._performanceMonitor.instantaneousFrameTime || 0;\n }\n /**\n * Gets the performance monitor attached to this engine\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/optimize_your_scene#engineinstrumentation\n */\n get performanceMonitor() {\n return this._performanceMonitor;\n }\n /**\n * Begin a new frame\n */\n beginFrame() {\n this._measureFps();\n super.beginFrame();\n }\n /**\n * End the current frame\n */\n endFrame() {\n this._endCurrentRenderPass();\n this._snapshotRendering.endFrame();\n this._timestampQuery.endFrame(this._renderEncoder);\n this._timestampIndex = 0;\n this.flushFramebuffer();\n this._textureHelper.destroyDeferredTextures();\n this._bufferManager.destroyDeferredBuffers();\n if (this._features._collectUbosUpdatedInFrame) {\n if (this.dbgVerboseLogsForFirstFrames) {\n if (this._count === undefined) {\n this._count = 0;\n }\n if (!this._count || this._count < this.dbgVerboseLogsNumFrames) {\n const list = [];\n for (const name in UniformBuffer._UpdatedUbosInFrame) {\n list.push(name + \":\" + UniformBuffer._UpdatedUbosInFrame[name]);\n }\n Logger.Log([\"frame #\" + this._count + \" - updated ubos -\", list.join(\", \")]);\n }\n }\n UniformBuffer._UpdatedUbosInFrame = {};\n }\n this.countersLastFrame.numEnableEffects = this._counters.numEnableEffects;\n this.countersLastFrame.numEnableDrawWrapper = this._counters.numEnableDrawWrapper;\n this.countersLastFrame.numBundleCreationNonCompatMode = this._counters.numBundleCreationNonCompatMode;\n this.countersLastFrame.numBundleReuseNonCompatMode = this._counters.numBundleReuseNonCompatMode;\n this._counters.numEnableEffects = 0;\n this._counters.numEnableDrawWrapper = 0;\n this._counters.numBundleCreationNonCompatMode = 0;\n this._counters.numBundleReuseNonCompatMode = 0;\n this._cacheRenderPipeline.endFrame();\n this._cacheBindGroups.endFrame();\n this._pendingDebugCommands.length = 0;\n if (this.dbgVerboseLogsForFirstFrames) {\n if (this._count === undefined) {\n this._count = 0;\n }\n if (this._count < this.dbgVerboseLogsNumFrames) {\n Logger.Log([\"%c frame #\" + this._count + \" - end\", \"background: #ffff00\"]);\n }\n if (this._count < this.dbgVerboseLogsNumFrames) {\n this._count++;\n if (this._count !== this.dbgVerboseLogsNumFrames) {\n Logger.Log([\"%c frame #\" + this._count + \" - begin\", \"background: #ffff00\"]);\n }\n }\n }\n super.endFrame();\n }\n /**Gets driver info if available */\n extractDriverInfo() {\n return \"\";\n }\n /**\n * Force a WebGPU flush (ie. a flush of all waiting commands)\n */\n flushFramebuffer() {\n // we need to end the current render pass (main or rtt) if any as we are not allowed to submit the command buffers when being in a pass\n this._endCurrentRenderPass();\n this._commandBuffers[0] = this._uploadEncoder.finish();\n this._commandBuffers[1] = this._renderEncoder.finish();\n this._device.queue.submit(this._commandBuffers);\n this._uploadEncoder = this._device.createCommandEncoder(this._uploadEncoderDescriptor);\n this._renderEncoder = this._device.createCommandEncoder(this._renderEncoderDescriptor);\n this._timestampQuery.startFrame(this._uploadEncoder);\n this._textureHelper.setCommandEncoder(this._uploadEncoder);\n this._bundleList.reset();\n }\n /** @internal */\n _currentFrameBufferIsDefaultFrameBuffer() {\n return this._currentPassIsMainPass();\n }\n //------------------------------------------------------------------------------\n // Render Pass\n //------------------------------------------------------------------------------\n _startRenderTargetRenderPass(renderTargetWrapper, setClearStates, clearColor, clearDepth, clearStencil) {\n var _this$_debugPushGroup, _renderTargetWrapper$, _this$_occlusionQuery, _this$_debugFlushPend;\n this._endCurrentRenderPass();\n const rtWrapper = renderTargetWrapper;\n const depthStencilTexture = rtWrapper._depthStencilTexture;\n const gpuDepthStencilWrapper = depthStencilTexture === null || depthStencilTexture === void 0 ? void 0 : depthStencilTexture._hardwareTexture;\n const gpuDepthStencilTexture = gpuDepthStencilWrapper === null || gpuDepthStencilWrapper === void 0 ? void 0 : gpuDepthStencilWrapper.underlyingResource;\n const gpuDepthStencilMSAATexture = gpuDepthStencilWrapper === null || gpuDepthStencilWrapper === void 0 ? void 0 : gpuDepthStencilWrapper.getMSAATexture(0);\n const depthTextureView = gpuDepthStencilTexture === null || gpuDepthStencilTexture === void 0 ? void 0 : gpuDepthStencilTexture.createView(this._rttRenderPassWrapper.depthAttachmentViewDescriptor);\n const depthMSAATextureView = gpuDepthStencilMSAATexture === null || gpuDepthStencilMSAATexture === void 0 ? void 0 : gpuDepthStencilMSAATexture.createView(this._rttRenderPassWrapper.depthAttachmentViewDescriptor);\n const depthTextureHasStencil = gpuDepthStencilWrapper ? WebGPUTextureHelper.HasStencilAspect(gpuDepthStencilWrapper.format) : false;\n const colorAttachments = [];\n if (this.useReverseDepthBuffer) {\n this.setDepthFunctionToGreaterOrEqual();\n }\n const clearColorForIntegerRT = tempColor4;\n if (clearColor) {\n clearColorForIntegerRT.r = clearColor.r * 255;\n clearColorForIntegerRT.g = clearColor.g * 255;\n clearColorForIntegerRT.b = clearColor.b * 255;\n clearColorForIntegerRT.a = clearColor.a * 255;\n }\n const mustClearColor = setClearStates && clearColor;\n const mustClearDepth = setClearStates && clearDepth;\n const mustClearStencil = setClearStates && clearStencil;\n if (rtWrapper._attachments && rtWrapper.isMulti) {\n // multi render targets\n if (!this._mrtAttachments || this._mrtAttachments.length === 0) {\n this._mrtAttachments = rtWrapper._defaultAttachments;\n }\n for (let i = 0; i < this._mrtAttachments.length; ++i) {\n const index = this._mrtAttachments[i]; // if index == 0 it means the texture should not be written to => at render pass creation time, it means we should not clear it\n const mrtTexture = rtWrapper.textures[i];\n const gpuMRTWrapper = mrtTexture === null || mrtTexture === void 0 ? void 0 : mrtTexture._hardwareTexture;\n const gpuMRTTexture = gpuMRTWrapper === null || gpuMRTWrapper === void 0 ? void 0 : gpuMRTWrapper.underlyingResource;\n if (gpuMRTWrapper && gpuMRTTexture) {\n var _rtWrapper$layerIndic, _rtWrapper$layerIndic2;\n const baseArrayLayer = rtWrapper.getBaseArrayLayer(i);\n const gpuMSAATexture = gpuMRTWrapper.getMSAATexture(baseArrayLayer);\n const viewDescriptor = {\n ...this._rttRenderPassWrapper.colorAttachmentViewDescriptor,\n dimension: mrtTexture.is3D ? \"3d\" /* WebGPUConstants.TextureViewDimension.E3d */ : \"2d\" /* WebGPUConstants.TextureViewDimension.E2d */,\n format: gpuMRTWrapper.format,\n baseArrayLayer\n };\n const msaaViewDescriptor = {\n ...this._rttRenderPassWrapper.colorAttachmentViewDescriptor,\n dimension: mrtTexture.is3D ? \"3d\" /* WebGPUConstants.TextureViewDimension.E3d */ : \"2d\" /* WebGPUConstants.TextureViewDimension.E2d */,\n format: gpuMRTWrapper.format,\n baseArrayLayer: 0\n };\n const isRTInteger = mrtTexture.type === 7 || mrtTexture.type === 5;\n const colorTextureView = gpuMRTTexture.createView(viewDescriptor);\n const colorMSAATextureView = gpuMSAATexture === null || gpuMSAATexture === void 0 ? void 0 : gpuMSAATexture.createView(msaaViewDescriptor);\n colorAttachments.push({\n view: colorMSAATextureView ? colorMSAATextureView : colorTextureView,\n resolveTarget: gpuMSAATexture ? colorTextureView : undefined,\n depthSlice: mrtTexture.is3D ? (_rtWrapper$layerIndic = (_rtWrapper$layerIndic2 = rtWrapper.layerIndices) === null || _rtWrapper$layerIndic2 === void 0 ? void 0 : _rtWrapper$layerIndic2[i]) !== null && _rtWrapper$layerIndic !== void 0 ? _rtWrapper$layerIndic : 0 : undefined,\n clearValue: index !== 0 && mustClearColor ? isRTInteger ? clearColorForIntegerRT : clearColor : undefined,\n loadOp: index !== 0 && mustClearColor ? \"clear\" /* WebGPUConstants.LoadOp.Clear */ : \"load\" /* WebGPUConstants.LoadOp.Load */,\n storeOp: \"store\" /* WebGPUConstants.StoreOp.Store */\n });\n }\n }\n this._cacheRenderPipeline.setMRT(rtWrapper.textures, this._mrtAttachments.length);\n this._cacheRenderPipeline.setMRTAttachments(this._mrtAttachments);\n } else {\n // single render target\n const internalTexture = rtWrapper.texture;\n if (internalTexture) {\n const gpuWrapper = internalTexture._hardwareTexture;\n const gpuTexture = gpuWrapper.underlyingResource;\n let depthSlice = undefined;\n if (rtWrapper.is3D) {\n depthSlice = this._rttRenderPassWrapper.colorAttachmentViewDescriptor.baseArrayLayer;\n this._rttRenderPassWrapper.colorAttachmentViewDescriptor.baseArrayLayer = 0;\n }\n const gpuMSAATexture = gpuWrapper.getMSAATexture(0);\n const colorTextureView = gpuTexture.createView(this._rttRenderPassWrapper.colorAttachmentViewDescriptor);\n const colorMSAATextureView = gpuMSAATexture === null || gpuMSAATexture === void 0 ? void 0 : gpuMSAATexture.createView(this._rttRenderPassWrapper.colorAttachmentViewDescriptor);\n const isRTInteger = internalTexture.type === 7 || internalTexture.type === 5;\n colorAttachments.push({\n view: colorMSAATextureView ? colorMSAATextureView : colorTextureView,\n resolveTarget: gpuMSAATexture ? colorTextureView : undefined,\n depthSlice,\n clearValue: mustClearColor ? isRTInteger ? clearColorForIntegerRT : clearColor : undefined,\n loadOp: mustClearColor ? \"clear\" /* WebGPUConstants.LoadOp.Clear */ : \"load\" /* WebGPUConstants.LoadOp.Load */,\n storeOp: \"store\" /* WebGPUConstants.StoreOp.Store */\n });\n } else {\n colorAttachments.push(null);\n }\n }\n (_this$_debugPushGroup = this._debugPushGroup) === null || _this$_debugPushGroup === void 0 || _this$_debugPushGroup.call(this, \"render target pass\" + (renderTargetWrapper.label ? \" (\" + renderTargetWrapper.label + \")\" : \"\"), 0);\n this._rttRenderPassWrapper.renderPassDescriptor = {\n label: ((_renderTargetWrapper$ = renderTargetWrapper.label) !== null && _renderTargetWrapper$ !== void 0 ? _renderTargetWrapper$ : \"RTT\") + \" - RenderPass\",\n colorAttachments,\n depthStencilAttachment: depthStencilTexture && gpuDepthStencilTexture ? {\n view: depthMSAATextureView ? depthMSAATextureView : depthTextureView,\n depthClearValue: mustClearDepth ? this.useReverseDepthBuffer ? this._clearReverseDepthValue : this._clearDepthValue : undefined,\n depthLoadOp: mustClearDepth ? \"clear\" /* WebGPUConstants.LoadOp.Clear */ : \"load\" /* WebGPUConstants.LoadOp.Load */,\n depthStoreOp: \"store\" /* WebGPUConstants.StoreOp.Store */,\n stencilClearValue: rtWrapper._depthStencilTextureWithStencil && mustClearStencil ? this._clearStencilValue : undefined,\n stencilLoadOp: !depthTextureHasStencil ? undefined : rtWrapper._depthStencilTextureWithStencil && mustClearStencil ? \"clear\" /* WebGPUConstants.LoadOp.Clear */ : \"load\" /* WebGPUConstants.LoadOp.Load */,\n stencilStoreOp: !depthTextureHasStencil ? undefined : \"store\" /* WebGPUConstants.StoreOp.Store */\n } : undefined,\n occlusionQuerySet: (_this$_occlusionQuery = this._occlusionQuery) !== null && _this$_occlusionQuery !== void 0 && _this$_occlusionQuery.hasQueries ? this._occlusionQuery.querySet : undefined\n };\n this._timestampQuery.startPass(this._rttRenderPassWrapper.renderPassDescriptor, this._timestampIndex);\n this._currentRenderPass = this._renderEncoder.beginRenderPass(this._rttRenderPassWrapper.renderPassDescriptor);\n if (this.dbgVerboseLogsForFirstFrames) {\n if (this._count === undefined) {\n this._count = 0;\n }\n if (!this._count || this._count < this.dbgVerboseLogsNumFrames) {\n const internalTexture = rtWrapper.texture;\n Logger.Log([\"frame #\" + this._count + \" - render target begin pass - rtt name=\" + renderTargetWrapper.label + \", internalTexture.uniqueId=\" + internalTexture.uniqueId + \", width=\" + internalTexture.width + \", height=\" + internalTexture.height + \", setClearStates=\" + setClearStates, \"renderPassDescriptor=\", this._rttRenderPassWrapper.renderPassDescriptor]);\n }\n }\n (_this$_debugFlushPend = this._debugFlushPendingCommands) === null || _this$_debugFlushPend === void 0 || _this$_debugFlushPend.call(this);\n this._resetRenderPassStates();\n if (!gpuDepthStencilWrapper || !WebGPUTextureHelper.HasStencilAspect(gpuDepthStencilWrapper.format)) {\n this._stencilStateComposer.enabled = false;\n }\n }\n _startMainRenderPass(setClearStates, clearColor, clearDepth, clearStencil) {\n var _this$_occlusionQuery2, _this$_debugPushGroup2, _this$_debugFlushPend2;\n this._endCurrentRenderPass();\n if (this.useReverseDepthBuffer) {\n this.setDepthFunctionToGreaterOrEqual();\n }\n const mustClearColor = setClearStates && clearColor;\n const mustClearDepth = setClearStates && clearDepth;\n const mustClearStencil = setClearStates && clearStencil;\n this._mainRenderPassWrapper.renderPassDescriptor.colorAttachments[0].clearValue = mustClearColor ? clearColor : undefined;\n this._mainRenderPassWrapper.renderPassDescriptor.colorAttachments[0].loadOp = mustClearColor ? \"clear\" /* WebGPUConstants.LoadOp.Clear */ : \"load\" /* WebGPUConstants.LoadOp.Load */;\n this._mainRenderPassWrapper.renderPassDescriptor.depthStencilAttachment.depthClearValue = mustClearDepth ? this.useReverseDepthBuffer ? this._clearReverseDepthValue : this._clearDepthValue : undefined;\n this._mainRenderPassWrapper.renderPassDescriptor.depthStencilAttachment.depthLoadOp = mustClearDepth ? \"clear\" /* WebGPUConstants.LoadOp.Clear */ : \"load\" /* WebGPUConstants.LoadOp.Load */;\n this._mainRenderPassWrapper.renderPassDescriptor.depthStencilAttachment.stencilClearValue = mustClearStencil ? this._clearStencilValue : undefined;\n this._mainRenderPassWrapper.renderPassDescriptor.depthStencilAttachment.stencilLoadOp = !this.isStencilEnable ? undefined : mustClearStencil ? \"clear\" /* WebGPUConstants.LoadOp.Clear */ : \"load\" /* WebGPUConstants.LoadOp.Load */;\n this._mainRenderPassWrapper.renderPassDescriptor.occlusionQuerySet = (_this$_occlusionQuery2 = this._occlusionQuery) !== null && _this$_occlusionQuery2 !== void 0 && _this$_occlusionQuery2.hasQueries ? this._occlusionQuery.querySet : undefined;\n const swapChainTexture = this._context.getCurrentTexture();\n this._mainRenderPassWrapper.colorAttachmentGPUTextures[0].set(swapChainTexture);\n // Resolve in case of MSAA\n if (this._options.antialias) {\n viewDescriptorSwapChainAntialiasing.format = swapChainTexture.format;\n this._mainRenderPassWrapper.renderPassDescriptor.colorAttachments[0].resolveTarget = swapChainTexture.createView(viewDescriptorSwapChainAntialiasing);\n } else {\n viewDescriptorSwapChain.format = swapChainTexture.format;\n this._mainRenderPassWrapper.renderPassDescriptor.colorAttachments[0].view = swapChainTexture.createView(viewDescriptorSwapChain);\n }\n if (this.dbgVerboseLogsForFirstFrames) {\n if (this._count === undefined) {\n this._count = 0;\n }\n if (!this._count || this._count < this.dbgVerboseLogsNumFrames) {\n Logger.Log([\"frame #\" + this._count + \" - main begin pass - texture width=\" + this._mainTextureExtends.width, \" height=\" + this._mainTextureExtends.height + \", setClearStates=\" + setClearStates, \"renderPassDescriptor=\", this._mainRenderPassWrapper.renderPassDescriptor]);\n }\n }\n (_this$_debugPushGroup2 = this._debugPushGroup) === null || _this$_debugPushGroup2 === void 0 || _this$_debugPushGroup2.call(this, \"main pass\", 0);\n this._timestampQuery.startPass(this._mainRenderPassWrapper.renderPassDescriptor, this._timestampIndex);\n this._currentRenderPass = this._renderEncoder.beginRenderPass(this._mainRenderPassWrapper.renderPassDescriptor);\n this._setDepthTextureFormat(this._mainRenderPassWrapper);\n this._setColorFormat(this._mainRenderPassWrapper);\n (_this$_debugFlushPend2 = this._debugFlushPendingCommands) === null || _this$_debugFlushPend2 === void 0 || _this$_debugFlushPend2.call(this);\n this._resetRenderPassStates();\n if (!this._isStencilEnable) {\n this._stencilStateComposer.enabled = false;\n }\n }\n /**\n * Binds the frame buffer to the specified texture.\n * @param texture The render target wrapper to render to\n * @param faceIndex The face of the texture to render to in case of cube texture\n * @param requiredWidth The width of the target to render to\n * @param requiredHeight The height of the target to render to\n * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true\n * @param lodLevel defines the lod level to bind to the frame buffer\n * @param layer defines the 2d array index to bind to frame buffer to\n */\n bindFramebuffer(texture, faceIndex = 0, requiredWidth, requiredHeight, forceFullscreenViewport, lodLevel = 0, layer = 0) {\n var _texture$texture;\n const hardwareTexture = (_texture$texture = texture.texture) === null || _texture$texture === void 0 ? void 0 : _texture$texture._hardwareTexture;\n if (this._currentRenderTarget) {\n this.unBindFramebuffer(this._currentRenderTarget);\n } else {\n this._endCurrentRenderPass();\n }\n this._currentRenderTarget = texture;\n const depthStencilTexture = this._currentRenderTarget._depthStencilTexture;\n this._rttRenderPassWrapper.colorAttachmentGPUTextures[0] = hardwareTexture;\n this._rttRenderPassWrapper.depthTextureFormat = depthStencilTexture ? WebGPUTextureHelper.GetWebGPUTextureFormat(-1, depthStencilTexture.format) : undefined;\n this._setDepthTextureFormat(this._rttRenderPassWrapper);\n this._setColorFormat(this._rttRenderPassWrapper);\n this._rttRenderPassWrapper.colorAttachmentViewDescriptor = {\n format: this._colorFormat,\n dimension: texture.is3D ? \"3d\" /* WebGPUConstants.TextureViewDimension.E3d */ : \"2d\" /* WebGPUConstants.TextureViewDimension.E2d */,\n mipLevelCount: 1,\n baseArrayLayer: texture.isCube ? layer * 6 + faceIndex : layer,\n baseMipLevel: lodLevel,\n arrayLayerCount: 1,\n aspect: \"all\" /* WebGPUConstants.TextureAspect.All */\n };\n this._rttRenderPassWrapper.depthAttachmentViewDescriptor = {\n format: this._depthTextureFormat,\n dimension: depthStencilTexture && depthStencilTexture.is3D ? \"3d\" /* WebGPUConstants.TextureViewDimension.E3d */ : \"2d\" /* WebGPUConstants.TextureViewDimension.E2d */,\n mipLevelCount: 1,\n baseArrayLayer: depthStencilTexture ? depthStencilTexture.isCube ? layer * 6 + faceIndex : layer : 0,\n baseMipLevel: 0,\n arrayLayerCount: 1,\n aspect: \"all\" /* WebGPUConstants.TextureAspect.All */\n };\n if (this.dbgVerboseLogsForFirstFrames) {\n if (this._count === undefined) {\n this._count = 0;\n }\n if (!this._count || this._count < this.dbgVerboseLogsNumFrames) {\n var _texture$texture2;\n Logger.Log([\"frame #\" + this._count + \" - bindFramebuffer - rtt name=\" + texture.label + \", internalTexture.uniqueId=\" + ((_texture$texture2 = texture.texture) === null || _texture$texture2 === void 0 ? void 0 : _texture$texture2.uniqueId) + \", face=\" + faceIndex + \", lodLevel=\" + lodLevel + \", layer=\" + layer, \"colorAttachmentViewDescriptor=\", this._rttRenderPassWrapper.colorAttachmentViewDescriptor, \"depthAttachmentViewDescriptor=\", this._rttRenderPassWrapper.depthAttachmentViewDescriptor]);\n }\n }\n // We don't create the render pass just now, we do a lazy creation of the render pass, hoping the render pass will be created by a call to clear()...\n if (this._cachedViewport && !forceFullscreenViewport) {\n this.setViewport(this._cachedViewport, requiredWidth, requiredHeight);\n } else {\n if (!requiredWidth) {\n requiredWidth = texture.width;\n if (lodLevel) {\n requiredWidth = requiredWidth / Math.pow(2, lodLevel);\n }\n }\n if (!requiredHeight) {\n requiredHeight = texture.height;\n if (lodLevel) {\n requiredHeight = requiredHeight / Math.pow(2, lodLevel);\n }\n }\n this._viewport(0, 0, requiredWidth, requiredHeight);\n }\n this.wipeCaches();\n }\n /**\n * Unbind the current render target texture from the WebGPU context\n * @param texture defines the render target wrapper to unbind\n * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated\n * @param onBeforeUnbind defines a function which will be called before the effective unbind\n */\n unBindFramebuffer(texture, disableGenerateMipMaps = false, onBeforeUnbind) {\n const saveCRT = this._currentRenderTarget;\n this._currentRenderTarget = null; // to be iso with abstractEngine, this._currentRenderTarget must be null when onBeforeUnbind is called\n if (onBeforeUnbind) {\n onBeforeUnbind();\n }\n this._currentRenderTarget = saveCRT;\n this._endCurrentRenderPass();\n if (!disableGenerateMipMaps) {\n if (texture.isMulti) {\n this.generateMipMapsMultiFramebuffer(texture);\n } else {\n this.generateMipMapsFramebuffer(texture);\n }\n }\n this._currentRenderTarget = null;\n if (this.dbgVerboseLogsForFirstFrames) {\n if (this._count === undefined) {\n this._count = 0;\n }\n if (!this._count || this._count < this.dbgVerboseLogsNumFrames) {\n var _texture$texture3;\n Logger.Log(\"frame #\" + this._count + \" - unBindFramebuffer - rtt name=\" + texture.label + \", internalTexture.uniqueId=\", (_texture$texture3 = texture.texture) === null || _texture$texture3 === void 0 ? void 0 : _texture$texture3.uniqueId);\n }\n }\n this._mrtAttachments = [];\n this._cacheRenderPipeline.setMRT([]);\n this._cacheRenderPipeline.setMRTAttachments(this._mrtAttachments);\n }\n /**\n * Generates mipmaps for the texture of the (single) render target\n * @param texture The render target containing the texture to generate the mipmaps for\n */\n generateMipMapsFramebuffer(texture) {\n var _texture$texture4;\n if (!texture.isMulti && (_texture$texture4 = texture.texture) !== null && _texture$texture4 !== void 0 && _texture$texture4.generateMipMaps && !texture.isCube) {\n this._generateMipmaps(texture.texture);\n }\n }\n /**\n * Resolves the MSAA texture of the (single) render target into its non-MSAA version.\n * Note that if \"texture\" is not a MSAA render target, no resolve is performed.\n * @param _texture The render target texture containing the MSAA texture to resolve\n */\n resolveFramebuffer(_texture) {\n throw new Error(\"resolveFramebuffer is not yet implemented in WebGPU!\");\n }\n /**\n * Unbind the current render target and bind the default framebuffer\n */\n restoreDefaultFramebuffer() {\n if (this._currentRenderTarget) {\n this.unBindFramebuffer(this._currentRenderTarget);\n } else if (!this._currentRenderPass) {\n this._startMainRenderPass(false);\n }\n if (this._cachedViewport) {\n this.setViewport(this._cachedViewport);\n }\n this.wipeCaches();\n }\n //------------------------------------------------------------------------------\n // Render\n //------------------------------------------------------------------------------\n /**\n * @internal\n */\n _setColorFormat(wrapper) {\n var _wrapper$colorAttachm, _wrapper$colorAttachm2;\n const format = (_wrapper$colorAttachm = (_wrapper$colorAttachm2 = wrapper.colorAttachmentGPUTextures[0]) === null || _wrapper$colorAttachm2 === void 0 ? void 0 : _wrapper$colorAttachm2.format) !== null && _wrapper$colorAttachm !== void 0 ? _wrapper$colorAttachm : null;\n this._cacheRenderPipeline.setColorFormat(format);\n if (this._colorFormat === format) {\n return;\n }\n this._colorFormat = format;\n }\n /**\n * @internal\n */\n _setDepthTextureFormat(wrapper) {\n this._cacheRenderPipeline.setDepthStencilFormat(wrapper.depthTextureFormat);\n if (this._depthTextureFormat === wrapper.depthTextureFormat) {\n return;\n }\n this._depthTextureFormat = wrapper.depthTextureFormat;\n }\n setDitheringState() {\n // Does not exist in WebGPU\n }\n setRasterizerState() {\n // Does not exist in WebGPU\n }\n /**\n * @internal\n */\n _executeWhenRenderingStateIsCompiled(pipelineContext, action) {\n // No parallel shader compilation.\n // No Async, so direct launch\n action();\n }\n /**\n * @internal\n */\n bindSamplers() {}\n /** @internal */\n _getUnpackAlignement() {\n return 1;\n }\n /**\n * @internal\n */\n _bindTextureDirectly() {\n return false;\n }\n /**\n * Set various states to the webGL context\n * @param culling defines culling state: true to enable culling, false to disable it\n * @param zOffset defines the value to apply to zOffset (0 by default)\n * @param force defines if states must be applied even if cache is up to date\n * @param reverseSide defines if culling must be reversed (CCW if false, CW if true)\n * @param cullBackFaces true to cull back faces, false to cull front faces (if culling is enabled)\n * @param stencil stencil states to set\n * @param zOffsetUnits defines the value to apply to zOffsetUnits (0 by default)\n */\n setState(culling, zOffset = 0, force, reverseSide = false, cullBackFaces, stencil, zOffsetUnits = 0) {\n var _ref3, _this$cullBackFaces;\n // Culling\n if (this._depthCullingState.cull !== culling || force) {\n this._depthCullingState.cull = culling;\n }\n // Cull face\n const cullFace = ((_ref3 = (_this$cullBackFaces = this.cullBackFaces) !== null && _this$cullBackFaces !== void 0 ? _this$cullBackFaces : cullBackFaces) !== null && _ref3 !== void 0 ? _ref3 : true) ? 1 : 2;\n if (this._depthCullingState.cullFace !== cullFace || force) {\n this._depthCullingState.cullFace = cullFace;\n }\n // Z offset\n this.setZOffset(zOffset);\n this.setZOffsetUnits(zOffsetUnits);\n // Front face\n const frontFace = reverseSide ? this._currentRenderTarget ? 1 : 2 : this._currentRenderTarget ? 2 : 1;\n if (this._depthCullingState.frontFace !== frontFace || force) {\n this._depthCullingState.frontFace = frontFace;\n }\n this._stencilStateComposer.stencilMaterial = stencil;\n }\n _applyRenderPassChanges(bundleList) {\n const mustUpdateStencilRef = !this._stencilStateComposer.enabled ? false : this._mustUpdateStencilRef();\n const mustUpdateBlendColor = !this._alphaState.alphaBlend ? false : this._mustUpdateBlendColor();\n if (this._mustUpdateViewport()) {\n this._applyViewport(bundleList);\n }\n if (this._mustUpdateScissor()) {\n this._applyScissor(bundleList);\n }\n if (mustUpdateStencilRef) {\n this._applyStencilRef(bundleList);\n }\n if (mustUpdateBlendColor) {\n this._applyBlendColor(bundleList);\n }\n }\n _draw(drawType, fillMode, start, count, instancesCount) {\n const renderPass = this._getCurrentRenderPass();\n const bundleList = this._bundleList;\n this.applyStates();\n const webgpuPipelineContext = this._currentEffect._pipelineContext;\n this.bindUniformBufferBase(this._currentRenderTarget ? this._ubInvertY : this._ubDontInvertY, 0, WebGPUShaderProcessor.InternalsUBOName);\n if (webgpuPipelineContext.uniformBuffer) {\n webgpuPipelineContext.uniformBuffer.update();\n this.bindUniformBufferBase(webgpuPipelineContext.uniformBuffer.getBuffer(), 0, WebGPUShaderProcessor.LeftOvertUBOName);\n }\n if (this._snapshotRendering.play) {\n this._reportDrawCall();\n return;\n }\n if (!this.compatibilityMode && (this._currentDrawContext.isDirty(this._currentMaterialContext.updateId) || this._currentMaterialContext.isDirty || this._currentMaterialContext.forceBindGroupCreation)) {\n this._currentDrawContext.fastBundle = undefined;\n }\n const useFastPath = !this.compatibilityMode && this._currentDrawContext.fastBundle;\n let renderPass2 = renderPass;\n if (useFastPath || this._snapshotRendering.record) {\n this._applyRenderPassChanges(bundleList);\n if (!this._snapshotRendering.record) {\n this._counters.numBundleReuseNonCompatMode++;\n if (this._currentDrawContext.indirectDrawBuffer) {\n this._currentDrawContext.setIndirectData(count, instancesCount || 1, start);\n }\n bundleList.addBundle(this._currentDrawContext.fastBundle);\n this._reportDrawCall();\n return;\n }\n renderPass2 = bundleList.getBundleEncoder(this._cacheRenderPipeline.colorFormats, this._depthTextureFormat, this.currentSampleCount); // for snapshot recording mode\n bundleList.numDrawCalls++;\n }\n let textureState = 0;\n if (this._currentMaterialContext.hasFloatOrDepthTextures) {\n let bitVal = 1;\n for (let i = 0; i < webgpuPipelineContext.shaderProcessingContext.textureNames.length; ++i) {\n var _this$_currentMateria;\n const textureName = webgpuPipelineContext.shaderProcessingContext.textureNames[i];\n const texture = (_this$_currentMateria = this._currentMaterialContext.textures[textureName]) === null || _this$_currentMateria === void 0 ? void 0 : _this$_currentMateria.texture;\n const textureIsDepth = texture && texture.format >= 13 && texture.format <= 18;\n if ((texture === null || texture === void 0 ? void 0 : texture.type) === 1 && !this._caps.textureFloatLinearFiltering || textureIsDepth) {\n textureState |= bitVal;\n }\n bitVal = bitVal << 1;\n }\n }\n this._currentMaterialContext.textureState = textureState;\n const pipeline = this._cacheRenderPipeline.getRenderPipeline(fillMode, this._currentEffect, this.currentSampleCount, textureState);\n const bindGroups = this._cacheBindGroups.getBindGroups(webgpuPipelineContext, this._currentDrawContext, this._currentMaterialContext);\n if (!this._snapshotRendering.record) {\n this._applyRenderPassChanges(!this.compatibilityMode ? bundleList : null);\n if (!this.compatibilityMode) {\n this._counters.numBundleCreationNonCompatMode++;\n renderPass2 = this._device.createRenderBundleEncoder({\n colorFormats: this._cacheRenderPipeline.colorFormats,\n depthStencilFormat: this._depthTextureFormat,\n sampleCount: WebGPUTextureHelper.GetSample(this.currentSampleCount)\n });\n }\n }\n // bind pipeline\n renderPass2.setPipeline(pipeline);\n // bind index/vertex buffers\n if (this._currentIndexBuffer) {\n renderPass2.setIndexBuffer(this._currentIndexBuffer.underlyingResource, this._currentIndexBuffer.is32Bits ? \"uint32\" /* WebGPUConstants.IndexFormat.Uint32 */ : \"uint16\" /* WebGPUConstants.IndexFormat.Uint16 */, 0);\n }\n const vertexBuffers = this._cacheRenderPipeline.vertexBuffers;\n for (let index = 0; index < vertexBuffers.length; index++) {\n const vertexBuffer = vertexBuffers[index];\n const buffer = vertexBuffer.effectiveBuffer;\n if (buffer) {\n renderPass2.setVertexBuffer(index, buffer.underlyingResource, vertexBuffer._validOffsetRange ? 0 : vertexBuffer.byteOffset);\n }\n }\n // bind bind groups\n for (let i = 0; i < bindGroups.length; i++) {\n renderPass2.setBindGroup(i, bindGroups[i]);\n }\n // draw\n const nonCompatMode = !this.compatibilityMode && !this._snapshotRendering.record;\n if (nonCompatMode && this._currentDrawContext.indirectDrawBuffer) {\n this._currentDrawContext.setIndirectData(count, instancesCount || 1, start);\n if (drawType === 0) {\n renderPass2.drawIndexedIndirect(this._currentDrawContext.indirectDrawBuffer, 0);\n } else {\n renderPass2.drawIndirect(this._currentDrawContext.indirectDrawBuffer, 0);\n }\n } else if (drawType === 0) {\n renderPass2.drawIndexed(count, instancesCount || 1, start, 0, 0);\n } else {\n renderPass2.draw(count, instancesCount || 1, start, 0);\n }\n if (nonCompatMode) {\n this._currentDrawContext.fastBundle = renderPass2.finish();\n bundleList.addBundle(this._currentDrawContext.fastBundle);\n }\n this._reportDrawCall();\n }\n /**\n * Draw a list of indexed primitives\n * @param fillMode defines the primitive to use\n * @param indexStart defines the starting index\n * @param indexCount defines the number of index to draw\n * @param instancesCount defines the number of instances to draw (if instantiation is enabled)\n */\n drawElementsType(fillMode, indexStart, indexCount, instancesCount = 1) {\n this._draw(0, fillMode, indexStart, indexCount, instancesCount);\n }\n /**\n * Draw a list of unindexed primitives\n * @param fillMode defines the primitive to use\n * @param verticesStart defines the index of first vertex to draw\n * @param verticesCount defines the count of vertices to draw\n * @param instancesCount defines the number of instances to draw (if instantiation is enabled)\n */\n drawArraysType(fillMode, verticesStart, verticesCount, instancesCount = 1) {\n this._currentIndexBuffer = null;\n this._draw(1, fillMode, verticesStart, verticesCount, instancesCount);\n }\n //------------------------------------------------------------------------------\n // Dispose\n //------------------------------------------------------------------------------\n /**\n * Dispose and release all associated resources\n */\n dispose() {\n var _this$_mainTexture, _this$_depthTexture;\n this._isDisposed = true;\n this.hideLoadingUI();\n this._timestampQuery.dispose();\n (_this$_mainTexture = this._mainTexture) === null || _this$_mainTexture === void 0 || _this$_mainTexture.destroy();\n (_this$_depthTexture = this._depthTexture) === null || _this$_depthTexture === void 0 || _this$_depthTexture.destroy();\n this._textureHelper.destroyDeferredTextures();\n this._bufferManager.destroyDeferredBuffers();\n this._device.destroy();\n _CommonDispose(this, this._renderingCanvas);\n super.dispose();\n }\n //------------------------------------------------------------------------------\n // Misc\n //------------------------------------------------------------------------------\n /**\n * Gets the current render width\n * @param useScreen defines if screen size must be used (or the current render target if any)\n * @returns a number defining the current render width\n */\n getRenderWidth(useScreen = false) {\n var _this$_renderingCanva, _this$_renderingCanva2;\n if (!useScreen && this._currentRenderTarget) {\n return this._currentRenderTarget.width;\n }\n return (_this$_renderingCanva = (_this$_renderingCanva2 = this._renderingCanvas) === null || _this$_renderingCanva2 === void 0 ? void 0 : _this$_renderingCanva2.width) !== null && _this$_renderingCanva !== void 0 ? _this$_renderingCanva : 0;\n }\n /**\n * Gets the current render height\n * @param useScreen defines if screen size must be used (or the current render target if any)\n * @returns a number defining the current render height\n */\n getRenderHeight(useScreen = false) {\n var _this$_renderingCanva3, _this$_renderingCanva4;\n if (!useScreen && this._currentRenderTarget) {\n return this._currentRenderTarget.height;\n }\n return (_this$_renderingCanva3 = (_this$_renderingCanva4 = this._renderingCanvas) === null || _this$_renderingCanva4 === void 0 ? void 0 : _this$_renderingCanva4.height) !== null && _this$_renderingCanva3 !== void 0 ? _this$_renderingCanva3 : 0;\n }\n //------------------------------------------------------------------------------\n // Errors\n //------------------------------------------------------------------------------\n /**\n * Get the current error code of the WebGPU context\n * @returns the error code\n */\n getError() {\n // TODO WEBGPU. from the webgpu errors.\n return 0;\n }\n //------------------------------------------------------------------------------\n // External Textures\n //------------------------------------------------------------------------------\n /**\n * Creates an external texture\n * @param video video element\n * @returns the external texture, or null if external textures are not supported by the engine\n */\n createExternalTexture(video) {\n const texture = new WebGPUExternalTexture(video);\n return texture;\n }\n /**\n * Sets an internal texture to the according uniform.\n * @param name The name of the uniform in the effect\n * @param texture The texture to apply\n */\n setExternalTexture(name, texture) {\n if (!texture) {\n this._currentMaterialContext.setTexture(name, null);\n return;\n }\n this._setInternalTexture(name, texture);\n }\n //------------------------------------------------------------------------------\n // Samplers\n //------------------------------------------------------------------------------\n /**\n * Sets a texture sampler to the according uniform.\n * @param name The name of the uniform in the effect\n * @param sampler The sampler to apply\n */\n setTextureSampler(name, sampler) {\n var _this$_currentMateria2;\n (_this$_currentMateria2 = this._currentMaterialContext) === null || _this$_currentMateria2 === void 0 || _this$_currentMateria2.setSampler(name, sampler);\n }\n //------------------------------------------------------------------------------\n // Storage Buffers\n //------------------------------------------------------------------------------\n /**\n * Creates a storage buffer\n * @param data the data for the storage buffer or the size of the buffer\n * @param creationFlags flags to use when creating the buffer (see undefined). The BUFFER_CREATIONFLAG_STORAGE flag will be automatically added\n * @param label defines the label of the buffer (for debug purpose)\n * @returns the new buffer\n */\n createStorageBuffer(data, creationFlags, label) {\n return this._createBuffer(data, creationFlags | 32, label);\n }\n /**\n * Updates a storage buffer\n * @param buffer the storage buffer to update\n * @param data the data used to update the storage buffer\n * @param byteOffset the byte offset of the data\n * @param byteLength the byte length of the data\n */\n updateStorageBuffer(buffer, data, byteOffset, byteLength) {\n const dataBuffer = buffer;\n if (byteOffset === undefined) {\n byteOffset = 0;\n }\n let view;\n if (byteLength === undefined) {\n if (data instanceof Array) {\n view = new Float32Array(data);\n } else if (data instanceof ArrayBuffer) {\n view = new Uint8Array(data);\n } else {\n view = data;\n }\n byteLength = view.byteLength;\n } else {\n if (data instanceof Array) {\n view = new Float32Array(data);\n } else if (data instanceof ArrayBuffer) {\n view = new Uint8Array(data);\n } else {\n view = data;\n }\n }\n this._bufferManager.setSubData(dataBuffer, byteOffset, view, 0, byteLength);\n }\n _readFromGPUBuffer(gpuBuffer, size, buffer, noDelay) {\n return new Promise((resolve, reject) => {\n const readFromBuffer = () => {\n gpuBuffer.mapAsync(1 /* WebGPUConstants.MapMode.Read */, 0, size).then(() => {\n const copyArrayBuffer = gpuBuffer.getMappedRange(0, size);\n let data = buffer;\n if (data === undefined) {\n data = new Uint8Array(size);\n data.set(new Uint8Array(copyArrayBuffer));\n } else {\n const ctor = data.constructor; // we want to create result data with the same type as buffer (Uint8Array, Float32Array, ...)\n data = new ctor(data.buffer);\n data.set(new ctor(copyArrayBuffer));\n }\n gpuBuffer.unmap();\n this._bufferManager.releaseBuffer(gpuBuffer);\n resolve(data);\n }, reason => {\n if (this.isDisposed) {\n resolve(new Uint8Array());\n } else {\n reject(reason);\n }\n });\n };\n if (noDelay) {\n this.flushFramebuffer();\n readFromBuffer();\n } else {\n // we are using onEndFrameObservable because we need to map the gpuBuffer AFTER the command buffers\n // have been submitted, else we get the error: \"Buffer used in a submit while mapped\"\n this.onEndFrameObservable.addOnce(() => {\n readFromBuffer();\n });\n }\n });\n }\n /**\n * Read data from a storage buffer\n * @param storageBuffer The storage buffer to read from\n * @param offset The offset in the storage buffer to start reading from (default: 0)\n * @param size The number of bytes to read from the storage buffer (default: capacity of the buffer)\n * @param buffer The buffer to write the data we have read from the storage buffer to (optional)\n * @param noDelay If true, a call to flushFramebuffer will be issued so that the data can be read back immediately and not in engine.onEndFrameObservable. This can speed up data retrieval, at the cost of a small perf penalty (default: false).\n * @returns If not undefined, returns the (promise) buffer (as provided by the 4th parameter) filled with the data, else it returns a (promise) Uint8Array with the data read from the storage buffer\n */\n readFromStorageBuffer(storageBuffer, offset, size, buffer, noDelay) {\n size = size || storageBuffer.capacity;\n const gpuBuffer = this._bufferManager.createRawBuffer(size, WebGPUConstants.BufferUsage.MapRead | WebGPUConstants.BufferUsage.CopyDst, undefined, \"TempReadFromStorageBuffer\");\n this._renderEncoder.copyBufferToBuffer(storageBuffer.underlyingResource, offset !== null && offset !== void 0 ? offset : 0, gpuBuffer, 0, size);\n return this._readFromGPUBuffer(gpuBuffer, size, buffer, noDelay);\n }\n /**\n * Read data from multiple storage buffers\n * @param storageBuffers The list of storage buffers to read from\n * @param offset The offset in the storage buffer to start reading from (default: 0). This is the same offset for all storage buffers!\n * @param size The number of bytes to read from each storage buffer (default: capacity of the first buffer)\n * @param buffer The buffer to write the data we have read from the storage buffers to (optional). If provided, the buffer should be large enough to hold the data from all storage buffers!\n * @param noDelay If true, a call to flushFramebuffer will be issued so that the data can be read back immediately and not in engine.onEndFrameObservable. This can speed up data retrieval, at the cost of a small perf penalty (default: false).\n * @returns If not undefined, returns the (promise) buffer (as provided by the 4th parameter) filled with the data, else it returns a (promise) Uint8Array with the data read from the storage buffer\n */\n readFromMultipleStorageBuffers(storageBuffers, offset, size, buffer, noDelay) {\n size = size || storageBuffers[0].capacity;\n const gpuBuffer = this._bufferManager.createRawBuffer(size * storageBuffers.length, WebGPUConstants.BufferUsage.MapRead | WebGPUConstants.BufferUsage.CopyDst, undefined, \"TempReadFromMultipleStorageBuffers\");\n for (let i = 0; i < storageBuffers.length; i++) {\n this._renderEncoder.copyBufferToBuffer(storageBuffers[i].underlyingResource, offset !== null && offset !== void 0 ? offset : 0, gpuBuffer, i * size, size);\n }\n return this._readFromGPUBuffer(gpuBuffer, size * storageBuffers.length, buffer, noDelay);\n }\n /**\n * Sets a storage buffer in the shader\n * @param name Defines the name of the storage buffer as defined in the shader\n * @param buffer Defines the value to give to the uniform\n */\n setStorageBuffer(name, buffer) {\n var _this$_currentDrawCon, _buffer$getBuffer;\n (_this$_currentDrawCon = this._currentDrawContext) === null || _this$_currentDrawCon === void 0 || _this$_currentDrawCon.setBuffer(name, (_buffer$getBuffer = buffer === null || buffer === void 0 ? void 0 : buffer.getBuffer()) !== null && _buffer$getBuffer !== void 0 ? _buffer$getBuffer : null);\n }\n}\n// Default glslang options.\nWebGPUEngine._GlslangDefaultOptions = {\n jsPath: `${Tools._DefaultCdnUrl}/glslang/glslang.js`,\n wasmPath: `${Tools._DefaultCdnUrl}/glslang/glslang.wasm`\n};\nWebGPUEngine._InstanceId = 0;","map":{"version":3,"names":["Logger","ThinWebGPUEngine","Color4","InternalTexture","Effect","WebGPUConstants","VertexBuffer","WebGPUPipelineContext","WebGPUShaderProcessorGLSL","WebGPUShaderProcessorWGSL","WebGPUShaderProcessingContext","Tools","WebGPUTextureHelper","WebGPUTextureManager","AbstractEngine","WebGPUBufferManager","WebGPUHardwareTexture","UniformBuffer","WebGPUCacheSampler","WebGPUCacheRenderPipelineTree","WebGPUStencilStateComposer","WebGPUDepthCullingState","WebGPUMaterialContext","WebGPUDrawContext","WebGPUCacheBindGroups","WebGPUClearQuad","WebGPURenderItemBlendColor","WebGPURenderItemScissor","WebGPURenderItemStencilRef","WebGPURenderItemViewport","WebGPUBundleList","WebGPUTimestampQuery","WebGPUOcclusionQuery","ShaderCodeInliner","WebGPUTintWASM","WebGPUShaderProcessor","WebGPUSnapshotRendering","SphericalPolynomial","PerformanceMonitor","CreateImageBitmapFromSource","ExitFullscreen","ExitPointerlock","GetFontOffset","RequestFullscreen","RequestPointerlock","ResizeImageBitmap","_CommonDispose","_CommonInit","IsWrapper","PerfCounter","resetCachedPipeline","WebGPUExternalTexture","viewDescriptorSwapChainAntialiasing","label","dimension","format","undefined","mipLevelCount","arrayLayerCount","viewDescriptorSwapChain","tempColor4","WebGPUEngine","snapshotRenderingMode","_snapshotRendering","mode","snapshotRenderingReset","reset","snapshotRendering","enabled","activate","disableCacheSamplers","_cacheSampler","disabled","disable","disableCacheRenderPipelines","_cacheRenderPipeline","disableCacheBindGroups","_cacheBindGroups","areAllEffectsReady","getFontOffset","font","IsSupportedAsync","navigator","gpu","Promise","resolve","requestAdapter","then","adapter","catch","IsSupported","Warn","supportsUniformBuffers","supportedExtensions","_adapterSupportedExtensions","enabledExtensions","_deviceEnabledExtensions","supportedLimits","_adapterSupportedLimits","currentLimits","_deviceLimits","description","name","version","getInfo","vendor","_adapterInfo","renderer","architecture","compatibilityMode","_compatibilityMode","currentSampleCount","_currentRenderTarget","samples","_mainPassSampleCount","CreateAsync","canvas","options","engine","initAsync","glslangOptions","twgslOptions","constructor","_options$antialias","_options$enableGPUDeb","antialias","uniqueId","_uploadEncoderDescriptor","_renderEncoderDescriptor","_clearDepthValue","_clearReverseDepthValue","_clearStencilValue","_defaultSampleCount","_glslang","_tintWASM","_glslangAndTintAreFullyLoaded","device","_compiledComputeEffects","_counters","numEnableEffects","numEnableDrawWrapper","numBundleCreationNonCompatMode","numBundleReuseNonCompatMode","countersLastFrame","numMaxUncapturedErrors","scenes","_virtualScenes","Array","_commandBuffers","_mainRenderPassWrapper","renderPassDescriptor","colorAttachmentViewDescriptor","depthAttachmentViewDescriptor","colorAttachmentGPUTextures","depthTextureFormat","_rttRenderPassWrapper","_pendingDebugCommands","_currentOverrideVertexBuffers","_currentIndexBuffer","_colorWriteLocal","_forceEnableEffect","isNDCHalfZRange","hasOriginBottomLeft","_workingGlslangAndTintPromise","_viewportsCurrent","x","y","w","h","_scissorsCurrent","_scissorCached","z","_stencilRefsCurrent","_blendColorsCurrent","_performanceMonitor","_name","_drawCalls","deviceDescriptor","enableGPUDebugMarkers","Log","Version","Error","swapChainFormat","getPreferredCanvasFormat","_isWebGPU","_shaderPlatformName","_renderingCanvas","_options","userAgent","_setupMobileChecks","_sharedInit","_shaderProcessor","_shaderProcessorWGSL","prepareGlslangAndTintAsync","_this$_glslangOptions","_this$_options","_initGlslang","_glslangOptions","glslang","_this$_twgslOptions","_this$_options2","initTwgsl","_twgslOptions","_this","_InstanceId","_this$_adapter$featur","_this$_options$device","_deviceDescriptor$req","_adapter","features","forEach","feature","push","limits","info","requiredFeatures","enableAllFeatures","requestedExtensions","validExtensions","extension","indexOf","setMaximumLimits","requiredLimits","requestDevice","_this$_device$feature","_device","numUncapturedErrors","addEventListener","event","error","message","_doNotHandleContextLost","_this$_device$lost","lost","_isDisposed","_contextWasLost","onContextLostObservable","notifyObservers","_restoreEngineAfterContextLost","_asyncToGenerator","_this$_glslangOptions2","_this$_options3","_this$_twgslOptions2","_this$_options4","enableGPUTimingMeasurements","_currentRenderPass","_initializeLimits","_bufferManager","_textureHelper","_timestampQuery","_occlusionQuery","createQuerySet","_bundleList","_snapshotRenderingMode","_ubInvertY","createBuffer","Float32Array","BufferUsage","Uniform","CopyDst","_ubDontInvertY","dbgVerboseLogsForFirstFrames","_count","_uploadEncoder","createCommandEncoder","_renderEncoder","_emptyVertexBuffer","stride","offset","size","_depthCullingState","_stencilStateComposer","stencilGlobal","_stencilState","depthTest","depthFunc","depthMask","setCommandEncoder","_clearQuad","_defaultDrawContext","createDrawContext","_currentDrawContext","_defaultMaterialContext","createMaterialContext","_currentMaterialContext","_initializeContextAndSwapChain","_initializeMainAttachments","resize","e","_GlslangDefaultOptions","self","wasmPath","jsPath","LoadBabylonScriptAsync","GetBabylonScriptURL","reject","_caps","maxTexturesImageUnits","maxSampledTexturesPerShaderStage","maxVertexTextureImageUnits","maxCombinedTexturesImageUnits","maxTextureSize","maxTextureDimension2D","maxCubemapTextureSize","maxRenderTextureSize","maxVertexAttribs","maxVertexAttributes","maxDrawBuffers","maxVaryingVectors","maxInterStageShaderVariables","maxFragmentUniformVectors","Math","floor","maxUniformBufferBindingSize","maxVertexUniformVectors","standardDerivatives","astc","s3tc","pvrtc","etc1","etc2","bptc","maxAnisotropy","uintIndices","fragmentDepthSupported","highPrecisionShaderSupported","colorBufferFloat","supportFloatTexturesResolve","rg11b10ufColorRenderable","textureFloat","textureFloatLinearFiltering","textureFloatRender","textureHalfFloat","textureHalfFloatLinearFiltering","textureHalfFloatRender","textureLOD","texelFetch","drawBuffersExtension","depthTextureExtension","vertexArrayObject","instancedArrays","timerQuery","BigUint64Array","supportOcclusionQuery","canUseTimestampForTimerQuery","multiview","oculusMultiview","parallelShaderCompile","blendMinMax","maxMSAASamples","canUseGLInstanceID","canUseGLVertexID","supportComputeShaders","supportSRGBBuffers","supportTransformFeedbacks","textureMaxLevel","texture2DArrayMaxLayerCount","maxTextureArrayLayers","disableMorphTargetTexture","textureNorm16","_features","forceBitmapOverHTMLImageElement","supportRenderAndCopyToLodForFloatTextures","supportDepthStencilTexture","supportShadowSamplers","uniformBufferHardCheckMatrix","allowTexturePrefiltering","trackUbosInFrame","checkUbosContentBeforeUpload","supportCSM","basisNeedsPOT","support3DTextures","needTypeSuffixInShaderConstants","supportMSAA","supportSSAO2","supportIBLShadows","supportExtendedTextureFormats","supportSwitchCaseInShader","supportSyncTextureRead","needsInvertingBitmap","useUBOBindingCache","needShaderCodeInlining","needToAlwaysBindUniformBuffers","supportRenderPasses","supportSpriteInstancing","forceVertexBufferStrideAndOffsetMultiple4Bytes","_checkNonFloatVertexBuffersDontRecreatePipelineContext","_collectUbosUpdatedInFrame","_context","getContext","_configureContext","_colorFormat","_setColorFormat","flushFramebuffer","_mainTextureExtends","width","getRenderWidth","height","getRenderHeight","depthOrArrayLayers","bufferDataUpdate","setSubData","mainColorAttachments","mainTextureDescriptor","sampleCount","usage","_mainTexture","releaseTexture","createTexture","view","createView","clearValue","loadOp","storeOp","isStencilEnable","_setDepthTextureFormat","depthTextureDescriptor","_depthTexture","mainDepthAttachment","depthClearValue","depthLoadOp","depthStoreOp","stencilClearValue","stencilLoadOp","stencilStoreOp","colorAttachments","depthStencilAttachment","_creationOptions","configure","alphaMode","premultipliedAlpha","resizeImageBitmap","image","bufferWidth","bufferHeight","_createImageBitmapFromSource","imageSource","switchFullscreen","requestPointerLock","isFullscreen","exitFullscreen","enterFullscreen","_pointerLockRequested","enterPointerlock","exitPointerlock","_rebuildBuffers","storageBuffer","_storageBuffers","getBuffer","engineId","_rebuild","initEngine","ResetCache","cleanScenes","scene","mesh","meshes","subMeshes","subMesh","_drawWrappers","material","materials","_material$_materialCo","_materialContext","uboList","uniformBuffer","_uniformBuffers","setSize","forceSetSize","dbgVerboseLogsNumFrames","_getShaderProcessor","shaderLanguage","_getShaderProcessingContext","pureMode","_getCurrentRenderPass","_startRenderTargetRenderPass","_startMainRenderPass","_getCurrentRenderPassWrapper","applyStates","apply","setAlphaBlendEnabled","_alphaState","alphaBlend","wipeCaches","bruteForce","preventCacheWipeBetweenFrames","setBuffers","_alphaMode","_alphaEquation","setAlphaBlendFactors","_blendFunctionParameters","_blendEquationParameters","setColorWrite","_cachedVertexBuffers","_cachedIndexBuffer","_cachedEffectForVertexBuffers","enable","setWriteMask","getColorWrite","_mustUpdateViewport","_viewportCached","update","_applyViewport","bundleList","addItem","setViewport","_currentPassIsMainPass","_viewport","_mustUpdateScissor","_applyScissor","setScissorRect","_scissorIsActive","enableScissor","disableScissor","_mustUpdateStencilRef","funcRef","_applyStencilRef","_this$_stencilStateCo","_this$_stencilStateCo2","setStencilReference","_mustUpdateBlendColor","colorBlend","_blendConstants","_applyBlendColor","slice","setBlendConstant","_resetRenderPassStates","clear","color","backBuffer","depth","stencil","a","hasScissor","_clearFullQuad","_endCurrentRenderPass","clearColor","clearDepth","clearStencil","_this$_cacheRenderPip","_this$_cacheRenderPip2","renderPass","setColorFormat","setDepthStencilFormat","_depthTextureFormat","setMRTAttachments","mrtAttachments","mrtTextureArray","mrtTextureCount","bundle","addBundle","_reportDrawCall","createVertexBuffer","data","_updatable","ArrayBuffer","Uint8Array","dataBuffer","Vertex","createDynamicVertexBuffer","createIndexBuffer","indices","is32Bits","Uint32Array","Int32Array","Uint16Array","length","Index","updateDynamicIndexBuffer","indexBuffer","gpuBuffer","updateDynamicVertexBuffer","vertexBuffer","byteOffset","byteLength","_createBuffer","creationFlags","flags","CopySrc","Storage","Indirect","bindBuffersDirectly","updateAndBindInstancesBuffer","unbindInstanceAttributes","bindBuffers","vertexBuffers","effect","overrideVertexBuffers","_releaseBuffer","buffer","releaseBuffer","createUniformBuffer","elements","createDynamicUniformBuffer","updateUniformBuffer","count","bindUniformBufferBase","_location","setBuffer","bindUniformBlock","createEffect","baseName","attributesNamesOrOptions","uniformsNamesOrEngine","samplers","defines","fallbacks","onCompiled","onError","indexParameters","extraInitializationsAsync","_ref2","_attributesNamesOrOpt","_attributesNamesOrOpt2","vertex","vertexToken","vertexSource","vertexElement","fragment","fragmentToken","fragmentSource","fragmentElement","globalDefines","_getGlobalDefines","fullDefines","_compiledEffects","compiledEffect","isReady","_refCount","_compileRawShaderToSpirV","source","type","compileGLSL","_compileShaderToSpirV","shaderVersion","_getWGSLShader","split","join","_createPipelineStageDescriptor","vertexShader","fragmentShader","disableUniformityAnalysisInVertex","disableUniformityAnalysisInFragment","convertSpirV2WGSL","vertexStage","module","createShaderModule","code","entryPoint","fragmentStage","_compileRawPipelineStageDescriptor","vertexCode","fragmentCode","_compilePipelineStageDescriptor","onBeforeShaderCompilationObservable","program","onAfterShaderCompilationObservable","createRawShaderProgram","createShaderProgram","inlineShaderCode","sci","debug","processCode","createPipelineContext","shaderProcessingContext","_preparePipelineContext","pipelineContext","vertexSourceCode","fragmentSourceCode","createAsRaw","rawVertexSourceCode","rawFragmentSourceCode","_rebuildRebind","_transformFeedbackVaryings","_key","onReady","_this2","webGpuContext","dbgShowShaderCode","sources","rawVertex","rawFragment","stages","getAttributes","attributesNames","results","gpuPipelineContext","i","attributeName","attributeLocation","availableAttributes","enableEffect","_currentEffect","dbgLogIfNotDrawWrapper","materialContext","drawContext","dbgShowEmptyEnableEffectCalls","stencilMaterial","onBind","_onBindObservable","_releaseEffect","_deletePipelineContext","getPipelineContext","releaseEffects","webGPUPipelineContext","webgpuPipelineContext","needPOTTextures","_createHardwareTexture","_releaseTexture","texture","index","_internalTexturesCache","splice","_getRGBABufferInternalSizedFormat","updateTextureComparisonFunction","comparisonFunction","_comparisonFunction","_createInternalTexture","delayGPUTextureCreation","fullOptions","_options$samples","_options$creationFlag","_options$useSRGBBuffe","generateMipMaps","createMipMaps","samplingMode","useSRGBBuffer","layers","baseWidth","baseHeight","is2DArray","is3D","_cachedWrapU","_cachedWrapV","_useSRGBBuffer","createMipMapsOnly","createGPUTextureForInternalTexture","url","noMipmap","invertY","onLoad","fallback","forcedExtension","mimeType","loaderOptions","_createTextureBase","img","isCompressed","processFunction","_texture$_hardwareTex","imageBitmap","_creationFlags","_hardwareTexture","underlyingResource","gpuTextureWrapper","IsImageBitmap","updateTexture","_generateMipmaps","removePendingData","onLoadedObservable","wrapWebGPUTexture","hardwareTexture","internalTexture","wrapWebGLTexture","_getUseSRGBBuffer","_noMipmap","_unpackFlipY","value","updateTextureSamplingMode","updateTextureWrappingMode","wrapU","wrapV","wrapR","_cachedWrapR","updateTextureDimensions","additionalUsages","textureAdditionalUsages","release","_setInternalTexture","_baseName","_pipelineContext","availableTexture","availableTextures","setTexture","autoBindSampler","samplerName","setSampler","createPrefilteredCubeTexture","rootUrl","lodScale","lodOffset","createPolynomials","callback","loadData","_sphericalPolynomial","sphericalPolynomial","_source","createCubeTexture","channel","unused","_setTexture","setTextureArray","textures","toString","isPartOfTextureArray","depthStencilTexture","_baseName2","video","delayLoadState","delayLoad","getInternalTexture","isCube","emptyCubeTexture","emptyTexture3D","emptyTexture2DArray","emptyTexture","isMultiview","_cachedCoordinatesMode","coordinatesMode","textureWrapMode","_setAnisotropicLevel","anisotropicFilteringLevel","target","_cachedAnisotropicFilteringLevel","min","_bindTexture","generateMipmaps","updateTextureData","imageData","xOffset","yOffset","faceIndex","lod","_texture$_hardwareTex2","_uploadCompressedDataToTextureDirectly","internalFormat","_texture$_hardwareTex3","_uploadDataToTextureDirectly","babylonInternalFormat","useTextureWidthAndHeight","_texture$_hardwareTex4","lodMaxWidth","round","log","LOG2E","lodMaxHeight","pow","max","_uploadArrayBufferViewToTexture","_uploadImageToTexture","_texture$_hardwareTex5","HTMLImageElement","bitmap","ceil","readPixels","hasAlpha","flushRenderer","renderPassWrapper","gpuTexture","gpuTextureFormat","_measureFps","sampleFrame","_fps","averageFPS","_deltaTime","instantaneousFrameTime","performanceMonitor","beginFrame","endFrame","_timestampIndex","destroyDeferredTextures","destroyDeferredBuffers","list","_UpdatedUbosInFrame","extractDriverInfo","finish","queue","submit","startFrame","_currentFrameBufferIsDefaultFrameBuffer","renderTargetWrapper","setClearStates","_this$_debugPushGroup","_renderTargetWrapper$","_this$_occlusionQuery","_this$_debugFlushPend","rtWrapper","_depthStencilTexture","gpuDepthStencilWrapper","gpuDepthStencilTexture","gpuDepthStencilMSAATexture","getMSAATexture","depthTextureView","depthMSAATextureView","depthTextureHasStencil","HasStencilAspect","useReverseDepthBuffer","setDepthFunctionToGreaterOrEqual","clearColorForIntegerRT","r","g","b","mustClearColor","mustClearDepth","mustClearStencil","_attachments","isMulti","_mrtAttachments","_defaultAttachments","mrtTexture","gpuMRTWrapper","gpuMRTTexture","_rtWrapper$layerIndic","_rtWrapper$layerIndic2","baseArrayLayer","getBaseArrayLayer","gpuMSAATexture","viewDescriptor","msaaViewDescriptor","isRTInteger","colorTextureView","colorMSAATextureView","resolveTarget","depthSlice","layerIndices","setMRT","gpuWrapper","_debugPushGroup","call","_depthStencilTextureWithStencil","occlusionQuerySet","hasQueries","querySet","startPass","beginRenderPass","_debugFlushPendingCommands","_this$_occlusionQuery2","_this$_debugPushGroup2","_this$_debugFlushPend2","swapChainTexture","getCurrentTexture","set","_isStencilEnable","bindFramebuffer","requiredWidth","requiredHeight","forceFullscreenViewport","lodLevel","layer","_texture$texture","unBindFramebuffer","GetWebGPUTextureFormat","baseMipLevel","aspect","_texture$texture2","_cachedViewport","disableGenerateMipMaps","onBeforeUnbind","saveCRT","generateMipMapsMultiFramebuffer","generateMipMapsFramebuffer","_texture$texture3","_texture$texture4","resolveFramebuffer","_texture","restoreDefaultFramebuffer","wrapper","_wrapper$colorAttachm","_wrapper$colorAttachm2","setDitheringState","setRasterizerState","_executeWhenRenderingStateIsCompiled","action","bindSamplers","_getUnpackAlignement","_bindTextureDirectly","setState","culling","zOffset","force","reverseSide","cullBackFaces","zOffsetUnits","_ref3","_this$cullBackFaces","cull","cullFace","setZOffset","setZOffsetUnits","frontFace","_applyRenderPassChanges","mustUpdateStencilRef","mustUpdateBlendColor","_draw","drawType","fillMode","start","instancesCount","InternalsUBOName","LeftOvertUBOName","play","isDirty","updateId","forceBindGroupCreation","fastBundle","useFastPath","renderPass2","record","indirectDrawBuffer","setIndirectData","getBundleEncoder","colorFormats","numDrawCalls","textureState","hasFloatOrDepthTextures","bitVal","textureNames","_this$_currentMateria","textureName","textureIsDepth","pipeline","getRenderPipeline","bindGroups","getBindGroups","createRenderBundleEncoder","depthStencilFormat","GetSample","setPipeline","setIndexBuffer","effectiveBuffer","setVertexBuffer","_validOffsetRange","setBindGroup","nonCompatMode","drawIndexedIndirect","drawIndirect","drawIndexed","draw","drawElementsType","indexStart","indexCount","drawArraysType","verticesStart","verticesCount","dispose","_this$_mainTexture","_this$_depthTexture","hideLoadingUI","destroy","useScreen","_this$_renderingCanva","_this$_renderingCanva2","_this$_renderingCanva3","_this$_renderingCanva4","getError","createExternalTexture","setExternalTexture","setTextureSampler","sampler","_this$_currentMateria2","createStorageBuffer","updateStorageBuffer","_readFromGPUBuffer","noDelay","readFromBuffer","mapAsync","copyArrayBuffer","getMappedRange","ctor","unmap","reason","isDisposed","onEndFrameObservable","addOnce","readFromStorageBuffer","capacity","createRawBuffer","MapRead","copyBufferToBuffer","readFromMultipleStorageBuffers","storageBuffers","setStorageBuffer","_this$_currentDrawCon","_buffer$getBuffer","_DefaultCdnUrl"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Engines/webgpuEngine.js"],"sourcesContent":["/* eslint-disable babylonjs/available */\nimport { Logger } from \"../Misc/logger.js\";\nimport { ThinWebGPUEngine } from \"./thinWebGPUEngine.js\";\nimport { Color4 } from \"../Maths/math.js\";\nimport { InternalTexture } from \"../Materials/Textures/internalTexture.js\";\nimport { Effect } from \"../Materials/effect.js\";\n\n// eslint-disable-next-line @typescript-eslint/naming-convention\nimport * as WebGPUConstants from \"./WebGPU/webgpuConstants.js\";\nimport { VertexBuffer } from \"../Buffers/buffer.js\";\nimport { WebGPUPipelineContext } from \"./WebGPU/webgpuPipelineContext.js\";\nimport { WebGPUShaderProcessorGLSL } from \"./WebGPU/webgpuShaderProcessorsGLSL.js\";\nimport { WebGPUShaderProcessorWGSL } from \"./WebGPU/webgpuShaderProcessorsWGSL.js\";\nimport { WebGPUShaderProcessingContext } from \"./WebGPU/webgpuShaderProcessingContext.js\";\nimport { Tools } from \"../Misc/tools.js\";\nimport { WebGPUTextureHelper } from \"./WebGPU/webgpuTextureHelper.js\";\nimport { WebGPUTextureManager } from \"./WebGPU/webgpuTextureManager.js\";\nimport { AbstractEngine } from \"./abstractEngine.js\";\nimport { WebGPUBufferManager } from \"./WebGPU/webgpuBufferManager.js\";\nimport { WebGPUHardwareTexture } from \"./WebGPU/webgpuHardwareTexture.js\";\nimport { UniformBuffer } from \"../Materials/uniformBuffer.js\";\nimport { WebGPUCacheSampler } from \"./WebGPU/webgpuCacheSampler.js\";\nimport { WebGPUCacheRenderPipelineTree } from \"./WebGPU/webgpuCacheRenderPipelineTree.js\";\nimport { WebGPUStencilStateComposer } from \"./WebGPU/webgpuStencilStateComposer.js\";\nimport { WebGPUDepthCullingState } from \"./WebGPU/webgpuDepthCullingState.js\";\nimport { WebGPUMaterialContext } from \"./WebGPU/webgpuMaterialContext.js\";\nimport { WebGPUDrawContext } from \"./WebGPU/webgpuDrawContext.js\";\nimport { WebGPUCacheBindGroups } from \"./WebGPU/webgpuCacheBindGroups.js\";\nimport { WebGPUClearQuad } from \"./WebGPU/webgpuClearQuad.js\";\nimport { WebGPURenderItemBlendColor, WebGPURenderItemScissor, WebGPURenderItemStencilRef, WebGPURenderItemViewport, WebGPUBundleList } from \"./WebGPU/webgpuBundleList.js\";\nimport { WebGPUTimestampQuery } from \"./WebGPU/webgpuTimestampQuery.js\";\nimport { WebGPUOcclusionQuery } from \"./WebGPU/webgpuOcclusionQuery.js\";\nimport { ShaderCodeInliner } from \"./Processors/shaderCodeInliner.js\";\nimport { WebGPUTintWASM } from \"./WebGPU/webgpuTintWASM.js\";\nimport { WebGPUShaderProcessor } from \"./WebGPU/webgpuShaderProcessor.js\";\nimport { WebGPUSnapshotRendering } from \"./WebGPU/webgpuSnapshotRendering.js\";\nimport \"../Buffers/buffer.align.js\";\nimport { SphericalPolynomial } from \"../Maths/sphericalPolynomial.js\";\nimport { PerformanceMonitor } from \"../Misc/performanceMonitor.js\";\nimport { CreateImageBitmapFromSource, ExitFullscreen, ExitPointerlock, GetFontOffset, RequestFullscreen, RequestPointerlock, ResizeImageBitmap, _CommonDispose, _CommonInit, } from \"./engine.common.js\";\nimport { IsWrapper } from \"../Materials/drawWrapper.functions.js\";\nimport { PerfCounter } from \"../Misc/perfCounter.js\";\nimport \"./AbstractEngine/abstractEngine.loadingScreen.js\";\nimport \"./AbstractEngine/abstractEngine.dom.js\";\nimport \"./AbstractEngine/abstractEngine.states.js\";\nimport \"./AbstractEngine/abstractEngine.renderPass.js\";\nimport \"../Audio/audioEngine.js\";\nimport { resetCachedPipeline } from \"../Materials/effect.functions.js\";\nimport { WebGPUExternalTexture } from \"./WebGPU/webgpuExternalTexture.js\";\nimport \"./WebGPU/Extensions/engine.alpha.js\";\nimport \"./WebGPU/Extensions/engine.rawTexture.js\";\nimport \"./WebGPU/Extensions/engine.readTexture.js\";\nimport \"./WebGPU/Extensions/engine.cubeTexture.js\";\nimport \"./WebGPU/Extensions/engine.renderTarget.js\";\nimport \"./WebGPU/Extensions/engine.renderTargetTexture.js\";\nimport \"./WebGPU/Extensions/engine.renderTargetCube.js\";\nimport \"./WebGPU/Extensions/engine.query.js\";\nconst viewDescriptorSwapChainAntialiasing = {\n label: `TextureView_SwapChain_ResolveTarget`,\n dimension: \"2d\" /* WebGPUConstants.TextureDimension.E2d */,\n format: undefined, // will be updated with the right value\n mipLevelCount: 1,\n arrayLayerCount: 1,\n};\nconst viewDescriptorSwapChain = {\n label: `TextureView_SwapChain`,\n dimension: \"2d\" /* WebGPUConstants.TextureDimension.E2d */,\n format: undefined, // will be updated with the right value\n mipLevelCount: 1,\n arrayLayerCount: 1,\n};\nconst tempColor4 = new Color4();\n/**\n * The web GPU engine class provides support for WebGPU version of babylon.js.\n * @since 5.0.0\n */\nexport class WebGPUEngine extends ThinWebGPUEngine {\n /**\n * Gets or sets the snapshot rendering mode\n */\n get snapshotRenderingMode() {\n return this._snapshotRendering.mode;\n }\n set snapshotRenderingMode(mode) {\n this._snapshotRendering.mode = mode;\n }\n /**\n * Creates a new snapshot at the next frame using the current snapshotRenderingMode\n */\n snapshotRenderingReset() {\n this._snapshotRendering.reset();\n }\n /**\n * Enables or disables the snapshot rendering mode\n * Note that the WebGL engine does not support snapshot rendering so setting the value won't have any effect for this engine\n */\n get snapshotRendering() {\n return this._snapshotRendering.enabled;\n }\n set snapshotRendering(activate) {\n this._snapshotRendering.enabled = activate;\n }\n /**\n * Sets this to true to disable the cache for the samplers. You should do it only for testing purpose!\n */\n get disableCacheSamplers() {\n return this._cacheSampler ? this._cacheSampler.disabled : false;\n }\n set disableCacheSamplers(disable) {\n if (this._cacheSampler) {\n this._cacheSampler.disabled = disable;\n }\n }\n /**\n * Sets this to true to disable the cache for the render pipelines. You should do it only for testing purpose!\n */\n get disableCacheRenderPipelines() {\n return this._cacheRenderPipeline ? this._cacheRenderPipeline.disabled : false;\n }\n set disableCacheRenderPipelines(disable) {\n if (this._cacheRenderPipeline) {\n this._cacheRenderPipeline.disabled = disable;\n }\n }\n /**\n * Sets this to true to disable the cache for the bind groups. You should do it only for testing purpose!\n */\n get disableCacheBindGroups() {\n return this._cacheBindGroups ? this._cacheBindGroups.disabled : false;\n }\n set disableCacheBindGroups(disable) {\n if (this._cacheBindGroups) {\n this._cacheBindGroups.disabled = disable;\n }\n }\n /**\n * Gets a boolean indicating if all created effects are ready\n * @returns true if all effects are ready\n */\n areAllEffectsReady() {\n return true;\n }\n /**\n * Get Font size information\n * @param font font name\n * @returns an object containing ascent, height and descent\n */\n getFontOffset(font) {\n return GetFontOffset(font);\n }\n /**\n * Gets a Promise<boolean> indicating if the engine can be instantiated (ie. if a WebGPU context can be found)\n */\n static get IsSupportedAsync() {\n return !navigator.gpu\n ? Promise.resolve(false)\n : navigator.gpu\n .requestAdapter()\n .then((adapter) => !!adapter, () => false)\n .catch(() => false);\n }\n /**\n * Not supported by WebGPU, you should call IsSupportedAsync instead!\n */\n static get IsSupported() {\n Logger.Warn(\"You must call IsSupportedAsync for WebGPU!\");\n return false;\n }\n /**\n * Gets a boolean indicating that the engine supports uniform buffers\n */\n get supportsUniformBuffers() {\n return true;\n }\n /** Gets the supported extensions by the WebGPU adapter */\n get supportedExtensions() {\n return this._adapterSupportedExtensions;\n }\n /** Gets the currently enabled extensions on the WebGPU device */\n get enabledExtensions() {\n return this._deviceEnabledExtensions;\n }\n /** Gets the supported limits by the WebGPU adapter */\n get supportedLimits() {\n return this._adapterSupportedLimits;\n }\n /** Gets the current limits of the WebGPU device */\n get currentLimits() {\n return this._deviceLimits;\n }\n /**\n * Returns a string describing the current engine\n */\n get description() {\n const description = this.name + this.version;\n return description;\n }\n /**\n * Returns the version of the engine\n */\n get version() {\n return 1;\n }\n /**\n * Gets an object containing information about the current engine context\n * @returns an object containing the vendor, the renderer and the version of the current engine context\n */\n getInfo() {\n return {\n vendor: this._adapterInfo.vendor || \"unknown vendor\",\n renderer: this._adapterInfo.architecture || \"unknown renderer\",\n version: this._adapterInfo.description || \"unknown version\",\n };\n }\n /**\n * (WebGPU only) True (default) to be in compatibility mode, meaning rendering all existing scenes without artifacts (same rendering than WebGL).\n * Setting the property to false will improve performances but may not work in some scenes if some precautions are not taken.\n * See https://doc.babylonjs.com/setup/support/webGPU/webGPUOptimization/webGPUNonCompatibilityMode for more details\n */\n get compatibilityMode() {\n return this._compatibilityMode;\n }\n set compatibilityMode(mode) {\n this._compatibilityMode = mode;\n }\n /** @internal */\n get currentSampleCount() {\n return this._currentRenderTarget ? this._currentRenderTarget.samples : this._mainPassSampleCount;\n }\n /**\n * Create a new instance of the gpu engine asynchronously\n * @param canvas Defines the canvas to use to display the result\n * @param options Defines the options passed to the engine to create the GPU context dependencies\n * @returns a promise that resolves with the created engine\n */\n static CreateAsync(canvas, options = {}) {\n const engine = new WebGPUEngine(canvas, options);\n return new Promise((resolve) => {\n engine.initAsync(options.glslangOptions, options.twgslOptions).then(() => resolve(engine));\n });\n }\n /**\n * Create a new instance of the gpu engine.\n * @param canvas Defines the canvas to use to display the result\n * @param options Defines the options passed to the engine to create the GPU context dependencies\n */\n constructor(canvas, options = {}) {\n super(options.antialias ?? true, options);\n /** A unique id to identify this instance */\n this.uniqueId = -1;\n // Page Life cycle and constants\n this._uploadEncoderDescriptor = { label: \"upload\" };\n this._renderEncoderDescriptor = { label: \"render\" };\n /** @internal */\n this._clearDepthValue = 1;\n /** @internal */\n this._clearReverseDepthValue = 0;\n /** @internal */\n this._clearStencilValue = 0;\n this._defaultSampleCount = 4; // Only supported value for now.\n this._glslang = null;\n this._tintWASM = null;\n this._glslangAndTintAreFullyLoaded = false;\n this._adapterInfo = {\n vendor: \"\",\n architecture: \"\",\n device: \"\",\n description: \"\",\n };\n /** @internal */\n this._compiledComputeEffects = {};\n /** @internal */\n this._counters = {\n numEnableEffects: 0,\n numEnableDrawWrapper: 0,\n numBundleCreationNonCompatMode: 0,\n numBundleReuseNonCompatMode: 0,\n };\n /**\n * Counters from last frame\n */\n this.countersLastFrame = {\n numEnableEffects: 0,\n numEnableDrawWrapper: 0,\n numBundleCreationNonCompatMode: 0,\n numBundleReuseNonCompatMode: 0,\n };\n /**\n * Max number of uncaptured error messages to log\n */\n this.numMaxUncapturedErrors = 20;\n /**\n * Gets the list of created scenes\n */\n this.scenes = [];\n /** @internal */\n this._virtualScenes = new Array();\n this._commandBuffers = [null, null];\n // Frame Buffer Life Cycle (recreated for each render target pass)\n this._mainRenderPassWrapper = {\n renderPassDescriptor: null,\n colorAttachmentViewDescriptor: null,\n depthAttachmentViewDescriptor: null,\n colorAttachmentGPUTextures: [],\n depthTextureFormat: undefined,\n };\n this._rttRenderPassWrapper = {\n renderPassDescriptor: null,\n colorAttachmentViewDescriptor: null,\n depthAttachmentViewDescriptor: null,\n colorAttachmentGPUTextures: [],\n depthTextureFormat: undefined,\n };\n /** @internal */\n this._pendingDebugCommands = [];\n this._currentOverrideVertexBuffers = null;\n this._currentIndexBuffer = null;\n this._colorWriteLocal = true;\n this._forceEnableEffect = false;\n /**\n * Indicates if the z range in NDC space is 0..1 (value: true) or -1..1 (value: false)\n */\n this.isNDCHalfZRange = true;\n /**\n * Indicates that the origin of the texture/framebuffer space is the bottom left corner. If false, the origin is top left\n */\n this.hasOriginBottomLeft = false;\n //------------------------------------------------------------------------------\n // Initialization\n //------------------------------------------------------------------------------\n this._workingGlslangAndTintPromise = null;\n //------------------------------------------------------------------------------\n // Dynamic WebGPU States\n //------------------------------------------------------------------------------\n // index 0 is for main render pass, 1 for RTT render pass\n this._viewportsCurrent = { x: 0, y: 0, w: 0, h: 0 };\n this._scissorsCurrent = { x: 0, y: 0, w: 0, h: 0 };\n this._scissorCached = { x: 0, y: 0, z: 0, w: 0 };\n this._stencilRefsCurrent = -1;\n this._blendColorsCurrent = [null, null, null, null];\n this._performanceMonitor = new PerformanceMonitor();\n this._name = \"WebGPU\";\n this._drawCalls = new PerfCounter();\n options.deviceDescriptor = options.deviceDescriptor || {};\n options.enableGPUDebugMarkers = options.enableGPUDebugMarkers ?? false;\n Logger.Log(`Babylon.js v${AbstractEngine.Version} - ${this.description} engine`);\n if (!navigator.gpu) {\n Logger.Error(\"WebGPU is not supported by your browser.\");\n return;\n }\n options.swapChainFormat = options.swapChainFormat || navigator.gpu.getPreferredCanvasFormat();\n this._isWebGPU = true;\n this._shaderPlatformName = \"WEBGPU\";\n this._renderingCanvas = canvas;\n this._options = options;\n this._mainPassSampleCount = options.antialias ? this._defaultSampleCount : 1;\n if (navigator && navigator.userAgent) {\n this._setupMobileChecks();\n }\n this._sharedInit(this._renderingCanvas);\n this._shaderProcessor = new WebGPUShaderProcessorGLSL();\n this._shaderProcessorWGSL = new WebGPUShaderProcessorWGSL();\n }\n /**\n * Load the glslang and tintWASM libraries and prepare them for use.\n * @returns a promise that resolves when the engine is ready to use the glslang and tintWASM\n */\n prepareGlslangAndTintAsync() {\n if (!this._workingGlslangAndTintPromise) {\n this._workingGlslangAndTintPromise = new Promise((resolve) => {\n this._initGlslang(this._glslangOptions ?? this._options?.glslangOptions).then((glslang) => {\n this._glslang = glslang;\n this._tintWASM = new WebGPUTintWASM();\n this._tintWASM.initTwgsl(this._twgslOptions ?? this._options?.twgslOptions).then(() => {\n this._glslangAndTintAreFullyLoaded = true;\n resolve();\n });\n });\n });\n }\n return this._workingGlslangAndTintPromise;\n }\n /**\n * Initializes the WebGPU context and dependencies.\n * @param glslangOptions Defines the GLSLang compiler options if necessary\n * @param twgslOptions Defines the Twgsl compiler options if necessary\n * @returns a promise notifying the readiness of the engine.\n */\n initAsync(glslangOptions, twgslOptions) {\n this.uniqueId = WebGPUEngine._InstanceId++;\n this._glslangOptions = glslangOptions;\n this._twgslOptions = twgslOptions;\n return navigator\n .gpu.requestAdapter(this._options)\n .then((adapter) => {\n if (!adapter) {\n // eslint-disable-next-line no-throw-literal\n throw \"Could not retrieve a WebGPU adapter (adapter is null).\";\n }\n else {\n this._adapter = adapter;\n this._adapterSupportedExtensions = [];\n this._adapter.features?.forEach((feature) => this._adapterSupportedExtensions.push(feature));\n this._adapterSupportedLimits = this._adapter.limits;\n this._adapterInfo = this._adapter.info;\n const deviceDescriptor = this._options.deviceDescriptor ?? {};\n const requiredFeatures = deviceDescriptor?.requiredFeatures ?? (this._options.enableAllFeatures ? this._adapterSupportedExtensions : undefined);\n if (requiredFeatures) {\n const requestedExtensions = requiredFeatures;\n const validExtensions = [];\n for (const extension of requestedExtensions) {\n if (this._adapterSupportedExtensions.indexOf(extension) !== -1) {\n validExtensions.push(extension);\n }\n }\n deviceDescriptor.requiredFeatures = validExtensions;\n }\n if (this._options.setMaximumLimits && !deviceDescriptor.requiredLimits) {\n deviceDescriptor.requiredLimits = {};\n for (const name in this._adapterSupportedLimits) {\n if (name === \"minSubgroupSize\" || name === \"maxSubgroupSize\") {\n // Chrome exposes these limits in \"webgpu developer\" mode, but these can't be set on the device.\n continue;\n }\n deviceDescriptor.requiredLimits[name] = this._adapterSupportedLimits[name];\n }\n }\n deviceDescriptor.label = `BabylonWebGPUDevice${this.uniqueId}`;\n return this._adapter.requestDevice(deviceDescriptor);\n }\n })\n .then((device) => {\n this._device = device;\n this._deviceEnabledExtensions = [];\n this._device.features?.forEach((feature) => this._deviceEnabledExtensions.push(feature));\n this._deviceLimits = device.limits;\n let numUncapturedErrors = -1;\n this._device.addEventListener(\"uncapturederror\", (event) => {\n if (++numUncapturedErrors < this.numMaxUncapturedErrors) {\n Logger.Warn(`WebGPU uncaptured error (${numUncapturedErrors + 1}): ${event.error} - ${event.error.message}`);\n }\n else if (numUncapturedErrors++ === this.numMaxUncapturedErrors) {\n Logger.Warn(`WebGPU uncaptured error: too many warnings (${this.numMaxUncapturedErrors}), no more warnings will be reported to the console for this engine.`);\n }\n });\n if (!this._doNotHandleContextLost) {\n this._device.lost?.then((info) => {\n if (this._isDisposed) {\n return;\n }\n this._contextWasLost = true;\n Logger.Warn(\"WebGPU context lost. \" + info);\n this.onContextLostObservable.notifyObservers(this);\n this._restoreEngineAfterContextLost(async () => {\n const snapshotRenderingMode = this.snapshotRenderingMode;\n const snapshotRendering = this.snapshotRendering;\n const disableCacheSamplers = this.disableCacheSamplers;\n const disableCacheRenderPipelines = this.disableCacheRenderPipelines;\n const disableCacheBindGroups = this.disableCacheBindGroups;\n const enableGPUTimingMeasurements = this.enableGPUTimingMeasurements;\n await this.initAsync(this._glslangOptions ?? this._options?.glslangOptions, this._twgslOptions ?? this._options?.twgslOptions);\n this.snapshotRenderingMode = snapshotRenderingMode;\n this.snapshotRendering = snapshotRendering;\n this.disableCacheSamplers = disableCacheSamplers;\n this.disableCacheRenderPipelines = disableCacheRenderPipelines;\n this.disableCacheBindGroups = disableCacheBindGroups;\n this.enableGPUTimingMeasurements = enableGPUTimingMeasurements;\n this._currentRenderPass = null;\n });\n });\n }\n })\n .then(() => {\n this._initializeLimits();\n this._bufferManager = new WebGPUBufferManager(this, this._device);\n this._textureHelper = new WebGPUTextureManager(this, this._device, this._bufferManager, this._deviceEnabledExtensions);\n this._cacheSampler = new WebGPUCacheSampler(this._device);\n this._cacheBindGroups = new WebGPUCacheBindGroups(this._device, this._cacheSampler, this);\n this._timestampQuery = new WebGPUTimestampQuery(this, this._device, this._bufferManager);\n this._occlusionQuery = this._device.createQuerySet ? new WebGPUOcclusionQuery(this, this._device, this._bufferManager) : undefined;\n this._bundleList = new WebGPUBundleList(this._device);\n this._snapshotRendering = new WebGPUSnapshotRendering(this, this._snapshotRenderingMode, this._bundleList);\n this._ubInvertY = this._bufferManager.createBuffer(new Float32Array([-1, 0]), WebGPUConstants.BufferUsage.Uniform | WebGPUConstants.BufferUsage.CopyDst, \"UBInvertY\");\n this._ubDontInvertY = this._bufferManager.createBuffer(new Float32Array([1, 0]), WebGPUConstants.BufferUsage.Uniform | WebGPUConstants.BufferUsage.CopyDst, \"UBDontInvertY\");\n if (this.dbgVerboseLogsForFirstFrames) {\n if (this._count === undefined) {\n this._count = 0;\n Logger.Log([\"%c frame #\" + this._count + \" - begin\", \"background: #ffff00\"]);\n }\n }\n this._uploadEncoder = this._device.createCommandEncoder(this._uploadEncoderDescriptor);\n this._renderEncoder = this._device.createCommandEncoder(this._renderEncoderDescriptor);\n this._emptyVertexBuffer = new VertexBuffer(this, [0], \"\", {\n stride: 1,\n offset: 0,\n size: 1,\n label: \"EmptyVertexBuffer\",\n });\n this._cacheRenderPipeline = new WebGPUCacheRenderPipelineTree(this._device, this._emptyVertexBuffer);\n this._depthCullingState = new WebGPUDepthCullingState(this._cacheRenderPipeline);\n this._stencilStateComposer = new WebGPUStencilStateComposer(this._cacheRenderPipeline);\n this._stencilStateComposer.stencilGlobal = this._stencilState;\n this._depthCullingState.depthTest = true;\n this._depthCullingState.depthFunc = 515;\n this._depthCullingState.depthMask = true;\n this._textureHelper.setCommandEncoder(this._uploadEncoder);\n this._clearQuad = new WebGPUClearQuad(this._device, this, this._emptyVertexBuffer);\n this._defaultDrawContext = this.createDrawContext();\n this._currentDrawContext = this._defaultDrawContext;\n this._defaultMaterialContext = this.createMaterialContext();\n this._currentMaterialContext = this._defaultMaterialContext;\n this._initializeContextAndSwapChain();\n this._initializeMainAttachments();\n this.resize();\n })\n .catch((e) => {\n Logger.Error(\"A fatal error occurred during WebGPU creation/initialization.\");\n throw e;\n });\n }\n _initGlslang(glslangOptions) {\n glslangOptions = glslangOptions || {};\n glslangOptions = {\n ...WebGPUEngine._GlslangDefaultOptions,\n ...glslangOptions,\n };\n if (glslangOptions.glslang) {\n return Promise.resolve(glslangOptions.glslang);\n }\n if (self.glslang) {\n return self.glslang(glslangOptions.wasmPath);\n }\n if (glslangOptions.jsPath && glslangOptions.wasmPath) {\n return Tools.LoadBabylonScriptAsync(glslangOptions.jsPath).then(() => {\n return self.glslang(Tools.GetBabylonScriptURL(glslangOptions.wasmPath));\n });\n }\n return Promise.reject(\"gslang is not available.\");\n }\n _initializeLimits() {\n // Init caps\n // TODO WEBGPU Real Capability check once limits will be working.\n this._caps = {\n maxTexturesImageUnits: this._deviceLimits.maxSampledTexturesPerShaderStage,\n maxVertexTextureImageUnits: this._deviceLimits.maxSampledTexturesPerShaderStage,\n maxCombinedTexturesImageUnits: this._deviceLimits.maxSampledTexturesPerShaderStage * 2,\n maxTextureSize: this._deviceLimits.maxTextureDimension2D,\n maxCubemapTextureSize: this._deviceLimits.maxTextureDimension2D,\n maxRenderTextureSize: this._deviceLimits.maxTextureDimension2D,\n maxVertexAttribs: this._deviceLimits.maxVertexAttributes,\n maxDrawBuffers: 8,\n maxVaryingVectors: this._deviceLimits.maxInterStageShaderVariables,\n maxFragmentUniformVectors: Math.floor(this._deviceLimits.maxUniformBufferBindingSize / 4),\n maxVertexUniformVectors: Math.floor(this._deviceLimits.maxUniformBufferBindingSize / 4),\n standardDerivatives: true,\n astc: (this._deviceEnabledExtensions.indexOf(\"texture-compression-astc\" /* WebGPUConstants.FeatureName.TextureCompressionASTC */) >= 0 ? true : undefined),\n s3tc: (this._deviceEnabledExtensions.indexOf(\"texture-compression-bc\" /* WebGPUConstants.FeatureName.TextureCompressionBC */) >= 0 ? true : undefined),\n pvrtc: null,\n etc1: null,\n etc2: (this._deviceEnabledExtensions.indexOf(\"texture-compression-etc2\" /* WebGPUConstants.FeatureName.TextureCompressionETC2 */) >= 0 ? true : undefined),\n bptc: this._deviceEnabledExtensions.indexOf(\"texture-compression-bc\" /* WebGPUConstants.FeatureName.TextureCompressionBC */) >= 0 ? true : undefined,\n maxAnisotropy: 16, // Most implementations support maxAnisotropy values in range between 1 and 16, inclusive. The used value of maxAnisotropy will be clamped to the maximum value that the platform supports.\n uintIndices: true,\n fragmentDepthSupported: true,\n highPrecisionShaderSupported: true,\n colorBufferFloat: true,\n supportFloatTexturesResolve: false, // See https://github.com/gpuweb/gpuweb/issues/3844\n rg11b10ufColorRenderable: this._deviceEnabledExtensions.indexOf(\"rg11b10ufloat-renderable\" /* WebGPUConstants.FeatureName.RG11B10UFloatRenderable */) >= 0,\n textureFloat: true,\n textureFloatLinearFiltering: this._deviceEnabledExtensions.indexOf(\"float32-filterable\" /* WebGPUConstants.FeatureName.Float32Filterable */) >= 0,\n textureFloatRender: true,\n textureHalfFloat: true,\n textureHalfFloatLinearFiltering: true,\n textureHalfFloatRender: true,\n textureLOD: true,\n texelFetch: true,\n drawBuffersExtension: true,\n depthTextureExtension: true,\n vertexArrayObject: false,\n instancedArrays: true,\n timerQuery: typeof BigUint64Array !== \"undefined\" && this._deviceEnabledExtensions.indexOf(\"timestamp-query\" /* WebGPUConstants.FeatureName.TimestampQuery */) !== -1 ? true : undefined,\n supportOcclusionQuery: typeof BigUint64Array !== \"undefined\",\n canUseTimestampForTimerQuery: true,\n multiview: false,\n oculusMultiview: false,\n parallelShaderCompile: undefined,\n blendMinMax: true,\n maxMSAASamples: 4, // the spec only supports values of 1 and 4\n canUseGLInstanceID: true,\n canUseGLVertexID: true,\n supportComputeShaders: true,\n supportSRGBBuffers: true,\n supportTransformFeedbacks: false,\n textureMaxLevel: true,\n texture2DArrayMaxLayerCount: this._deviceLimits.maxTextureArrayLayers,\n disableMorphTargetTexture: false,\n textureNorm16: false, // in the works: https://github.com/gpuweb/gpuweb/issues/3001\n };\n this._features = {\n forceBitmapOverHTMLImageElement: true,\n supportRenderAndCopyToLodForFloatTextures: true,\n supportDepthStencilTexture: true,\n supportShadowSamplers: true,\n uniformBufferHardCheckMatrix: false,\n allowTexturePrefiltering: true,\n trackUbosInFrame: true,\n checkUbosContentBeforeUpload: true,\n supportCSM: true,\n basisNeedsPOT: false,\n support3DTextures: true,\n needTypeSuffixInShaderConstants: true,\n supportMSAA: true,\n supportSSAO2: true,\n supportIBLShadows: true,\n supportExtendedTextureFormats: true,\n supportSwitchCaseInShader: true,\n supportSyncTextureRead: false,\n needsInvertingBitmap: false,\n useUBOBindingCache: false,\n needShaderCodeInlining: true,\n needToAlwaysBindUniformBuffers: true,\n supportRenderPasses: true,\n supportSpriteInstancing: true,\n forceVertexBufferStrideAndOffsetMultiple4Bytes: true,\n _checkNonFloatVertexBuffersDontRecreatePipelineContext: true,\n _collectUbosUpdatedInFrame: false,\n };\n }\n _initializeContextAndSwapChain() {\n if (!this._renderingCanvas) {\n // eslint-disable-next-line no-throw-literal\n throw \"The rendering canvas has not been set!\";\n }\n this._context = this._renderingCanvas.getContext(\"webgpu\");\n this._configureContext();\n this._colorFormat = this._options.swapChainFormat;\n this._mainRenderPassWrapper.colorAttachmentGPUTextures = [new WebGPUHardwareTexture(this)];\n this._mainRenderPassWrapper.colorAttachmentGPUTextures[0].format = this._colorFormat;\n this._setColorFormat(this._mainRenderPassWrapper);\n }\n // Set default values as WebGL with depth and stencil attachment for the broadest Compat.\n _initializeMainAttachments() {\n if (!this._bufferManager) {\n return;\n }\n this.flushFramebuffer();\n this._mainTextureExtends = {\n width: this.getRenderWidth(true),\n height: this.getRenderHeight(true),\n depthOrArrayLayers: 1,\n };\n const bufferDataUpdate = new Float32Array([this.getRenderHeight(true)]);\n this._bufferManager.setSubData(this._ubInvertY, 4, bufferDataUpdate);\n this._bufferManager.setSubData(this._ubDontInvertY, 4, bufferDataUpdate);\n let mainColorAttachments;\n if (this._options.antialias) {\n const mainTextureDescriptor = {\n label: `Texture_MainColor_${this._mainTextureExtends.width}x${this._mainTextureExtends.height}_antialiasing`,\n size: this._mainTextureExtends,\n mipLevelCount: 1,\n sampleCount: this._mainPassSampleCount,\n dimension: \"2d\" /* WebGPUConstants.TextureDimension.E2d */,\n format: this._options.swapChainFormat,\n usage: 16 /* WebGPUConstants.TextureUsage.RenderAttachment */,\n };\n if (this._mainTexture) {\n this._textureHelper.releaseTexture(this._mainTexture);\n }\n this._mainTexture = this._device.createTexture(mainTextureDescriptor);\n mainColorAttachments = [\n {\n view: this._mainTexture.createView({\n label: \"TextureView_MainColor_antialiasing\",\n dimension: \"2d\" /* WebGPUConstants.TextureDimension.E2d */,\n format: this._options.swapChainFormat,\n mipLevelCount: 1,\n arrayLayerCount: 1,\n }),\n clearValue: new Color4(0, 0, 0, 1),\n loadOp: \"clear\" /* WebGPUConstants.LoadOp.Clear */,\n storeOp: \"store\" /* WebGPUConstants.StoreOp.Store */, // don't use StoreOp.Discard, else using several cameras with different viewports or using scissors will fail because we call beginRenderPass / endPass several times for the same color attachment!\n },\n ];\n }\n else {\n mainColorAttachments = [\n {\n view: undefined,\n clearValue: new Color4(0, 0, 0, 1),\n loadOp: \"clear\" /* WebGPUConstants.LoadOp.Clear */,\n storeOp: \"store\" /* WebGPUConstants.StoreOp.Store */,\n },\n ];\n }\n this._mainRenderPassWrapper.depthTextureFormat = this.isStencilEnable ? \"depth24plus-stencil8\" /* WebGPUConstants.TextureFormat.Depth24PlusStencil8 */ : \"depth32float\" /* WebGPUConstants.TextureFormat.Depth32Float */;\n this._setDepthTextureFormat(this._mainRenderPassWrapper);\n this._setColorFormat(this._mainRenderPassWrapper);\n const depthTextureDescriptor = {\n label: `Texture_MainDepthStencil_${this._mainTextureExtends.width}x${this._mainTextureExtends.height}`,\n size: this._mainTextureExtends,\n mipLevelCount: 1,\n sampleCount: this._mainPassSampleCount,\n dimension: \"2d\" /* WebGPUConstants.TextureDimension.E2d */,\n format: this._mainRenderPassWrapper.depthTextureFormat,\n usage: 16 /* WebGPUConstants.TextureUsage.RenderAttachment */,\n };\n if (this._depthTexture) {\n this._textureHelper.releaseTexture(this._depthTexture);\n }\n this._depthTexture = this._device.createTexture(depthTextureDescriptor);\n const mainDepthAttachment = {\n view: this._depthTexture.createView({\n label: `TextureView_MainDepthStencil_${this._mainTextureExtends.width}x${this._mainTextureExtends.height}`,\n dimension: \"2d\" /* WebGPUConstants.TextureDimension.E2d */,\n format: this._depthTexture.format,\n mipLevelCount: 1,\n arrayLayerCount: 1,\n }),\n depthClearValue: this._clearDepthValue,\n depthLoadOp: \"clear\" /* WebGPUConstants.LoadOp.Clear */,\n depthStoreOp: \"store\" /* WebGPUConstants.StoreOp.Store */,\n stencilClearValue: this._clearStencilValue,\n stencilLoadOp: !this.isStencilEnable ? undefined : \"clear\" /* WebGPUConstants.LoadOp.Clear */,\n stencilStoreOp: !this.isStencilEnable ? undefined : \"store\" /* WebGPUConstants.StoreOp.Store */,\n };\n this._mainRenderPassWrapper.renderPassDescriptor = {\n label: \"MainRenderPass\",\n colorAttachments: mainColorAttachments,\n depthStencilAttachment: mainDepthAttachment,\n };\n }\n /**\n * Shared initialization across engines types.\n * @param canvas The canvas associated with this instance of the engine.\n */\n _sharedInit(canvas) {\n super._sharedInit(canvas);\n _CommonInit(this, canvas, this._creationOptions);\n }\n _configureContext() {\n this._context.configure({\n device: this._device,\n format: this._options.swapChainFormat,\n usage: 16 /* WebGPUConstants.TextureUsage.RenderAttachment */ | 1 /* WebGPUConstants.TextureUsage.CopySrc */,\n alphaMode: this.premultipliedAlpha ? \"premultiplied\" /* WebGPUConstants.CanvasAlphaMode.Premultiplied */ : \"opaque\" /* WebGPUConstants.CanvasAlphaMode.Opaque */,\n });\n }\n /**\n * Resize an image and returns the image data as an uint8array\n * @param image image to resize\n * @param bufferWidth destination buffer width\n * @param bufferHeight destination buffer height\n * @returns an uint8array containing RGBA values of bufferWidth * bufferHeight size\n */\n resizeImageBitmap(image, bufferWidth, bufferHeight) {\n return ResizeImageBitmap(this, image, bufferWidth, bufferHeight);\n }\n /**\n * Engine abstraction for loading and creating an image bitmap from a given source string.\n * @param imageSource source to load the image from.\n * @param options An object that sets options for the image's extraction.\n * @returns ImageBitmap\n */\n _createImageBitmapFromSource(imageSource, options) {\n return CreateImageBitmapFromSource(this, imageSource, options);\n }\n /**\n * Toggle full screen mode\n * @param requestPointerLock defines if a pointer lock should be requested from the user\n */\n switchFullscreen(requestPointerLock) {\n if (this.isFullscreen) {\n this.exitFullscreen();\n }\n else {\n this.enterFullscreen(requestPointerLock);\n }\n }\n /**\n * Enters full screen mode\n * @param requestPointerLock defines if a pointer lock should be requested from the user\n */\n enterFullscreen(requestPointerLock) {\n if (!this.isFullscreen) {\n this._pointerLockRequested = requestPointerLock;\n if (this._renderingCanvas) {\n RequestFullscreen(this._renderingCanvas);\n }\n }\n }\n /**\n * Exits full screen mode\n */\n exitFullscreen() {\n if (this.isFullscreen) {\n ExitFullscreen();\n }\n }\n /**\n * Enters Pointerlock mode\n */\n enterPointerlock() {\n if (this._renderingCanvas) {\n RequestPointerlock(this._renderingCanvas);\n }\n }\n /**\n * Exits Pointerlock mode\n */\n exitPointerlock() {\n ExitPointerlock();\n }\n _rebuildBuffers() {\n super._rebuildBuffers();\n for (const storageBuffer of this._storageBuffers) {\n // The buffer can already be rebuilt by the call to _rebuildGeometries(), which recreates the storage buffers for the ComputeShaderParticleSystem\n if (storageBuffer.getBuffer().engineId !== this.uniqueId) {\n storageBuffer._rebuild();\n }\n }\n }\n _restoreEngineAfterContextLost(initEngine) {\n WebGPUCacheRenderPipelineTree.ResetCache();\n WebGPUCacheBindGroups.ResetCache();\n // Clear the draw wrappers and material contexts\n const cleanScenes = (scenes) => {\n for (const scene of scenes) {\n for (const mesh of scene.meshes) {\n const subMeshes = mesh.subMeshes;\n if (!subMeshes) {\n continue;\n }\n for (const subMesh of subMeshes) {\n subMesh._drawWrappers = [];\n }\n }\n for (const material of scene.materials) {\n material._materialContext?.reset();\n }\n }\n };\n cleanScenes(this.scenes);\n cleanScenes(this._virtualScenes);\n // The leftOver uniform buffers are removed from the list because they will be recreated when we rebuild the effects\n const uboList = [];\n for (const uniformBuffer of this._uniformBuffers) {\n if (uniformBuffer.name.indexOf(\"leftOver\") < 0) {\n uboList.push(uniformBuffer);\n }\n }\n this._uniformBuffers = uboList;\n super._restoreEngineAfterContextLost(initEngine);\n }\n /**\n * Force a specific size of the canvas\n * @param width defines the new canvas' width\n * @param height defines the new canvas' height\n * @param forceSetSize true to force setting the sizes of the underlying canvas\n * @returns true if the size was changed\n */\n setSize(width, height, forceSetSize = false) {\n if (!super.setSize(width, height, forceSetSize)) {\n return false;\n }\n if (this.dbgVerboseLogsForFirstFrames) {\n if (this._count === undefined) {\n this._count = 0;\n }\n if (!this._count || this._count < this.dbgVerboseLogsNumFrames) {\n Logger.Log([\"frame #\" + this._count + \" - setSize -\", width, height]);\n }\n }\n this._initializeMainAttachments();\n if (this.snapshotRendering) {\n // reset snapshot rendering so that the next frame will record a new list of bundles\n this.snapshotRenderingReset();\n }\n return true;\n }\n /**\n * @internal\n */\n _getShaderProcessor(shaderLanguage) {\n if (shaderLanguage === 1 /* ShaderLanguage.WGSL */) {\n return this._shaderProcessorWGSL;\n }\n return this._shaderProcessor;\n }\n /**\n * @internal\n */\n _getShaderProcessingContext(shaderLanguage, pureMode) {\n return new WebGPUShaderProcessingContext(shaderLanguage, pureMode);\n }\n _getCurrentRenderPass() {\n if (this._currentRenderTarget && !this._currentRenderPass) {\n // delayed creation of the render target pass, but we now need to create it as we are requested the render pass\n this._startRenderTargetRenderPass(this._currentRenderTarget, false, null, false, false);\n }\n else if (!this._currentRenderPass) {\n this._startMainRenderPass(false);\n }\n return this._currentRenderPass;\n }\n /** @internal */\n _getCurrentRenderPassWrapper() {\n return this._currentRenderTarget ? this._rttRenderPassWrapper : this._mainRenderPassWrapper;\n }\n //------------------------------------------------------------------------------\n // Static Pipeline WebGPU States\n //------------------------------------------------------------------------------\n /** @internal */\n applyStates() {\n this._stencilStateComposer.apply();\n this._cacheRenderPipeline.setAlphaBlendEnabled(this._alphaState.alphaBlend);\n }\n /**\n * Force the entire cache to be cleared\n * You should not have to use this function unless your engine needs to share the WebGPU context with another engine\n * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)\n */\n wipeCaches(bruteForce) {\n if (this.preventCacheWipeBetweenFrames && !bruteForce) {\n return;\n }\n //this._currentEffect = null; // can't reset _currentEffect, else some crashes can occur (for eg in ProceduralTexture which calls bindFrameBuffer (which calls wipeCaches) after having called enableEffect and before drawing into the texture)\n // _forceEnableEffect = true assumes the role of _currentEffect = null\n this._forceEnableEffect = true;\n this._currentIndexBuffer = null;\n this._currentOverrideVertexBuffers = null;\n this._cacheRenderPipeline.setBuffers(null, null, null);\n if (bruteForce) {\n this._stencilStateComposer.reset();\n this._depthCullingState.reset();\n this._depthCullingState.depthFunc = 515;\n this._alphaState.reset();\n this._alphaMode = 1;\n this._alphaEquation = 0;\n this._cacheRenderPipeline.setAlphaBlendFactors(this._alphaState._blendFunctionParameters, this._alphaState._blendEquationParameters);\n this._cacheRenderPipeline.setAlphaBlendEnabled(false);\n this.setColorWrite(true);\n }\n this._cachedVertexBuffers = null;\n this._cachedIndexBuffer = null;\n this._cachedEffectForVertexBuffers = null;\n }\n /**\n * Enable or disable color writing\n * @param enable defines the state to set\n */\n setColorWrite(enable) {\n this._colorWriteLocal = enable;\n this._cacheRenderPipeline.setWriteMask(enable ? 0xf : 0);\n }\n /**\n * Gets a boolean indicating if color writing is enabled\n * @returns the current color writing state\n */\n getColorWrite() {\n return this._colorWriteLocal;\n }\n _mustUpdateViewport() {\n const x = this._viewportCached.x, y = this._viewportCached.y, w = this._viewportCached.z, h = this._viewportCached.w;\n const update = this._viewportsCurrent.x !== x || this._viewportsCurrent.y !== y || this._viewportsCurrent.w !== w || this._viewportsCurrent.h !== h;\n if (update) {\n this._viewportsCurrent.x = this._viewportCached.x;\n this._viewportsCurrent.y = this._viewportCached.y;\n this._viewportsCurrent.w = this._viewportCached.z;\n this._viewportsCurrent.h = this._viewportCached.w;\n }\n return update;\n }\n _applyViewport(bundleList) {\n const x = Math.floor(this._viewportCached.x);\n const w = Math.floor(this._viewportCached.z);\n const h = Math.floor(this._viewportCached.w);\n let y = Math.floor(this._viewportCached.y);\n if (!this._currentRenderTarget) {\n y = this.getRenderHeight(true) - y - h;\n }\n if (bundleList) {\n bundleList.addItem(new WebGPURenderItemViewport(x, y, w, h));\n }\n else {\n this._getCurrentRenderPass().setViewport(x, y, w, h, 0, 1);\n }\n if (this.dbgVerboseLogsForFirstFrames) {\n if (this._count === undefined) {\n this._count = 0;\n }\n if (!this._count || this._count < this.dbgVerboseLogsNumFrames) {\n Logger.Log([\n \"frame #\" + this._count + \" - viewport applied - (\",\n this._viewportCached.x,\n this._viewportCached.y,\n this._viewportCached.z,\n this._viewportCached.w,\n \") current pass is main pass=\" + this._currentPassIsMainPass(),\n ]);\n }\n }\n }\n /**\n * @internal\n */\n _viewport(x, y, width, height) {\n this._viewportCached.x = x;\n this._viewportCached.y = y;\n this._viewportCached.z = width;\n this._viewportCached.w = height;\n }\n _mustUpdateScissor() {\n const x = this._scissorCached.x, y = this._scissorCached.y, w = this._scissorCached.z, h = this._scissorCached.w;\n const update = this._scissorsCurrent.x !== x || this._scissorsCurrent.y !== y || this._scissorsCurrent.w !== w || this._scissorsCurrent.h !== h;\n if (update) {\n this._scissorsCurrent.x = this._scissorCached.x;\n this._scissorsCurrent.y = this._scissorCached.y;\n this._scissorsCurrent.w = this._scissorCached.z;\n this._scissorsCurrent.h = this._scissorCached.w;\n }\n return update;\n }\n _applyScissor(bundleList) {\n const y = this._currentRenderTarget ? this._scissorCached.y : this.getRenderHeight() - this._scissorCached.w - this._scissorCached.y;\n if (bundleList) {\n bundleList.addItem(new WebGPURenderItemScissor(this._scissorCached.x, y, this._scissorCached.z, this._scissorCached.w));\n }\n else {\n this._getCurrentRenderPass().setScissorRect(this._scissorCached.x, y, this._scissorCached.z, this._scissorCached.w);\n }\n if (this.dbgVerboseLogsForFirstFrames) {\n if (this._count === undefined) {\n this._count = 0;\n }\n if (!this._count || this._count < this.dbgVerboseLogsNumFrames) {\n Logger.Log([\n \"frame #\" + this._count + \" - scissor applied - (\",\n this._scissorCached.x,\n this._scissorCached.y,\n this._scissorCached.z,\n this._scissorCached.w,\n \") current pass is main pass=\" + this._currentPassIsMainPass(),\n ]);\n }\n }\n }\n _scissorIsActive() {\n return this._scissorCached.x !== 0 || this._scissorCached.y !== 0 || this._scissorCached.z !== 0 || this._scissorCached.w !== 0;\n }\n enableScissor(x, y, width, height) {\n this._scissorCached.x = x;\n this._scissorCached.y = y;\n this._scissorCached.z = width;\n this._scissorCached.w = height;\n }\n disableScissor() {\n this._scissorCached.x = this._scissorCached.y = this._scissorCached.z = this._scissorCached.w = 0;\n this._scissorsCurrent.x = this._scissorsCurrent.y = this._scissorsCurrent.w = this._scissorsCurrent.h = 0;\n }\n _mustUpdateStencilRef() {\n const update = this._stencilStateComposer.funcRef !== this._stencilRefsCurrent;\n if (update) {\n this._stencilRefsCurrent = this._stencilStateComposer.funcRef;\n }\n return update;\n }\n _applyStencilRef(bundleList) {\n if (bundleList) {\n bundleList.addItem(new WebGPURenderItemStencilRef(this._stencilStateComposer.funcRef ?? 0));\n }\n else {\n this._getCurrentRenderPass().setStencilReference(this._stencilStateComposer.funcRef ?? 0);\n }\n }\n _mustUpdateBlendColor() {\n const colorBlend = this._alphaState._blendConstants;\n const update = colorBlend[0] !== this._blendColorsCurrent[0] ||\n colorBlend[1] !== this._blendColorsCurrent[1] ||\n colorBlend[2] !== this._blendColorsCurrent[2] ||\n colorBlend[3] !== this._blendColorsCurrent[3];\n if (update) {\n this._blendColorsCurrent[0] = colorBlend[0];\n this._blendColorsCurrent[1] = colorBlend[1];\n this._blendColorsCurrent[2] = colorBlend[2];\n this._blendColorsCurrent[3] = colorBlend[3];\n }\n return update;\n }\n _applyBlendColor(bundleList) {\n if (bundleList) {\n bundleList.addItem(new WebGPURenderItemBlendColor(this._alphaState._blendConstants.slice()));\n }\n else {\n this._getCurrentRenderPass().setBlendConstant(this._alphaState._blendConstants);\n }\n }\n _resetRenderPassStates() {\n this._viewportsCurrent.x = this._viewportsCurrent.y = this._viewportsCurrent.w = this._viewportsCurrent.h = 0;\n this._scissorsCurrent.x = this._scissorsCurrent.y = this._scissorsCurrent.w = this._scissorsCurrent.h = 0;\n this._stencilRefsCurrent = -1;\n this._blendColorsCurrent[0] = this._blendColorsCurrent[1] = this._blendColorsCurrent[2] = this._blendColorsCurrent[3] = null;\n }\n /**\n * Clear the current render buffer or the current render target (if any is set up)\n * @param color defines the color to use\n * @param backBuffer defines if the back buffer must be cleared\n * @param depth defines if the depth buffer must be cleared\n * @param stencil defines if the stencil buffer must be cleared\n */\n clear(color, backBuffer, depth, stencil = false) {\n // Some PGs are using color3...\n if (color && color.a === undefined) {\n color.a = 1;\n }\n const hasScissor = this._scissorIsActive();\n if (this.dbgVerboseLogsForFirstFrames) {\n if (this._count === undefined) {\n this._count = 0;\n }\n if (!this._count || this._count < this.dbgVerboseLogsNumFrames) {\n Logger.Log([\"frame #\" + this._count + \" - clear - backBuffer=\", backBuffer, \" depth=\", depth, \" stencil=\", stencil, \" scissor is active=\", hasScissor]);\n }\n }\n // We need to recreate the render pass so that the new parameters for clear color / depth / stencil are taken into account\n if (this._currentRenderTarget) {\n if (hasScissor) {\n if (!this._currentRenderPass) {\n this._startRenderTargetRenderPass(this._currentRenderTarget, false, backBuffer ? color : null, depth, stencil);\n }\n this._applyScissor(!this.compatibilityMode ? this._bundleList : null);\n this._clearFullQuad(backBuffer ? color : null, depth, stencil);\n }\n else {\n if (this._currentRenderPass) {\n this._endCurrentRenderPass();\n }\n this._startRenderTargetRenderPass(this._currentRenderTarget, true, backBuffer ? color : null, depth, stencil);\n }\n }\n else {\n if (!this._currentRenderPass || !hasScissor) {\n this._startMainRenderPass(!hasScissor, backBuffer ? color : null, depth, stencil);\n }\n if (hasScissor) {\n this._applyScissor(!this.compatibilityMode ? this._bundleList : null);\n this._clearFullQuad(backBuffer ? color : null, depth, stencil);\n }\n }\n }\n _clearFullQuad(clearColor, clearDepth, clearStencil) {\n const renderPass = !this.compatibilityMode ? null : this._getCurrentRenderPass();\n this._clearQuad.setColorFormat(this._colorFormat);\n this._clearQuad.setDepthStencilFormat(this._depthTextureFormat);\n this._clearQuad.setMRTAttachments(this._cacheRenderPipeline.mrtAttachments ?? [], this._cacheRenderPipeline.mrtTextureArray ?? [], this._cacheRenderPipeline.mrtTextureCount);\n if (!this.compatibilityMode) {\n this._bundleList.addItem(new WebGPURenderItemStencilRef(this._clearStencilValue));\n }\n else {\n renderPass.setStencilReference(this._clearStencilValue);\n }\n const bundle = this._clearQuad.clear(renderPass, clearColor, clearDepth, clearStencil, this.currentSampleCount);\n if (!this.compatibilityMode) {\n this._bundleList.addBundle(bundle);\n this._applyStencilRef(this._bundleList);\n this._reportDrawCall();\n }\n else {\n this._applyStencilRef(null);\n }\n }\n //------------------------------------------------------------------------------\n // Vertex/Index/Storage Buffers\n //------------------------------------------------------------------------------\n /**\n * Creates a vertex buffer\n * @param data the data or the size for the vertex buffer\n * @param _updatable whether the buffer should be created as updatable\n * @param label defines the label of the buffer (for debug purpose)\n * @returns the new buffer\n */\n createVertexBuffer(data, _updatable, label) {\n let view;\n if (data instanceof Array) {\n view = new Float32Array(data);\n }\n else if (data instanceof ArrayBuffer) {\n view = new Uint8Array(data);\n }\n else {\n view = data;\n }\n const dataBuffer = this._bufferManager.createBuffer(view, WebGPUConstants.BufferUsage.Vertex | WebGPUConstants.BufferUsage.CopyDst, label);\n return dataBuffer;\n }\n /**\n * Creates a vertex buffer\n * @param data the data for the dynamic vertex buffer\n * @param label defines the label of the buffer (for debug purpose)\n * @returns the new buffer\n */\n createDynamicVertexBuffer(data, label) {\n return this.createVertexBuffer(data, undefined, label);\n }\n /**\n * Creates a new index buffer\n * @param indices defines the content of the index buffer\n * @param _updatable defines if the index buffer must be updatable\n * @param label defines the label of the buffer (for debug purpose)\n * @returns a new buffer\n */\n createIndexBuffer(indices, _updatable, label) {\n let is32Bits = true;\n let view;\n if (indices instanceof Uint32Array || indices instanceof Int32Array) {\n view = indices;\n }\n else if (indices instanceof Uint16Array) {\n view = indices;\n is32Bits = false;\n }\n else {\n if (indices.length > 65535) {\n view = new Uint32Array(indices);\n }\n else {\n view = new Uint16Array(indices);\n is32Bits = false;\n }\n }\n const dataBuffer = this._bufferManager.createBuffer(view, WebGPUConstants.BufferUsage.Index | WebGPUConstants.BufferUsage.CopyDst, label);\n dataBuffer.is32Bits = is32Bits;\n return dataBuffer;\n }\n /**\n * Update a dynamic index buffer\n * @param indexBuffer defines the target index buffer\n * @param indices defines the data to update\n * @param offset defines the offset in the target index buffer where update should start\n */\n updateDynamicIndexBuffer(indexBuffer, indices, offset = 0) {\n const gpuBuffer = indexBuffer;\n let view;\n if (indexBuffer.is32Bits) {\n view = indices instanceof Uint32Array ? indices : new Uint32Array(indices);\n }\n else {\n view = indices instanceof Uint16Array ? indices : new Uint16Array(indices);\n }\n this._bufferManager.setSubData(gpuBuffer, offset, view);\n }\n /**\n * Updates a dynamic vertex buffer.\n * @param vertexBuffer the vertex buffer to update\n * @param data the data used to update the vertex buffer\n * @param byteOffset the byte offset of the data\n * @param byteLength the byte length of the data\n */\n updateDynamicVertexBuffer(vertexBuffer, data, byteOffset, byteLength) {\n const dataBuffer = vertexBuffer;\n if (byteOffset === undefined) {\n byteOffset = 0;\n }\n let view;\n if (byteLength === undefined) {\n if (data instanceof Array) {\n view = new Float32Array(data);\n }\n else if (data instanceof ArrayBuffer) {\n view = new Uint8Array(data);\n }\n else {\n view = data;\n }\n byteLength = view.byteLength;\n }\n else {\n if (data instanceof Array) {\n view = new Float32Array(data);\n }\n else if (data instanceof ArrayBuffer) {\n view = new Uint8Array(data);\n }\n else {\n view = data;\n }\n }\n this._bufferManager.setSubData(dataBuffer, byteOffset, view, 0, byteLength);\n }\n /**\n * @internal\n */\n _createBuffer(data, creationFlags, label) {\n let view;\n if (data instanceof Array) {\n view = new Float32Array(data);\n }\n else if (data instanceof ArrayBuffer) {\n view = new Uint8Array(data);\n }\n else {\n view = data;\n }\n let flags = 0;\n if (creationFlags & 1) {\n flags |= WebGPUConstants.BufferUsage.CopySrc;\n }\n if (creationFlags & 2) {\n flags |= WebGPUConstants.BufferUsage.CopyDst;\n }\n if (creationFlags & 4) {\n flags |= WebGPUConstants.BufferUsage.Uniform;\n }\n if (creationFlags & 8) {\n flags |= WebGPUConstants.BufferUsage.Vertex;\n }\n if (creationFlags & 16) {\n flags |= WebGPUConstants.BufferUsage.Index;\n }\n if (creationFlags & 32) {\n flags |= WebGPUConstants.BufferUsage.Storage;\n }\n if (creationFlags & 64) {\n flags |= WebGPUConstants.BufferUsage.Indirect;\n }\n return this._bufferManager.createBuffer(view, flags, label);\n }\n /**\n * @internal\n */\n bindBuffersDirectly() {\n // eslint-disable-next-line no-throw-literal\n throw \"Not implemented on WebGPU\";\n }\n /**\n * @internal\n */\n updateAndBindInstancesBuffer() {\n // eslint-disable-next-line no-throw-literal\n throw \"Not implemented on WebGPU\";\n }\n /**\n * Unbind all instance attributes\n */\n unbindInstanceAttributes() {\n // Does nothing\n }\n /**\n * Bind a list of vertex buffers with the engine\n * @param vertexBuffers defines the list of vertex buffers to bind\n * @param indexBuffer defines the index buffer to bind\n * @param effect defines the effect associated with the vertex buffers\n * @param overrideVertexBuffers defines optional list of avertex buffers that overrides the entries in vertexBuffers\n */\n bindBuffers(vertexBuffers, indexBuffer, effect, overrideVertexBuffers) {\n this._currentIndexBuffer = indexBuffer;\n this._currentOverrideVertexBuffers = overrideVertexBuffers ?? null;\n this._cacheRenderPipeline.setBuffers(vertexBuffers, indexBuffer, this._currentOverrideVertexBuffers);\n }\n /**\n * @internal\n */\n _releaseBuffer(buffer) {\n return this._bufferManager.releaseBuffer(buffer);\n }\n //------------------------------------------------------------------------------\n // Uniform Buffers\n //------------------------------------------------------------------------------\n /**\n * Create an uniform buffer\n * @see https://doc.babylonjs.com/setup/support/webGL2#uniform-buffer-objets\n * @param elements defines the content of the uniform buffer\n * @param label defines a name for the buffer (for debugging purpose)\n * @returns the webGL uniform buffer\n */\n createUniformBuffer(elements, label) {\n let view;\n if (elements instanceof Array) {\n view = new Float32Array(elements);\n }\n else {\n view = elements;\n }\n const dataBuffer = this._bufferManager.createBuffer(view, WebGPUConstants.BufferUsage.Uniform | WebGPUConstants.BufferUsage.CopyDst, label);\n return dataBuffer;\n }\n /**\n * Create a dynamic uniform buffer (no different from a non dynamic uniform buffer in WebGPU)\n * @see https://doc.babylonjs.com/setup/support/webGL2#uniform-buffer-objets\n * @param elements defines the content of the uniform buffer\n * @param label defines a name for the buffer (for debugging purpose)\n * @returns the webGL uniform buffer\n */\n createDynamicUniformBuffer(elements, label) {\n return this.createUniformBuffer(elements, label);\n }\n /**\n * Update an existing uniform buffer\n * @see https://doc.babylonjs.com/setup/support/webGL2#uniform-buffer-objets\n * @param uniformBuffer defines the target uniform buffer\n * @param elements defines the content to update\n * @param offset defines the offset in the uniform buffer where update should start\n * @param count defines the size of the data to update\n */\n updateUniformBuffer(uniformBuffer, elements, offset, count) {\n if (offset === undefined) {\n offset = 0;\n }\n const dataBuffer = uniformBuffer;\n let view;\n if (count === undefined) {\n if (elements instanceof Float32Array) {\n view = elements;\n }\n else {\n view = new Float32Array(elements);\n }\n count = view.byteLength;\n }\n else {\n if (elements instanceof Float32Array) {\n view = elements;\n }\n else {\n view = new Float32Array(elements);\n }\n }\n this._bufferManager.setSubData(dataBuffer, offset, view, 0, count);\n }\n /**\n * Bind a buffer to the current draw context\n * @param buffer defines the buffer to bind\n * @param _location not used in WebGPU\n * @param name Name of the uniform variable to bind\n */\n bindUniformBufferBase(buffer, _location, name) {\n this._currentDrawContext.setBuffer(name, buffer);\n }\n /**\n * Unused in WebGPU\n */\n bindUniformBlock() { }\n //------------------------------------------------------------------------------\n // Effects\n //------------------------------------------------------------------------------\n /**\n * Create a new effect (used to store vertex/fragment shaders)\n * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)\n * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object\n * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use\n * @param samplers defines an array of string used to represent textures\n * @param defines defines the string containing the defines to use to compile the shaders\n * @param fallbacks defines the list of potential fallbacks to use if shader compilation fails\n * @param onCompiled defines a function to call when the effect creation is successful\n * @param onError defines a function to call when the effect creation has failed\n * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)\n * @param shaderLanguage the language the shader is written in (default: GLSL)\n * @param extraInitializationsAsync additional async code to run before preparing the effect\n * @returns the new Effect\n */\n createEffect(baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, defines, fallbacks, onCompiled, onError, indexParameters, shaderLanguage = 0 /* ShaderLanguage.GLSL */, extraInitializationsAsync) {\n const vertex = typeof baseName === \"string\" ? baseName : baseName.vertexToken || baseName.vertexSource || baseName.vertexElement || baseName.vertex;\n const fragment = typeof baseName === \"string\" ? baseName : baseName.fragmentToken || baseName.fragmentSource || baseName.fragmentElement || baseName.fragment;\n const globalDefines = this._getGlobalDefines();\n let fullDefines = defines ?? attributesNamesOrOptions.defines ?? \"\";\n if (globalDefines) {\n fullDefines += \"\\n\" + globalDefines;\n }\n const name = vertex + \"+\" + fragment + \"@\" + fullDefines;\n if (this._compiledEffects[name]) {\n const compiledEffect = this._compiledEffects[name];\n if (onCompiled && compiledEffect.isReady()) {\n onCompiled(compiledEffect);\n }\n compiledEffect._refCount++;\n return compiledEffect;\n }\n const effect = new Effect(baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, this, defines, fallbacks, onCompiled, onError, indexParameters, name, attributesNamesOrOptions.shaderLanguage ?? shaderLanguage, attributesNamesOrOptions.extraInitializationsAsync ?? extraInitializationsAsync);\n this._compiledEffects[name] = effect;\n return effect;\n }\n _compileRawShaderToSpirV(source, type) {\n return this._glslang.compileGLSL(source, type);\n }\n _compileShaderToSpirV(source, type, defines, shaderVersion) {\n return this._compileRawShaderToSpirV(shaderVersion + (defines ? defines + \"\\n\" : \"\") + source, type);\n }\n _getWGSLShader(source, type, defines) {\n if (defines) {\n defines = \"//\" + defines.split(\"\\n\").join(\"\\n//\") + \"\\n\";\n }\n else {\n defines = \"\";\n }\n return defines + source;\n }\n _createPipelineStageDescriptor(vertexShader, fragmentShader, shaderLanguage, disableUniformityAnalysisInVertex, disableUniformityAnalysisInFragment) {\n if (this._tintWASM && shaderLanguage === 0 /* ShaderLanguage.GLSL */) {\n vertexShader = this._tintWASM.convertSpirV2WGSL(vertexShader, disableUniformityAnalysisInVertex);\n fragmentShader = this._tintWASM.convertSpirV2WGSL(fragmentShader, disableUniformityAnalysisInFragment);\n }\n return {\n vertexStage: {\n module: this._device.createShaderModule({\n label: \"vertex\",\n code: vertexShader,\n }),\n entryPoint: \"main\",\n },\n fragmentStage: {\n module: this._device.createShaderModule({\n label: \"fragment\",\n code: fragmentShader,\n }),\n entryPoint: \"main\",\n },\n };\n }\n _compileRawPipelineStageDescriptor(vertexCode, fragmentCode, shaderLanguage) {\n const disableUniformityAnalysisInVertex = vertexCode.indexOf(`#define DISABLE_UNIFORMITY_ANALYSIS`) >= 0;\n const disableUniformityAnalysisInFragment = fragmentCode.indexOf(`#define DISABLE_UNIFORMITY_ANALYSIS`) >= 0;\n const vertexShader = shaderLanguage === 0 /* ShaderLanguage.GLSL */ ? this._compileRawShaderToSpirV(vertexCode, \"vertex\") : vertexCode;\n const fragmentShader = shaderLanguage === 0 /* ShaderLanguage.GLSL */ ? this._compileRawShaderToSpirV(fragmentCode, \"fragment\") : fragmentCode;\n return this._createPipelineStageDescriptor(vertexShader, fragmentShader, shaderLanguage, disableUniformityAnalysisInVertex, disableUniformityAnalysisInFragment);\n }\n _compilePipelineStageDescriptor(vertexCode, fragmentCode, defines, shaderLanguage) {\n this.onBeforeShaderCompilationObservable.notifyObservers(this);\n const disableUniformityAnalysisInVertex = vertexCode.indexOf(`#define DISABLE_UNIFORMITY_ANALYSIS`) >= 0;\n const disableUniformityAnalysisInFragment = fragmentCode.indexOf(`#define DISABLE_UNIFORMITY_ANALYSIS`) >= 0;\n const shaderVersion = \"#version 450\\n\";\n const vertexShader = shaderLanguage === 0 /* ShaderLanguage.GLSL */ ? this._compileShaderToSpirV(vertexCode, \"vertex\", defines, shaderVersion) : this._getWGSLShader(vertexCode, \"vertex\", defines);\n const fragmentShader = shaderLanguage === 0 /* ShaderLanguage.GLSL */\n ? this._compileShaderToSpirV(fragmentCode, \"fragment\", defines, shaderVersion)\n : this._getWGSLShader(fragmentCode, \"fragment\", defines);\n const program = this._createPipelineStageDescriptor(vertexShader, fragmentShader, shaderLanguage, disableUniformityAnalysisInVertex, disableUniformityAnalysisInFragment);\n this.onAfterShaderCompilationObservable.notifyObservers(this);\n return program;\n }\n /**\n * @internal\n */\n createRawShaderProgram() {\n // eslint-disable-next-line no-throw-literal\n throw \"Not available on WebGPU\";\n }\n /**\n * @internal\n */\n createShaderProgram() {\n // eslint-disable-next-line no-throw-literal\n throw \"Not available on WebGPU\";\n }\n /**\n * Inline functions in shader code that are marked to be inlined\n * @param code code to inline\n * @returns inlined code\n */\n inlineShaderCode(code) {\n const sci = new ShaderCodeInliner(code);\n sci.debug = false;\n sci.processCode();\n return sci.code;\n }\n /**\n * Creates a new pipeline context\n * @param shaderProcessingContext defines the shader processing context used during the processing if available\n * @returns the new pipeline\n */\n createPipelineContext(shaderProcessingContext) {\n return new WebGPUPipelineContext(shaderProcessingContext, this);\n }\n /**\n * Creates a new material context\n * @returns the new context\n */\n createMaterialContext() {\n return new WebGPUMaterialContext();\n }\n /**\n * Creates a new draw context\n * @returns the new context\n */\n createDrawContext() {\n return new WebGPUDrawContext(this._bufferManager);\n }\n /**\n * @internal\n */\n async _preparePipelineContext(pipelineContext, vertexSourceCode, fragmentSourceCode, createAsRaw, rawVertexSourceCode, rawFragmentSourceCode, _rebuildRebind, defines, _transformFeedbackVaryings, _key, onReady) {\n const webGpuContext = pipelineContext;\n const shaderLanguage = webGpuContext.shaderProcessingContext.shaderLanguage;\n if (shaderLanguage === 0 /* ShaderLanguage.GLSL */ && !this._glslangAndTintAreFullyLoaded) {\n await this.prepareGlslangAndTintAsync();\n }\n if (this.dbgShowShaderCode) {\n Logger.Log([\"defines\", defines]);\n Logger.Log(vertexSourceCode);\n Logger.Log(fragmentSourceCode);\n Logger.Log(\"***********************************************\");\n }\n webGpuContext.sources = {\n fragment: fragmentSourceCode,\n vertex: vertexSourceCode,\n rawVertex: rawVertexSourceCode,\n rawFragment: rawFragmentSourceCode,\n };\n if (createAsRaw) {\n webGpuContext.stages = this._compileRawPipelineStageDescriptor(vertexSourceCode, fragmentSourceCode, shaderLanguage);\n }\n else {\n webGpuContext.stages = this._compilePipelineStageDescriptor(vertexSourceCode, fragmentSourceCode, defines, shaderLanguage);\n }\n onReady();\n }\n /**\n * Gets the list of active attributes for a given WebGPU program\n * @param pipelineContext defines the pipeline context to use\n * @param attributesNames defines the list of attribute names to get\n * @returns an array of indices indicating the offset of each attribute\n */\n getAttributes(pipelineContext, attributesNames) {\n const results = new Array(attributesNames.length);\n const gpuPipelineContext = pipelineContext;\n for (let i = 0; i < attributesNames.length; i++) {\n const attributeName = attributesNames[i];\n const attributeLocation = gpuPipelineContext.shaderProcessingContext.availableAttributes[attributeName];\n if (attributeLocation === undefined) {\n continue;\n }\n results[i] = attributeLocation;\n }\n return results;\n }\n /**\n * Activates an effect, making it the current one (ie. the one used for rendering)\n * @param effect defines the effect to activate\n */\n enableEffect(effect) {\n if (!effect) {\n return;\n }\n if (!IsWrapper(effect)) {\n this._currentEffect = effect;\n this._currentMaterialContext = this._defaultMaterialContext;\n this._currentDrawContext = this._defaultDrawContext;\n this._counters.numEnableEffects++;\n if (this.dbgLogIfNotDrawWrapper) {\n Logger.Warn(`enableEffect has been called with an Effect and not a Wrapper! effect.uniqueId=${effect.uniqueId}, effect.name=${effect.name}, effect.name.vertex=${typeof effect.name === \"string\" ? \"\" : effect.name.vertex}, effect.name.fragment=${typeof effect.name === \"string\" ? \"\" : effect.name.fragment}`, 10);\n }\n }\n else if (!effect.effect ||\n (effect.effect === this._currentEffect &&\n effect.materialContext === this._currentMaterialContext &&\n effect.drawContext === this._currentDrawContext &&\n !this._forceEnableEffect)) {\n if (!effect.effect && this.dbgShowEmptyEnableEffectCalls) {\n Logger.Log([\"drawWrapper=\", effect]);\n // eslint-disable-next-line no-throw-literal\n throw \"Invalid call to enableEffect: the effect property is empty!\";\n }\n return;\n }\n else {\n this._currentEffect = effect.effect;\n this._currentMaterialContext = effect.materialContext;\n this._currentDrawContext = effect.drawContext;\n this._counters.numEnableDrawWrapper++;\n if (!this._currentMaterialContext) {\n Logger.Log([\"drawWrapper=\", effect]);\n // eslint-disable-next-line no-throw-literal\n throw `Invalid call to enableEffect: the materialContext property is empty!`;\n }\n }\n this._stencilStateComposer.stencilMaterial = undefined;\n this._forceEnableEffect = false;\n if (this._currentEffect.onBind) {\n this._currentEffect.onBind(this._currentEffect);\n }\n if (this._currentEffect._onBindObservable) {\n this._currentEffect._onBindObservable.notifyObservers(this._currentEffect);\n }\n }\n /**\n * @internal\n */\n _releaseEffect(effect) {\n if (this._compiledEffects[effect._key]) {\n delete this._compiledEffects[effect._key];\n this._deletePipelineContext(effect.getPipelineContext());\n }\n }\n /**\n * Force the engine to release all cached effects. This means that next effect compilation will have to be done completely even if a similar effect was already compiled\n */\n releaseEffects() {\n for (const name in this._compiledEffects) {\n const webGPUPipelineContext = this._compiledEffects[name].getPipelineContext();\n this._deletePipelineContext(webGPUPipelineContext);\n }\n this._compiledEffects = {};\n }\n _deletePipelineContext(pipelineContext) {\n const webgpuPipelineContext = pipelineContext;\n if (webgpuPipelineContext) {\n resetCachedPipeline(webgpuPipelineContext);\n }\n }\n //------------------------------------------------------------------------------\n // Textures\n //------------------------------------------------------------------------------\n /**\n * Gets a boolean indicating that only power of 2 textures are supported\n * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them\n */\n get needPOTTextures() {\n return false;\n }\n /** @internal */\n _createHardwareTexture() {\n return new WebGPUHardwareTexture(this);\n }\n /**\n * @internal\n */\n _releaseTexture(texture) {\n const index = this._internalTexturesCache.indexOf(texture);\n if (index !== -1) {\n this._internalTexturesCache.splice(index, 1);\n }\n this._textureHelper.releaseTexture(texture);\n }\n /**\n * @internal\n */\n _getRGBABufferInternalSizedFormat() {\n return 5;\n }\n updateTextureComparisonFunction(texture, comparisonFunction) {\n texture._comparisonFunction = comparisonFunction;\n }\n /**\n * Creates an internal texture without binding it to a framebuffer\n * @internal\n * @param size defines the size of the texture\n * @param options defines the options used to create the texture\n * @param delayGPUTextureCreation true to delay the texture creation the first time it is really needed. false to create it right away\n * @param source source type of the texture\n * @returns a new internal texture\n */\n _createInternalTexture(size, options, delayGPUTextureCreation = true, source = 0 /* InternalTextureSource.Unknown */) {\n const fullOptions = {};\n if (options !== undefined && typeof options === \"object\") {\n fullOptions.generateMipMaps = options.generateMipMaps;\n fullOptions.createMipMaps = options.createMipMaps;\n fullOptions.type = options.type === undefined ? 0 : options.type;\n fullOptions.samplingMode = options.samplingMode === undefined ? 3 : options.samplingMode;\n fullOptions.format = options.format === undefined ? 5 : options.format;\n fullOptions.samples = options.samples ?? 1;\n fullOptions.creationFlags = options.creationFlags ?? 0;\n fullOptions.useSRGBBuffer = options.useSRGBBuffer ?? false;\n fullOptions.label = options.label;\n }\n else {\n fullOptions.generateMipMaps = options;\n fullOptions.type = 0;\n fullOptions.samplingMode = 3;\n fullOptions.format = 5;\n fullOptions.samples = 1;\n fullOptions.creationFlags = 0;\n fullOptions.useSRGBBuffer = false;\n }\n if (fullOptions.type === 1 && !this._caps.textureFloatLinearFiltering) {\n fullOptions.samplingMode = 1;\n }\n else if (fullOptions.type === 2 && !this._caps.textureHalfFloatLinearFiltering) {\n fullOptions.samplingMode = 1;\n }\n if (fullOptions.type === 1 && !this._caps.textureFloat) {\n fullOptions.type = 0;\n Logger.Warn(\"Float textures are not supported. Type forced to TEXTURETYPE_UNSIGNED_BYTE\");\n }\n const texture = new InternalTexture(this, source);\n const width = size.width || size;\n const height = size.height || size;\n const depth = size.depth || 0;\n const layers = size.layers || 0;\n texture.baseWidth = width;\n texture.baseHeight = height;\n texture.width = width;\n texture.height = height;\n texture.depth = depth || layers;\n texture.isReady = true;\n texture.samples = fullOptions.samples;\n texture.generateMipMaps = !!fullOptions.generateMipMaps;\n texture.samplingMode = fullOptions.samplingMode;\n texture.type = fullOptions.type;\n texture.format = fullOptions.format;\n texture.is2DArray = layers > 0;\n texture.is3D = depth > 0;\n texture._cachedWrapU = 0;\n texture._cachedWrapV = 0;\n texture._useSRGBBuffer = fullOptions.useSRGBBuffer;\n texture.label = fullOptions.label;\n this._internalTexturesCache.push(texture);\n if (!delayGPUTextureCreation) {\n const createMipMapsOnly = !fullOptions.generateMipMaps && fullOptions.createMipMaps;\n if (createMipMapsOnly) {\n // So that the call to createGPUTextureForInternalTexture creates the mipmaps\n texture.generateMipMaps = true;\n }\n this._textureHelper.createGPUTextureForInternalTexture(texture, width, height, layers || 1, fullOptions.creationFlags);\n if (createMipMapsOnly) {\n // So that we don't automatically generate mipmaps when the render target is unbound\n texture.generateMipMaps = false;\n }\n }\n return texture;\n }\n /**\n * Usually called from Texture.ts.\n * Passed information to create a hardware texture\n * @param url defines a value which contains one of the following:\n * * A conventional http URL, e.g. 'http://...' or 'file://...'\n * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'\n * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'\n * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file\n * @param invertY when true, image is flipped when loaded. You probably want true. Certain compressed textures may invert this if their default is inverted (eg. ktx)\n * @param scene needed for loading to the correct scene\n * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)\n * @param onLoad optional callback to be called upon successful completion\n * @param onError optional callback to be called upon failure\n * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), HTMLImageElement (image format), or a Blob\n * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities\n * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures\n * @param forcedExtension defines the extension to use to pick the right loader\n * @param mimeType defines an optional mime type\n * @param loaderOptions options to be passed to the loader\n * @param creationFlags specific flags to use when creating the texture (1 for storage textures, for eg)\n * @param useSRGBBuffer defines if the texture must be loaded in a sRGB GPU buffer (if supported by the GPU).\n * @returns a InternalTexture for assignment back into BABYLON.Texture\n */\n createTexture(url, noMipmap, invertY, scene, samplingMode = 3, onLoad = null, onError = null, buffer = null, fallback = null, format = null, forcedExtension = null, mimeType, loaderOptions, creationFlags, useSRGBBuffer) {\n return this._createTextureBase(url, noMipmap, invertY, scene, samplingMode, onLoad, onError, (texture, extension, scene, img, invertY, noMipmap, isCompressed, processFunction) => {\n const imageBitmap = img; // we will never get an HTMLImageElement in WebGPU\n texture.baseWidth = imageBitmap.width;\n texture.baseHeight = imageBitmap.height;\n texture.width = imageBitmap.width;\n texture.height = imageBitmap.height;\n texture.format = texture.format !== -1 ? texture.format : (format ?? 5);\n texture.type = texture.type !== -1 ? texture.type : 0;\n texture._creationFlags = creationFlags ?? 0;\n processFunction(texture.width, texture.height, imageBitmap, extension, texture, () => { });\n if (!texture._hardwareTexture?.underlyingResource) {\n // the texture could have been created before reaching this point so don't recreate it if already existing\n const gpuTextureWrapper = this._textureHelper.createGPUTextureForInternalTexture(texture, imageBitmap.width, imageBitmap.height, undefined, creationFlags);\n if (WebGPUTextureHelper.IsImageBitmap(imageBitmap)) {\n this._textureHelper.updateTexture(imageBitmap, texture, imageBitmap.width, imageBitmap.height, texture.depth, gpuTextureWrapper.format, 0, 0, invertY, false, 0, 0);\n if (!noMipmap && !isCompressed) {\n this._generateMipmaps(texture, this._uploadEncoder);\n }\n }\n }\n else if (!noMipmap && !isCompressed) {\n this._generateMipmaps(texture, this._uploadEncoder);\n }\n if (scene) {\n scene.removePendingData(texture);\n }\n texture.isReady = true;\n texture.onLoadedObservable.notifyObservers(texture);\n texture.onLoadedObservable.clear();\n }, () => false, buffer, fallback, format, forcedExtension, mimeType, loaderOptions, useSRGBBuffer);\n }\n /**\n * Wraps an external web gpu texture in a Babylon texture.\n * @param texture defines the external texture\n * @returns the babylon internal texture\n */\n wrapWebGPUTexture(texture) {\n const hardwareTexture = new WebGPUHardwareTexture(this, texture);\n const internalTexture = new InternalTexture(this, 0 /* InternalTextureSource.Unknown */, true);\n internalTexture._hardwareTexture = hardwareTexture;\n internalTexture.isReady = true;\n return internalTexture;\n }\n // eslint-disable-next-line jsdoc/require-returns-check\n /**\n * Wraps an external web gl texture in a Babylon texture.\n * @returns the babylon internal texture\n */\n wrapWebGLTexture() {\n throw new Error(\"wrapWebGLTexture is not supported, use wrapWebGPUTexture instead.\");\n }\n /**\n * @internal\n */\n _getUseSRGBBuffer(useSRGBBuffer, _noMipmap) {\n return useSRGBBuffer && this._caps.supportSRGBBuffers;\n }\n /**\n * @internal\n */\n _unpackFlipY(value) { }\n /**\n * Update the sampling mode of a given texture\n * @param samplingMode defines the required sampling mode\n * @param texture defines the texture to update\n * @param generateMipMaps defines whether to generate mipmaps for the texture\n */\n updateTextureSamplingMode(samplingMode, texture, generateMipMaps = false) {\n if (generateMipMaps) {\n texture.generateMipMaps = true;\n this._generateMipmaps(texture);\n }\n texture.samplingMode = samplingMode;\n }\n /**\n * Update the sampling mode of a given texture\n * @param texture defines the texture to update\n * @param wrapU defines the texture wrap mode of the u coordinates\n * @param wrapV defines the texture wrap mode of the v coordinates\n * @param wrapR defines the texture wrap mode of the r coordinates\n */\n updateTextureWrappingMode(texture, wrapU, wrapV = null, wrapR = null) {\n if (wrapU !== null) {\n texture._cachedWrapU = wrapU;\n }\n if (wrapV !== null) {\n texture._cachedWrapV = wrapV;\n }\n if ((texture.is2DArray || texture.is3D) && wrapR !== null) {\n texture._cachedWrapR = wrapR;\n }\n }\n /**\n * Update the dimensions of a texture\n * @param texture texture to update\n * @param width new width of the texture\n * @param height new height of the texture\n * @param depth new depth of the texture\n */\n updateTextureDimensions(texture, width, height, depth = 1) {\n if (!texture._hardwareTexture) {\n // the gpu texture is not created yet, so when it is it will be created with the right dimensions\n return;\n }\n if (texture.width === width && texture.height === height && texture.depth === depth) {\n return;\n }\n const additionalUsages = texture._hardwareTexture.textureAdditionalUsages;\n texture._hardwareTexture.release(); // don't defer the releasing! Else we will release at the end of this frame the gpu texture we are about to create in the next line...\n this._textureHelper.createGPUTextureForInternalTexture(texture, width, height, depth, additionalUsages);\n }\n /**\n * @internal\n */\n _setInternalTexture(name, texture, baseName) {\n baseName = baseName ?? name;\n if (this._currentEffect) {\n const webgpuPipelineContext = this._currentEffect._pipelineContext;\n const availableTexture = webgpuPipelineContext.shaderProcessingContext.availableTextures[baseName];\n this._currentMaterialContext.setTexture(name, texture);\n if (availableTexture && availableTexture.autoBindSampler) {\n const samplerName = baseName + `Sampler`;\n this._currentMaterialContext.setSampler(samplerName, texture); // we can safely cast to InternalTexture because ExternalTexture always has autoBindSampler = false\n }\n }\n }\n /**\n * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)\n * @param rootUrl defines the url where the file to load is located\n * @param scene defines the current scene\n * @param lodScale defines scale to apply to the mip map selection\n * @param lodOffset defines offset to apply to the mip map selection\n * @param onLoad defines an optional callback raised when the texture is loaded\n * @param onError defines an optional callback raised if there is an issue to load the texture\n * @param format defines the format of the data\n * @param forcedExtension defines the extension to use to pick the right loader\n * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture\n * @returns the cube texture as an InternalTexture\n */\n createPrefilteredCubeTexture(rootUrl, scene, lodScale, lodOffset, onLoad = null, onError = null, format, forcedExtension = null, createPolynomials = true) {\n const callback = (loadData) => {\n if (!loadData) {\n if (onLoad) {\n onLoad(null);\n }\n return;\n }\n const texture = loadData.texture;\n if (!createPolynomials) {\n texture._sphericalPolynomial = new SphericalPolynomial();\n }\n else if (loadData.info.sphericalPolynomial) {\n texture._sphericalPolynomial = loadData.info.sphericalPolynomial;\n }\n texture._source = 9 /* InternalTextureSource.CubePrefiltered */;\n if (onLoad) {\n onLoad(texture);\n }\n };\n return this.createCubeTexture(rootUrl, scene, null, false, callback, onError, format, forcedExtension, createPolynomials, lodScale, lodOffset);\n }\n /**\n * Sets a texture to the according uniform.\n * @param channel The texture channel\n * @param unused unused parameter\n * @param texture The texture to apply\n * @param name The name of the uniform in the effect\n */\n setTexture(channel, unused, texture, name) {\n this._setTexture(channel, texture, false, false, name, name);\n }\n /**\n * Sets an array of texture to the WebGPU context\n * @param channel defines the channel where the texture array must be set\n * @param unused unused parameter\n * @param textures defines the array of textures to bind\n * @param name name of the channel\n */\n setTextureArray(channel, unused, textures, name) {\n for (let index = 0; index < textures.length; index++) {\n this._setTexture(-1, textures[index], true, false, name + index.toString(), name);\n }\n }\n /**\n * @internal\n */\n _setTexture(channel, texture, \n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n isPartOfTextureArray = false, depthStencilTexture = false, name = \"\", baseName) {\n // name == baseName for a texture that is not part of a texture array\n // Else, name is something like 'myTexture0' / 'myTexture1' / ... and baseName is 'myTexture'\n // baseName is used to look up the texture in the shaderProcessingContext.availableTextures map\n // name is used to look up the texture in the _currentMaterialContext.textures map\n baseName = baseName ?? name;\n if (this._currentEffect) {\n if (!texture) {\n this._currentMaterialContext.setTexture(name, null);\n return false;\n }\n // Video\n if (texture.video) {\n texture.update();\n }\n else if (texture.delayLoadState === 4) {\n // Delay loading\n texture.delayLoad();\n return false;\n }\n let internalTexture = null;\n if (depthStencilTexture) {\n internalTexture = texture.depthStencilTexture;\n }\n else if (texture.isReady()) {\n internalTexture = texture.getInternalTexture();\n }\n else if (texture.isCube) {\n internalTexture = this.emptyCubeTexture;\n }\n else if (texture.is3D) {\n internalTexture = this.emptyTexture3D;\n }\n else if (texture.is2DArray) {\n internalTexture = this.emptyTexture2DArray;\n }\n else {\n internalTexture = this.emptyTexture;\n }\n if (internalTexture && !internalTexture.isMultiview) {\n // CUBIC_MODE and SKYBOX_MODE both require CLAMP_TO_EDGE. All other modes use REPEAT.\n if (internalTexture.isCube && internalTexture._cachedCoordinatesMode !== texture.coordinatesMode) {\n internalTexture._cachedCoordinatesMode = texture.coordinatesMode;\n const textureWrapMode = texture.coordinatesMode !== 3 && texture.coordinatesMode !== 5\n ? 1\n : 0;\n texture.wrapU = textureWrapMode;\n texture.wrapV = textureWrapMode;\n }\n internalTexture._cachedWrapU = texture.wrapU;\n internalTexture._cachedWrapV = texture.wrapV;\n if (internalTexture.is3D) {\n internalTexture._cachedWrapR = texture.wrapR;\n }\n this._setAnisotropicLevel(0, internalTexture, texture.anisotropicFilteringLevel);\n }\n this._setInternalTexture(name, internalTexture, baseName);\n }\n else {\n if (this.dbgVerboseLogsForFirstFrames) {\n if (this._count === undefined) {\n this._count = 0;\n }\n if (!this._count || this._count < this.dbgVerboseLogsNumFrames) {\n Logger.Log([\"frame #\" + this._count + \" - _setTexture called with a null _currentEffect! texture=\", texture]);\n }\n }\n }\n return true;\n }\n /**\n * @internal\n */\n _setAnisotropicLevel(target, internalTexture, anisotropicFilteringLevel) {\n if (internalTexture._cachedAnisotropicFilteringLevel !== anisotropicFilteringLevel) {\n internalTexture._cachedAnisotropicFilteringLevel = Math.min(anisotropicFilteringLevel, this._caps.maxAnisotropy);\n }\n }\n /**\n * @internal\n */\n _bindTexture(channel, texture, name) {\n if (channel === undefined) {\n return;\n }\n this._setInternalTexture(name, texture);\n }\n /**\n * Generates the mipmaps for a texture\n * @param texture texture to generate the mipmaps for\n */\n generateMipmaps(texture) {\n this._generateMipmaps(texture);\n }\n /**\n * Update a portion of an internal texture\n * @param texture defines the texture to update\n * @param imageData defines the data to store into the texture\n * @param xOffset defines the x coordinates of the update rectangle\n * @param yOffset defines the y coordinates of the update rectangle\n * @param width defines the width of the update rectangle\n * @param height defines the height of the update rectangle\n * @param faceIndex defines the face index if texture is a cube (0 by default)\n * @param lod defines the lod level to update (0 by default)\n * @param generateMipMaps defines whether to generate mipmaps or not\n */\n updateTextureData(texture, imageData, xOffset, yOffset, width, height, faceIndex = 0, lod = 0, generateMipMaps = false) {\n let gpuTextureWrapper = texture._hardwareTexture;\n if (!texture._hardwareTexture?.underlyingResource) {\n gpuTextureWrapper = this._textureHelper.createGPUTextureForInternalTexture(texture);\n }\n const data = new Uint8Array(imageData.buffer, imageData.byteOffset, imageData.byteLength);\n this._textureHelper.updateTexture(data, texture, width, height, texture.depth, gpuTextureWrapper.format, faceIndex, lod, texture.invertY, false, xOffset, yOffset);\n if (generateMipMaps) {\n this._generateMipmaps(texture);\n }\n }\n /**\n * @internal\n */\n _uploadCompressedDataToTextureDirectly(texture, internalFormat, width, height, imageData, faceIndex = 0, lod = 0) {\n let gpuTextureWrapper = texture._hardwareTexture;\n if (!texture._hardwareTexture?.underlyingResource) {\n texture.format = internalFormat;\n gpuTextureWrapper = this._textureHelper.createGPUTextureForInternalTexture(texture, width, height);\n }\n const data = new Uint8Array(imageData.buffer, imageData.byteOffset, imageData.byteLength);\n this._textureHelper.updateTexture(data, texture, width, height, texture.depth, gpuTextureWrapper.format, faceIndex, lod, false, false, 0, 0);\n }\n /**\n * @internal\n */\n _uploadDataToTextureDirectly(texture, imageData, faceIndex = 0, lod = 0, babylonInternalFormat, useTextureWidthAndHeight = false) {\n const lodMaxWidth = Math.round(Math.log(texture.width) * Math.LOG2E);\n const lodMaxHeight = Math.round(Math.log(texture.height) * Math.LOG2E);\n const width = useTextureWidthAndHeight ? texture.width : Math.pow(2, Math.max(lodMaxWidth - lod, 0));\n const height = useTextureWidthAndHeight ? texture.height : Math.pow(2, Math.max(lodMaxHeight - lod, 0));\n let gpuTextureWrapper = texture._hardwareTexture;\n if (!texture._hardwareTexture?.underlyingResource) {\n gpuTextureWrapper = this._textureHelper.createGPUTextureForInternalTexture(texture, width, height);\n }\n const data = new Uint8Array(imageData.buffer, imageData.byteOffset, imageData.byteLength);\n this._textureHelper.updateTexture(data, texture, width, height, texture.depth, gpuTextureWrapper.format, faceIndex, lod, texture.invertY, false, 0, 0);\n }\n /**\n * @internal\n */\n _uploadArrayBufferViewToTexture(texture, imageData, faceIndex = 0, lod = 0) {\n this._uploadDataToTextureDirectly(texture, imageData, faceIndex, lod);\n }\n /**\n * @internal\n */\n _uploadImageToTexture(texture, image, faceIndex = 0, lod = 0) {\n let gpuTextureWrapper = texture._hardwareTexture;\n if (!texture._hardwareTexture?.underlyingResource) {\n gpuTextureWrapper = this._textureHelper.createGPUTextureForInternalTexture(texture);\n }\n if (image instanceof HTMLImageElement) {\n // eslint-disable-next-line no-throw-literal\n throw \"WebGPU engine: HTMLImageElement not supported in _uploadImageToTexture!\";\n }\n const bitmap = image; // in WebGPU we will always get an ImageBitmap, not an HTMLImageElement\n const width = Math.ceil(texture.width / (1 << lod));\n const height = Math.ceil(texture.height / (1 << lod));\n this._textureHelper.updateTexture(bitmap, texture, width, height, texture.depth, gpuTextureWrapper.format, faceIndex, lod, texture.invertY, false, 0, 0);\n }\n /**\n * Reads pixels from the current frame buffer. Please note that this function can be slow\n * @param x defines the x coordinate of the rectangle where pixels must be read\n * @param y defines the y coordinate of the rectangle where pixels must be read\n * @param width defines the width of the rectangle where pixels must be read\n * @param height defines the height of the rectangle where pixels must be read\n * @param hasAlpha defines whether the output should have alpha or not (defaults to true)\n * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels\n * @returns a ArrayBufferView promise (Uint8Array) containing RGBA colors\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n readPixels(x, y, width, height, hasAlpha = true, flushRenderer = true) {\n const renderPassWrapper = this._getCurrentRenderPassWrapper();\n const hardwareTexture = renderPassWrapper.colorAttachmentGPUTextures[0];\n if (!hardwareTexture) {\n // we are calling readPixels for a render pass with no color texture bound\n return Promise.resolve(new Uint8Array(0));\n }\n const gpuTexture = hardwareTexture.underlyingResource;\n const gpuTextureFormat = hardwareTexture.format;\n if (!gpuTexture) {\n // we are calling readPixels before startMainRenderPass has been called and no RTT is bound, so swapChainTexture is not setup yet!\n return Promise.resolve(new Uint8Array(0));\n }\n if (flushRenderer) {\n this.flushFramebuffer();\n }\n return this._textureHelper.readPixels(gpuTexture, x, y, width, height, gpuTextureFormat);\n }\n //------------------------------------------------------------------------------\n // Frame management\n //------------------------------------------------------------------------------\n _measureFps() {\n this._performanceMonitor.sampleFrame();\n this._fps = this._performanceMonitor.averageFPS;\n this._deltaTime = this._performanceMonitor.instantaneousFrameTime || 0;\n }\n /**\n * Gets the performance monitor attached to this engine\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/optimize_your_scene#engineinstrumentation\n */\n get performanceMonitor() {\n return this._performanceMonitor;\n }\n /**\n * Begin a new frame\n */\n beginFrame() {\n this._measureFps();\n super.beginFrame();\n }\n /**\n * End the current frame\n */\n endFrame() {\n this._endCurrentRenderPass();\n this._snapshotRendering.endFrame();\n this._timestampQuery.endFrame(this._renderEncoder);\n this._timestampIndex = 0;\n this.flushFramebuffer();\n this._textureHelper.destroyDeferredTextures();\n this._bufferManager.destroyDeferredBuffers();\n if (this._features._collectUbosUpdatedInFrame) {\n if (this.dbgVerboseLogsForFirstFrames) {\n if (this._count === undefined) {\n this._count = 0;\n }\n if (!this._count || this._count < this.dbgVerboseLogsNumFrames) {\n const list = [];\n for (const name in UniformBuffer._UpdatedUbosInFrame) {\n list.push(name + \":\" + UniformBuffer._UpdatedUbosInFrame[name]);\n }\n Logger.Log([\"frame #\" + this._count + \" - updated ubos -\", list.join(\", \")]);\n }\n }\n UniformBuffer._UpdatedUbosInFrame = {};\n }\n this.countersLastFrame.numEnableEffects = this._counters.numEnableEffects;\n this.countersLastFrame.numEnableDrawWrapper = this._counters.numEnableDrawWrapper;\n this.countersLastFrame.numBundleCreationNonCompatMode = this._counters.numBundleCreationNonCompatMode;\n this.countersLastFrame.numBundleReuseNonCompatMode = this._counters.numBundleReuseNonCompatMode;\n this._counters.numEnableEffects = 0;\n this._counters.numEnableDrawWrapper = 0;\n this._counters.numBundleCreationNonCompatMode = 0;\n this._counters.numBundleReuseNonCompatMode = 0;\n this._cacheRenderPipeline.endFrame();\n this._cacheBindGroups.endFrame();\n this._pendingDebugCommands.length = 0;\n if (this.dbgVerboseLogsForFirstFrames) {\n if (this._count === undefined) {\n this._count = 0;\n }\n if (this._count < this.dbgVerboseLogsNumFrames) {\n Logger.Log([\"%c frame #\" + this._count + \" - end\", \"background: #ffff00\"]);\n }\n if (this._count < this.dbgVerboseLogsNumFrames) {\n this._count++;\n if (this._count !== this.dbgVerboseLogsNumFrames) {\n Logger.Log([\"%c frame #\" + this._count + \" - begin\", \"background: #ffff00\"]);\n }\n }\n }\n super.endFrame();\n }\n /**Gets driver info if available */\n extractDriverInfo() {\n return \"\";\n }\n /**\n * Force a WebGPU flush (ie. a flush of all waiting commands)\n */\n flushFramebuffer() {\n // we need to end the current render pass (main or rtt) if any as we are not allowed to submit the command buffers when being in a pass\n this._endCurrentRenderPass();\n this._commandBuffers[0] = this._uploadEncoder.finish();\n this._commandBuffers[1] = this._renderEncoder.finish();\n this._device.queue.submit(this._commandBuffers);\n this._uploadEncoder = this._device.createCommandEncoder(this._uploadEncoderDescriptor);\n this._renderEncoder = this._device.createCommandEncoder(this._renderEncoderDescriptor);\n this._timestampQuery.startFrame(this._uploadEncoder);\n this._textureHelper.setCommandEncoder(this._uploadEncoder);\n this._bundleList.reset();\n }\n /** @internal */\n _currentFrameBufferIsDefaultFrameBuffer() {\n return this._currentPassIsMainPass();\n }\n //------------------------------------------------------------------------------\n // Render Pass\n //------------------------------------------------------------------------------\n _startRenderTargetRenderPass(renderTargetWrapper, setClearStates, clearColor, clearDepth, clearStencil) {\n this._endCurrentRenderPass();\n const rtWrapper = renderTargetWrapper;\n const depthStencilTexture = rtWrapper._depthStencilTexture;\n const gpuDepthStencilWrapper = depthStencilTexture?._hardwareTexture;\n const gpuDepthStencilTexture = gpuDepthStencilWrapper?.underlyingResource;\n const gpuDepthStencilMSAATexture = gpuDepthStencilWrapper?.getMSAATexture(0);\n const depthTextureView = gpuDepthStencilTexture?.createView(this._rttRenderPassWrapper.depthAttachmentViewDescriptor);\n const depthMSAATextureView = gpuDepthStencilMSAATexture?.createView(this._rttRenderPassWrapper.depthAttachmentViewDescriptor);\n const depthTextureHasStencil = gpuDepthStencilWrapper ? WebGPUTextureHelper.HasStencilAspect(gpuDepthStencilWrapper.format) : false;\n const colorAttachments = [];\n if (this.useReverseDepthBuffer) {\n this.setDepthFunctionToGreaterOrEqual();\n }\n const clearColorForIntegerRT = tempColor4;\n if (clearColor) {\n clearColorForIntegerRT.r = clearColor.r * 255;\n clearColorForIntegerRT.g = clearColor.g * 255;\n clearColorForIntegerRT.b = clearColor.b * 255;\n clearColorForIntegerRT.a = clearColor.a * 255;\n }\n const mustClearColor = setClearStates && clearColor;\n const mustClearDepth = setClearStates && clearDepth;\n const mustClearStencil = setClearStates && clearStencil;\n if (rtWrapper._attachments && rtWrapper.isMulti) {\n // multi render targets\n if (!this._mrtAttachments || this._mrtAttachments.length === 0) {\n this._mrtAttachments = rtWrapper._defaultAttachments;\n }\n for (let i = 0; i < this._mrtAttachments.length; ++i) {\n const index = this._mrtAttachments[i]; // if index == 0 it means the texture should not be written to => at render pass creation time, it means we should not clear it\n const mrtTexture = rtWrapper.textures[i];\n const gpuMRTWrapper = mrtTexture?._hardwareTexture;\n const gpuMRTTexture = gpuMRTWrapper?.underlyingResource;\n if (gpuMRTWrapper && gpuMRTTexture) {\n const baseArrayLayer = rtWrapper.getBaseArrayLayer(i);\n const gpuMSAATexture = gpuMRTWrapper.getMSAATexture(baseArrayLayer);\n const viewDescriptor = {\n ...this._rttRenderPassWrapper.colorAttachmentViewDescriptor,\n dimension: mrtTexture.is3D ? \"3d\" /* WebGPUConstants.TextureViewDimension.E3d */ : \"2d\" /* WebGPUConstants.TextureViewDimension.E2d */,\n format: gpuMRTWrapper.format,\n baseArrayLayer,\n };\n const msaaViewDescriptor = {\n ...this._rttRenderPassWrapper.colorAttachmentViewDescriptor,\n dimension: mrtTexture.is3D ? \"3d\" /* WebGPUConstants.TextureViewDimension.E3d */ : \"2d\" /* WebGPUConstants.TextureViewDimension.E2d */,\n format: gpuMRTWrapper.format,\n baseArrayLayer: 0,\n };\n const isRTInteger = mrtTexture.type === 7 || mrtTexture.type === 5;\n const colorTextureView = gpuMRTTexture.createView(viewDescriptor);\n const colorMSAATextureView = gpuMSAATexture?.createView(msaaViewDescriptor);\n colorAttachments.push({\n view: colorMSAATextureView ? colorMSAATextureView : colorTextureView,\n resolveTarget: gpuMSAATexture ? colorTextureView : undefined,\n depthSlice: mrtTexture.is3D ? (rtWrapper.layerIndices?.[i] ?? 0) : undefined,\n clearValue: index !== 0 && mustClearColor ? (isRTInteger ? clearColorForIntegerRT : clearColor) : undefined,\n loadOp: index !== 0 && mustClearColor ? \"clear\" /* WebGPUConstants.LoadOp.Clear */ : \"load\" /* WebGPUConstants.LoadOp.Load */,\n storeOp: \"store\" /* WebGPUConstants.StoreOp.Store */,\n });\n }\n }\n this._cacheRenderPipeline.setMRT(rtWrapper.textures, this._mrtAttachments.length);\n this._cacheRenderPipeline.setMRTAttachments(this._mrtAttachments);\n }\n else {\n // single render target\n const internalTexture = rtWrapper.texture;\n if (internalTexture) {\n const gpuWrapper = internalTexture._hardwareTexture;\n const gpuTexture = gpuWrapper.underlyingResource;\n let depthSlice = undefined;\n if (rtWrapper.is3D) {\n depthSlice = this._rttRenderPassWrapper.colorAttachmentViewDescriptor.baseArrayLayer;\n this._rttRenderPassWrapper.colorAttachmentViewDescriptor.baseArrayLayer = 0;\n }\n const gpuMSAATexture = gpuWrapper.getMSAATexture(0);\n const colorTextureView = gpuTexture.createView(this._rttRenderPassWrapper.colorAttachmentViewDescriptor);\n const colorMSAATextureView = gpuMSAATexture?.createView(this._rttRenderPassWrapper.colorAttachmentViewDescriptor);\n const isRTInteger = internalTexture.type === 7 || internalTexture.type === 5;\n colorAttachments.push({\n view: colorMSAATextureView ? colorMSAATextureView : colorTextureView,\n resolveTarget: gpuMSAATexture ? colorTextureView : undefined,\n depthSlice,\n clearValue: mustClearColor ? (isRTInteger ? clearColorForIntegerRT : clearColor) : undefined,\n loadOp: mustClearColor ? \"clear\" /* WebGPUConstants.LoadOp.Clear */ : \"load\" /* WebGPUConstants.LoadOp.Load */,\n storeOp: \"store\" /* WebGPUConstants.StoreOp.Store */,\n });\n }\n else {\n colorAttachments.push(null);\n }\n }\n this._debugPushGroup?.(\"render target pass\" + (renderTargetWrapper.label ? \" (\" + renderTargetWrapper.label + \")\" : \"\"), 0);\n this._rttRenderPassWrapper.renderPassDescriptor = {\n label: (renderTargetWrapper.label ?? \"RTT\") + \" - RenderPass\",\n colorAttachments,\n depthStencilAttachment: depthStencilTexture && gpuDepthStencilTexture\n ? {\n view: depthMSAATextureView ? depthMSAATextureView : depthTextureView,\n depthClearValue: mustClearDepth ? (this.useReverseDepthBuffer ? this._clearReverseDepthValue : this._clearDepthValue) : undefined,\n depthLoadOp: mustClearDepth ? \"clear\" /* WebGPUConstants.LoadOp.Clear */ : \"load\" /* WebGPUConstants.LoadOp.Load */,\n depthStoreOp: \"store\" /* WebGPUConstants.StoreOp.Store */,\n stencilClearValue: rtWrapper._depthStencilTextureWithStencil && mustClearStencil ? this._clearStencilValue : undefined,\n stencilLoadOp: !depthTextureHasStencil\n ? undefined\n : rtWrapper._depthStencilTextureWithStencil && mustClearStencil\n ? \"clear\" /* WebGPUConstants.LoadOp.Clear */\n : \"load\" /* WebGPUConstants.LoadOp.Load */,\n stencilStoreOp: !depthTextureHasStencil ? undefined : \"store\" /* WebGPUConstants.StoreOp.Store */,\n }\n : undefined,\n occlusionQuerySet: this._occlusionQuery?.hasQueries ? this._occlusionQuery.querySet : undefined,\n };\n this._timestampQuery.startPass(this._rttRenderPassWrapper.renderPassDescriptor, this._timestampIndex);\n this._currentRenderPass = this._renderEncoder.beginRenderPass(this._rttRenderPassWrapper.renderPassDescriptor);\n if (this.dbgVerboseLogsForFirstFrames) {\n if (this._count === undefined) {\n this._count = 0;\n }\n if (!this._count || this._count < this.dbgVerboseLogsNumFrames) {\n const internalTexture = rtWrapper.texture;\n Logger.Log([\n \"frame #\" +\n this._count +\n \" - render target begin pass - rtt name=\" +\n renderTargetWrapper.label +\n \", internalTexture.uniqueId=\" +\n internalTexture.uniqueId +\n \", width=\" +\n internalTexture.width +\n \", height=\" +\n internalTexture.height +\n \", setClearStates=\" +\n setClearStates,\n \"renderPassDescriptor=\",\n this._rttRenderPassWrapper.renderPassDescriptor,\n ]);\n }\n }\n this._debugFlushPendingCommands?.();\n this._resetRenderPassStates();\n if (!gpuDepthStencilWrapper || !WebGPUTextureHelper.HasStencilAspect(gpuDepthStencilWrapper.format)) {\n this._stencilStateComposer.enabled = false;\n }\n }\n _startMainRenderPass(setClearStates, clearColor, clearDepth, clearStencil) {\n this._endCurrentRenderPass();\n if (this.useReverseDepthBuffer) {\n this.setDepthFunctionToGreaterOrEqual();\n }\n const mustClearColor = setClearStates && clearColor;\n const mustClearDepth = setClearStates && clearDepth;\n const mustClearStencil = setClearStates && clearStencil;\n this._mainRenderPassWrapper.renderPassDescriptor.colorAttachments[0].clearValue = mustClearColor ? clearColor : undefined;\n this._mainRenderPassWrapper.renderPassDescriptor.colorAttachments[0].loadOp = mustClearColor ? \"clear\" /* WebGPUConstants.LoadOp.Clear */ : \"load\" /* WebGPUConstants.LoadOp.Load */;\n this._mainRenderPassWrapper.renderPassDescriptor.depthStencilAttachment.depthClearValue = mustClearDepth\n ? this.useReverseDepthBuffer\n ? this._clearReverseDepthValue\n : this._clearDepthValue\n : undefined;\n this._mainRenderPassWrapper.renderPassDescriptor.depthStencilAttachment.depthLoadOp = mustClearDepth ? \"clear\" /* WebGPUConstants.LoadOp.Clear */ : \"load\" /* WebGPUConstants.LoadOp.Load */;\n this._mainRenderPassWrapper.renderPassDescriptor.depthStencilAttachment.stencilClearValue = mustClearStencil ? this._clearStencilValue : undefined;\n this._mainRenderPassWrapper.renderPassDescriptor.depthStencilAttachment.stencilLoadOp = !this.isStencilEnable\n ? undefined\n : mustClearStencil\n ? \"clear\" /* WebGPUConstants.LoadOp.Clear */\n : \"load\" /* WebGPUConstants.LoadOp.Load */;\n this._mainRenderPassWrapper.renderPassDescriptor.occlusionQuerySet = this._occlusionQuery?.hasQueries ? this._occlusionQuery.querySet : undefined;\n const swapChainTexture = this._context.getCurrentTexture();\n this._mainRenderPassWrapper.colorAttachmentGPUTextures[0].set(swapChainTexture);\n // Resolve in case of MSAA\n if (this._options.antialias) {\n viewDescriptorSwapChainAntialiasing.format = swapChainTexture.format;\n this._mainRenderPassWrapper.renderPassDescriptor.colorAttachments[0].resolveTarget = swapChainTexture.createView(viewDescriptorSwapChainAntialiasing);\n }\n else {\n viewDescriptorSwapChain.format = swapChainTexture.format;\n this._mainRenderPassWrapper.renderPassDescriptor.colorAttachments[0].view = swapChainTexture.createView(viewDescriptorSwapChain);\n }\n if (this.dbgVerboseLogsForFirstFrames) {\n if (this._count === undefined) {\n this._count = 0;\n }\n if (!this._count || this._count < this.dbgVerboseLogsNumFrames) {\n Logger.Log([\n \"frame #\" + this._count + \" - main begin pass - texture width=\" + this._mainTextureExtends.width,\n \" height=\" + this._mainTextureExtends.height + \", setClearStates=\" + setClearStates,\n \"renderPassDescriptor=\",\n this._mainRenderPassWrapper.renderPassDescriptor,\n ]);\n }\n }\n this._debugPushGroup?.(\"main pass\", 0);\n this._timestampQuery.startPass(this._mainRenderPassWrapper.renderPassDescriptor, this._timestampIndex);\n this._currentRenderPass = this._renderEncoder.beginRenderPass(this._mainRenderPassWrapper.renderPassDescriptor);\n this._setDepthTextureFormat(this._mainRenderPassWrapper);\n this._setColorFormat(this._mainRenderPassWrapper);\n this._debugFlushPendingCommands?.();\n this._resetRenderPassStates();\n if (!this._isStencilEnable) {\n this._stencilStateComposer.enabled = false;\n }\n }\n /**\n * Binds the frame buffer to the specified texture.\n * @param texture The render target wrapper to render to\n * @param faceIndex The face of the texture to render to in case of cube texture\n * @param requiredWidth The width of the target to render to\n * @param requiredHeight The height of the target to render to\n * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true\n * @param lodLevel defines the lod level to bind to the frame buffer\n * @param layer defines the 2d array index to bind to frame buffer to\n */\n bindFramebuffer(texture, faceIndex = 0, requiredWidth, requiredHeight, forceFullscreenViewport, lodLevel = 0, layer = 0) {\n const hardwareTexture = texture.texture?._hardwareTexture;\n if (this._currentRenderTarget) {\n this.unBindFramebuffer(this._currentRenderTarget);\n }\n else {\n this._endCurrentRenderPass();\n }\n this._currentRenderTarget = texture;\n const depthStencilTexture = this._currentRenderTarget._depthStencilTexture;\n this._rttRenderPassWrapper.colorAttachmentGPUTextures[0] = hardwareTexture;\n this._rttRenderPassWrapper.depthTextureFormat = depthStencilTexture ? WebGPUTextureHelper.GetWebGPUTextureFormat(-1, depthStencilTexture.format) : undefined;\n this._setDepthTextureFormat(this._rttRenderPassWrapper);\n this._setColorFormat(this._rttRenderPassWrapper);\n this._rttRenderPassWrapper.colorAttachmentViewDescriptor = {\n format: this._colorFormat,\n dimension: texture.is3D ? \"3d\" /* WebGPUConstants.TextureViewDimension.E3d */ : \"2d\" /* WebGPUConstants.TextureViewDimension.E2d */,\n mipLevelCount: 1,\n baseArrayLayer: texture.isCube ? layer * 6 + faceIndex : layer,\n baseMipLevel: lodLevel,\n arrayLayerCount: 1,\n aspect: \"all\" /* WebGPUConstants.TextureAspect.All */,\n };\n this._rttRenderPassWrapper.depthAttachmentViewDescriptor = {\n format: this._depthTextureFormat,\n dimension: depthStencilTexture && depthStencilTexture.is3D ? \"3d\" /* WebGPUConstants.TextureViewDimension.E3d */ : \"2d\" /* WebGPUConstants.TextureViewDimension.E2d */,\n mipLevelCount: 1,\n baseArrayLayer: depthStencilTexture ? (depthStencilTexture.isCube ? layer * 6 + faceIndex : layer) : 0,\n baseMipLevel: 0,\n arrayLayerCount: 1,\n aspect: \"all\" /* WebGPUConstants.TextureAspect.All */,\n };\n if (this.dbgVerboseLogsForFirstFrames) {\n if (this._count === undefined) {\n this._count = 0;\n }\n if (!this._count || this._count < this.dbgVerboseLogsNumFrames) {\n Logger.Log([\n \"frame #\" +\n this._count +\n \" - bindFramebuffer - rtt name=\" +\n texture.label +\n \", internalTexture.uniqueId=\" +\n texture.texture?.uniqueId +\n \", face=\" +\n faceIndex +\n \", lodLevel=\" +\n lodLevel +\n \", layer=\" +\n layer,\n \"colorAttachmentViewDescriptor=\",\n this._rttRenderPassWrapper.colorAttachmentViewDescriptor,\n \"depthAttachmentViewDescriptor=\",\n this._rttRenderPassWrapper.depthAttachmentViewDescriptor,\n ]);\n }\n }\n // We don't create the render pass just now, we do a lazy creation of the render pass, hoping the render pass will be created by a call to clear()...\n if (this._cachedViewport && !forceFullscreenViewport) {\n this.setViewport(this._cachedViewport, requiredWidth, requiredHeight);\n }\n else {\n if (!requiredWidth) {\n requiredWidth = texture.width;\n if (lodLevel) {\n requiredWidth = requiredWidth / Math.pow(2, lodLevel);\n }\n }\n if (!requiredHeight) {\n requiredHeight = texture.height;\n if (lodLevel) {\n requiredHeight = requiredHeight / Math.pow(2, lodLevel);\n }\n }\n this._viewport(0, 0, requiredWidth, requiredHeight);\n }\n this.wipeCaches();\n }\n /**\n * Unbind the current render target texture from the WebGPU context\n * @param texture defines the render target wrapper to unbind\n * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated\n * @param onBeforeUnbind defines a function which will be called before the effective unbind\n */\n unBindFramebuffer(texture, disableGenerateMipMaps = false, onBeforeUnbind) {\n const saveCRT = this._currentRenderTarget;\n this._currentRenderTarget = null; // to be iso with abstractEngine, this._currentRenderTarget must be null when onBeforeUnbind is called\n if (onBeforeUnbind) {\n onBeforeUnbind();\n }\n this._currentRenderTarget = saveCRT;\n this._endCurrentRenderPass();\n if (!disableGenerateMipMaps) {\n if (texture.isMulti) {\n this.generateMipMapsMultiFramebuffer(texture);\n }\n else {\n this.generateMipMapsFramebuffer(texture);\n }\n }\n this._currentRenderTarget = null;\n if (this.dbgVerboseLogsForFirstFrames) {\n if (this._count === undefined) {\n this._count = 0;\n }\n if (!this._count || this._count < this.dbgVerboseLogsNumFrames) {\n Logger.Log(\"frame #\" + this._count + \" - unBindFramebuffer - rtt name=\" + texture.label + \", internalTexture.uniqueId=\", texture.texture?.uniqueId);\n }\n }\n this._mrtAttachments = [];\n this._cacheRenderPipeline.setMRT([]);\n this._cacheRenderPipeline.setMRTAttachments(this._mrtAttachments);\n }\n /**\n * Generates mipmaps for the texture of the (single) render target\n * @param texture The render target containing the texture to generate the mipmaps for\n */\n generateMipMapsFramebuffer(texture) {\n if (!texture.isMulti && texture.texture?.generateMipMaps && !texture.isCube) {\n this._generateMipmaps(texture.texture);\n }\n }\n /**\n * Resolves the MSAA texture of the (single) render target into its non-MSAA version.\n * Note that if \"texture\" is not a MSAA render target, no resolve is performed.\n * @param _texture The render target texture containing the MSAA texture to resolve\n */\n resolveFramebuffer(_texture) {\n throw new Error(\"resolveFramebuffer is not yet implemented in WebGPU!\");\n }\n /**\n * Unbind the current render target and bind the default framebuffer\n */\n restoreDefaultFramebuffer() {\n if (this._currentRenderTarget) {\n this.unBindFramebuffer(this._currentRenderTarget);\n }\n else if (!this._currentRenderPass) {\n this._startMainRenderPass(false);\n }\n if (this._cachedViewport) {\n this.setViewport(this._cachedViewport);\n }\n this.wipeCaches();\n }\n //------------------------------------------------------------------------------\n // Render\n //------------------------------------------------------------------------------\n /**\n * @internal\n */\n _setColorFormat(wrapper) {\n const format = wrapper.colorAttachmentGPUTextures[0]?.format ?? null;\n this._cacheRenderPipeline.setColorFormat(format);\n if (this._colorFormat === format) {\n return;\n }\n this._colorFormat = format;\n }\n /**\n * @internal\n */\n _setDepthTextureFormat(wrapper) {\n this._cacheRenderPipeline.setDepthStencilFormat(wrapper.depthTextureFormat);\n if (this._depthTextureFormat === wrapper.depthTextureFormat) {\n return;\n }\n this._depthTextureFormat = wrapper.depthTextureFormat;\n }\n setDitheringState() {\n // Does not exist in WebGPU\n }\n setRasterizerState() {\n // Does not exist in WebGPU\n }\n /**\n * @internal\n */\n _executeWhenRenderingStateIsCompiled(pipelineContext, action) {\n // No parallel shader compilation.\n // No Async, so direct launch\n action();\n }\n /**\n * @internal\n */\n bindSamplers() { }\n /** @internal */\n _getUnpackAlignement() {\n return 1;\n }\n /**\n * @internal\n */\n _bindTextureDirectly() {\n return false;\n }\n /**\n * Set various states to the webGL context\n * @param culling defines culling state: true to enable culling, false to disable it\n * @param zOffset defines the value to apply to zOffset (0 by default)\n * @param force defines if states must be applied even if cache is up to date\n * @param reverseSide defines if culling must be reversed (CCW if false, CW if true)\n * @param cullBackFaces true to cull back faces, false to cull front faces (if culling is enabled)\n * @param stencil stencil states to set\n * @param zOffsetUnits defines the value to apply to zOffsetUnits (0 by default)\n */\n setState(culling, zOffset = 0, force, reverseSide = false, cullBackFaces, stencil, zOffsetUnits = 0) {\n // Culling\n if (this._depthCullingState.cull !== culling || force) {\n this._depthCullingState.cull = culling;\n }\n // Cull face\n const cullFace = (this.cullBackFaces ?? cullBackFaces ?? true) ? 1 : 2;\n if (this._depthCullingState.cullFace !== cullFace || force) {\n this._depthCullingState.cullFace = cullFace;\n }\n // Z offset\n this.setZOffset(zOffset);\n this.setZOffsetUnits(zOffsetUnits);\n // Front face\n const frontFace = reverseSide ? (this._currentRenderTarget ? 1 : 2) : this._currentRenderTarget ? 2 : 1;\n if (this._depthCullingState.frontFace !== frontFace || force) {\n this._depthCullingState.frontFace = frontFace;\n }\n this._stencilStateComposer.stencilMaterial = stencil;\n }\n _applyRenderPassChanges(bundleList) {\n const mustUpdateStencilRef = !this._stencilStateComposer.enabled ? false : this._mustUpdateStencilRef();\n const mustUpdateBlendColor = !this._alphaState.alphaBlend ? false : this._mustUpdateBlendColor();\n if (this._mustUpdateViewport()) {\n this._applyViewport(bundleList);\n }\n if (this._mustUpdateScissor()) {\n this._applyScissor(bundleList);\n }\n if (mustUpdateStencilRef) {\n this._applyStencilRef(bundleList);\n }\n if (mustUpdateBlendColor) {\n this._applyBlendColor(bundleList);\n }\n }\n _draw(drawType, fillMode, start, count, instancesCount) {\n const renderPass = this._getCurrentRenderPass();\n const bundleList = this._bundleList;\n this.applyStates();\n const webgpuPipelineContext = this._currentEffect._pipelineContext;\n this.bindUniformBufferBase(this._currentRenderTarget ? this._ubInvertY : this._ubDontInvertY, 0, WebGPUShaderProcessor.InternalsUBOName);\n if (webgpuPipelineContext.uniformBuffer) {\n webgpuPipelineContext.uniformBuffer.update();\n this.bindUniformBufferBase(webgpuPipelineContext.uniformBuffer.getBuffer(), 0, WebGPUShaderProcessor.LeftOvertUBOName);\n }\n if (this._snapshotRendering.play) {\n this._reportDrawCall();\n return;\n }\n if (!this.compatibilityMode &&\n (this._currentDrawContext.isDirty(this._currentMaterialContext.updateId) || this._currentMaterialContext.isDirty || this._currentMaterialContext.forceBindGroupCreation)) {\n this._currentDrawContext.fastBundle = undefined;\n }\n const useFastPath = !this.compatibilityMode && this._currentDrawContext.fastBundle;\n let renderPass2 = renderPass;\n if (useFastPath || this._snapshotRendering.record) {\n this._applyRenderPassChanges(bundleList);\n if (!this._snapshotRendering.record) {\n this._counters.numBundleReuseNonCompatMode++;\n if (this._currentDrawContext.indirectDrawBuffer) {\n this._currentDrawContext.setIndirectData(count, instancesCount || 1, start);\n }\n bundleList.addBundle(this._currentDrawContext.fastBundle);\n this._reportDrawCall();\n return;\n }\n renderPass2 = bundleList.getBundleEncoder(this._cacheRenderPipeline.colorFormats, this._depthTextureFormat, this.currentSampleCount); // for snapshot recording mode\n bundleList.numDrawCalls++;\n }\n let textureState = 0;\n if (this._currentMaterialContext.hasFloatOrDepthTextures) {\n let bitVal = 1;\n for (let i = 0; i < webgpuPipelineContext.shaderProcessingContext.textureNames.length; ++i) {\n const textureName = webgpuPipelineContext.shaderProcessingContext.textureNames[i];\n const texture = this._currentMaterialContext.textures[textureName]?.texture;\n const textureIsDepth = texture && texture.format >= 13 && texture.format <= 18;\n if ((texture?.type === 1 && !this._caps.textureFloatLinearFiltering) || textureIsDepth) {\n textureState |= bitVal;\n }\n bitVal = bitVal << 1;\n }\n }\n this._currentMaterialContext.textureState = textureState;\n const pipeline = this._cacheRenderPipeline.getRenderPipeline(fillMode, this._currentEffect, this.currentSampleCount, textureState);\n const bindGroups = this._cacheBindGroups.getBindGroups(webgpuPipelineContext, this._currentDrawContext, this._currentMaterialContext);\n if (!this._snapshotRendering.record) {\n this._applyRenderPassChanges(!this.compatibilityMode ? bundleList : null);\n if (!this.compatibilityMode) {\n this._counters.numBundleCreationNonCompatMode++;\n renderPass2 = this._device.createRenderBundleEncoder({\n colorFormats: this._cacheRenderPipeline.colorFormats,\n depthStencilFormat: this._depthTextureFormat,\n sampleCount: WebGPUTextureHelper.GetSample(this.currentSampleCount),\n });\n }\n }\n // bind pipeline\n renderPass2.setPipeline(pipeline);\n // bind index/vertex buffers\n if (this._currentIndexBuffer) {\n renderPass2.setIndexBuffer(this._currentIndexBuffer.underlyingResource, this._currentIndexBuffer.is32Bits ? \"uint32\" /* WebGPUConstants.IndexFormat.Uint32 */ : \"uint16\" /* WebGPUConstants.IndexFormat.Uint16 */, 0);\n }\n const vertexBuffers = this._cacheRenderPipeline.vertexBuffers;\n for (let index = 0; index < vertexBuffers.length; index++) {\n const vertexBuffer = vertexBuffers[index];\n const buffer = vertexBuffer.effectiveBuffer;\n if (buffer) {\n renderPass2.setVertexBuffer(index, buffer.underlyingResource, vertexBuffer._validOffsetRange ? 0 : vertexBuffer.byteOffset);\n }\n }\n // bind bind groups\n for (let i = 0; i < bindGroups.length; i++) {\n renderPass2.setBindGroup(i, bindGroups[i]);\n }\n // draw\n const nonCompatMode = !this.compatibilityMode && !this._snapshotRendering.record;\n if (nonCompatMode && this._currentDrawContext.indirectDrawBuffer) {\n this._currentDrawContext.setIndirectData(count, instancesCount || 1, start);\n if (drawType === 0) {\n renderPass2.drawIndexedIndirect(this._currentDrawContext.indirectDrawBuffer, 0);\n }\n else {\n renderPass2.drawIndirect(this._currentDrawContext.indirectDrawBuffer, 0);\n }\n }\n else if (drawType === 0) {\n renderPass2.drawIndexed(count, instancesCount || 1, start, 0, 0);\n }\n else {\n renderPass2.draw(count, instancesCount || 1, start, 0);\n }\n if (nonCompatMode) {\n this._currentDrawContext.fastBundle = renderPass2.finish();\n bundleList.addBundle(this._currentDrawContext.fastBundle);\n }\n this._reportDrawCall();\n }\n /**\n * Draw a list of indexed primitives\n * @param fillMode defines the primitive to use\n * @param indexStart defines the starting index\n * @param indexCount defines the number of index to draw\n * @param instancesCount defines the number of instances to draw (if instantiation is enabled)\n */\n drawElementsType(fillMode, indexStart, indexCount, instancesCount = 1) {\n this._draw(0, fillMode, indexStart, indexCount, instancesCount);\n }\n /**\n * Draw a list of unindexed primitives\n * @param fillMode defines the primitive to use\n * @param verticesStart defines the index of first vertex to draw\n * @param verticesCount defines the count of vertices to draw\n * @param instancesCount defines the number of instances to draw (if instantiation is enabled)\n */\n drawArraysType(fillMode, verticesStart, verticesCount, instancesCount = 1) {\n this._currentIndexBuffer = null;\n this._draw(1, fillMode, verticesStart, verticesCount, instancesCount);\n }\n //------------------------------------------------------------------------------\n // Dispose\n //------------------------------------------------------------------------------\n /**\n * Dispose and release all associated resources\n */\n dispose() {\n this._isDisposed = true;\n this.hideLoadingUI();\n this._timestampQuery.dispose();\n this._mainTexture?.destroy();\n this._depthTexture?.destroy();\n this._textureHelper.destroyDeferredTextures();\n this._bufferManager.destroyDeferredBuffers();\n this._device.destroy();\n _CommonDispose(this, this._renderingCanvas);\n super.dispose();\n }\n //------------------------------------------------------------------------------\n // Misc\n //------------------------------------------------------------------------------\n /**\n * Gets the current render width\n * @param useScreen defines if screen size must be used (or the current render target if any)\n * @returns a number defining the current render width\n */\n getRenderWidth(useScreen = false) {\n if (!useScreen && this._currentRenderTarget) {\n return this._currentRenderTarget.width;\n }\n return this._renderingCanvas?.width ?? 0;\n }\n /**\n * Gets the current render height\n * @param useScreen defines if screen size must be used (or the current render target if any)\n * @returns a number defining the current render height\n */\n getRenderHeight(useScreen = false) {\n if (!useScreen && this._currentRenderTarget) {\n return this._currentRenderTarget.height;\n }\n return this._renderingCanvas?.height ?? 0;\n }\n //------------------------------------------------------------------------------\n // Errors\n //------------------------------------------------------------------------------\n /**\n * Get the current error code of the WebGPU context\n * @returns the error code\n */\n getError() {\n // TODO WEBGPU. from the webgpu errors.\n return 0;\n }\n //------------------------------------------------------------------------------\n // External Textures\n //------------------------------------------------------------------------------\n /**\n * Creates an external texture\n * @param video video element\n * @returns the external texture, or null if external textures are not supported by the engine\n */\n createExternalTexture(video) {\n const texture = new WebGPUExternalTexture(video);\n return texture;\n }\n /**\n * Sets an internal texture to the according uniform.\n * @param name The name of the uniform in the effect\n * @param texture The texture to apply\n */\n setExternalTexture(name, texture) {\n if (!texture) {\n this._currentMaterialContext.setTexture(name, null);\n return;\n }\n this._setInternalTexture(name, texture);\n }\n //------------------------------------------------------------------------------\n // Samplers\n //------------------------------------------------------------------------------\n /**\n * Sets a texture sampler to the according uniform.\n * @param name The name of the uniform in the effect\n * @param sampler The sampler to apply\n */\n setTextureSampler(name, sampler) {\n this._currentMaterialContext?.setSampler(name, sampler);\n }\n //------------------------------------------------------------------------------\n // Storage Buffers\n //------------------------------------------------------------------------------\n /**\n * Creates a storage buffer\n * @param data the data for the storage buffer or the size of the buffer\n * @param creationFlags flags to use when creating the buffer (see undefined). The BUFFER_CREATIONFLAG_STORAGE flag will be automatically added\n * @param label defines the label of the buffer (for debug purpose)\n * @returns the new buffer\n */\n createStorageBuffer(data, creationFlags, label) {\n return this._createBuffer(data, creationFlags | 32, label);\n }\n /**\n * Updates a storage buffer\n * @param buffer the storage buffer to update\n * @param data the data used to update the storage buffer\n * @param byteOffset the byte offset of the data\n * @param byteLength the byte length of the data\n */\n updateStorageBuffer(buffer, data, byteOffset, byteLength) {\n const dataBuffer = buffer;\n if (byteOffset === undefined) {\n byteOffset = 0;\n }\n let view;\n if (byteLength === undefined) {\n if (data instanceof Array) {\n view = new Float32Array(data);\n }\n else if (data instanceof ArrayBuffer) {\n view = new Uint8Array(data);\n }\n else {\n view = data;\n }\n byteLength = view.byteLength;\n }\n else {\n if (data instanceof Array) {\n view = new Float32Array(data);\n }\n else if (data instanceof ArrayBuffer) {\n view = new Uint8Array(data);\n }\n else {\n view = data;\n }\n }\n this._bufferManager.setSubData(dataBuffer, byteOffset, view, 0, byteLength);\n }\n _readFromGPUBuffer(gpuBuffer, size, buffer, noDelay) {\n return new Promise((resolve, reject) => {\n const readFromBuffer = () => {\n gpuBuffer.mapAsync(1 /* WebGPUConstants.MapMode.Read */, 0, size).then(() => {\n const copyArrayBuffer = gpuBuffer.getMappedRange(0, size);\n let data = buffer;\n if (data === undefined) {\n data = new Uint8Array(size);\n data.set(new Uint8Array(copyArrayBuffer));\n }\n else {\n const ctor = data.constructor; // we want to create result data with the same type as buffer (Uint8Array, Float32Array, ...)\n data = new ctor(data.buffer);\n data.set(new ctor(copyArrayBuffer));\n }\n gpuBuffer.unmap();\n this._bufferManager.releaseBuffer(gpuBuffer);\n resolve(data);\n }, (reason) => {\n if (this.isDisposed) {\n resolve(new Uint8Array());\n }\n else {\n reject(reason);\n }\n });\n };\n if (noDelay) {\n this.flushFramebuffer();\n readFromBuffer();\n }\n else {\n // we are using onEndFrameObservable because we need to map the gpuBuffer AFTER the command buffers\n // have been submitted, else we get the error: \"Buffer used in a submit while mapped\"\n this.onEndFrameObservable.addOnce(() => {\n readFromBuffer();\n });\n }\n });\n }\n /**\n * Read data from a storage buffer\n * @param storageBuffer The storage buffer to read from\n * @param offset The offset in the storage buffer to start reading from (default: 0)\n * @param size The number of bytes to read from the storage buffer (default: capacity of the buffer)\n * @param buffer The buffer to write the data we have read from the storage buffer to (optional)\n * @param noDelay If true, a call to flushFramebuffer will be issued so that the data can be read back immediately and not in engine.onEndFrameObservable. This can speed up data retrieval, at the cost of a small perf penalty (default: false).\n * @returns If not undefined, returns the (promise) buffer (as provided by the 4th parameter) filled with the data, else it returns a (promise) Uint8Array with the data read from the storage buffer\n */\n readFromStorageBuffer(storageBuffer, offset, size, buffer, noDelay) {\n size = size || storageBuffer.capacity;\n const gpuBuffer = this._bufferManager.createRawBuffer(size, WebGPUConstants.BufferUsage.MapRead | WebGPUConstants.BufferUsage.CopyDst, undefined, \"TempReadFromStorageBuffer\");\n this._renderEncoder.copyBufferToBuffer(storageBuffer.underlyingResource, offset ?? 0, gpuBuffer, 0, size);\n return this._readFromGPUBuffer(gpuBuffer, size, buffer, noDelay);\n }\n /**\n * Read data from multiple storage buffers\n * @param storageBuffers The list of storage buffers to read from\n * @param offset The offset in the storage buffer to start reading from (default: 0). This is the same offset for all storage buffers!\n * @param size The number of bytes to read from each storage buffer (default: capacity of the first buffer)\n * @param buffer The buffer to write the data we have read from the storage buffers to (optional). If provided, the buffer should be large enough to hold the data from all storage buffers!\n * @param noDelay If true, a call to flushFramebuffer will be issued so that the data can be read back immediately and not in engine.onEndFrameObservable. This can speed up data retrieval, at the cost of a small perf penalty (default: false).\n * @returns If not undefined, returns the (promise) buffer (as provided by the 4th parameter) filled with the data, else it returns a (promise) Uint8Array with the data read from the storage buffer\n */\n readFromMultipleStorageBuffers(storageBuffers, offset, size, buffer, noDelay) {\n size = size || storageBuffers[0].capacity;\n const gpuBuffer = this._bufferManager.createRawBuffer(size * storageBuffers.length, WebGPUConstants.BufferUsage.MapRead | WebGPUConstants.BufferUsage.CopyDst, undefined, \"TempReadFromMultipleStorageBuffers\");\n for (let i = 0; i < storageBuffers.length; i++) {\n this._renderEncoder.copyBufferToBuffer(storageBuffers[i].underlyingResource, offset ?? 0, gpuBuffer, i * size, size);\n }\n return this._readFromGPUBuffer(gpuBuffer, size * storageBuffers.length, buffer, noDelay);\n }\n /**\n * Sets a storage buffer in the shader\n * @param name Defines the name of the storage buffer as defined in the shader\n * @param buffer Defines the value to give to the uniform\n */\n setStorageBuffer(name, buffer) {\n this._currentDrawContext?.setBuffer(name, buffer?.getBuffer() ?? null);\n }\n}\n// Default glslang options.\nWebGPUEngine._GlslangDefaultOptions = {\n jsPath: `${Tools._DefaultCdnUrl}/glslang/glslang.js`,\n wasmPath: `${Tools._DefaultCdnUrl}/glslang/glslang.wasm`,\n};\nWebGPUEngine._InstanceId = 0;\n"],"mappings":";AAAA;AACA,SAASA,MAAM,QAAQ,mBAAmB;AAC1C,SAASC,gBAAgB,QAAQ,uBAAuB;AACxD,SAASC,MAAM,QAAQ,kBAAkB;AACzC,SAASC,eAAe,QAAQ,0CAA0C;AAC1E,SAASC,MAAM,QAAQ,wBAAwB;;AAE/C;AACA,OAAO,KAAKC,eAAe,MAAM,6BAA6B;AAC9D,SAASC,YAAY,QAAQ,sBAAsB;AACnD,SAASC,qBAAqB,QAAQ,mCAAmC;AACzE,SAASC,yBAAyB,QAAQ,wCAAwC;AAClF,SAASC,yBAAyB,QAAQ,wCAAwC;AAClF,SAASC,6BAA6B,QAAQ,2CAA2C;AACzF,SAASC,KAAK,QAAQ,kBAAkB;AACxC,SAASC,mBAAmB,QAAQ,iCAAiC;AACrE,SAASC,oBAAoB,QAAQ,kCAAkC;AACvE,SAASC,cAAc,QAAQ,qBAAqB;AACpD,SAASC,mBAAmB,QAAQ,iCAAiC;AACrE,SAASC,qBAAqB,QAAQ,mCAAmC;AACzE,SAASC,aAAa,QAAQ,+BAA+B;AAC7D,SAASC,kBAAkB,QAAQ,gCAAgC;AACnE,SAASC,6BAA6B,QAAQ,2CAA2C;AACzF,SAASC,0BAA0B,QAAQ,wCAAwC;AACnF,SAASC,uBAAuB,QAAQ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