@babylonjs/core 7.1.0 → 7.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Animations/animationGroup.d.ts +1 -1
- package/Animations/animationGroup.js +1 -1
- package/Animations/animationGroup.js.map +1 -1
- package/Compute/computeEffect.d.ts +0 -1
- package/Compute/computeEffect.js +40 -33
- package/Compute/computeEffect.js.map +1 -1
- package/Engines/Extensions/engine.computeShader.d.ts +25 -1
- package/Engines/Extensions/engine.computeShader.js +1 -1
- package/Engines/Extensions/engine.computeShader.js.map +1 -1
- package/Engines/WebGL/webGLRenderTargetWrapper.d.ts +1 -2
- package/Engines/WebGL/webGLRenderTargetWrapper.js +2 -3
- package/Engines/WebGL/webGLRenderTargetWrapper.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.computeShader.js +22 -0
- package/Engines/WebGPU/Extensions/engine.computeShader.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.renderTarget.js +2 -3
- package/Engines/WebGPU/Extensions/engine.renderTarget.js.map +1 -1
- package/Engines/WebGPU/webgpuComputePipelineContext.js +4 -2
- package/Engines/WebGPU/webgpuComputePipelineContext.js.map +1 -1
- package/Engines/WebGPU/webgpuShaderProcessorsWGSL.d.ts +1 -0
- package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js +6 -1
- package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js.map +1 -1
- package/Engines/WebGPU/webgpuTextureManager.js +2 -2
- package/Engines/WebGPU/webgpuTextureManager.js.map +1 -1
- package/Engines/renderTargetWrapper.d.ts +6 -2
- package/Engines/renderTargetWrapper.js +9 -2
- package/Engines/renderTargetWrapper.js.map +1 -1
- package/Engines/thinEngine.js +2 -2
- package/Engines/thinEngine.js.map +1 -1
- package/Engines/webgpuEngine.js +4 -5
- package/Engines/webgpuEngine.js.map +1 -1
- package/Gizmos/axisScaleGizmo.js +6 -1
- package/Gizmos/axisScaleGizmo.js.map +1 -1
- package/Gizmos/boundingBoxGizmo.d.ts +2 -2
- package/Gizmos/boundingBoxGizmo.js +27 -17
- package/Gizmos/boundingBoxGizmo.js.map +1 -1
- package/Gizmos/scaleGizmo.d.ts +6 -0
- package/Gizmos/scaleGizmo.js +10 -2
- package/Gizmos/scaleGizmo.js.map +1 -1
- package/Lights/Shadows/cascadedShadowGenerator.js +1 -1
- package/Lights/Shadows/cascadedShadowGenerator.js.map +1 -1
- package/Lights/Shadows/shadowGenerator.js +17 -2
- package/Lights/Shadows/shadowGenerator.js.map +1 -1
- package/Materials/PBR/pbrBaseMaterial.js +1 -5
- package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
- package/Materials/PBR/pbrClearCoatConfiguration.d.ts +0 -1
- package/Materials/PBR/pbrClearCoatConfiguration.js +3 -12
- package/Materials/PBR/pbrClearCoatConfiguration.js.map +1 -1
- package/Materials/PBR/pbrIridescenceConfiguration.d.ts +1 -4
- package/Materials/PBR/pbrIridescenceConfiguration.js +5 -15
- package/Materials/PBR/pbrIridescenceConfiguration.js.map +1 -1
- package/Materials/PBR/pbrSheenConfiguration.d.ts +0 -1
- package/Materials/PBR/pbrSheenConfiguration.js +3 -12
- package/Materials/PBR/pbrSheenConfiguration.js.map +1 -1
- package/Materials/PBR/pbrSubSurfaceConfiguration.js +5 -17
- package/Materials/PBR/pbrSubSurfaceConfiguration.js.map +1 -1
- package/Materials/Textures/baseTexture.d.ts +0 -6
- package/Materials/Textures/baseTexture.js +0 -8
- package/Materials/Textures/baseTexture.js.map +1 -1
- package/Materials/Textures/renderTargetTexture.d.ts +2 -1
- package/Materials/Textures/renderTargetTexture.js +3 -2
- package/Materials/Textures/renderTargetTexture.js.map +1 -1
- package/Materials/Textures/texture.d.ts +0 -6
- package/Materials/Textures/texture.js +0 -15
- package/Materials/Textures/texture.js.map +1 -1
- package/Materials/Textures/thinTexture.js +1 -1
- package/Materials/Textures/thinTexture.js.map +1 -1
- package/Maths/math.vector.d.ts +12 -0
- package/Maths/math.vector.js +17 -2
- package/Maths/math.vector.js.map +1 -1
- package/Maths/tensor.d.ts +13 -11
- package/Maths/tensor.js.map +1 -1
- package/Meshes/Builders/greasedLineBuilder.js +14 -0
- package/Meshes/Builders/greasedLineBuilder.js.map +1 -1
- package/Meshes/GreasedLine/greasedLineBaseMesh.d.ts +14 -3
- package/Meshes/GreasedLine/greasedLineBaseMesh.js +18 -2
- package/Meshes/GreasedLine/greasedLineBaseMesh.js.map +1 -1
- package/Meshes/GreasedLine/greasedLineMesh.js +3 -4
- package/Meshes/GreasedLine/greasedLineMesh.js.map +1 -1
- package/Meshes/GreasedLine/greasedLineRibbonMesh.js +10 -1
- package/Meshes/GreasedLine/greasedLineRibbonMesh.js.map +1 -1
- package/Physics/v2/IPhysicsEnginePlugin.d.ts +1 -0
- package/Physics/v2/IPhysicsEnginePlugin.js.map +1 -1
- package/Physics/v2/Plugins/havokPlugin.d.ts +7 -0
- package/Physics/v2/Plugins/havokPlugin.js +16 -0
- package/Physics/v2/Plugins/havokPlugin.js.map +1 -1
- package/Physics/v2/physicsBody.d.ts +7 -1
- package/Physics/v2/physicsBody.js +10 -1
- package/Physics/v2/physicsBody.js.map +1 -1
- package/Physics/v2/physicsEngineComponent.d.ts +5 -0
- package/Physics/v2/physicsEngineComponent.js +13 -0
- package/Physics/v2/physicsEngineComponent.js.map +1 -1
- package/Rendering/depthPeelingRenderer.js +1 -1
- package/Rendering/depthPeelingRenderer.js.map +1 -1
- package/Rendering/fluidRenderer/fluidRenderer.js +1 -1
- package/Rendering/fluidRenderer/fluidRenderer.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockClearcoat.js +0 -4
- package/Shaders/ShadersInclude/pbrBlockClearcoat.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockIridescence.js +0 -3
- package/Shaders/ShadersInclude/pbrBlockIridescence.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockSheen.js +1 -5
- package/Shaders/ShadersInclude/pbrBlockSheen.js.map +1 -1
- package/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.js +2 -2
- package/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.js.map +1 -1
- package/Shaders/greasedLine.vertex.js +3 -3
- package/Shaders/greasedLine.vertex.js.map +1 -1
- package/Shaders/pbr.fragment.js +4 -4
- package/Shaders/pbr.fragment.js.map +1 -1
- package/XR/features/WebXRHandTracking.d.ts +5 -0
- package/XR/features/WebXRHandTracking.js +6 -0
- package/XR/features/WebXRHandTracking.js.map +1 -1
- package/XR/webXRCamera.js +4 -0
- package/XR/webXRCamera.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"computeEffect.js","sourceRoot":"","sources":["../../../../dev/core/src/Compute/computeEffect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC/E,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAExE,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAqD7D;;GAEG;AACH,MAAM,OAAO,aAAa;IAgEtB;;;;;;OAMG;IACH,YAAY,QAAqC,EAAE,OAAsC,EAAE,MAAc,EAAE,GAAG,GAAG,EAAE;QA5DnH;;WAEG;QACI,YAAO,GAAW,EAAE,CAAC;QAC5B;;WAEG;QACI,eAAU,GAA8C,IAAI,CAAC;QACpE;;WAEG;QACI,YAAO,GAA8D,IAAI,CAAC;QACjF;;WAEG;QACI,aAAQ,GAAG,CAAC,CAAC;QACpB;;;WAGG;QACI,wBAAmB,GAAG,IAAI,UAAU,EAAiB,CAAC;QAC7D;;WAEG;QACI,sBAAiB,GAAG,IAAI,UAAU,EAAiB,CAAC;QAC3D;;WAEG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OAAO,EAAE,CAAC;SACnC;QACD,IAAI,CAAC,OAAO,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC;IAC7C,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,cAAc,CAAC,IAAY,EAAE,aAAqB;QAC5D,WAAW,CAAC,eAAe,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,eAAe,CAAC,GAAG,aAAa,CAAC;IAC7F,CAAC;;AAvZc,2BAAa,GAAG,CAAC,AAAJ,CAAK;AAEjC;;GAEG;AACW,6CAA+B,GAAG,IAAI,AAAP,CAAQ","sourcesContent":["import { Logger } from \"../Misc/logger\";\r\nimport type { Nullable } from \"../types\";\r\nimport { Observable } from \"../Misc/observable\";\r\nimport type { IComputePipelineContext } from \"./IComputePipelineContext\";\r\nimport { GetDOMTextContent, IsWindowObjectExist } from \"../Misc/domManagement\";\r\nimport { ShaderProcessor } from \"../Engines/Processors/shaderProcessor\";\r\nimport type { ProcessingOptions } from \"../Engines/Processors/shaderProcessingOptions\";\r\nimport { ShaderStore } from \"../Engines/shaderStore\";\r\nimport { ShaderLanguage } from \"../Materials/shaderLanguage\";\r\n\r\nimport type { Engine } from \"../Engines/engine\";\r\n\r\n/**\r\n * Defines the route to the shader code. The priority is as follows:\r\n * * object: `{ computeSource: \"compute shader code string\"}` for directly passing the shader code\r\n * * object: `{ computeElement: \"vertexShaderCode\" }`, used with shader code in script tags\r\n * * object: `{ compute: \"custom\" }`, used with `Effect.ShadersStore[\"customVertexShader\"]` and `Effect.ShadersStore[\"customFragmentShader\"]`\r\n * * string: `\"./COMMON_NAME\"`, used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.\r\n */\r\nexport type IComputeShaderPath = {\r\n /**\r\n * Directly pass the shader code\r\n */\r\n computeSource?: string;\r\n /**\r\n * Used with Effect.ShadersStore. If the `vertex` is set to `\"custom`, then\r\n * Babylon.js will read from Effect.ShadersStore[\"customVertexShader\"]\r\n */\r\n compute?: string;\r\n /**\r\n * Used with shader code in script tags\r\n */\r\n computeElement?: string;\r\n};\r\n\r\n/**\r\n * Options to be used when creating a compute effect.\r\n */\r\nexport interface IComputeEffectCreationOptions {\r\n /**\r\n * Define statements that will be set in the shader.\r\n */\r\n defines: any;\r\n /**\r\n * The name of the entry point in the shader source (default: \"main\")\r\n */\r\n entryPoint?: string;\r\n /**\r\n * Callback that will be called when the shader is compiled.\r\n */\r\n onCompiled: Nullable<(effect: ComputeEffect) => void>;\r\n /**\r\n * Callback that will be called if an error occurs during shader compilation.\r\n */\r\n onError: Nullable<(effect: ComputeEffect, errors: string) => void>;\r\n /**\r\n * If provided, will be called with the shader code so that this code can be updated before it is compiled by the GPU\r\n */\r\n processFinalCode?: Nullable<(code: string) => string>;\r\n}\r\n\r\n/**\r\n * Effect wrapping a compute shader and let execute (dispatch) the shader\r\n */\r\nexport class ComputeEffect {\r\n private static _UniqueIdSeed = 0;\r\n\r\n /**\r\n * Enable logging of the shader code when a compilation error occurs\r\n */\r\n public static LogShaderCodeOnCompilationError = true;\r\n /**\r\n * Name of the effect.\r\n */\r\n public name: IComputeShaderPath | string;\r\n /**\r\n * String container all the define statements that should be set on the shader.\r\n */\r\n public defines: string = \"\";\r\n /**\r\n * Callback that will be called when the shader is compiled.\r\n */\r\n public onCompiled: Nullable<(effect: ComputeEffect) => void> = null;\r\n /**\r\n * Callback that will be called if an error occurs during shader compilation.\r\n */\r\n public onError: Nullable<(effect: ComputeEffect, errors: string) => void> = null;\r\n /**\r\n * Unique ID of the effect.\r\n */\r\n public uniqueId = 0;\r\n /**\r\n * Observable that will be called when the shader is compiled.\r\n * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.\r\n */\r\n public onCompileObservable = new Observable<ComputeEffect>();\r\n /**\r\n * Observable that will be called if an error occurs during shader compilation.\r\n */\r\n public onErrorObservable = new Observable<ComputeEffect>();\r\n /**\r\n * Observable that will be called when effect is bound.\r\n */\r\n public onBindObservable = new Observable<ComputeEffect>();\r\n\r\n /**\r\n * @internal\r\n * Specifies if the effect was previously ready\r\n */\r\n public _wasPreviouslyReady = false;\r\n\r\n private _engine: Engine;\r\n private _isReady = false;\r\n private _compilationError = \"\";\r\n /** @internal */\r\n public _key: string = \"\";\r\n private _computeSourceCodeOverride: string = \"\";\r\n /** @internal */\r\n public _pipelineContext: Nullable<IComputePipelineContext> = null;\r\n /** @internal */\r\n public _computeSourceCode: string = \"\";\r\n private _rawComputeSourceCode: string = \"\";\r\n private _entryPoint: string;\r\n private _shaderLanguage = ShaderLanguage.WGSL;\r\n private _shaderStore: { [key: string]: string };\r\n private _shaderRepository: string;\r\n private _includeShaderStore: { [key: string]: string };\r\n\r\n /**\r\n * Creates a compute effect that can be used to execute a compute shader\r\n * @param baseName Name of the effect\r\n * @param options Set of all options to create the effect\r\n * @param engine The engine the effect is created for\r\n * @param key Effect Key identifying uniquely compiled shader variants\r\n */\r\n constructor(baseName: IComputeShaderPath | string, options: IComputeEffectCreationOptions, engine: Engine, key = \"\") {\r\n this.name = baseName;\r\n this._key = key;\r\n\r\n this._engine = engine;\r\n this.uniqueId = ComputeEffect._UniqueIdSeed++;\r\n\r\n this.defines = options.defines ?? \"\";\r\n this.onError = options.onError;\r\n this.onCompiled = options.onCompiled;\r\n this._entryPoint = options.entryPoint ?? \"main\";\r\n\r\n this._shaderStore = ShaderStore.GetShadersStore(this._shaderLanguage);\r\n this._shaderRepository = ShaderStore.GetShadersRepository(this._shaderLanguage);\r\n this._includeShaderStore = ShaderStore.GetIncludesShadersStore(this._shaderLanguage);\r\n\r\n let computeSource: IComputeShaderPath | HTMLElement | string;\r\n\r\n const hostDocument = IsWindowObjectExist() ? this._engine.getHostDocument() : null;\r\n\r\n if (typeof baseName === \"string\") {\r\n computeSource = baseName;\r\n } else if (baseName.computeSource) {\r\n computeSource = \"source:\" + baseName.computeSource;\r\n } else if (baseName.computeElement) {\r\n computeSource = hostDocument?.getElementById(baseName.computeElement) || baseName.computeElement;\r\n } else {\r\n computeSource = baseName.compute || baseName;\r\n }\r\n\r\n const processorOptions: ProcessingOptions = {\r\n defines: this.defines.split(\"\\n\"),\r\n indexParameters: undefined,\r\n isFragment: false,\r\n shouldUseHighPrecisionShader: false,\r\n processor: null,\r\n supportsUniformBuffers: this._engine.supportsUniformBuffers,\r\n shadersRepository: this._shaderRepository,\r\n includesShadersStore: this._includeShaderStore,\r\n version: (this._engine.version * 100).toString(),\r\n platformName: this._engine.shaderPlatformName,\r\n processingContext: null,\r\n isNDCHalfZRange: this._engine.isNDCHalfZRange,\r\n useReverseDepthBuffer: this._engine.useReverseDepthBuffer,\r\n };\r\n\r\n this._loadShader(computeSource, \"Compute\", \"\", (computeCode) => {\r\n ShaderProcessor.Initialize(processorOptions);\r\n ShaderProcessor.PreProcess(\r\n computeCode,\r\n processorOptions,\r\n (migratedCommputeCode) => {\r\n this._rawComputeSourceCode = computeCode;\r\n if (options.processFinalCode) {\r\n migratedCommputeCode = options.processFinalCode(migratedCommputeCode);\r\n }\r\n const finalShaders = ShaderProcessor.Finalize(migratedCommputeCode, \"\", processorOptions);\r\n this._useFinalCode(finalShaders.vertexCode, baseName);\r\n },\r\n this._engine\r\n );\r\n });\r\n }\r\n\r\n private _useFinalCode(migratedCommputeCode: string, baseName: any) {\r\n if (baseName) {\r\n const compute = baseName.computeElement || baseName.compute || baseName.spectorName || baseName;\r\n\r\n this._computeSourceCode = \"//#define SHADER_NAME compute:\" + compute + \"\\n\" + migratedCommputeCode;\r\n } else {\r\n this._computeSourceCode = migratedCommputeCode;\r\n }\r\n this._prepareEffect();\r\n }\r\n\r\n /**\r\n * Unique key for this effect\r\n */\r\n public get key(): string {\r\n return this._key;\r\n }\r\n\r\n /**\r\n * If the effect has been compiled and prepared.\r\n * @returns if the effect is compiled and prepared.\r\n */\r\n public isReady(): boolean {\r\n try {\r\n return this._isReadyInternal();\r\n } catch {\r\n return false;\r\n }\r\n }\r\n\r\n private _isReadyInternal(): boolean {\r\n if (this._isReady) {\r\n return true;\r\n }\r\n if (this._pipelineContext) {\r\n return this._pipelineContext.isReady;\r\n }\r\n return false;\r\n }\r\n\r\n /**\r\n * The engine the effect was initialized with.\r\n * @returns the engine.\r\n */\r\n public getEngine(): Engine {\r\n return this._engine;\r\n }\r\n\r\n /**\r\n * The pipeline context for this effect\r\n * @returns the associated pipeline context\r\n */\r\n public getPipelineContext(): Nullable<IComputePipelineContext> {\r\n return this._pipelineContext;\r\n }\r\n\r\n /**\r\n * The error from the last compilation.\r\n * @returns the error string.\r\n */\r\n public getCompilationError(): string {\r\n return this._compilationError;\r\n }\r\n\r\n /**\r\n * Adds a callback to the onCompiled observable and call the callback immediately if already ready.\r\n * @param func The callback to be used.\r\n */\r\n public executeWhenCompiled(func: (effect: ComputeEffect) => void): void {\r\n if (this.isReady()) {\r\n func(this);\r\n return;\r\n }\r\n\r\n this.onCompileObservable.add((effect) => {\r\n func(effect);\r\n });\r\n\r\n if (!this._pipelineContext || this._pipelineContext.isAsync) {\r\n setTimeout(() => {\r\n this._checkIsReady(null);\r\n }, 16);\r\n }\r\n }\r\n\r\n private _checkIsReady(previousPipelineContext: Nullable<IComputePipelineContext>) {\r\n try {\r\n if (this._isReadyInternal()) {\r\n return;\r\n }\r\n } catch (e) {\r\n this._processCompilationErrors(e, previousPipelineContext);\r\n return;\r\n }\r\n\r\n setTimeout(() => {\r\n this._checkIsReady(previousPipelineContext);\r\n }, 16);\r\n }\r\n\r\n private _loadShader(shader: any, key: string, optionalKey: string, callback: (data: any) => void): void {\r\n if (typeof HTMLElement !== \"undefined\") {\r\n // DOM element ?\r\n if (shader instanceof HTMLElement) {\r\n const shaderCode = GetDOMTextContent(shader);\r\n callback(shaderCode);\r\n return;\r\n }\r\n }\r\n\r\n // Direct source ?\r\n if (shader.substr(0, 7) === \"source:\") {\r\n callback(shader.substr(7));\r\n return;\r\n }\r\n\r\n // Base64 encoded ?\r\n if (shader.substr(0, 7) === \"base64:\") {\r\n const shaderBinary = window.atob(shader.substr(7));\r\n callback(shaderBinary);\r\n return;\r\n }\r\n\r\n // Is in local store ?\r\n if (this._shaderStore[shader + key + \"Shader\"]) {\r\n callback(this._shaderStore[shader + key + \"Shader\"]);\r\n return;\r\n }\r\n\r\n if (optionalKey && this._shaderStore[shader + optionalKey + \"Shader\"]) {\r\n callback(this._shaderStore[shader + optionalKey + \"Shader\"]);\r\n return;\r\n }\r\n\r\n let shaderUrl;\r\n\r\n if (shader[0] === \".\" || shader[0] === \"/\" || shader.indexOf(\"http\") > -1) {\r\n shaderUrl = shader;\r\n } else {\r\n shaderUrl = this._shaderRepository + shader;\r\n }\r\n\r\n this._engine._loadFile(shaderUrl + \".\" + key.toLowerCase() + \".fx\", callback);\r\n }\r\n\r\n /**\r\n * Gets the compute shader source code of this effect\r\n */\r\n public get computeSourceCode(): string {\r\n return this._computeSourceCodeOverride ? this._computeSourceCodeOverride : this._pipelineContext?._getComputeShaderCode() ?? this._computeSourceCode;\r\n }\r\n\r\n /**\r\n * Gets the compute shader source code before it has been processed by the preprocessor\r\n */\r\n public get rawComputeSourceCode(): string {\r\n return this._rawComputeSourceCode;\r\n }\r\n\r\n /**\r\n * Prepares the effect\r\n * @internal\r\n */\r\n public _prepareEffect() {\r\n const defines = this.defines;\r\n\r\n const previousPipelineContext = this._pipelineContext;\r\n\r\n this._isReady = false;\r\n\r\n try {\r\n const engine = this._engine;\r\n\r\n this._pipelineContext = engine.createComputePipelineContext();\r\n this._pipelineContext._name = this._key;\r\n\r\n engine._prepareComputePipelineContext(\r\n this._pipelineContext,\r\n this._computeSourceCodeOverride ? this._computeSourceCodeOverride : this._computeSourceCode,\r\n this._rawComputeSourceCode,\r\n this._computeSourceCodeOverride ? null : defines,\r\n this._entryPoint\r\n );\r\n\r\n engine._executeWhenComputeStateIsCompiled(this._pipelineContext, () => {\r\n this._compilationError = \"\";\r\n this._isReady = true;\r\n if (this.onCompiled) {\r\n this.onCompiled(this);\r\n }\r\n this.onCompileObservable.notifyObservers(this);\r\n this.onCompileObservable.clear();\r\n\r\n if (previousPipelineContext) {\r\n this.getEngine()._deleteComputePipelineContext(previousPipelineContext);\r\n }\r\n });\r\n\r\n if (this._pipelineContext.isAsync) {\r\n this._checkIsReady(previousPipelineContext);\r\n }\r\n } catch (e) {\r\n this._processCompilationErrors(e, previousPipelineContext);\r\n }\r\n }\r\n\r\n private _getShaderCodeAndErrorLine(code: Nullable<string>, error: Nullable<string>): [Nullable<string>, Nullable<string>] {\r\n const regexp = /COMPUTE SHADER ERROR: 0:(\\d+?):/;\r\n\r\n let errorLine = null;\r\n\r\n if (error && code) {\r\n const res = error.match(regexp);\r\n if (res && res.length === 2) {\r\n const lineNumber = parseInt(res[1]);\r\n const lines = code.split(\"\\n\", -1);\r\n if (lines.length >= lineNumber) {\r\n errorLine = `Offending line [${lineNumber}] in compute code: ${lines[lineNumber - 1]}`;\r\n }\r\n }\r\n }\r\n\r\n return [code, errorLine];\r\n }\r\n\r\n private _processCompilationErrors(e: any, previousPipelineContext: Nullable<IComputePipelineContext> = null) {\r\n this._compilationError = e.message;\r\n\r\n // Let's go through fallbacks then\r\n Logger.Error(\"Unable to compile compute effect:\");\r\n Logger.Error(\"Defines:\\n\" + this.defines);\r\n if (ComputeEffect.LogShaderCodeOnCompilationError) {\r\n let lineErrorVertex = null,\r\n code = null;\r\n if (this._pipelineContext?._getComputeShaderCode()) {\r\n [code, lineErrorVertex] = this._getShaderCodeAndErrorLine(this._pipelineContext._getComputeShaderCode(), this._compilationError);\r\n if (code) {\r\n Logger.Error(\"Compute code:\");\r\n Logger.Error(code);\r\n }\r\n }\r\n if (lineErrorVertex) {\r\n Logger.Error(lineErrorVertex);\r\n }\r\n }\r\n Logger.Error(\"Error: \" + this._compilationError);\r\n if (previousPipelineContext) {\r\n this._pipelineContext = previousPipelineContext;\r\n this._isReady = true;\r\n if (this.onError) {\r\n this.onError(this, this._compilationError);\r\n }\r\n this.onErrorObservable.notifyObservers(this);\r\n }\r\n }\r\n\r\n /**\r\n * Release all associated resources.\r\n **/\r\n public dispose() {\r\n if (this._pipelineContext) {\r\n this._pipelineContext.dispose();\r\n }\r\n this._engine._releaseComputeEffect(this);\r\n }\r\n\r\n /**\r\n * This function will add a new compute shader to the shader store\r\n * @param name the name of the shader\r\n * @param computeShader compute shader content\r\n */\r\n public static RegisterShader(name: string, computeShader: string) {\r\n ShaderStore.GetShadersStore(ShaderLanguage.WGSL)[`${name}ComputeShader`] = computeShader;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"computeEffect.js","sourceRoot":"","sources":["../../../../dev/core/src/Compute/computeEffect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC/E,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAExE,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAsD7D;;GAEG;AACH,MAAM,OAAO,aAAa;IAgEtB;;;;;;OAMG;IACH,YAAY,QAAqC,EAAE,OAAsC,EAAE,MAAc,EAAE,GAAG,GAAG,EAAE;QA5DnH;;WAEG;QACI,YAAO,GAAW,EAAE,CAAC;QAC5B;;WAEG;QACI,eAAU,GAA8C,IAAI,CAAC;QACpE;;WAEG;QACI,YAAO,GAA8D,IAAI,CAAC;QACjF;;WAEG;QACI,aAAQ,GAAG,CAAC,CAAC;QACpB;;;WAGG;QACI,wBAAmB,GAAG,IAAI,UAAU,EAAiB,CAAC;QAC7D;;WAEG;QACI,sBAAiB,GAAG,IAAI,UAAU,EAAiB,CAAC;QAC3D;;WAEG;QACI,qBAAgB,GAAG,IAAI,UAAU,EAAiB,CAAC;QAE1D;;;WAGG;QACI,wBAAmB,GAAG,KAAK,CAAC;QAG3B,aAA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ACD,IAAI,CAAC,OAAO,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC;IAC7C,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,cAAc,CAAC,IAAY,EAAE,aAAqB;QAC5D,WAAW,CAAC,eAAe,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,eAAe,CAAC,GAAG,aAAa,CAAC;IAC7F,CAAC;;AA7Zc,2BAAa,GAAG,CAAC,AAAJ,CAAK;AAEjC;;GAEG;AACW,6CAA+B,GAAG,IAAI,AAAP,CAAQ","sourcesContent":["import { Logger } from \"../Misc/logger\";\r\nimport type { Nullable } from \"../types\";\r\nimport { Observable } from \"../Misc/observable\";\r\nimport type { IComputePipelineContext } from \"./IComputePipelineContext\";\r\nimport { GetDOMTextContent, IsWindowObjectExist } from \"../Misc/domManagement\";\r\nimport { ShaderProcessor } from \"../Engines/Processors/shaderProcessor\";\r\nimport type { ProcessingOptions } from \"../Engines/Processors/shaderProcessingOptions\";\r\nimport { ShaderStore } from \"../Engines/shaderStore\";\r\nimport { ShaderLanguage } from \"../Materials/shaderLanguage\";\r\n\r\nimport type { Engine } from \"../Engines/engine\";\r\nimport type { ComputeCompilationMessages } from \"../Engines/Extensions/engine.computeShader\";\r\n\r\n/**\r\n * Defines the route to the shader code. The priority is as follows:\r\n * * object: `{ computeSource: \"compute shader code string\"}` for directly passing the shader code\r\n * * object: `{ computeElement: \"vertexShaderCode\" }`, used with shader code in script tags\r\n * * object: `{ compute: \"custom\" }`, used with `Effect.ShadersStore[\"customVertexShader\"]` and `Effect.ShadersStore[\"customFragmentShader\"]`\r\n * * string: `\"./COMMON_NAME\"`, used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.\r\n */\r\nexport type IComputeShaderPath = {\r\n /**\r\n * Directly pass the shader code\r\n */\r\n computeSource?: string;\r\n /**\r\n * Used with Effect.ShadersStore. If the `vertex` is set to `\"custom`, then\r\n * Babylon.js will read from Effect.ShadersStore[\"customVertexShader\"]\r\n */\r\n compute?: string;\r\n /**\r\n * Used with shader code in script tags\r\n */\r\n computeElement?: string;\r\n};\r\n\r\n/**\r\n * Options to be used when creating a compute effect.\r\n */\r\nexport interface IComputeEffectCreationOptions {\r\n /**\r\n * Define statements that will be set in the shader.\r\n */\r\n defines: any;\r\n /**\r\n * The name of the entry point in the shader source (default: \"main\")\r\n */\r\n entryPoint?: string;\r\n /**\r\n * Callback that will be called when the shader is compiled.\r\n */\r\n onCompiled: Nullable<(effect: ComputeEffect) => void>;\r\n /**\r\n * Callback that will be called if an error occurs during shader compilation.\r\n */\r\n onError: Nullable<(effect: ComputeEffect, errors: string) => void>;\r\n /**\r\n * If provided, will be called with the shader code so that this code can be updated before it is compiled by the GPU\r\n */\r\n processFinalCode?: Nullable<(code: string) => string>;\r\n}\r\n\r\n/**\r\n * Effect wrapping a compute shader and let execute (dispatch) the shader\r\n */\r\nexport class ComputeEffect {\r\n private static _UniqueIdSeed = 0;\r\n\r\n /**\r\n * Enable logging of the shader code when a compilation error occurs\r\n */\r\n public static LogShaderCodeOnCompilationError = true;\r\n /**\r\n * Name of the effect.\r\n */\r\n public name: IComputeShaderPath | string;\r\n /**\r\n * String container all the define statements that should be set on the shader.\r\n */\r\n public defines: string = \"\";\r\n /**\r\n * Callback that will be called when the shader is compiled.\r\n */\r\n public onCompiled: Nullable<(effect: ComputeEffect) => void> = null;\r\n /**\r\n * Callback that will be called if an error occurs during shader compilation.\r\n */\r\n public onError: Nullable<(effect: ComputeEffect, errors: string) => void> = null;\r\n /**\r\n * Unique ID of the effect.\r\n */\r\n public uniqueId = 0;\r\n /**\r\n * Observable that will be called when the shader is compiled.\r\n * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.\r\n */\r\n public onCompileObservable = new Observable<ComputeEffect>();\r\n /**\r\n * Observable that will be called if an error occurs during shader compilation.\r\n */\r\n public onErrorObservable = new Observable<ComputeEffect>();\r\n /**\r\n * Observable that will be called when effect is bound.\r\n */\r\n public onBindObservable = new Observable<ComputeEffect>();\r\n\r\n /**\r\n * @internal\r\n * Specifies if the effect was previously ready\r\n */\r\n public _wasPreviouslyReady = false;\r\n\r\n private _engine: Engine;\r\n private _isReady = false;\r\n private _compilationError = \"\";\r\n /** @internal */\r\n public _key: string = \"\";\r\n private _computeSourceCodeOverride: string = \"\";\r\n /** @internal */\r\n public _pipelineContext: Nullable<IComputePipelineContext> = null;\r\n /** @internal */\r\n public _computeSourceCode: string = \"\";\r\n private _rawComputeSourceCode: string = \"\";\r\n private _entryPoint: string;\r\n private _shaderLanguage = ShaderLanguage.WGSL;\r\n private _shaderStore: { [key: string]: string };\r\n private _shaderRepository: string;\r\n private _includeShaderStore: { [key: string]: string };\r\n\r\n /**\r\n * Creates a compute effect that can be used to execute a compute shader\r\n * @param baseName Name of the effect\r\n * @param options Set of all options to create the effect\r\n * @param engine The engine the effect is created for\r\n * @param key Effect Key identifying uniquely compiled shader variants\r\n */\r\n constructor(baseName: IComputeShaderPath | string, options: IComputeEffectCreationOptions, engine: Engine, key = \"\") {\r\n this.name = baseName;\r\n this._key = key;\r\n\r\n this._engine = engine;\r\n this.uniqueId = ComputeEffect._UniqueIdSeed++;\r\n\r\n this.defines = options.defines ?? \"\";\r\n this.onError = options.onError;\r\n this.onCompiled = options.onCompiled;\r\n this._entryPoint = options.entryPoint ?? \"main\";\r\n\r\n this._shaderStore = ShaderStore.GetShadersStore(this._shaderLanguage);\r\n this._shaderRepository = ShaderStore.GetShadersRepository(this._shaderLanguage);\r\n this._includeShaderStore = ShaderStore.GetIncludesShadersStore(this._shaderLanguage);\r\n\r\n let computeSource: IComputeShaderPath | HTMLElement | string;\r\n\r\n const hostDocument = IsWindowObjectExist() ? this._engine.getHostDocument() : null;\r\n\r\n if (typeof baseName === \"string\") {\r\n computeSource = baseName;\r\n } else if (baseName.computeSource) {\r\n computeSource = \"source:\" + baseName.computeSource;\r\n } else if (baseName.computeElement) {\r\n computeSource = hostDocument?.getElementById(baseName.computeElement) || baseName.computeElement;\r\n } else {\r\n computeSource = baseName.compute || baseName;\r\n }\r\n\r\n const processorOptions: ProcessingOptions = {\r\n defines: this.defines.split(\"\\n\"),\r\n indexParameters: undefined,\r\n isFragment: false,\r\n shouldUseHighPrecisionShader: false,\r\n processor: null,\r\n supportsUniformBuffers: this._engine.supportsUniformBuffers,\r\n shadersRepository: this._shaderRepository,\r\n includesShadersStore: this._includeShaderStore,\r\n version: (this._engine.version * 100).toString(),\r\n platformName: this._engine.shaderPlatformName,\r\n processingContext: null,\r\n isNDCHalfZRange: this._engine.isNDCHalfZRange,\r\n useReverseDepthBuffer: this._engine.useReverseDepthBuffer,\r\n };\r\n\r\n this._loadShader(computeSource, \"Compute\", \"\", (computeCode) => {\r\n ShaderProcessor.Initialize(processorOptions);\r\n ShaderProcessor.PreProcess(\r\n computeCode,\r\n processorOptions,\r\n (migratedCommputeCode) => {\r\n this._rawComputeSourceCode = computeCode;\r\n if (options.processFinalCode) {\r\n migratedCommputeCode = options.processFinalCode(migratedCommputeCode);\r\n }\r\n const finalShaders = ShaderProcessor.Finalize(migratedCommputeCode, \"\", processorOptions);\r\n this._useFinalCode(finalShaders.vertexCode, baseName);\r\n },\r\n this._engine\r\n );\r\n });\r\n }\r\n\r\n private _useFinalCode(migratedCommputeCode: string, baseName: any) {\r\n if (baseName) {\r\n const compute = baseName.computeElement || baseName.compute || baseName.spectorName || baseName;\r\n\r\n this._computeSourceCode = \"//#define SHADER_NAME compute:\" + compute + \"\\n\" + migratedCommputeCode;\r\n } else {\r\n this._computeSourceCode = migratedCommputeCode;\r\n }\r\n this._prepareEffect();\r\n }\r\n\r\n /**\r\n * Unique key for this effect\r\n */\r\n public get key(): string {\r\n return this._key;\r\n }\r\n\r\n /**\r\n * If the effect has been compiled and prepared.\r\n * @returns if the effect is compiled and prepared.\r\n */\r\n public isReady(): boolean {\r\n try {\r\n return this._isReadyInternal();\r\n } catch {\r\n return false;\r\n }\r\n }\r\n\r\n private _isReadyInternal(): boolean {\r\n if (this._isReady) {\r\n return true;\r\n }\r\n if (this._pipelineContext) {\r\n return this._pipelineContext.isReady;\r\n }\r\n return false;\r\n }\r\n\r\n /**\r\n * The engine the effect was initialized with.\r\n * @returns the engine.\r\n */\r\n public getEngine(): Engine {\r\n return this._engine;\r\n }\r\n\r\n /**\r\n * The pipeline context for this effect\r\n * @returns the associated pipeline context\r\n */\r\n public getPipelineContext(): Nullable<IComputePipelineContext> {\r\n return this._pipelineContext;\r\n }\r\n\r\n /**\r\n * The error from the last compilation.\r\n * @returns the error string.\r\n */\r\n public getCompilationError(): string {\r\n return this._compilationError;\r\n }\r\n\r\n /**\r\n * Adds a callback to the onCompiled observable and call the callback immediately if already ready.\r\n * @param func The callback to be used.\r\n */\r\n public executeWhenCompiled(func: (effect: ComputeEffect) => void): void {\r\n if (this.isReady()) {\r\n func(this);\r\n return;\r\n }\r\n\r\n this.onCompileObservable.add((effect) => {\r\n func(effect);\r\n });\r\n\r\n if (!this._pipelineContext || this._pipelineContext.isAsync) {\r\n setTimeout(() => {\r\n this._checkIsReady(null);\r\n }, 16);\r\n }\r\n }\r\n\r\n private _checkIsReady(previousPipelineContext: Nullable<IComputePipelineContext>) {\r\n try {\r\n if (this._isReadyInternal()) {\r\n return;\r\n }\r\n } catch (e) {\r\n this._processCompilationErrors(e, previousPipelineContext);\r\n return;\r\n }\r\n\r\n setTimeout(() => {\r\n this._checkIsReady(previousPipelineContext);\r\n }, 16);\r\n }\r\n\r\n private _loadShader(shader: any, key: string, optionalKey: string, callback: (data: any) => void): void {\r\n if (typeof HTMLElement !== \"undefined\") {\r\n // DOM element ?\r\n if (shader instanceof HTMLElement) {\r\n const shaderCode = GetDOMTextContent(shader);\r\n callback(shaderCode);\r\n return;\r\n }\r\n }\r\n\r\n // Direct source ?\r\n if (shader.substr(0, 7) === \"source:\") {\r\n callback(shader.substr(7));\r\n return;\r\n }\r\n\r\n // Base64 encoded ?\r\n if (shader.substr(0, 7) === \"base64:\") {\r\n const shaderBinary = window.atob(shader.substr(7));\r\n callback(shaderBinary);\r\n return;\r\n }\r\n\r\n // Is in local store ?\r\n if (this._shaderStore[shader + key + \"Shader\"]) {\r\n callback(this._shaderStore[shader + key + \"Shader\"]);\r\n return;\r\n }\r\n\r\n if (optionalKey && this._shaderStore[shader + optionalKey + \"Shader\"]) {\r\n callback(this._shaderStore[shader + optionalKey + \"Shader\"]);\r\n return;\r\n }\r\n\r\n let shaderUrl;\r\n\r\n if (shader[0] === \".\" || shader[0] === \"/\" || shader.indexOf(\"http\") > -1) {\r\n shaderUrl = shader;\r\n } else {\r\n shaderUrl = this._shaderRepository + shader;\r\n }\r\n\r\n this._engine._loadFile(shaderUrl + \".\" + key.toLowerCase() + \".fx\", callback);\r\n }\r\n\r\n /**\r\n * Gets the compute shader source code of this effect\r\n */\r\n public get computeSourceCode(): string {\r\n return this._computeSourceCodeOverride ? this._computeSourceCodeOverride : this._pipelineContext?._getComputeShaderCode() ?? this._computeSourceCode;\r\n }\r\n\r\n /**\r\n * Gets the compute shader source code before it has been processed by the preprocessor\r\n */\r\n public get rawComputeSourceCode(): string {\r\n return this._rawComputeSourceCode;\r\n }\r\n\r\n /**\r\n * Prepares the effect\r\n * @internal\r\n */\r\n public _prepareEffect() {\r\n const defines = this.defines;\r\n\r\n const previousPipelineContext = this._pipelineContext;\r\n\r\n this._isReady = false;\r\n\r\n try {\r\n const engine = this._engine;\r\n\r\n this._pipelineContext = engine.createComputePipelineContext();\r\n this._pipelineContext._name = this._key;\r\n\r\n engine._prepareComputePipelineContext(\r\n this._pipelineContext,\r\n this._computeSourceCodeOverride ? this._computeSourceCodeOverride : this._computeSourceCode,\r\n this._rawComputeSourceCode,\r\n this._computeSourceCodeOverride ? null : defines,\r\n this._entryPoint\r\n );\r\n\r\n engine._executeWhenComputeStateIsCompiled(this._pipelineContext, (messages: Nullable<ComputeCompilationMessages>) => {\r\n if (messages && messages.numErrors > 0) {\r\n this._processCompilationErrors(messages, previousPipelineContext);\r\n return;\r\n }\r\n this._compilationError = \"\";\r\n this._isReady = true;\r\n if (this.onCompiled) {\r\n this.onCompiled(this);\r\n }\r\n this.onCompileObservable.notifyObservers(this);\r\n this.onCompileObservable.clear();\r\n\r\n if (previousPipelineContext) {\r\n this.getEngine()._deleteComputePipelineContext(previousPipelineContext);\r\n }\r\n });\r\n\r\n if (this._pipelineContext.isAsync) {\r\n this._checkIsReady(previousPipelineContext);\r\n }\r\n } catch (e) {\r\n this._processCompilationErrors(e, previousPipelineContext);\r\n }\r\n }\r\n\r\n private _processCompilationErrors(e: ComputeCompilationMessages | string, previousPipelineContext: Nullable<IComputePipelineContext> = null) {\r\n this._compilationError = \"\";\r\n\r\n Logger.Error(\"Unable to compile compute effect:\");\r\n if (this.defines) {\r\n Logger.Error(\"Defines:\\n\" + this.defines);\r\n }\r\n\r\n if (ComputeEffect.LogShaderCodeOnCompilationError) {\r\n const code = this._pipelineContext?._getComputeShaderCode();\r\n if (code) {\r\n Logger.Error(\"Compute code:\");\r\n Logger.Error(code);\r\n }\r\n }\r\n\r\n if (typeof e === \"string\") {\r\n this._compilationError = e;\r\n Logger.Error(\"Error: \" + this._compilationError);\r\n } else {\r\n for (const message of e.messages) {\r\n let msg = \"\";\r\n if (message.line !== undefined) {\r\n msg += \"Line \" + message.line + \", \";\r\n }\r\n if (message.offset !== undefined) {\r\n msg += \"Offset \" + message.offset + \", \";\r\n }\r\n if (message.length !== undefined) {\r\n msg += \"Length \" + message.length + \", \";\r\n }\r\n msg += message.type + \": \" + message.text;\r\n\r\n if (this._compilationError) {\r\n this._compilationError += \"\\n\";\r\n }\r\n this._compilationError += msg;\r\n Logger.Error(msg);\r\n }\r\n }\r\n\r\n if (previousPipelineContext) {\r\n this._pipelineContext = previousPipelineContext;\r\n this._isReady = true;\r\n }\r\n\r\n if (this.onError) {\r\n this.onError(this, this._compilationError);\r\n }\r\n this.onErrorObservable.notifyObservers(this);\r\n }\r\n\r\n /**\r\n * Release all associated resources.\r\n **/\r\n public dispose() {\r\n if (this._pipelineContext) {\r\n this._pipelineContext.dispose();\r\n }\r\n this._engine._releaseComputeEffect(this);\r\n }\r\n\r\n /**\r\n * This function will add a new compute shader to the shader store\r\n * @param name the name of the shader\r\n * @param computeShader compute shader content\r\n */\r\n public static RegisterShader(name: string, computeShader: string) {\r\n ShaderStore.GetShadersStore(ShaderLanguage.WGSL)[`${name}ComputeShader`] = computeShader;\r\n }\r\n}\r\n"]}
|
|
@@ -18,6 +18,30 @@ export type ComputeBindingLocation = {
|
|
|
18
18
|
export type ComputeBindingMapping = {
|
|
19
19
|
[key: string]: ComputeBindingLocation;
|
|
20
20
|
};
|
|
21
|
+
/**
|
|
22
|
+
* Types of messages that can be generated during compilation
|
|
23
|
+
*/
|
|
24
|
+
export type ComputeCompilationMessageType = "error" | "warning" | "info";
|
|
25
|
+
/**
|
|
26
|
+
* Messages generated during compilation
|
|
27
|
+
*/
|
|
28
|
+
export interface ComputeCompilationMessages {
|
|
29
|
+
/**
|
|
30
|
+
* Number of errors generated during compilation
|
|
31
|
+
*/
|
|
32
|
+
numErrors: number;
|
|
33
|
+
/**
|
|
34
|
+
* List of messages generated during compilation
|
|
35
|
+
*/
|
|
36
|
+
messages: {
|
|
37
|
+
type: ComputeCompilationMessageType;
|
|
38
|
+
text: string;
|
|
39
|
+
line?: number;
|
|
40
|
+
column?: number;
|
|
41
|
+
length?: number;
|
|
42
|
+
offset?: number;
|
|
43
|
+
}[];
|
|
44
|
+
}
|
|
21
45
|
/** @internal */
|
|
22
46
|
export declare enum ComputeBindingType {
|
|
23
47
|
Texture = 0,
|
|
@@ -87,7 +111,7 @@ declare module "../../Engines/thinEngine" {
|
|
|
87
111
|
/** @internal */
|
|
88
112
|
_rebuildComputeEffects(): void;
|
|
89
113
|
/** @internal */
|
|
90
|
-
_executeWhenComputeStateIsCompiled(pipelineContext: IComputePipelineContext, action: () => void): void;
|
|
114
|
+
_executeWhenComputeStateIsCompiled(pipelineContext: IComputePipelineContext, action: (messages: Nullable<ComputeCompilationMessages>) => void): void;
|
|
91
115
|
/** @internal */
|
|
92
116
|
_releaseComputeEffect(effect: ComputeEffect): void;
|
|
93
117
|
/** @internal */
|
|
@@ -30,7 +30,7 @@ ThinEngine.prototype.releaseComputeEffects = function () { };
|
|
|
30
30
|
ThinEngine.prototype._prepareComputePipelineContext = function (pipelineContext, computeSourceCode, rawComputeSourceCode, defines, entryPoint) { };
|
|
31
31
|
ThinEngine.prototype._rebuildComputeEffects = function () { };
|
|
32
32
|
ThinEngine.prototype._executeWhenComputeStateIsCompiled = function (pipelineContext, action) {
|
|
33
|
-
action();
|
|
33
|
+
action(null);
|
|
34
34
|
};
|
|
35
35
|
ThinEngine.prototype._releaseComputeEffect = function (effect) { };
|
|
36
36
|
ThinEngine.prototype._deleteComputePipelineContext = function (pipelineContext) { };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.computeShader.js","sourceRoot":"","sources":["../../../../../dev/core/src/Engines/Extensions/engine.computeShader.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"engine.computeShader.js","sourceRoot":"","sources":["../../../../../dev/core/src/Engines/Extensions/engine.computeShader.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AA0CtD,gBAAgB;AAChB,MAAM,CAAN,IAAY,kBASX;AATD,WAAY,kBAAkB;IAC1B,iEAAW,CAAA;IACX,+EAAkB,CAAA;IAClB,6EAAiB,CAAA;IACjB,6EAAiB,CAAA;IACjB,6FAAyB,CAAA;IACzB,iEAAW,CAAA;IACX,iFAAmB,CAAA;IACnB,uEAAc,CAAA;AAClB,CAAC,EATW,kBAAkB,KAAlB,kBAAkB,QAS7B;AA6FD,UAAU,CAAC,SAAS,CAAC,mBAAmB,GAAG,UAAU,QAAwD,EAAE,OAAsC;IACjJ,MAAM,IAAI,KAAK,CAAC,oEAAoE,CAAC,CAAC;AAC1F,CAAC,CAAC;AAEF,UAAU,CAAC,SAAS,CAAC,4BAA4B,GAAG;IAChD,MAAM,IAAI,KAAK,CAAC,6EAA6E,CAAC,CAAC;AACnG,CAAC,CAAC;AAEF,UAAU,CAAC,SAAS,CAAC,oBAAoB,GAAG;IACxC,OAAO,SAAS,CAAC;AACrB,CAAC,CAAC;AAEF,UAAU,CAAC,SAAS,CAAC,eAAe,GAAG,UACnC,MAAqB,EACrB,OAAwB,EACxB,QAA4B,EAC5B,CAAS,EACT,CAAU,EACV,CAAU,EACV,eAAuC;IAEvC,MAAM,IAAI,KAAK,CAAC,gEAAgE,CAAC,CAAC;AACtF,CAAC,CAAC;AAEF,UAAU,CAAC,SAAS,CAAC,yBAAyB,GAAG;IAC7C,OAAO,IAAI,CAAC;AAChB,CAAC,CAAC;AAEF,UAAU,CAAC,SAAS,CAAC,qBAAqB,GAAG,cAAmB,CAAC,CAAC;AAElE,UAAU,CAAC,SAAS,CAAC,8BAA8B,GAAG,UAClD,eAAwC,EACxC,iBAAyB,EACzB,oBAA4B,EAC5B,OAAyB,EACzB,UAAkB,IACb,CAAC,CAAC;AAEX,UAAU,CAAC,SAAS,CAAC,sBAAsB,GAAG,cAAmB,CAAC,CAAC;AAEnE,UAAU,CAAC,SAAS,CAAC,kCAAkC,GAAG,UACtD,eAAwC,EACxC,MAAgE;IAEhE,MAAM,CAAC,IAAI,CAAC,CAAC;AACjB,CAAC,CAAC;AAEF,UAAU,CAAC,SAAS,CAAC,qBAAqB,GAAG,UAAU,MAAqB,IAAS,CAAC,CAAC;AAEvF,UAAU,CAAC,SAAS,CAAC,6BAA6B,GAAG,UAAU,eAAwC,IAAS,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\r\nimport type { ComputeEffect, IComputeEffectCreationOptions, IComputeShaderPath } from \"../../Compute/computeEffect\";\r\nimport type { IComputeContext } from \"../../Compute/IComputeContext\";\r\nimport type { IComputePipelineContext } from \"../../Compute/IComputePipelineContext\";\r\nimport { ThinEngine } from \"../../Engines/thinEngine\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { WebGPUPerfCounter } from \"../WebGPU/webgpuPerfCounter\";\r\n\r\n/**\r\n * Type used to locate a resource in a compute shader.\r\n * TODO: remove this when browsers support reflection for wgsl shaders\r\n */\r\nexport type ComputeBindingLocation = { group: number; binding: number };\r\n\r\n/**\r\n * Type used to lookup a resource and retrieve its binding location\r\n * TODO: remove this when browsers support reflection for wgsl shaders\r\n */\r\nexport type ComputeBindingMapping = { [key: string]: ComputeBindingLocation };\r\n\r\n/**\r\n * Types of messages that can be generated during compilation\r\n */\r\nexport type ComputeCompilationMessageType = \"error\" | \"warning\" | \"info\";\r\n\r\n/**\r\n * Messages generated during compilation\r\n */\r\nexport interface ComputeCompilationMessages {\r\n /**\r\n * Number of errors generated during compilation\r\n */\r\n numErrors: number;\r\n /**\r\n * List of messages generated during compilation\r\n */\r\n messages: {\r\n type: ComputeCompilationMessageType;\r\n text: string;\r\n line?: number;\r\n column?: number;\r\n length?: number;\r\n offset?: number;\r\n }[];\r\n}\r\n\r\n/** @internal */\r\nexport enum ComputeBindingType {\r\n Texture = 0,\r\n StorageTexture = 1,\r\n UniformBuffer = 2,\r\n StorageBuffer = 3,\r\n TextureWithoutSampler = 4,\r\n Sampler = 5,\r\n ExternalTexture = 6,\r\n DataBuffer = 7,\r\n}\r\n\r\n/** @internal */\r\nexport type ComputeBindingList = { [key: string]: { type: ComputeBindingType; object: any; indexInGroupEntries?: number } };\r\n\r\ndeclare module \"../../Engines/thinEngine\" {\r\n export interface ThinEngine {\r\n /**\r\n * Creates a new compute effect\r\n * @param baseName Name of the effect\r\n * @param options Options used to create the effect\r\n * @returns The new compute effect\r\n */\r\n createComputeEffect(\r\n baseName:\r\n | string\r\n | (IComputeShaderPath & {\r\n /**\r\n * @internal\r\n */\r\n computeToken?: string;\r\n }),\r\n options: IComputeEffectCreationOptions\r\n ): ComputeEffect;\r\n\r\n /**\r\n * Creates a new compute pipeline context\r\n * @returns the new pipeline\r\n */\r\n createComputePipelineContext(): IComputePipelineContext;\r\n\r\n /**\r\n * Creates a new compute context\r\n * @returns the new context\r\n */\r\n createComputeContext(): IComputeContext | undefined;\r\n\r\n /**\r\n * Dispatches a compute shader\r\n * @param effect The compute effect\r\n * @param context The compute context\r\n * @param bindings The list of resources to bind to the shader\r\n * @param x The number of workgroups to execute on the X dimension\r\n * @param y The number of workgroups to execute on the Y dimension\r\n * @param z The number of workgroups to execute on the Z dimension\r\n * @param bindingsMapping list of bindings mapping (key is property name, value is binding location)\r\n * @param gpuPerfCounter GPU time computed for the compute shader will be assigned to this object\r\n */\r\n computeDispatch(\r\n effect: ComputeEffect,\r\n context: IComputeContext,\r\n bindings: ComputeBindingList,\r\n x: number,\r\n y?: number,\r\n z?: number,\r\n bindingsMapping?: ComputeBindingMapping,\r\n gpuPerfCounter?: WebGPUPerfCounter\r\n ): void;\r\n\r\n /**\r\n * Gets a boolean indicating if all created compute effects are ready\r\n * @returns true if all effects are ready\r\n */\r\n areAllComputeEffectsReady(): boolean;\r\n\r\n /**\r\n * Forces the engine to release all cached compute effects. This means that next effect compilation will have to be done completely even if a similar effect was already compiled\r\n */\r\n releaseComputeEffects(): void;\r\n\r\n /** @internal */\r\n _prepareComputePipelineContext(\r\n pipelineContext: IComputePipelineContext,\r\n computeSourceCode: string,\r\n rawComputeSourceCode: string,\r\n defines: Nullable<string>,\r\n entryPoint: string\r\n ): void;\r\n\r\n /** @internal */\r\n _rebuildComputeEffects(): void;\r\n\r\n /** @internal */\r\n _executeWhenComputeStateIsCompiled(pipelineContext: IComputePipelineContext, action: (messages: Nullable<ComputeCompilationMessages>) => void): void;\r\n\r\n /** @internal */\r\n _releaseComputeEffect(effect: ComputeEffect): void;\r\n\r\n /** @internal */\r\n _deleteComputePipelineContext(pipelineContext: IComputePipelineContext): void;\r\n }\r\n}\r\n\r\nThinEngine.prototype.createComputeEffect = function (baseName: IComputeShaderPath & { computeToken?: string }, options: IComputeEffectCreationOptions): ComputeEffect {\r\n throw new Error(\"createComputeEffect: This engine does not support compute shaders!\");\r\n};\r\n\r\nThinEngine.prototype.createComputePipelineContext = function (): IComputePipelineContext {\r\n throw new Error(\"createComputePipelineContext: This engine does not support compute shaders!\");\r\n};\r\n\r\nThinEngine.prototype.createComputeContext = function (): IComputeContext | undefined {\r\n return undefined;\r\n};\r\n\r\nThinEngine.prototype.computeDispatch = function (\r\n effect: ComputeEffect,\r\n context: IComputeContext,\r\n bindings: ComputeBindingList,\r\n x: number,\r\n y?: number,\r\n z?: number,\r\n bindingsMapping?: ComputeBindingMapping\r\n): void {\r\n throw new Error(\"computeDispatch: This engine does not support compute shaders!\");\r\n};\r\n\r\nThinEngine.prototype.areAllComputeEffectsReady = function (): boolean {\r\n return true;\r\n};\r\n\r\nThinEngine.prototype.releaseComputeEffects = function (): void {};\r\n\r\nThinEngine.prototype._prepareComputePipelineContext = function (\r\n pipelineContext: IComputePipelineContext,\r\n computeSourceCode: string,\r\n rawComputeSourceCode: string,\r\n defines: Nullable<string>,\r\n entryPoint: string\r\n): void {};\r\n\r\nThinEngine.prototype._rebuildComputeEffects = function (): void {};\r\n\r\nThinEngine.prototype._executeWhenComputeStateIsCompiled = function (\r\n pipelineContext: IComputePipelineContext,\r\n action: (messages: Nullable<ComputeCompilationMessages>) => void\r\n): void {\r\n action(null);\r\n};\r\n\r\nThinEngine.prototype._releaseComputeEffect = function (effect: ComputeEffect): void {};\r\n\r\nThinEngine.prototype._deleteComputePipelineContext = function (pipelineContext: IComputePipelineContext): void {};\r\n"]}
|
|
@@ -50,10 +50,9 @@ export declare class WebGLRenderTargetWrapper extends RenderTargetWrapper {
|
|
|
50
50
|
createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean, samples?: number, format?: number, label?: string): InternalTexture;
|
|
51
51
|
/**
|
|
52
52
|
* Shares the depth buffer of this render target with another render target.
|
|
53
|
-
* @internal
|
|
54
53
|
* @param renderTarget Destination renderTarget
|
|
55
54
|
*/
|
|
56
|
-
|
|
55
|
+
shareDepth(renderTarget: WebGLRenderTargetWrapper): void;
|
|
57
56
|
/**
|
|
58
57
|
* Binds a texture to this render target on a specific attachment
|
|
59
58
|
* @param texture The texture to bind to the framebuffer
|
|
@@ -85,11 +85,10 @@ export class WebGLRenderTargetWrapper extends RenderTargetWrapper {
|
|
|
85
85
|
}
|
|
86
86
|
/**
|
|
87
87
|
* Shares the depth buffer of this render target with another render target.
|
|
88
|
-
* @internal
|
|
89
88
|
* @param renderTarget Destination renderTarget
|
|
90
89
|
*/
|
|
91
|
-
|
|
92
|
-
super.
|
|
90
|
+
shareDepth(renderTarget) {
|
|
91
|
+
super.shareDepth(renderTarget);
|
|
93
92
|
const gl = this._context;
|
|
94
93
|
const depthbuffer = this._depthStencilBuffer;
|
|
95
94
|
const framebuffer = renderTarget._MSAAFramebuffer || renderTarget._framebuffer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webGLRenderTargetWrapper.js","sourceRoot":"","sources":["../../../../../dev/core/src/Engines/WebGL/webGLRenderTargetWrapper.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAG7D,gBAAgB;AAChB,MAAM,OAAO,wBAAyB,SAAQ,mBAAmB;IAoC7D,YAAY,OAAgB,EAAE,MAAe,EAAE,IAAiB,EAAE,MAAkB,EAAE,OAA8B;QAChH,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;QAlCzC;;WAEG;QACI,iBAAY,GAA+B,IAAI,CAAC;QACvD;;WAEG;QACI,wBAAmB,GAAgC,IAAI,CAAC;QAC/D,gEAAgE;QAChE;;WAEG;QACH,gEAAgE;QACzD,qBAAgB,GAA+B,IAAI,CAAC;QAE3D,YAAY;QACZ;;WAEG;QACI,uBAAkB,GAA2B,IAAI,C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AAC,IAAI,CAAC,YAAY,CAAC,CAAC;YACxC,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;SAC5B;QAED,IAAI,IAAI,CAAC,mBAAmB,EAAE;YAC1B,EAAE,CAAC,kBAAkB,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;YAChD,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC;SACnC;QAED,IAAI,IAAI,CAAC,gBAAgB,EAAE;YACvB,EAAE,CAAC,iBAAiB,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;YAC5C,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC;SAChC;QAED,KAAK,CAAC,OAAO,CAAC,uBAAuB,CAAC,CAAC;IAC3C,CAAC;CACJ","sourcesContent":["import type { InternalTexture } from \"../../Materials/Textures/internalTexture\";\r\nimport type { TextureSize } from \"../../Materials/Textures/textureCreationOptions\";\r\nimport type { Nullable } from \"../../types\";\r\nimport { Constants } from \"../constants\";\r\nimport type { Engine } from \"../engine\";\r\nimport { RenderTargetWrapper } from \"../renderTargetWrapper\";\r\nimport type { ThinEngine } from \"../thinEngine\";\r\n\r\n/** @internal */\r\nexport class WebGLRenderTargetWrapper extends RenderTargetWrapper {\r\n private _context: WebGLRenderingContext;\r\n\r\n /**\r\n * @internal\r\n */\r\n public _framebuffer: Nullable<WebGLFramebuffer> = null;\r\n /**\r\n * @internal\r\n */\r\n public _depthStencilBuffer: Nullable<WebGLRenderbuffer> = null;\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n /**\r\n * @internal\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n public _MSAAFramebuffer: Nullable<WebGLFramebuffer> = null;\r\n\r\n // Multiview\r\n /**\r\n * @internal\r\n */\r\n public _colorTextureArray: Nullable<WebGLTexture> = null;\r\n /**\r\n * @internal\r\n */\r\n public _depthStencilTextureArray: Nullable<WebGLTexture> = null;\r\n /**\r\n * @internal\r\n */\r\n public _disposeOnlyFramebuffers = false;\r\n /**\r\n * @internal\r\n */\r\n public _currentLOD = 0;\r\n\r\n constructor(isMulti: boolean, isCube: boolean, size: TextureSize, engine: ThinEngine, context: WebGLRenderingContext) {\r\n super(isMulti, isCube, size, engine);\r\n\r\n this._context = context;\r\n }\r\n\r\n protected _cloneRenderTargetWrapper(): Nullable<RenderTargetWrapper> {\r\n let rtw: Nullable<RenderTargetWrapper> = null;\r\n\r\n if (this._colorTextureArray && this._depthStencilTextureArray) {\r\n rtw = (this._engine as Engine).createMultiviewRenderTargetTexture(this.width, this.height);\r\n rtw.texture!.isReady = true;\r\n } else {\r\n rtw = super._cloneRenderTargetWrapper();\r\n }\r\n\r\n return rtw;\r\n }\r\n\r\n protected _swapRenderTargetWrapper(target: WebGLRenderTargetWrapper): void {\r\n super._swapRenderTargetWrapper(target);\r\n\r\n target._framebuffer = this._framebuffer;\r\n target._depthStencilBuffer = this._depthStencilBuffer;\r\n target._MSAAFramebuffer = this._MSAAFramebuffer;\r\n target._colorTextureArray = this._colorTextureArray;\r\n target._depthStencilTextureArray = this._depthStencilTextureArray;\r\n\r\n this._framebuffer = this._depthStencilBuffer = this._MSAAFramebuffer = this._colorTextureArray = this._depthStencilTextureArray = null;\r\n }\r\n\r\n /**\r\n * Creates the depth/stencil texture\r\n * @param comparisonFunction Comparison function to use for the texture\r\n * @param bilinearFiltering true if bilinear filtering should be used when sampling the texture\r\n * @param generateStencil true if the stencil aspect should also be created\r\n * @param samples sample count to use when creating the texture\r\n * @param format format of the depth texture\r\n * @param label defines the label to use for the texture (for debugging purpose only)\r\n * @returns the depth/stencil created texture\r\n */\r\n public createDepthStencilTexture(\r\n comparisonFunction: number = 0,\r\n bilinearFiltering: boolean = true,\r\n generateStencil: boolean = false,\r\n samples: number = 1,\r\n format: number = Constants.TEXTUREFORMAT_DEPTH32_FLOAT,\r\n label?: string\r\n ): InternalTexture {\r\n if (this._depthStencilBuffer) {\r\n // Dispose previous depth/stencil render buffers and clear the corresponding attachment.\r\n // Next time this framebuffer is bound, the new depth/stencil texture will be attached.\r\n const currentFrameBuffer = this._engine._currentFramebuffer;\r\n const gl = this._context;\r\n\r\n this._engine._bindUnboundFramebuffer(this._framebuffer);\r\n gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, null);\r\n gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, null);\r\n gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.STENCIL_ATTACHMENT, gl.RENDERBUFFER, null);\r\n this._engine._bindUnboundFramebuffer(currentFrameBuffer);\r\n gl.deleteRenderbuffer(this._depthStencilBuffer);\r\n\r\n this._depthStencilBuffer = null;\r\n }\r\n\r\n return super.createDepthStencilTexture(comparisonFunction, bilinearFiltering, generateStencil, samples, format, label);\r\n }\r\n\r\n /**\r\n * Shares the depth buffer of this render target with another render target.\r\n * @internal\r\n * @param renderTarget Destination renderTarget\r\n */\r\n public _shareDepth(renderTarget: WebGLRenderTargetWrapper): void {\r\n super._shareDepth(renderTarget);\r\n\r\n const gl = this._context;\r\n const depthbuffer = this._depthStencilBuffer;\r\n const framebuffer = renderTarget._MSAAFramebuffer || renderTarget._framebuffer;\r\n\r\n if (renderTarget._depthStencilBuffer && renderTarget._depthStencilBuffer !== depthbuffer) {\r\n gl.deleteRenderbuffer(renderTarget._depthStencilBuffer);\r\n }\r\n renderTarget._depthStencilBuffer = depthbuffer;\r\n const attachment = renderTarget._generateStencilBuffer ? gl.DEPTH_STENCIL_ATTACHMENT : gl.DEPTH_ATTACHMENT;\r\n this._engine._bindUnboundFramebuffer(framebuffer);\r\n gl.framebufferRenderbuffer(gl.FRAMEBUFFER, attachment, gl.RENDERBUFFER, depthbuffer);\r\n this._engine._bindUnboundFramebuffer(null);\r\n }\r\n\r\n /**\r\n * Binds a texture to this render target on a specific attachment\r\n * @param texture The texture to bind to the framebuffer\r\n * @param attachmentIndex Index of the attachment\r\n * @param faceIndexOrLayer The face or layer of the texture to render to in case of cube texture or array texture\r\n * @param lodLevel defines the lod level to bind to the frame buffer\r\n */\r\n private _bindTextureRenderTarget(texture: InternalTexture, attachmentIndex: number = 0, faceIndexOrLayer?: number, lodLevel: number = 0) {\r\n if (!texture._hardwareTexture) {\r\n return;\r\n }\r\n\r\n const framebuffer = this._framebuffer;\r\n\r\n const currentFB = this._engine._currentFramebuffer;\r\n this._engine._bindUnboundFramebuffer(framebuffer);\r\n\r\n if (this._engine.webGLVersion > 1) {\r\n const gl = this._context as WebGL2RenderingContext;\r\n\r\n const attachment = (<any>gl)[\"COLOR_ATTACHMENT\" + attachmentIndex];\r\n if (texture.is2DArray || texture.is3D) {\r\n faceIndexOrLayer = faceIndexOrLayer ?? this.layerIndices?.[attachmentIndex] ?? 0;\r\n gl.framebufferTextureLayer(gl.FRAMEBUFFER, attachment, texture._hardwareTexture.underlyingResource, lodLevel, faceIndexOrLayer);\r\n } else if (texture.isCube) {\r\n // if face index is not specified, try to query it from faceIndices\r\n // default is face 0\r\n faceIndexOrLayer = faceIndexOrLayer ?? this.faceIndices?.[attachmentIndex] ?? 0;\r\n gl.framebufferTexture2D(gl.FRAMEBUFFER, attachment, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndexOrLayer, texture._hardwareTexture.underlyingResource, lodLevel);\r\n } else {\r\n gl.framebufferTexture2D(gl.FRAMEBUFFER, attachment, gl.TEXTURE_2D, texture._hardwareTexture.underlyingResource, lodLevel);\r\n }\r\n } else {\r\n // Default behavior (WebGL)\r\n const gl = this._context;\r\n\r\n const attachment = (<any>gl)[\"COLOR_ATTACHMENT\" + attachmentIndex + \"_WEBGL\"];\r\n const target = faceIndexOrLayer !== undefined ? gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndexOrLayer : gl.TEXTURE_2D;\r\n\r\n gl.framebufferTexture2D(gl.FRAMEBUFFER, attachment, target, texture._hardwareTexture.underlyingResource, lodLevel);\r\n }\r\n\r\n this._engine._bindUnboundFramebuffer(currentFB);\r\n }\r\n\r\n /**\r\n * Set a texture in the textures array\r\n * @param texture the texture to set\r\n * @param index the index in the textures array to set\r\n * @param disposePrevious If this function should dispose the previous texture\r\n */\r\n public setTexture(texture: InternalTexture, index: number = 0, disposePrevious: boolean = true) {\r\n super.setTexture(texture, index, disposePrevious);\r\n this._bindTextureRenderTarget(texture, index);\r\n }\r\n\r\n /**\r\n * Sets the layer and face indices of every render target texture\r\n * @param layers The layer of the texture to be set (make negative to not modify)\r\n * @param faces The face of the texture to be set (make negative to not modify)\r\n */\r\n public setLayerAndFaceIndices(layers: number[], faces: number[]) {\r\n super.setLayerAndFaceIndices(layers, faces);\r\n\r\n if (!this.textures || !this.layerIndices || !this.faceIndices) {\r\n return;\r\n }\r\n\r\n // the length of this._attachments is the right one as it does not count the depth texture, in case we generated it\r\n const textureCount = this._attachments?.length ?? this.textures.length;\r\n for (let index = 0; index < textureCount; index++) {\r\n const texture = this.textures[index];\r\n if (!texture) {\r\n // The target type was probably -1 at creation time and setTexture has not been called yet for this index\r\n continue;\r\n }\r\n if (texture.is2DArray || texture.is3D) {\r\n this._bindTextureRenderTarget(texture, index, this.layerIndices[index]);\r\n } else if (texture.isCube) {\r\n this._bindTextureRenderTarget(texture, index, this.faceIndices[index]);\r\n } else {\r\n this._bindTextureRenderTarget(texture, index);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Set the face and layer indices of a texture in the textures array\r\n * @param index The index of the texture in the textures array to modify\r\n * @param layer The layer of the texture to be set\r\n * @param face The face of the texture to be set\r\n */\r\n public setLayerAndFaceIndex(index: number = 0, layer?: number, face?: number): void {\r\n super.setLayerAndFaceIndex(index, layer, face);\r\n\r\n if (!this.textures || !this.layerIndices || !this.faceIndices) {\r\n return;\r\n }\r\n\r\n const texture = this.textures[index];\r\n if (texture.is2DArray || texture.is3D) {\r\n this._bindTextureRenderTarget(this.textures[index], index, this.layerIndices[index]);\r\n } else if (texture.isCube) {\r\n this._bindTextureRenderTarget(this.textures[index], index, this.faceIndices[index]);\r\n }\r\n }\r\n\r\n public dispose(disposeOnlyFramebuffers = this._disposeOnlyFramebuffers): void {\r\n const gl = this._context;\r\n\r\n if (!disposeOnlyFramebuffers) {\r\n if (this._colorTextureArray) {\r\n this._context.deleteTexture(this._colorTextureArray);\r\n this._colorTextureArray = null;\r\n }\r\n if (this._depthStencilTextureArray) {\r\n this._context.deleteTexture(this._depthStencilTextureArray);\r\n this._depthStencilTextureArray = null;\r\n }\r\n }\r\n\r\n if (this._framebuffer) {\r\n gl.deleteFramebuffer(this._framebuffer);\r\n this._framebuffer = null;\r\n }\r\n\r\n if (this._depthStencilBuffer) {\r\n gl.deleteRenderbuffer(this._depthStencilBuffer);\r\n this._depthStencilBuffer = null;\r\n }\r\n\r\n if (this._MSAAFramebuffer) {\r\n gl.deleteFramebuffer(this._MSAAFramebuffer);\r\n this._MSAAFramebuffer = null;\r\n }\r\n\r\n super.dispose(disposeOnlyFramebuffers);\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"webGLRenderTargetWrapper.js","sourceRoot":"","sources":["../../../../../dev/core/src/Engines/WebGL/webGLRenderTargetWrapper.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAG7D,gBAAgB;AAChB,MAAM,OAAO,wBAAyB,SAAQ,mBAAmB;IAoC7D,YAAY,OAAgB,EAAE,MAAe,EAAE,IAAiB,EAAE,MAAkB,EAAE,OAA8B;QAChH,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;QAlCzC;;WAEG;QACI,iBAAY,GAA+B,IAAI,CAAC;QACvD;;WAEG;QACI,wBAAmB,GAAgC,IAAI,CAAC;QAC/D,gEAAgE;QAChE;;WAEG;QACH,gEAAgE;QACzD,qBAAgB,GAA+B,IAAI,CAAC;QAE3D,YAAY;QACZ;;WA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E;YACnB,EAAE,CAAC,iBAAiB,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;YACxC,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;SAC5B;QAED,IAAI,IAAI,CAAC,mBAAmB,EAAE;YAC1B,EAAE,CAAC,kBAAkB,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;YAChD,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC;SACnC;QAED,IAAI,IAAI,CAAC,gBAAgB,EAAE;YACvB,EAAE,CAAC,iBAAiB,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;YAC5C,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC;SAChC;QAED,KAAK,CAAC,OAAO,CAAC,uBAAuB,CAAC,CAAC;IAC3C,CAAC;CACJ","sourcesContent":["import type { InternalTexture } from \"../../Materials/Textures/internalTexture\";\r\nimport type { TextureSize } from \"../../Materials/Textures/textureCreationOptions\";\r\nimport type { Nullable } from \"../../types\";\r\nimport { Constants } from \"../constants\";\r\nimport type { Engine } from \"../engine\";\r\nimport { RenderTargetWrapper } from \"../renderTargetWrapper\";\r\nimport type { ThinEngine } from \"../thinEngine\";\r\n\r\n/** @internal */\r\nexport class WebGLRenderTargetWrapper extends RenderTargetWrapper {\r\n private _context: WebGLRenderingContext;\r\n\r\n /**\r\n * @internal\r\n */\r\n public _framebuffer: Nullable<WebGLFramebuffer> = null;\r\n /**\r\n * @internal\r\n */\r\n public _depthStencilBuffer: Nullable<WebGLRenderbuffer> = null;\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n /**\r\n * @internal\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n public _MSAAFramebuffer: Nullable<WebGLFramebuffer> = null;\r\n\r\n // Multiview\r\n /**\r\n * @internal\r\n */\r\n public _colorTextureArray: Nullable<WebGLTexture> = null;\r\n /**\r\n * @internal\r\n */\r\n public _depthStencilTextureArray: Nullable<WebGLTexture> = null;\r\n /**\r\n * @internal\r\n */\r\n public _disposeOnlyFramebuffers = false;\r\n /**\r\n * @internal\r\n */\r\n public _currentLOD = 0;\r\n\r\n constructor(isMulti: boolean, isCube: boolean, size: TextureSize, engine: ThinEngine, context: WebGLRenderingContext) {\r\n super(isMulti, isCube, size, engine);\r\n\r\n this._context = context;\r\n }\r\n\r\n protected _cloneRenderTargetWrapper(): Nullable<RenderTargetWrapper> {\r\n let rtw: Nullable<RenderTargetWrapper> = null;\r\n\r\n if (this._colorTextureArray && this._depthStencilTextureArray) {\r\n rtw = (this._engine as Engine).createMultiviewRenderTargetTexture(this.width, this.height);\r\n rtw.texture!.isReady = true;\r\n } else {\r\n rtw = super._cloneRenderTargetWrapper();\r\n }\r\n\r\n return rtw;\r\n }\r\n\r\n protected _swapRenderTargetWrapper(target: WebGLRenderTargetWrapper): void {\r\n super._swapRenderTargetWrapper(target);\r\n\r\n target._framebuffer = this._framebuffer;\r\n target._depthStencilBuffer = this._depthStencilBuffer;\r\n target._MSAAFramebuffer = this._MSAAFramebuffer;\r\n target._colorTextureArray = this._colorTextureArray;\r\n target._depthStencilTextureArray = this._depthStencilTextureArray;\r\n\r\n this._framebuffer = this._depthStencilBuffer = this._MSAAFramebuffer = this._colorTextureArray = this._depthStencilTextureArray = null;\r\n }\r\n\r\n /**\r\n * Creates the depth/stencil texture\r\n * @param comparisonFunction Comparison function to use for the texture\r\n * @param bilinearFiltering true if bilinear filtering should be used when sampling the texture\r\n * @param generateStencil true if the stencil aspect should also be created\r\n * @param samples sample count to use when creating the texture\r\n * @param format format of the depth texture\r\n * @param label defines the label to use for the texture (for debugging purpose only)\r\n * @returns the depth/stencil created texture\r\n */\r\n public createDepthStencilTexture(\r\n comparisonFunction: number = 0,\r\n bilinearFiltering: boolean = true,\r\n generateStencil: boolean = false,\r\n samples: number = 1,\r\n format: number = Constants.TEXTUREFORMAT_DEPTH32_FLOAT,\r\n label?: string\r\n ): InternalTexture {\r\n if (this._depthStencilBuffer) {\r\n // Dispose previous depth/stencil render buffers and clear the corresponding attachment.\r\n // Next time this framebuffer is bound, the new depth/stencil texture will be attached.\r\n const currentFrameBuffer = this._engine._currentFramebuffer;\r\n const gl = this._context;\r\n\r\n this._engine._bindUnboundFramebuffer(this._framebuffer);\r\n gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, null);\r\n gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, null);\r\n gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.STENCIL_ATTACHMENT, gl.RENDERBUFFER, null);\r\n this._engine._bindUnboundFramebuffer(currentFrameBuffer);\r\n gl.deleteRenderbuffer(this._depthStencilBuffer);\r\n\r\n this._depthStencilBuffer = null;\r\n }\r\n\r\n return super.createDepthStencilTexture(comparisonFunction, bilinearFiltering, generateStencil, samples, format, label);\r\n }\r\n\r\n /**\r\n * Shares the depth buffer of this render target with another render target.\r\n * @param renderTarget Destination renderTarget\r\n */\r\n public shareDepth(renderTarget: WebGLRenderTargetWrapper): void {\r\n super.shareDepth(renderTarget);\r\n\r\n const gl = this._context;\r\n const depthbuffer = this._depthStencilBuffer;\r\n const framebuffer = renderTarget._MSAAFramebuffer || renderTarget._framebuffer;\r\n\r\n if (renderTarget._depthStencilBuffer && renderTarget._depthStencilBuffer !== depthbuffer) {\r\n gl.deleteRenderbuffer(renderTarget._depthStencilBuffer);\r\n }\r\n renderTarget._depthStencilBuffer = depthbuffer;\r\n const attachment = renderTarget._generateStencilBuffer ? gl.DEPTH_STENCIL_ATTACHMENT : gl.DEPTH_ATTACHMENT;\r\n this._engine._bindUnboundFramebuffer(framebuffer);\r\n gl.framebufferRenderbuffer(gl.FRAMEBUFFER, attachment, gl.RENDERBUFFER, depthbuffer);\r\n this._engine._bindUnboundFramebuffer(null);\r\n }\r\n\r\n /**\r\n * Binds a texture to this render target on a specific attachment\r\n * @param texture The texture to bind to the framebuffer\r\n * @param attachmentIndex Index of the attachment\r\n * @param faceIndexOrLayer The face or layer of the texture to render to in case of cube texture or array texture\r\n * @param lodLevel defines the lod level to bind to the frame buffer\r\n */\r\n private _bindTextureRenderTarget(texture: InternalTexture, attachmentIndex: number = 0, faceIndexOrLayer?: number, lodLevel: number = 0) {\r\n if (!texture._hardwareTexture) {\r\n return;\r\n }\r\n\r\n const framebuffer = this._framebuffer;\r\n\r\n const currentFB = this._engine._currentFramebuffer;\r\n this._engine._bindUnboundFramebuffer(framebuffer);\r\n\r\n if (this._engine.webGLVersion > 1) {\r\n const gl = this._context as WebGL2RenderingContext;\r\n\r\n const attachment = (<any>gl)[\"COLOR_ATTACHMENT\" + attachmentIndex];\r\n if (texture.is2DArray || texture.is3D) {\r\n faceIndexOrLayer = faceIndexOrLayer ?? this.layerIndices?.[attachmentIndex] ?? 0;\r\n gl.framebufferTextureLayer(gl.FRAMEBUFFER, attachment, texture._hardwareTexture.underlyingResource, lodLevel, faceIndexOrLayer);\r\n } else if (texture.isCube) {\r\n // if face index is not specified, try to query it from faceIndices\r\n // default is face 0\r\n faceIndexOrLayer = faceIndexOrLayer ?? this.faceIndices?.[attachmentIndex] ?? 0;\r\n gl.framebufferTexture2D(gl.FRAMEBUFFER, attachment, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndexOrLayer, texture._hardwareTexture.underlyingResource, lodLevel);\r\n } else {\r\n gl.framebufferTexture2D(gl.FRAMEBUFFER, attachment, gl.TEXTURE_2D, texture._hardwareTexture.underlyingResource, lodLevel);\r\n }\r\n } else {\r\n // Default behavior (WebGL)\r\n const gl = this._context;\r\n\r\n const attachment = (<any>gl)[\"COLOR_ATTACHMENT\" + attachmentIndex + \"_WEBGL\"];\r\n const target = faceIndexOrLayer !== undefined ? gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndexOrLayer : gl.TEXTURE_2D;\r\n\r\n gl.framebufferTexture2D(gl.FRAMEBUFFER, attachment, target, texture._hardwareTexture.underlyingResource, lodLevel);\r\n }\r\n\r\n this._engine._bindUnboundFramebuffer(currentFB);\r\n }\r\n\r\n /**\r\n * Set a texture in the textures array\r\n * @param texture the texture to set\r\n * @param index the index in the textures array to set\r\n * @param disposePrevious If this function should dispose the previous texture\r\n */\r\n public setTexture(texture: InternalTexture, index: number = 0, disposePrevious: boolean = true) {\r\n super.setTexture(texture, index, disposePrevious);\r\n this._bindTextureRenderTarget(texture, index);\r\n }\r\n\r\n /**\r\n * Sets the layer and face indices of every render target texture\r\n * @param layers The layer of the texture to be set (make negative to not modify)\r\n * @param faces The face of the texture to be set (make negative to not modify)\r\n */\r\n public setLayerAndFaceIndices(layers: number[], faces: number[]) {\r\n super.setLayerAndFaceIndices(layers, faces);\r\n\r\n if (!this.textures || !this.layerIndices || !this.faceIndices) {\r\n return;\r\n }\r\n\r\n // the length of this._attachments is the right one as it does not count the depth texture, in case we generated it\r\n const textureCount = this._attachments?.length ?? this.textures.length;\r\n for (let index = 0; index < textureCount; index++) {\r\n const texture = this.textures[index];\r\n if (!texture) {\r\n // The target type was probably -1 at creation time and setTexture has not been called yet for this index\r\n continue;\r\n }\r\n if (texture.is2DArray || texture.is3D) {\r\n this._bindTextureRenderTarget(texture, index, this.layerIndices[index]);\r\n } else if (texture.isCube) {\r\n this._bindTextureRenderTarget(texture, index, this.faceIndices[index]);\r\n } else {\r\n this._bindTextureRenderTarget(texture, index);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Set the face and layer indices of a texture in the textures array\r\n * @param index The index of the texture in the textures array to modify\r\n * @param layer The layer of the texture to be set\r\n * @param face The face of the texture to be set\r\n */\r\n public setLayerAndFaceIndex(index: number = 0, layer?: number, face?: number): void {\r\n super.setLayerAndFaceIndex(index, layer, face);\r\n\r\n if (!this.textures || !this.layerIndices || !this.faceIndices) {\r\n return;\r\n }\r\n\r\n const texture = this.textures[index];\r\n if (texture.is2DArray || texture.is3D) {\r\n this._bindTextureRenderTarget(this.textures[index], index, this.layerIndices[index]);\r\n } else if (texture.isCube) {\r\n this._bindTextureRenderTarget(this.textures[index], index, this.faceIndices[index]);\r\n }\r\n }\r\n\r\n public dispose(disposeOnlyFramebuffers = this._disposeOnlyFramebuffers): void {\r\n const gl = this._context;\r\n\r\n if (!disposeOnlyFramebuffers) {\r\n if (this._colorTextureArray) {\r\n this._context.deleteTexture(this._colorTextureArray);\r\n this._colorTextureArray = null;\r\n }\r\n if (this._depthStencilTextureArray) {\r\n this._context.deleteTexture(this._depthStencilTextureArray);\r\n this._depthStencilTextureArray = null;\r\n }\r\n }\r\n\r\n if (this._framebuffer) {\r\n gl.deleteFramebuffer(this._framebuffer);\r\n this._framebuffer = null;\r\n }\r\n\r\n if (this._depthStencilBuffer) {\r\n gl.deleteRenderbuffer(this._depthStencilBuffer);\r\n this._depthStencilBuffer = null;\r\n }\r\n\r\n if (this._MSAAFramebuffer) {\r\n gl.deleteFramebuffer(this._MSAAFramebuffer);\r\n this._MSAAFramebuffer = null;\r\n }\r\n\r\n super.dispose(disposeOnlyFramebuffers);\r\n }\r\n}\r\n"]}
|
|
@@ -99,6 +99,28 @@ WebGPUEngine.prototype._rebuildComputeEffects = function () {
|
|
|
99
99
|
effect._prepareEffect();
|
|
100
100
|
}
|
|
101
101
|
};
|
|
102
|
+
WebGPUEngine.prototype._executeWhenComputeStateIsCompiled = function (pipelineContext, action) {
|
|
103
|
+
pipelineContext.stage.module.getCompilationInfo().then((info) => {
|
|
104
|
+
const compilationMessages = {
|
|
105
|
+
numErrors: 0,
|
|
106
|
+
messages: [],
|
|
107
|
+
};
|
|
108
|
+
for (const message of info.messages) {
|
|
109
|
+
if (message.type === "error") {
|
|
110
|
+
compilationMessages.numErrors++;
|
|
111
|
+
}
|
|
112
|
+
compilationMessages.messages.push({
|
|
113
|
+
type: message.type,
|
|
114
|
+
text: message.message,
|
|
115
|
+
line: message.lineNum,
|
|
116
|
+
column: message.linePos,
|
|
117
|
+
length: message.length,
|
|
118
|
+
offset: message.offset,
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
action(compilationMessages);
|
|
122
|
+
});
|
|
123
|
+
};
|
|
102
124
|
WebGPUEngine.prototype._deleteComputePipelineContext = function (pipelineContext) {
|
|
103
125
|
const webgpuPipelineContext = pipelineContext;
|
|
104
126
|
if (webgpuPipelineContext) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.computeShader.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Engines/WebGPU/Extensions/engine.computeShader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,gCAAyB;AAE1C,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAK/D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,4BAA4B,EAAE,MAAM,iCAAiC,CAAC;AAC/E,OAAO,KAAK,eAAe,MAAM,oBAAoB,CAAC;AAUtD,MAAM,qBAAqB,GAA6B,EAAE,CAAC;AAE3D,YAAY,CAAC,SAAS,CAAC,oBAAoB,GAAG;IAC1C,OAAO,IAAI,oBAAoB,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;AACtE,CAAC,CAAC;AAEF,YAAY,CAAC,SAAS,CAAC,mBAAmB,GAAG,UAAU,QAAmE,EAAE,OAAsC;IAC9J,MAAM,OAAO,GAAG,OAAO,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,YAAY,IAAI,QAAQ,CAAC,aAAa,IAAI,QAAQ,CAAC,cAAc,IAAI,QAAQ,CAAC,OAAO,CAAC;IAEzJ,MAAM,IAAI,GAAG,OAAO,GAAG,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC;IAC7C,IAAI,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,EAAE;QACpC,MAAM,cAAc,GAAkB,IAAI,CAAC,uBAAuB,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,CAAC;KAC3B;AACL,CAAC,CAAC;AAEF,YAAY,CAAC,SAAS,CAAC,6BAA6B,GAAG,UAAU,eAAwC;IACrG,MAAM,qBAAqB,GAAG,eAA+C,CAAC;IAC9E,IAAI,qBAAqB,EAAE;QACvB,eAAe,CAAC,OAAO,EAAE,CAAC;KAC7B;AACL,CAAC,CAAC;AAEF,YAAY,CAAC,SAAS,CAAC,qCAAqC,GAAG,UAAU,aAAqB,EAAE,OAAyB,EAAE,UAAkB;IACzI,IAAI,OAAO,EAAE;QACT,OAAO,GAAG,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;KAC5D;SAAM;QACH,OAAO,GAAG,EAAE,CAAC;KAChB;IACD,OAAO;QACH,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC;YACpC,IAAI,EAAE,OAAO,GAAG,aAAa;SAChC,CAAC;QACF,UAAU;KACb,CAAC;AACN,CAAC,CAAC","sourcesContent":["import { Logger } from \"core/Misc/logger\";\r\nimport type { IComputeEffectCreationOptions, IComputeShaderPath } from \"../../../Compute/computeEffect\";\r\nimport { ComputeEffect } from \"../../../Compute/computeEffect\";\r\nimport type { IComputeContext } from \"../../../Compute/IComputeContext\";\r\nimport type { IComputePipelineContext } from \"../../../Compute/IComputePipelineContext\";\r\nimport type { Nullable } from \"../../../types\";\r\nimport type { ComputeBindingList, ComputeBindingMapping } from \"../../Extensions/engine.computeShader\";\r\nimport { WebGPUEngine } from \"../../webgpuEngine\";\r\nimport { WebGPUComputeContext } from \"../webgpuComputeContext\";\r\nimport { WebGPUComputePipelineContext } from \"../webgpuComputePipelineContext\";\r\nimport * as WebGPUConstants from \"../webgpuConstants\";\r\nimport type { WebGPUPerfCounter } from \"../webgpuPerfCounter\";\r\n\r\ndeclare module \"../../webgpuEngine\" {\r\n export interface WebGPUEngine {\r\n /** @internal */\r\n _createComputePipelineStageDescriptor(computeShader: string, defines: Nullable<string>, entryPoint: string): GPUProgrammableStage;\r\n }\r\n}\r\n\r\nconst computePassDescriptor: GPUComputePassDescriptor = {};\r\n\r\nWebGPUEngine.prototype.createComputeContext = function (): IComputeContext | undefined {\r\n return new WebGPUComputeContext(this._device, this._cacheSampler);\r\n};\r\n\r\nWebGPUEngine.prototype.createComputeEffect = function (baseName: string | (IComputeShaderPath & { computeToken?: string }), options: IComputeEffectCreationOptions): ComputeEffect {\r\n const compute = typeof baseName === \"string\" ? baseName : baseName.computeToken || baseName.computeSource || baseName.computeElement || baseName.compute;\r\n\r\n const name = compute + \"@\" + options.defines;\r\n if (this._compiledComputeEffects[name]) {\r\n const compiledEffect = <ComputeEffect>this._compiledComputeEffects[name];\r\n if (options.onCompiled && compiledEffect.isReady()) {\r\n options.onCompiled(compiledEffect);\r\n }\r\n\r\n return compiledEffect;\r\n }\r\n const effect = new ComputeEffect(baseName, options, this, name);\r\n this._compiledComputeEffects[name] = effect;\r\n\r\n return effect;\r\n};\r\n\r\nWebGPUEngine.prototype.createComputePipelineContext = function (): IComputePipelineContext {\r\n return new WebGPUComputePipelineContext(this);\r\n};\r\n\r\nWebGPUEngine.prototype.areAllComputeEffectsReady = function (): boolean {\r\n for (const key in this._compiledComputeEffects) {\r\n const effect = this._compiledComputeEffects[key];\r\n\r\n if (!effect.isReady()) {\r\n return false;\r\n }\r\n }\r\n\r\n return true;\r\n};\r\n\r\nWebGPUEngine.prototype.computeDispatch = function (\r\n effect: ComputeEffect,\r\n context: IComputeContext,\r\n bindings: ComputeBindingList,\r\n x: number,\r\n y = 1,\r\n z = 1,\r\n bindingsMapping?: ComputeBindingMapping,\r\n gpuPerfCounter?: WebGPUPerfCounter\r\n): void {\r\n this._endCurrentRenderPass();\r\n\r\n const contextPipeline = effect._pipelineContext as WebGPUComputePipelineContext;\r\n const computeContext = context as WebGPUComputeContext;\r\n\r\n if (!contextPipeline.computePipeline) {\r\n contextPipeline.computePipeline = this._device.createComputePipeline({\r\n layout: WebGPUConstants.AutoLayoutMode.Auto,\r\n compute: contextPipeline.stage!,\r\n });\r\n }\r\n\r\n if (gpuPerfCounter) {\r\n this._timestampQuery.startPass(computePassDescriptor, this._timestampIndex);\r\n }\r\n\r\n const computePass = this._renderEncoder.beginComputePass(computePassDescriptor);\r\n\r\n computePass.setPipeline(contextPipeline.computePipeline);\r\n\r\n const bindGroups = computeContext.getBindGroups(bindings, contextPipeline.computePipeline, bindingsMapping);\r\n for (let i = 0; i < bindGroups.length; ++i) {\r\n const bindGroup = bindGroups[i];\r\n if (!bindGroup) {\r\n continue;\r\n }\r\n computePass.setBindGroup(i, bindGroup);\r\n }\r\n\r\n if (x + y + z > 0) {\r\n computePass.dispatchWorkgroups(x, y, z);\r\n }\r\n computePass.end();\r\n\r\n if (gpuPerfCounter) {\r\n this._timestampQuery.endPass(this._timestampIndex, gpuPerfCounter);\r\n this._timestampIndex += 2;\r\n }\r\n};\r\n\r\nWebGPUEngine.prototype.releaseComputeEffects = function () {\r\n for (const name in this._compiledComputeEffects) {\r\n const webGPUPipelineContextCompute = this._compiledComputeEffects[name].getPipelineContext() as WebGPUComputePipelineContext;\r\n this._deleteComputePipelineContext(webGPUPipelineContextCompute);\r\n }\r\n\r\n this._compiledComputeEffects = {};\r\n};\r\n\r\nWebGPUEngine.prototype._prepareComputePipelineContext = function (\r\n pipelineContext: IComputePipelineContext,\r\n computeSourceCode: string,\r\n rawComputeSourceCode: string,\r\n defines: Nullable<string>,\r\n entryPoint: string\r\n): void {\r\n const webGpuContext = pipelineContext as WebGPUComputePipelineContext;\r\n\r\n if (this.dbgShowShaderCode) {\r\n Logger.Log(defines!);\r\n Logger.Log(computeSourceCode);\r\n }\r\n\r\n webGpuContext.sources = {\r\n compute: computeSourceCode,\r\n rawCompute: rawComputeSourceCode,\r\n };\r\n\r\n webGpuContext.stage = this._createComputePipelineStageDescriptor(computeSourceCode, defines, entryPoint);\r\n};\r\n\r\nWebGPUEngine.prototype._releaseComputeEffect = function (effect: ComputeEffect): void {\r\n if (this._compiledComputeEffects[effect._key]) {\r\n delete this._compiledComputeEffects[effect._key];\r\n\r\n this._deleteComputePipelineContext(effect.getPipelineContext() as WebGPUComputePipelineContext);\r\n }\r\n};\r\n\r\nWebGPUEngine.prototype._rebuildComputeEffects = function (): void {\r\n for (const key in this._compiledComputeEffects) {\r\n const effect = this._compiledComputeEffects[key];\r\n\r\n effect._pipelineContext = null;\r\n effect._wasPreviouslyReady = false;\r\n effect._prepareEffect();\r\n }\r\n};\r\n\r\nWebGPUEngine.prototype._deleteComputePipelineContext = function (pipelineContext: IComputePipelineContext): void {\r\n const webgpuPipelineContext = pipelineContext as WebGPUComputePipelineContext;\r\n if (webgpuPipelineContext) {\r\n pipelineContext.dispose();\r\n }\r\n};\r\n\r\nWebGPUEngine.prototype._createComputePipelineStageDescriptor = function (computeShader: string, defines: Nullable<string>, entryPoint: string): GPUProgrammableStage {\r\n if (defines) {\r\n defines = \"//\" + defines.split(\"\\n\").join(\"\\n//\") + \"\\n\";\r\n } else {\r\n defines = \"\";\r\n }\r\n return {\r\n module: this._device.createShaderModule({\r\n code: defines + computeShader,\r\n }),\r\n entryPoint,\r\n };\r\n};\r\n"]}
|
|
1
|
+
{"version":3,"file":"engine.computeShader.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Engines/WebGPU/Extensions/engine.computeShader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,gCAAyB;AAE1C,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAK/D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,4BAA4B,EAAE,MAAM,iCAAiC,CAAC;AAC/E,OAAO,KAAK,eAAe,MAAM,oBAAoB,CAAC;AAUtD,MAAM,qBAAqB,GAA6B,EAAE,CAAC;AAE3D,YAAY,CAAC,SAAS,CAAC,oBAAoB,GAAG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,MAAM,EAAE,OAAO,CAAC,MAAM;aACzB,CAAC,CAAC;SACN;QACD,MAAM,CAAC,mBAAmB,CAAC,CAAC;IAChC,CAAC,CAAC,CAAC;AACP,CAAC,CAAC;AAEF,YAAY,CAAC,SAAS,CAAC,6BAA6B,GAAG,UAAU,eAAwC;IACrG,MAAM,qBAAqB,GAAG,eAA+C,CAAC;IAC9E,IAAI,qBAAqB,EAAE;QACvB,eAAe,CAAC,OAAO,EAAE,CAAC;KAC7B;AACL,CAAC,CAAC;AAEF,YAAY,CAAC,SAAS,CAAC,qCAAqC,GAAG,UAAU,aAAqB,EAAE,OAAyB,EAAE,UAAkB;IACzI,IAAI,OAAO,EAAE;QACT,OAAO,GAAG,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;KAC5D;SAAM;QACH,OAAO,GAAG,EAAE,CAAC;KAChB;IACD,OAAO;QACH,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC;YACpC,IAAI,EAAE,OAAO,GAAG,aAAa;SAChC,CAAC;QACF,UAAU;KACb,CAAC;AACN,CAAC,CAAC","sourcesContent":["import { Logger } from \"core/Misc/logger\";\r\nimport type { IComputeEffectCreationOptions, IComputeShaderPath } from \"../../../Compute/computeEffect\";\r\nimport { ComputeEffect } from \"../../../Compute/computeEffect\";\r\nimport type { IComputeContext } from \"../../../Compute/IComputeContext\";\r\nimport type { IComputePipelineContext } from \"../../../Compute/IComputePipelineContext\";\r\nimport type { Nullable } from \"../../../types\";\r\nimport type { ComputeBindingList, ComputeBindingMapping, ComputeCompilationMessages } from \"../../Extensions/engine.computeShader\";\r\nimport { WebGPUEngine } from \"../../webgpuEngine\";\r\nimport { WebGPUComputeContext } from \"../webgpuComputeContext\";\r\nimport { WebGPUComputePipelineContext } from \"../webgpuComputePipelineContext\";\r\nimport * as WebGPUConstants from \"../webgpuConstants\";\r\nimport type { WebGPUPerfCounter } from \"../webgpuPerfCounter\";\r\n\r\ndeclare module \"../../webgpuEngine\" {\r\n export interface WebGPUEngine {\r\n /** @internal */\r\n _createComputePipelineStageDescriptor(computeShader: string, defines: Nullable<string>, entryPoint: string): GPUProgrammableStage;\r\n }\r\n}\r\n\r\nconst computePassDescriptor: GPUComputePassDescriptor = {};\r\n\r\nWebGPUEngine.prototype.createComputeContext = function (): IComputeContext | undefined {\r\n return new WebGPUComputeContext(this._device, this._cacheSampler);\r\n};\r\n\r\nWebGPUEngine.prototype.createComputeEffect = function (baseName: string | (IComputeShaderPath & { computeToken?: string }), options: IComputeEffectCreationOptions): ComputeEffect {\r\n const compute = typeof baseName === \"string\" ? baseName : baseName.computeToken || baseName.computeSource || baseName.computeElement || baseName.compute;\r\n\r\n const name = compute + \"@\" + options.defines;\r\n if (this._compiledComputeEffects[name]) {\r\n const compiledEffect = <ComputeEffect>this._compiledComputeEffects[name];\r\n if (options.onCompiled && compiledEffect.isReady()) {\r\n options.onCompiled(compiledEffect);\r\n }\r\n\r\n return compiledEffect;\r\n }\r\n const effect = new ComputeEffect(baseName, options, this, name);\r\n this._compiledComputeEffects[name] = effect;\r\n\r\n return effect;\r\n};\r\n\r\nWebGPUEngine.prototype.createComputePipelineContext = function (): IComputePipelineContext {\r\n return new WebGPUComputePipelineContext(this);\r\n};\r\n\r\nWebGPUEngine.prototype.areAllComputeEffectsReady = function (): boolean {\r\n for (const key in this._compiledComputeEffects) {\r\n const effect = this._compiledComputeEffects[key];\r\n\r\n if (!effect.isReady()) {\r\n return false;\r\n }\r\n }\r\n\r\n return true;\r\n};\r\n\r\nWebGPUEngine.prototype.computeDispatch = function (\r\n effect: ComputeEffect,\r\n context: IComputeContext,\r\n bindings: ComputeBindingList,\r\n x: number,\r\n y = 1,\r\n z = 1,\r\n bindingsMapping?: ComputeBindingMapping,\r\n gpuPerfCounter?: WebGPUPerfCounter\r\n): void {\r\n this._endCurrentRenderPass();\r\n\r\n const contextPipeline = effect._pipelineContext as WebGPUComputePipelineContext;\r\n const computeContext = context as WebGPUComputeContext;\r\n\r\n if (!contextPipeline.computePipeline) {\r\n contextPipeline.computePipeline = this._device.createComputePipeline({\r\n layout: WebGPUConstants.AutoLayoutMode.Auto,\r\n compute: contextPipeline.stage!,\r\n });\r\n }\r\n\r\n if (gpuPerfCounter) {\r\n this._timestampQuery.startPass(computePassDescriptor, this._timestampIndex);\r\n }\r\n\r\n const computePass = this._renderEncoder.beginComputePass(computePassDescriptor);\r\n\r\n computePass.setPipeline(contextPipeline.computePipeline);\r\n\r\n const bindGroups = computeContext.getBindGroups(bindings, contextPipeline.computePipeline, bindingsMapping);\r\n for (let i = 0; i < bindGroups.length; ++i) {\r\n const bindGroup = bindGroups[i];\r\n if (!bindGroup) {\r\n continue;\r\n }\r\n computePass.setBindGroup(i, bindGroup);\r\n }\r\n\r\n if (x + y + z > 0) {\r\n computePass.dispatchWorkgroups(x, y, z);\r\n }\r\n computePass.end();\r\n\r\n if (gpuPerfCounter) {\r\n this._timestampQuery.endPass(this._timestampIndex, gpuPerfCounter);\r\n this._timestampIndex += 2;\r\n }\r\n};\r\n\r\nWebGPUEngine.prototype.releaseComputeEffects = function () {\r\n for (const name in this._compiledComputeEffects) {\r\n const webGPUPipelineContextCompute = this._compiledComputeEffects[name].getPipelineContext() as WebGPUComputePipelineContext;\r\n this._deleteComputePipelineContext(webGPUPipelineContextCompute);\r\n }\r\n\r\n this._compiledComputeEffects = {};\r\n};\r\n\r\nWebGPUEngine.prototype._prepareComputePipelineContext = function (\r\n pipelineContext: IComputePipelineContext,\r\n computeSourceCode: string,\r\n rawComputeSourceCode: string,\r\n defines: Nullable<string>,\r\n entryPoint: string\r\n): void {\r\n const webGpuContext = pipelineContext as WebGPUComputePipelineContext;\r\n\r\n if (this.dbgShowShaderCode) {\r\n Logger.Log(defines!);\r\n Logger.Log(computeSourceCode);\r\n }\r\n\r\n webGpuContext.sources = {\r\n compute: computeSourceCode,\r\n rawCompute: rawComputeSourceCode,\r\n };\r\n\r\n webGpuContext.stage = this._createComputePipelineStageDescriptor(computeSourceCode, defines, entryPoint);\r\n};\r\n\r\nWebGPUEngine.prototype._releaseComputeEffect = function (effect: ComputeEffect): void {\r\n if (this._compiledComputeEffects[effect._key]) {\r\n delete this._compiledComputeEffects[effect._key];\r\n\r\n this._deleteComputePipelineContext(effect.getPipelineContext() as WebGPUComputePipelineContext);\r\n }\r\n};\r\n\r\nWebGPUEngine.prototype._rebuildComputeEffects = function (): void {\r\n for (const key in this._compiledComputeEffects) {\r\n const effect = this._compiledComputeEffects[key];\r\n\r\n effect._pipelineContext = null;\r\n effect._wasPreviouslyReady = false;\r\n effect._prepareEffect();\r\n }\r\n};\r\n\r\nWebGPUEngine.prototype._executeWhenComputeStateIsCompiled = function (\r\n pipelineContext: WebGPUComputePipelineContext,\r\n action: (messages: Nullable<ComputeCompilationMessages>) => void\r\n): void {\r\n pipelineContext.stage!.module.getCompilationInfo().then((info) => {\r\n const compilationMessages: ComputeCompilationMessages = {\r\n numErrors: 0,\r\n messages: [],\r\n };\r\n for (const message of info.messages) {\r\n if (message.type === \"error\") {\r\n compilationMessages.numErrors++;\r\n }\r\n compilationMessages.messages.push({\r\n type: message.type,\r\n text: message.message,\r\n line: message.lineNum,\r\n column: message.linePos,\r\n length: message.length,\r\n offset: message.offset,\r\n });\r\n }\r\n action(compilationMessages);\r\n });\r\n};\r\n\r\nWebGPUEngine.prototype._deleteComputePipelineContext = function (pipelineContext: IComputePipelineContext): void {\r\n const webgpuPipelineContext = pipelineContext as WebGPUComputePipelineContext;\r\n if (webgpuPipelineContext) {\r\n pipelineContext.dispose();\r\n }\r\n};\r\n\r\nWebGPUEngine.prototype._createComputePipelineStageDescriptor = function (computeShader: string, defines: Nullable<string>, entryPoint: string): GPUProgrammableStage {\r\n if (defines) {\r\n defines = \"//\" + defines.split(\"\\n\").join(\"\\n//\") + \"\\n\";\r\n } else {\r\n defines = \"\";\r\n }\r\n return {\r\n module: this._device.createShaderModule({\r\n code: defines + computeShader,\r\n }),\r\n entryPoint,\r\n };\r\n};\r\n"]}
|
|
@@ -73,9 +73,8 @@ WebGPUEngine.prototype._createDepthStencilTexture = function (size, options) {
|
|
|
73
73
|
WebGPUEngine.prototype._setupDepthStencilTexture = function (internalTexture, size, generateStencil, bilinearFiltering, comparisonFunction, samples = 1) {
|
|
74
74
|
const width = size.width || size;
|
|
75
75
|
const height = size.height || size;
|
|
76
|
-
|
|
77
|
-
const
|
|
78
|
-
const depth = 0;
|
|
76
|
+
const layers = size.layers || 0;
|
|
77
|
+
const depth = size.depth || 0;
|
|
79
78
|
internalTexture.baseWidth = width;
|
|
80
79
|
internalTexture.baseHeight = height;
|
|
81
80
|
internalTexture.width = width;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.renderTarget.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Engines/WebGPU/Extensions/engine.renderTarget.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,6CAA6C,CAAC;AAGrG,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAE7D,YAAY,CAAC,SAAS,CAAC,kCAAkC,GAAG,UAAU,OAAgB,EAAE,MAAe,EAAE,IAAiB;IACtH,MAAM,SAAS,GAAG,IAAI,yBAAyB,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC7E,IAAI,CAAC,yBAAyB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC/C,OAAO,SAAS,CAAC;AACrB,CAAC,CAAC;AAEF,YAAY,CAAC,SAAS,CAAC,yBAAyB,GAAG,UAAU,IAAiB,EAAE,OAA8C;IAC1H,MAAM,SAAS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AAG,UAAU,SAAwC,EAAE,OAAe;IAC7H,IAAI,CAAC,SAAS,IAAI,CAAC,SAAS,CAAC,OAAO,IAAI,SAAS,CAAC,OAAO,KAAK,OAAO,EAAE;QACnE,OAAO,OAAO,CAAC;KAClB;IAED,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,cAAc,CAAC,CAAC;IAE3D,IAAI,CAAC,cAAc,CAAC,iBAAiB,CAAC,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAElE,IAAI,SAAS,CAAC,oBAAoB,EAAE;QAChC,IAAI,CAAC,cAAc,CAAC,iBAAiB,CAAC,SAAS,CAAC,oBAAoB,EAAE,OAAO,CAAC,CAAC;QAC/E,SAAS,CAAC,oBAAoB,CAAC,OAAO,GAAG,OAAO,CAAC;KACpD;IAED,SAAS,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC7B,SAAS,CAAC,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC;IAEpC,OAAO,OAAO,CAAC;AACnB,CAAC,CAAC","sourcesContent":["import { InternalTexture, InternalTextureSource } from \"../../../Materials/Textures/internalTexture\";\r\nimport type { RenderTargetCreationOptions, DepthTextureCreationOptions, TextureSize } from \"../../../Materials/Textures/textureCreationOptions\";\r\nimport type { Nullable } from \"../../../types\";\r\nimport { Constants } from \"../../constants\";\r\nimport type { RenderTargetWrapper } from \"../../renderTargetWrapper\";\r\nimport { WebGPUEngine } from \"../../webgpuEngine\";\r\nimport type { WebGPUHardwareTexture } from \"../webgpuHardwareTexture\";\r\nimport { WebGPURenderTargetWrapper } from \"../webgpuRenderTargetWrapper\";\r\nimport { WebGPUTextureHelper } from \"../webgpuTextureHelper\";\r\n\r\nWebGPUEngine.prototype._createHardwareRenderTargetWrapper = function (isMulti: boolean, isCube: boolean, size: TextureSize): WebGPURenderTargetWrapper {\r\n const rtWrapper = new WebGPURenderTargetWrapper(isMulti, isCube, size, this);\r\n this._renderTargetWrapperCache.push(rtWrapper);\r\n return rtWrapper;\r\n};\r\n\r\nWebGPUEngine.prototype.createRenderTargetTexture = function (size: TextureSize, options: boolean | RenderTargetCreationOptions): WebGPURenderTargetWrapper {\r\n const rtWrapper = this._createHardwareRenderTargetWrapper(false, false, size) as WebGPURenderTargetWrapper;\r\n\r\n const fullOptions: RenderTargetCreationOptions = {};\r\n\r\n if (options !== undefined && typeof options === \"object\") {\r\n fullOptions.generateMipMaps = options.generateMipMaps;\r\n fullOptions.generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;\r\n fullOptions.generateStencilBuffer = fullOptions.generateDepthBuffer && options.generateStencilBuffer;\r\n fullOptions.samplingMode = options.samplingMode === undefined ? Constants.TEXTURE_TRILINEAR_SAMPLINGMODE : options.samplingMode;\r\n fullOptions.creationFlags = options.creationFlags ?? 0;\r\n fullOptions.noColorAttachment = !!options.noColorAttachment;\r\n fullOptions.samples = options.samples;\r\n fullOptions.label = options.label;\r\n } else {\r\n fullOptions.generateMipMaps = <boolean>options;\r\n fullOptions.generateDepthBuffer = true;\r\n fullOptions.generateStencilBuffer = false;\r\n fullOptions.samplingMode = Constants.TEXTURE_TRILINEAR_SAMPLINGMODE;\r\n fullOptions.creationFlags = 0;\r\n fullOptions.noColorAttachment = false;\r\n }\r\n\r\n const texture = fullOptions.noColorAttachment ? null : this._createInternalTexture(size, options, true, InternalTextureSource.RenderTarget);\r\n\r\n rtWrapper.label = fullOptions.label ?? \"RenderTargetWrapper\";\r\n rtWrapper._samples = fullOptions.samples ?? 1;\r\n rtWrapper._generateDepthBuffer = fullOptions.generateDepthBuffer;\r\n rtWrapper._generateStencilBuffer = fullOptions.generateStencilBuffer ? true : false;\r\n\r\n rtWrapper.setTextures(texture);\r\n\r\n if (rtWrapper._generateDepthBuffer || rtWrapper._generateStencilBuffer) {\r\n rtWrapper.createDepthStencilTexture(\r\n 0,\r\n false, // force false as filtering is not supported for depth textures\r\n rtWrapper._generateStencilBuffer,\r\n rtWrapper.samples,\r\n fullOptions.generateStencilBuffer ? Constants.TEXTUREFORMAT_DEPTH24_STENCIL8 : Constants.TEXTUREFORMAT_DEPTH32_FLOAT,\r\n fullOptions.label ? fullOptions.label + \"-DepthStencil\" : undefined\r\n );\r\n }\r\n\r\n if (texture) {\r\n if (options !== undefined && typeof options === \"object\" && options.createMipMaps && !fullOptions.generateMipMaps) {\r\n texture.generateMipMaps = true;\r\n }\r\n\r\n this._textureHelper.createGPUTextureForInternalTexture(texture, undefined, undefined, undefined, fullOptions.creationFlags);\r\n\r\n if (options !== undefined && typeof options === \"object\" && options.createMipMaps && !fullOptions.generateMipMaps) {\r\n texture.generateMipMaps = false;\r\n }\r\n }\r\n\r\n return rtWrapper;\r\n};\r\n\r\nWebGPUEngine.prototype._createDepthStencilTexture = function (size: TextureSize, options: DepthTextureCreationOptions): InternalTexture {\r\n const internalTexture = new InternalTexture(this, options.generateStencil ? InternalTextureSource.DepthStencil : InternalTextureSource.Depth);\r\n\r\n internalTexture.label = options.label;\r\n\r\n const internalOptions = {\r\n bilinearFiltering: false,\r\n comparisonFunction: 0,\r\n generateStencil: false,\r\n samples: 1,\r\n depthTextureFormat: options.generateStencil ? Constants.TEXTUREFORMAT_DEPTH24_STENCIL8 : Constants.TEXTUREFORMAT_DEPTH32_FLOAT,\r\n ...options,\r\n };\r\n\r\n internalTexture.format = internalOptions.depthTextureFormat;\r\n\r\n this._setupDepthStencilTexture(\r\n internalTexture,\r\n size,\r\n internalOptions.generateStencil,\r\n internalOptions.bilinearFiltering,\r\n internalOptions.comparisonFunction,\r\n internalOptions.samples\r\n );\r\n\r\n this._textureHelper.createGPUTextureForInternalTexture(internalTexture);\r\n\r\n // Now that the hardware texture is created, we can retrieve the GPU format and set the right type to the internal texture\r\n const gpuTextureWrapper = internalTexture._hardwareTexture as WebGPUHardwareTexture;\r\n\r\n internalTexture.type = WebGPUTextureHelper.GetTextureTypeFromFormat(gpuTextureWrapper.format);\r\n\r\n this._internalTexturesCache.push(internalTexture);\r\n\r\n return internalTexture;\r\n};\r\n\r\nWebGPUEngine.prototype._setupDepthStencilTexture = function (\r\n internalTexture: InternalTexture,\r\n size: TextureSize,\r\n generateStencil: boolean,\r\n bilinearFiltering: boolean,\r\n comparisonFunction: number,\r\n samples = 1\r\n): void {\r\n const width = (<{ width: number; height: number; layers?: number }>size).width || <number>size;\r\n const height = (<{ width: number; height: number; layers?: number }>size).height || <number>size;\r\n\r\n // Only 2D textures are supported for depth/stencil\r\n const layers = 0;\r\n const depth = 0;\r\n\r\n internalTexture.baseWidth = width;\r\n internalTexture.baseHeight = height;\r\n internalTexture.width = width;\r\n internalTexture.height = height;\r\n internalTexture.is2DArray = layers > 0;\r\n internalTexture.is3D = depth > 0;\r\n internalTexture.depth = layers || depth;\r\n internalTexture.isReady = true;\r\n internalTexture.samples = samples;\r\n internalTexture.generateMipMaps = false;\r\n internalTexture.samplingMode = bilinearFiltering ? Constants.TEXTURE_BILINEAR_SAMPLINGMODE : Constants.TEXTURE_NEAREST_SAMPLINGMODE;\r\n internalTexture.type = Constants.TEXTURETYPE_FLOAT;\r\n internalTexture._comparisonFunction = comparisonFunction;\r\n internalTexture._cachedWrapU = Constants.TEXTURE_CLAMP_ADDRESSMODE;\r\n internalTexture._cachedWrapV = Constants.TEXTURE_CLAMP_ADDRESSMODE;\r\n};\r\n\r\nWebGPUEngine.prototype.updateRenderTargetTextureSampleCount = function (rtWrapper: Nullable<RenderTargetWrapper>, samples: number): number {\r\n if (!rtWrapper || !rtWrapper.texture || rtWrapper.samples === samples) {\r\n return samples;\r\n }\r\n\r\n samples = Math.min(samples, this.getCaps().maxMSAASamples);\r\n\r\n this._textureHelper.createMSAATexture(rtWrapper.texture, samples);\r\n\r\n if (rtWrapper._depthStencilTexture) {\r\n this._textureHelper.createMSAATexture(rtWrapper._depthStencilTexture, samples);\r\n rtWrapper._depthStencilTexture.samples = samples;\r\n }\r\n\r\n rtWrapper._samples = samples;\r\n rtWrapper.texture.samples = samples;\r\n\r\n return samples;\r\n};\r\n"]}
|
|
1
|
+
{"version":3,"file":"engine.renderTarget.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Engines/WebGPU/Extensions/engine.renderTarget.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,6CAA6C,CAAC;AAGrG,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAE7D,YAAY,CAAC,SAAS,CAAC,kCAAkC,GAAG,UAAU,OAAgB,EAAE,MAAe,EAAE,IAAiB;IACtH,MAAM,SAAS,GAAG,IAAI,yBAAyB,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC7E,IAAI,CAAC,yBAAyB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC/C,OAAO,SAAS,CAAC;AACrB,CAAC,CAAC;AAEF,YAAY,CAAC,SAAS,CAAC,yBAAyB,GAAG,UAAU,IAAiB,EAAE,OAA8C;IAC1H,MAAM,SAAS,GAAG,IAAI,CAAC,kCAAkC,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,CAA8B,CAAC;IAE3G,MAAM,WAAW,GAAgC,EAAE,CAAC;IAEpD,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE;QACtD,WAAW,CAAC,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC;QACtD,WAAW,CAAC,mBAAmB,GAAG,OAAO,CAAC,mBAAmB,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,mBAAmB,CAAC;QACjH,WAAW,CAAC,qBAAqB,GAAG,WAAW,CAAC,mBAAmB,IAAI,O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CAAC,cAAc,CAAC,iBAAiB,CAAC,SAAS,CAAC,oBAAoB,EAAE,OAAO,CAAC,CAAC;QAC/E,SAAS,CAAC,oBAAoB,CAAC,OAAO,GAAG,OAAO,CAAC;KACpD;IAED,SAAS,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC7B,SAAS,CAAC,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC;IAEpC,OAAO,OAAO,CAAC;AACnB,CAAC,CAAC","sourcesContent":["import { InternalTexture, InternalTextureSource } from \"../../../Materials/Textures/internalTexture\";\r\nimport type { RenderTargetCreationOptions, DepthTextureCreationOptions, TextureSize } from \"../../../Materials/Textures/textureCreationOptions\";\r\nimport type { Nullable } from \"../../../types\";\r\nimport { Constants } from \"../../constants\";\r\nimport type { RenderTargetWrapper } from \"../../renderTargetWrapper\";\r\nimport { WebGPUEngine } from \"../../webgpuEngine\";\r\nimport type { WebGPUHardwareTexture } from \"../webgpuHardwareTexture\";\r\nimport { WebGPURenderTargetWrapper } from \"../webgpuRenderTargetWrapper\";\r\nimport { WebGPUTextureHelper } from \"../webgpuTextureHelper\";\r\n\r\nWebGPUEngine.prototype._createHardwareRenderTargetWrapper = function (isMulti: boolean, isCube: boolean, size: TextureSize): WebGPURenderTargetWrapper {\r\n const rtWrapper = new WebGPURenderTargetWrapper(isMulti, isCube, size, this);\r\n this._renderTargetWrapperCache.push(rtWrapper);\r\n return rtWrapper;\r\n};\r\n\r\nWebGPUEngine.prototype.createRenderTargetTexture = function (size: TextureSize, options: boolean | RenderTargetCreationOptions): WebGPURenderTargetWrapper {\r\n const rtWrapper = this._createHardwareRenderTargetWrapper(false, false, size) as WebGPURenderTargetWrapper;\r\n\r\n const fullOptions: RenderTargetCreationOptions = {};\r\n\r\n if (options !== undefined && typeof options === \"object\") {\r\n fullOptions.generateMipMaps = options.generateMipMaps;\r\n fullOptions.generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;\r\n fullOptions.generateStencilBuffer = fullOptions.generateDepthBuffer && options.generateStencilBuffer;\r\n fullOptions.samplingMode = options.samplingMode === undefined ? Constants.TEXTURE_TRILINEAR_SAMPLINGMODE : options.samplingMode;\r\n fullOptions.creationFlags = options.creationFlags ?? 0;\r\n fullOptions.noColorAttachment = !!options.noColorAttachment;\r\n fullOptions.samples = options.samples;\r\n fullOptions.label = options.label;\r\n } else {\r\n fullOptions.generateMipMaps = <boolean>options;\r\n fullOptions.generateDepthBuffer = true;\r\n fullOptions.generateStencilBuffer = false;\r\n fullOptions.samplingMode = Constants.TEXTURE_TRILINEAR_SAMPLINGMODE;\r\n fullOptions.creationFlags = 0;\r\n fullOptions.noColorAttachment = false;\r\n }\r\n\r\n const texture = fullOptions.noColorAttachment ? null : this._createInternalTexture(size, options, true, InternalTextureSource.RenderTarget);\r\n\r\n rtWrapper.label = fullOptions.label ?? \"RenderTargetWrapper\";\r\n rtWrapper._samples = fullOptions.samples ?? 1;\r\n rtWrapper._generateDepthBuffer = fullOptions.generateDepthBuffer;\r\n rtWrapper._generateStencilBuffer = fullOptions.generateStencilBuffer ? true : false;\r\n\r\n rtWrapper.setTextures(texture);\r\n\r\n if (rtWrapper._generateDepthBuffer || rtWrapper._generateStencilBuffer) {\r\n rtWrapper.createDepthStencilTexture(\r\n 0,\r\n false, // force false as filtering is not supported for depth textures\r\n rtWrapper._generateStencilBuffer,\r\n rtWrapper.samples,\r\n fullOptions.generateStencilBuffer ? Constants.TEXTUREFORMAT_DEPTH24_STENCIL8 : Constants.TEXTUREFORMAT_DEPTH32_FLOAT,\r\n fullOptions.label ? fullOptions.label + \"-DepthStencil\" : undefined\r\n );\r\n }\r\n\r\n if (texture) {\r\n if (options !== undefined && typeof options === \"object\" && options.createMipMaps && !fullOptions.generateMipMaps) {\r\n texture.generateMipMaps = true;\r\n }\r\n\r\n this._textureHelper.createGPUTextureForInternalTexture(texture, undefined, undefined, undefined, fullOptions.creationFlags);\r\n\r\n if (options !== undefined && typeof options === \"object\" && options.createMipMaps && !fullOptions.generateMipMaps) {\r\n texture.generateMipMaps = false;\r\n }\r\n }\r\n\r\n return rtWrapper;\r\n};\r\n\r\nWebGPUEngine.prototype._createDepthStencilTexture = function (size: TextureSize, options: DepthTextureCreationOptions): InternalTexture {\r\n const internalTexture = new InternalTexture(this, options.generateStencil ? InternalTextureSource.DepthStencil : InternalTextureSource.Depth);\r\n\r\n internalTexture.label = options.label;\r\n\r\n const internalOptions = {\r\n bilinearFiltering: false,\r\n comparisonFunction: 0,\r\n generateStencil: false,\r\n samples: 1,\r\n depthTextureFormat: options.generateStencil ? Constants.TEXTUREFORMAT_DEPTH24_STENCIL8 : Constants.TEXTUREFORMAT_DEPTH32_FLOAT,\r\n ...options,\r\n };\r\n\r\n internalTexture.format = internalOptions.depthTextureFormat;\r\n\r\n this._setupDepthStencilTexture(\r\n internalTexture,\r\n size,\r\n internalOptions.generateStencil,\r\n internalOptions.bilinearFiltering,\r\n internalOptions.comparisonFunction,\r\n internalOptions.samples\r\n );\r\n\r\n this._textureHelper.createGPUTextureForInternalTexture(internalTexture);\r\n\r\n // Now that the hardware texture is created, we can retrieve the GPU format and set the right type to the internal texture\r\n const gpuTextureWrapper = internalTexture._hardwareTexture as WebGPUHardwareTexture;\r\n\r\n internalTexture.type = WebGPUTextureHelper.GetTextureTypeFromFormat(gpuTextureWrapper.format);\r\n\r\n this._internalTexturesCache.push(internalTexture);\r\n\r\n return internalTexture;\r\n};\r\n\r\nWebGPUEngine.prototype._setupDepthStencilTexture = function (\r\n internalTexture: InternalTexture,\r\n size: TextureSize,\r\n generateStencil: boolean,\r\n bilinearFiltering: boolean,\r\n comparisonFunction: number,\r\n samples = 1\r\n): void {\r\n const width = (<{ width: number; height: number; layers?: number }>size).width || <number>size;\r\n const height = (<{ width: number; height: number; layers?: number }>size).height || <number>size;\r\n const layers = (<{ width: number; height: number; depth?: number; layers?: number }>size).layers || 0;\r\n const depth = (<{ width: number; height: number; depth?: number; layers?: number }>size).depth || 0;\r\n\r\n internalTexture.baseWidth = width;\r\n internalTexture.baseHeight = height;\r\n internalTexture.width = width;\r\n internalTexture.height = height;\r\n internalTexture.is2DArray = layers > 0;\r\n internalTexture.is3D = depth > 0;\r\n internalTexture.depth = layers || depth;\r\n internalTexture.isReady = true;\r\n internalTexture.samples = samples;\r\n internalTexture.generateMipMaps = false;\r\n internalTexture.samplingMode = bilinearFiltering ? Constants.TEXTURE_BILINEAR_SAMPLINGMODE : Constants.TEXTURE_NEAREST_SAMPLINGMODE;\r\n internalTexture.type = Constants.TEXTURETYPE_FLOAT;\r\n internalTexture._comparisonFunction = comparisonFunction;\r\n internalTexture._cachedWrapU = Constants.TEXTURE_CLAMP_ADDRESSMODE;\r\n internalTexture._cachedWrapV = Constants.TEXTURE_CLAMP_ADDRESSMODE;\r\n};\r\n\r\nWebGPUEngine.prototype.updateRenderTargetTextureSampleCount = function (rtWrapper: Nullable<RenderTargetWrapper>, samples: number): number {\r\n if (!rtWrapper || !rtWrapper.texture || rtWrapper.samples === samples) {\r\n return samples;\r\n }\r\n\r\n samples = Math.min(samples, this.getCaps().maxMSAASamples);\r\n\r\n this._textureHelper.createMSAATexture(rtWrapper.texture, samples);\r\n\r\n if (rtWrapper._depthStencilTexture) {\r\n this._textureHelper.createMSAATexture(rtWrapper._depthStencilTexture, samples);\r\n rtWrapper._depthStencilTexture.samples = samples;\r\n }\r\n\r\n rtWrapper._samples = samples;\r\n rtWrapper.texture.samples = samples;\r\n\r\n return samples;\r\n};\r\n"]}
|
|
@@ -4,9 +4,11 @@ export class WebGPUComputePipelineContext {
|
|
|
4
4
|
return false;
|
|
5
5
|
}
|
|
6
6
|
get isReady() {
|
|
7
|
-
if (this.
|
|
8
|
-
return true
|
|
7
|
+
if (this.isAsync) {
|
|
8
|
+
// When async mode is implemented, this should return true if the pipeline is ready
|
|
9
|
+
return false;
|
|
9
10
|
}
|
|
11
|
+
// In synchronous mode, we return false, the readiness being determined by ComputeEffect
|
|
10
12
|
return false;
|
|
11
13
|
}
|
|
12
14
|
constructor(engine) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgpuComputePipelineContext.js","sourceRoot":"","sources":["../../../../../dev/core/src/Engines/WebGPU/webgpuComputePipelineContext.ts"],"names":[],"mappings":"AAIA,gBAAgB;AAChB,MAAM,OAAO,4BAA4B;IAYrC,IAAW,OAAO;QACd,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,IAAW,OAAO;QACd,IAAI,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"webgpuComputePipelineContext.js","sourceRoot":"","sources":["../../../../../dev/core/src/Engines/WebGPU/webgpuComputePipelineContext.ts"],"names":[],"mappings":"AAIA,gBAAgB;AAChB,MAAM,OAAO,4BAA4B;IAYrC,IAAW,OAAO;QACd,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,IAAW,OAAO;QACd,IAAI,IAAI,CAAC,OAAO,EAAE;YACd,mFAAmF;YACnF,OAAO,KAAK,CAAC;SAChB;QAED,wFAAwF;QACxF,OAAO,KAAK,CAAC;IACjB,CAAC;IAKD,YAAY,MAAoB;QAC5B,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;IAEM,qBAAqB;QACxB,OAAO,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC;IACjC,CAAC;IAEM,OAAO,KAAU,CAAC;CAC5B","sourcesContent":["import type { IComputePipelineContext } from \"../../Compute/IComputePipelineContext\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { WebGPUEngine } from \"../webgpuEngine\";\r\n\r\n/** @internal */\r\nexport class WebGPUComputePipelineContext implements IComputePipelineContext {\r\n public engine: WebGPUEngine;\r\n\r\n public sources: {\r\n compute: string;\r\n rawCompute: string;\r\n };\r\n\r\n public stage: Nullable<GPUProgrammableStage>;\r\n\r\n public computePipeline: GPUComputePipeline;\r\n\r\n public get isAsync() {\r\n return false;\r\n }\r\n\r\n public get isReady(): boolean {\r\n if (this.isAsync) {\r\n // When async mode is implemented, this should return true if the pipeline is ready\r\n return false;\r\n }\r\n\r\n // In synchronous mode, we return false, the readiness being determined by ComputeEffect\r\n return false;\r\n }\r\n\r\n /** @internal */\r\n public _name: string;\r\n\r\n constructor(engine: WebGPUEngine) {\r\n this._name = \"unnamed\";\r\n this.engine = engine;\r\n }\r\n\r\n public _getComputeShaderCode(): string | null {\r\n return this.sources?.compute;\r\n }\r\n\r\n public dispose(): void {}\r\n}\r\n"]}
|
|
@@ -37,6 +37,7 @@ export declare class WebGPUShaderProcessorWGSL extends WebGPUShaderProcessor {
|
|
|
37
37
|
}): [string, string, number];
|
|
38
38
|
initializeShaders(processingContext: Nullable<ShaderProcessingContext>): void;
|
|
39
39
|
preProcessShaderCode(code: string): string;
|
|
40
|
+
varyingCheck(varying: string, isFragment: boolean): boolean;
|
|
40
41
|
varyingProcessor(varying: string, isFragment: boolean, preProcessors: {
|
|
41
42
|
[key: string]: string;
|
|
42
43
|
}): string;
|
|
@@ -87,6 +87,10 @@ export class WebGPUShaderProcessorWGSL extends WebGPUShaderProcessor {
|
|
|
87
87
|
const alreadyInjected = code.indexOf(ubDeclaration) !== -1;
|
|
88
88
|
return alreadyInjected ? code : ubDeclaration + RemoveComments(code);
|
|
89
89
|
}
|
|
90
|
+
varyingCheck(varying, isFragment) {
|
|
91
|
+
const regex = /(flat|linear|perspective)?\s*(center|centroid|sample)?\s*\bvarying\b/;
|
|
92
|
+
return regex.test(varying);
|
|
93
|
+
}
|
|
90
94
|
varyingProcessor(varying, isFragment, preProcessors) {
|
|
91
95
|
const varyingRegex = /\s*(flat|linear|perspective)?\s*(center|centroid|sample)?\s*varying\s+(?:(?:highp)?|(?:lowp)?)\s*(\S+)\s*:\s*(.+)\s*;/gm;
|
|
92
96
|
const match = varyingRegex.exec(varying);
|
|
@@ -95,6 +99,7 @@ export class WebGPUShaderProcessorWGSL extends WebGPUShaderProcessor {
|
|
|
95
99
|
const interpolationSampling = match[2] ?? "center";
|
|
96
100
|
const varyingType = match[4];
|
|
97
101
|
const name = match[3];
|
|
102
|
+
const interpolation = interpolationType === "flat" ? `@interpolate(${interpolationType})` : `@interpolate(${interpolationType}, ${interpolationSampling})`;
|
|
98
103
|
let location;
|
|
99
104
|
if (isFragment) {
|
|
100
105
|
location = this._webgpuProcessingContext.availableVaryings[name];
|
|
@@ -105,7 +110,7 @@ export class WebGPUShaderProcessorWGSL extends WebGPUShaderProcessor {
|
|
|
105
110
|
else {
|
|
106
111
|
location = this._webgpuProcessingContext.getVaryingNextLocation(varyingType, this._getArraySize(name, varyingType, preProcessors)[2]);
|
|
107
112
|
this._webgpuProcessingContext.availableVaryings[name] = location;
|
|
108
|
-
this._varyingsWGSL.push(` @location(${location})
|
|
113
|
+
this._varyingsWGSL.push(` @location(${location}) ${interpolation} ${name} : ${varyingType},`);
|
|
109
114
|
this._varyingNamesWGSL.push(name);
|
|
110
115
|
}
|
|
111
116
|
varying = "";
|