@babylonjs/core 6.49.0 → 7.1.0

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.
Files changed (121) hide show
  1. package/Animations/runtimeAnimation.js +10 -3
  2. package/Animations/runtimeAnimation.js.map +1 -1
  3. package/Compute/computeEffect.d.ts +24 -2
  4. package/Compute/computeEffect.js +5 -9
  5. package/Compute/computeEffect.js.map +1 -1
  6. package/Compute/computeShader.d.ts +4 -4
  7. package/Compute/computeShader.js +1 -1
  8. package/Compute/computeShader.js.map +1 -1
  9. package/Engines/Extensions/engine.computeShader.d.ts +7 -2
  10. package/Engines/Extensions/engine.computeShader.js.map +1 -1
  11. package/Engines/Extensions/engine.multiRender.js +1 -1
  12. package/Engines/Extensions/engine.multiRender.js.map +1 -1
  13. package/Engines/Extensions/engine.renderTarget.js +12 -2
  14. package/Engines/Extensions/engine.renderTarget.js.map +1 -1
  15. package/Engines/WebGPU/Extensions/engine.computeShader.js +1 -1
  16. package/Engines/WebGPU/Extensions/engine.computeShader.js.map +1 -1
  17. package/Engines/WebGPU/Extensions/engine.multiRender.js +1 -1
  18. package/Engines/WebGPU/Extensions/engine.multiRender.js.map +1 -1
  19. package/Engines/WebGPU/Extensions/engine.renderTarget.js +5 -2
  20. package/Engines/WebGPU/Extensions/engine.renderTarget.js.map +1 -1
  21. package/Engines/WebGPU/webgpuClearQuad.d.ts +2 -2
  22. package/Engines/WebGPU/webgpuClearQuad.js +8 -3
  23. package/Engines/WebGPU/webgpuClearQuad.js.map +1 -1
  24. package/Engines/WebGPU/webgpuHardwareTexture.js +1 -0
  25. package/Engines/WebGPU/webgpuHardwareTexture.js.map +1 -1
  26. package/Engines/WebGPU/webgpuShaderProcessor.js +15 -0
  27. package/Engines/WebGPU/webgpuShaderProcessor.js.map +1 -1
  28. package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js +4 -1
  29. package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js.map +1 -1
  30. package/Engines/WebGPU/webgpuTextureManager.d.ts +1 -1
  31. package/Engines/WebGPU/webgpuTextureManager.js +6 -6
  32. package/Engines/WebGPU/webgpuTextureManager.js.map +1 -1
  33. package/Engines/nativeEngine.d.ts +1 -0
  34. package/Engines/nativeEngine.js.map +1 -1
  35. package/Engines/nullEngine.d.ts +1 -0
  36. package/Engines/nullEngine.js.map +1 -1
  37. package/Engines/renderTargetWrapper.d.ts +8 -0
  38. package/Engines/renderTargetWrapper.js +14 -1
  39. package/Engines/renderTargetWrapper.js.map +1 -1
  40. package/Engines/thinEngine.d.ts +6 -7
  41. package/Engines/thinEngine.js +25 -11
  42. package/Engines/thinEngine.js.map +1 -1
  43. package/Engines/webgpuEngine.d.ts +5 -2
  44. package/Engines/webgpuEngine.js +19 -8
  45. package/Engines/webgpuEngine.js.map +1 -1
  46. package/Materials/Node/Blocks/Dual/textureBlock.js +5 -0
  47. package/Materials/Node/Blocks/Dual/textureBlock.js.map +1 -1
  48. package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js +2 -0
  49. package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js.map +1 -1
  50. package/Materials/Node/Blocks/addBlock.d.ts +2 -15
  51. package/Materials/Node/Blocks/addBlock.js +4 -32
  52. package/Materials/Node/Blocks/addBlock.js.map +1 -1
  53. package/Materials/Node/Blocks/baseMathBlock.d.ts +26 -0
  54. package/Materials/Node/Blocks/baseMathBlock.js +84 -0
  55. package/Materials/Node/Blocks/baseMathBlock.js.map +1 -0
  56. package/Materials/Node/Blocks/divideBlock.d.ts +2 -15
  57. package/Materials/Node/Blocks/divideBlock.js +4 -32
  58. package/Materials/Node/Blocks/divideBlock.js.map +1 -1
  59. package/Materials/Node/Blocks/multiplyBlock.d.ts +2 -15
  60. package/Materials/Node/Blocks/multiplyBlock.js +4 -32
  61. package/Materials/Node/Blocks/multiplyBlock.js.map +1 -1
  62. package/Materials/Node/Blocks/subtractBlock.d.ts +2 -15
  63. package/Materials/Node/Blocks/subtractBlock.js +4 -32
  64. package/Materials/Node/Blocks/subtractBlock.js.map +1 -1
  65. package/Materials/Node/nodeMaterialBlockConnectionPoint.d.ts +4 -0
  66. package/Materials/Node/nodeMaterialBlockConnectionPoint.js +7 -0
  67. package/Materials/Node/nodeMaterialBlockConnectionPoint.js.map +1 -1
  68. package/Materials/Node/nodeMaterialBuildState.js +1 -1
  69. package/Materials/Node/nodeMaterialBuildState.js.map +1 -1
  70. package/Materials/Textures/renderTargetTexture.d.ts +6 -23
  71. package/Materials/Textures/renderTargetTexture.js +10 -6
  72. package/Materials/Textures/renderTargetTexture.js.map +1 -1
  73. package/Materials/Textures/texture.d.ts +5 -2
  74. package/Materials/Textures/texture.js +10 -5
  75. package/Materials/Textures/texture.js.map +1 -1
  76. package/Materials/Textures/textureCreationOptions.d.ts +1 -0
  77. package/Materials/Textures/textureCreationOptions.js.map +1 -1
  78. package/Materials/effect.d.ts +37 -2
  79. package/Materials/effect.js +10 -14
  80. package/Materials/effect.js.map +1 -1
  81. package/Materials/shaderMaterial.d.ts +5 -9
  82. package/Materials/shaderMaterial.js +2 -6
  83. package/Materials/shaderMaterial.js.map +1 -1
  84. package/Meshes/Builders/ribbonBuilder.js +32 -28
  85. package/Meshes/Builders/ribbonBuilder.js.map +1 -1
  86. package/Meshes/GreasedLine/greasedLineBaseMesh.d.ts +4 -3
  87. package/Meshes/GreasedLine/greasedLineBaseMesh.js +1 -1
  88. package/Meshes/GreasedLine/greasedLineBaseMesh.js.map +1 -1
  89. package/Meshes/GreasedLine/greasedLineMesh.d.ts +0 -2
  90. package/Meshes/GreasedLine/greasedLineMesh.js +85 -77
  91. package/Meshes/GreasedLine/greasedLineMesh.js.map +1 -1
  92. package/Meshes/GreasedLine/greasedLineRibbonMesh.js +9 -3
  93. package/Meshes/GreasedLine/greasedLineRibbonMesh.js.map +1 -1
  94. package/Meshes/Node/Blocks/mathBlock.d.ts +6 -0
  95. package/Meshes/Node/Blocks/mathBlock.js +95 -23
  96. package/Meshes/Node/Blocks/mathBlock.js.map +1 -1
  97. package/Meshes/Node/nodeGeometryBlockConnectionPoint.d.ts +4 -0
  98. package/Meshes/Node/nodeGeometryBlockConnectionPoint.js +7 -0
  99. package/Meshes/Node/nodeGeometryBlockConnectionPoint.js.map +1 -1
  100. package/Misc/greasedLineTools.d.ts +6 -0
  101. package/Misc/greasedLineTools.js +21 -0
  102. package/Misc/greasedLineTools.js.map +1 -1
  103. package/Rendering/reflectiveShadowMap.js +1 -1
  104. package/Rendering/reflectiveShadowMap.js.map +1 -1
  105. package/Shaders/ShadersInclude/pbrBlockSubSurface.js +1 -1
  106. package/Shaders/ShadersInclude/pbrBlockSubSurface.js.map +1 -1
  107. package/Shaders/ShadersInclude/pbrDebug.js +2 -0
  108. package/Shaders/ShadersInclude/pbrDebug.js.map +1 -1
  109. package/ShadersWGSL/clearQuad.fragment.js +11 -0
  110. package/ShadersWGSL/clearQuad.fragment.js.map +1 -0
  111. package/ShadersWGSL/clearQuad.vertex.js +22 -0
  112. package/ShadersWGSL/clearQuad.vertex.js.map +1 -0
  113. package/node.js +1 -6
  114. package/node.js.map +1 -1
  115. package/package.json +1 -1
  116. package/Shaders/clearQuad.fragment.js +0 -10
  117. package/Shaders/clearQuad.fragment.js.map +0 -1
  118. package/Shaders/clearQuad.vertex.js +0 -19
  119. package/Shaders/clearQuad.vertex.js.map +0 -1
  120. /package/{Shaders → ShadersWGSL}/clearQuad.fragment.d.ts +0 -0
  121. /package/{Shaders → ShadersWGSL}/clearQuad.vertex.d.ts +0 -0
@@ -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,oB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AC,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 } 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: any, options: IComputeEffectCreationOptions): ComputeEffect {\r\n const compute = baseName.computeElement || baseName.compute || baseName.computeToken || baseName.computeSource || baseName;\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;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,CAAC,IAAI,CAAC,CAAC;QACzE,I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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"]}
@@ -11,7 +11,7 @@ WebGPUEngine.prototype.unBindMultiColorAttachmentFramebuffer = function (rtWrapp
11
11
  this._endCurrentRenderPass();
12
12
  for (let i = 0; i < count; i++) {
13
13
  const texture = rtWrapper.textures[i];
14
- if (texture.generateMipMaps && !disableGenerateMipMaps && !texture.isCube) {
14
+ if (texture.generateMipMaps && !disableGenerateMipMaps && !texture.isCube && !texture.is3D) {
15
15
  this._generateMipmaps(texture);
16
16
  }
17
17
  }
@@ -1 +1 @@
1
- {"version":3,"file":"engine.multiRender.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Engines/WebGPU/Extensions/engine.multiRender.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,6CAA6C,CAAC;AAErG,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;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ource } from \"../../../Materials/Textures/internalTexture\";\r\nimport type { IMultiRenderTargetOptions } from \"../../../Materials/Textures/multiRenderTarget\";\r\nimport { Logger } from \"../../../Misc/logger\";\r\nimport type { Nullable } from \"../../../types\";\r\nimport { Constants } from \"../../constants\";\r\nimport type { TextureSize } from \"../../../Materials/Textures/textureCreationOptions\";\r\nimport type { RenderTargetWrapper } from \"../../renderTargetWrapper\";\r\nimport { WebGPUEngine } from \"../../webgpuEngine\";\r\nimport type { WebGPURenderTargetWrapper } from \"../webgpuRenderTargetWrapper\";\r\nimport type { WebGPUHardwareTexture } from \"../webgpuHardwareTexture\";\r\n\r\nWebGPUEngine.prototype.unBindMultiColorAttachmentFramebuffer = function (\r\n rtWrapper: RenderTargetWrapper,\r\n disableGenerateMipMaps: boolean = false,\r\n onBeforeUnbind?: () => void\r\n): void {\r\n if (onBeforeUnbind) {\r\n onBeforeUnbind();\r\n }\r\n\r\n const attachments = rtWrapper._attachments!;\r\n const count = attachments.length;\r\n\r\n this._endCurrentRenderPass();\r\n\r\n for (let i = 0; i < count; i++) {\r\n const texture = rtWrapper.textures![i];\r\n if (texture.generateMipMaps && !disableGenerateMipMaps && !texture.isCube) {\r\n this._generateMipmaps(texture);\r\n }\r\n }\r\n\r\n this._currentRenderTarget = null;\r\n\r\n this._mrtAttachments = [];\r\n this._cacheRenderPipeline.setMRT([]);\r\n this._cacheRenderPipeline.setMRTAttachments(this._mrtAttachments);\r\n};\r\n\r\nWebGPUEngine.prototype.createMultipleRenderTarget = function (size: TextureSize, options: IMultiRenderTargetOptions, initializeBuffers?: boolean): RenderTargetWrapper {\r\n let generateMipMaps = false;\r\n let generateDepthBuffer = true;\r\n let generateStencilBuffer = false;\r\n let generateDepthTexture = false;\r\n let depthTextureFormat = Constants.TEXTUREFORMAT_DEPTH16;\r\n let textureCount = 1;\r\n\r\n const defaultType = Constants.TEXTURETYPE_UNSIGNED_INT;\r\n const defaultSamplingMode = Constants.TEXTURE_TRILINEAR_SAMPLINGMODE;\r\n const defaultUseSRGBBuffer = false;\r\n const defaultFormat = Constants.TEXTUREFORMAT_RGBA;\r\n const defaultTarget = Constants.TEXTURE_2D;\r\n\r\n let types: number[] = [];\r\n let samplingModes: number[] = [];\r\n let useSRGBBuffers: boolean[] = [];\r\n let formats: number[] = [];\r\n let targets: number[] = [];\r\n let faceIndex: number[] = [];\r\n let layerIndex: number[] = [];\r\n let layers: number[] = [];\r\n let labels: string[] = [];\r\n\r\n const rtWrapper = this._createHardwareRenderTargetWrapper(true, false, size) as WebGPURenderTargetWrapper;\r\n\r\n if (options !== undefined) {\r\n generateMipMaps = options.generateMipMaps === undefined ? false : options.generateMipMaps;\r\n generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;\r\n generateStencilBuffer = options.generateStencilBuffer === undefined ? false : options.generateStencilBuffer;\r\n generateDepthTexture = options.generateDepthTexture === undefined ? false : options.generateDepthTexture;\r\n textureCount = options.textureCount || 1;\r\n depthTextureFormat = options.depthTextureFormat ?? Constants.TEXTUREFORMAT_DEPTH16;\r\n\r\n if (options.types) {\r\n types = options.types;\r\n }\r\n if (options.samplingModes) {\r\n samplingModes = options.samplingModes;\r\n }\r\n if (options.useSRGBBuffers) {\r\n useSRGBBuffers = options.useSRGBBuffers;\r\n }\r\n if (options.formats) {\r\n formats = options.formats;\r\n }\r\n if (options.targetTypes) {\r\n targets = options.targetTypes;\r\n }\r\n if (options.faceIndex) {\r\n faceIndex = options.faceIndex;\r\n }\r\n if (options.layerIndex) {\r\n layerIndex = options.layerIndex;\r\n }\r\n if (options.layerCounts) {\r\n layers = options.layerCounts;\r\n }\r\n\r\n labels = options.labels ?? labels;\r\n }\r\n\r\n rtWrapper.label = options?.label ?? \"MultiRenderTargetWrapper\";\r\n\r\n const width = (<{ width: number; height: number }>size).width || <number>size;\r\n const height = (<{ width: number; height: number }>size).height || <number>size;\r\n\r\n let depthStencilTexture = null;\r\n if (generateDepthBuffer || generateStencilBuffer || generateDepthTexture) {\r\n if (!generateDepthTexture) {\r\n // The caller doesn't want a depth texture, so we are free to use the depth texture format we want.\r\n // So, we will align with what the WebGL engine does\r\n if (generateDepthBuffer && generateStencilBuffer) {\r\n depthTextureFormat = Constants.TEXTUREFORMAT_DEPTH24_STENCIL8;\r\n } else if (generateDepthBuffer) {\r\n depthTextureFormat = Constants.TEXTUREFORMAT_DEPTH32_FLOAT;\r\n } else {\r\n depthTextureFormat = Constants.TEXTUREFORMAT_STENCIL8;\r\n }\r\n }\r\n depthStencilTexture = rtWrapper.createDepthStencilTexture(0, false, generateStencilBuffer, 1, depthTextureFormat, \"MultipleRenderTargetDepthStencil\");\r\n }\r\n\r\n const textures: InternalTexture[] = [];\r\n const attachments: number[] = [];\r\n const defaultAttachments: number[] = [];\r\n\r\n rtWrapper._generateDepthBuffer = generateDepthBuffer;\r\n rtWrapper._generateStencilBuffer = generateStencilBuffer;\r\n rtWrapper._attachments = attachments;\r\n rtWrapper._defaultAttachments = defaultAttachments;\r\n\r\n for (let i = 0; i < textureCount; i++) {\r\n let samplingMode = samplingModes[i] || defaultSamplingMode;\r\n let type = types[i] || defaultType;\r\n\r\n const format = formats[i] || defaultFormat;\r\n const useSRGBBuffer = (useSRGBBuffers[i] || defaultUseSRGBBuffer) && this._caps.supportSRGBBuffers;\r\n\r\n const target = targets[i] || defaultTarget;\r\n const layerCount = layers[i] ?? 1;\r\n\r\n if (type === Constants.TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering) {\r\n // if floating point linear (FLOAT) then force to NEAREST_SAMPLINGMODE\r\n samplingMode = Constants.TEXTURE_NEAREST_SAMPLINGMODE;\r\n } else if (type === Constants.TEXTURETYPE_HALF_FLOAT && !this._caps.textureHalfFloatLinearFiltering) {\r\n // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE\r\n samplingMode = Constants.TEXTURE_NEAREST_SAMPLINGMODE;\r\n }\r\n\r\n if (type === Constants.TEXTURETYPE_FLOAT && !this._caps.textureFloat) {\r\n type = Constants.TEXTURETYPE_UNSIGNED_INT;\r\n Logger.Warn(\"Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type\");\r\n }\r\n\r\n attachments.push(i + 1);\r\n defaultAttachments.push(initializeBuffers ? i + 1 : i === 0 ? 1 : 0);\r\n\r\n if (target === -1) {\r\n continue;\r\n }\r\n\r\n const texture = new InternalTexture(this, InternalTextureSource.MultiRenderTarget);\r\n textures[i] = texture;\r\n\r\n switch (target) {\r\n case Constants.TEXTURE_CUBE_MAP:\r\n texture.isCube = true;\r\n break;\r\n case Constants.TEXTURE_3D:\r\n texture.is3D = true;\r\n texture.baseDepth = texture.depth = layerCount;\r\n break;\r\n case Constants.TEXTURE_2D_ARRAY:\r\n texture.is2DArray = true;\r\n texture.baseDepth = texture.depth = layerCount;\r\n break;\r\n }\r\n\r\n texture.baseWidth = width;\r\n texture.baseHeight = height;\r\n texture.width = width;\r\n texture.height = height;\r\n texture.isReady = true;\r\n texture.samples = 1;\r\n texture.generateMipMaps = generateMipMaps;\r\n texture.samplingMode = samplingMode;\r\n texture.type = type;\r\n texture._cachedWrapU = Constants.TEXTURE_CLAMP_ADDRESSMODE;\r\n texture._cachedWrapV = Constants.TEXTURE_CLAMP_ADDRESSMODE;\r\n texture._useSRGBBuffer = useSRGBBuffer;\r\n texture.format = format;\r\n texture.label = labels[i];\r\n\r\n this._internalTexturesCache.push(texture);\r\n\r\n this._textureHelper.createGPUTextureForInternalTexture(texture);\r\n }\r\n\r\n if (depthStencilTexture) {\r\n depthStencilTexture.incrementReferences();\r\n textures[textureCount] = depthStencilTexture;\r\n this._internalTexturesCache.push(depthStencilTexture);\r\n }\r\n\r\n rtWrapper.setTextures(textures);\r\n rtWrapper.setLayerAndFaceIndices(layerIndex, faceIndex);\r\n\r\n return rtWrapper;\r\n};\r\n\r\nWebGPUEngine.prototype.updateMultipleRenderTargetTextureSampleCount = function (rtWrapper: Nullable<RenderTargetWrapper>, samples: number): number {\r\n if (!rtWrapper || !rtWrapper.textures || rtWrapper.textures[0].samples === samples) {\r\n return samples;\r\n }\r\n\r\n const count = rtWrapper.textures.length;\r\n\r\n if (count === 0) {\r\n return 1;\r\n }\r\n\r\n samples = Math.min(samples, this.getCaps().maxMSAASamples);\r\n\r\n for (let i = 0; i < count; ++i) {\r\n const texture = rtWrapper.textures[i];\r\n const gpuTextureWrapper = texture._hardwareTexture as Nullable<WebGPUHardwareTexture>;\r\n\r\n gpuTextureWrapper?.releaseMSAATexture();\r\n }\r\n\r\n // Note that rtWrapper.textures can't have null textures, lastTextureIsDepthTexture can't be true if rtWrapper._depthStencilTexture is null\r\n const lastTextureIsDepthTexture = rtWrapper._depthStencilTexture === rtWrapper.textures[count - 1];\r\n\r\n for (let i = 0; i < count; ++i) {\r\n const texture = rtWrapper.textures[i];\r\n this._textureHelper.createMSAATexture(texture, samples, false, i === count - 1 && lastTextureIsDepthTexture ? 0 : i);\r\n texture.samples = samples;\r\n }\r\n\r\n // Note that the last texture of textures is the depth texture if the depth texture has been generated by the MRT class and so the MSAA texture\r\n // will be recreated for this texture by the loop above: in that case, there's no need to create the MSAA texture for rtWrapper._depthStencilTexture\r\n // because rtWrapper._depthStencilTexture is the same texture than the depth texture\r\n if (rtWrapper._depthStencilTexture && !lastTextureIsDepthTexture) {\r\n this._textureHelper.createMSAATexture(rtWrapper._depthStencilTexture, samples);\r\n rtWrapper._depthStencilTexture.samples = samples;\r\n }\r\n\r\n return samples;\r\n};\r\n\r\nWebGPUEngine.prototype.bindAttachments = function (attachments: number[]): void {\r\n if (attachments.length === 0 || !this._currentRenderTarget) {\r\n return;\r\n }\r\n\r\n this._mrtAttachments = attachments;\r\n if (this._currentRenderPass) {\r\n // the render pass has already been created, we need to call setMRTAttachments to update the state of the attachments\r\n this._cacheRenderPipeline.setMRTAttachments(attachments);\r\n } else {\r\n // the render pass is not created yet so we don't need to call setMRTAttachments: it will be called as part of the render pass creation (see WebGPUEngine._startRenderTargetRenderPass)\r\n }\r\n};\r\n\r\nWebGPUEngine.prototype.buildTextureLayout = function (textureStatus: boolean[]): number[] {\r\n const result = [];\r\n\r\n for (let i = 0; i < textureStatus.length; i++) {\r\n if (textureStatus[i]) {\r\n result.push(i + 1);\r\n } else {\r\n result.push(0);\r\n }\r\n }\r\n\r\n return result;\r\n};\r\n\r\nWebGPUEngine.prototype.restoreSingleAttachment = function (): void {\r\n // not sure what to do, probably nothing... This function and restoreSingleAttachmentForRenderTarget are not called in Babylon.js so it's hard to know the use case\r\n};\r\n\r\nWebGPUEngine.prototype.restoreSingleAttachmentForRenderTarget = function (): void {\r\n // not sure what to do, probably nothing... This function and restoreSingleAttachment are not called in Babylon.js so it's hard to know the use case\r\n};\r\n"]}
1
+ {"version":3,"file":"engine.multiRender.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Engines/WebGPU/Extensions/engine.multiRender.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,6CAA6C,CAAC;AAErG,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAIlD,YAAY,CAAC,SAAS,CAAC,qCAAqC,GAAG,UAC3D,SAA8B,EAC9B,yBAAkC,KAAK,EACvC,cAA2B;IAE3B,IAAI,cAAc,EAAE;QAChB,cAAc,EAAE,CAAC;KACpB;IAED,MAAM,WAAW,GAAG,SAAS,CAAC,YAAa,CAAC;IAC5C,MAAM,KAAK,GAAG,WAAW,CAAC,MAAM,CAAC;IAEjC,IAAI,CAAC,qBAAqB,EAAE,CAAC;IAE7B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE,EAAE;QAC5B,MAAM,OAAO,GAAG,SAAS,CAAC,QAAS,CAAC,CAAC,CAAC,CAAC;QACvC,IAAI,OAAO,CAAC,eAAe,IAAI,CAA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C,iBAAiB,CAAC,WAAW,CAAC,CAAC;KAC5D;SAAM;QACH,uLAAuL;KAC1L;AACL,CAAC,CAAC;AAEF,YAAY,CAAC,SAAS,CAAC,kBAAkB,GAAG,UAAU,aAAwB;IAC1E,MAAM,MAAM,GAAG,EAAE,CAAC;IAElB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,aAAa,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QAC3C,IAAI,aAAa,CAAC,CAAC,CAAC,EAAE;YAClB,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;SACtB;aAAM;YACH,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SAClB;KACJ;IAED,OAAO,MAAM,CAAC;AAClB,CAAC,CAAC;AAEF,YAAY,CAAC,SAAS,CAAC,uBAAuB,GAAG;IAC7C,mKAAmK;AACvK,CAAC,CAAC;AAEF,YAAY,CAAC,SAAS,CAAC,sCAAsC,GAAG;IAC5D,oJAAoJ;AACxJ,CAAC,CAAC","sourcesContent":["import { InternalTexture, InternalTextureSource } from \"../../../Materials/Textures/internalTexture\";\r\nimport type { IMultiRenderTargetOptions } from \"../../../Materials/Textures/multiRenderTarget\";\r\nimport { Logger } from \"../../../Misc/logger\";\r\nimport type { Nullable } from \"../../../types\";\r\nimport { Constants } from \"../../constants\";\r\nimport type { TextureSize } from \"../../../Materials/Textures/textureCreationOptions\";\r\nimport type { RenderTargetWrapper } from \"../../renderTargetWrapper\";\r\nimport { WebGPUEngine } from \"../../webgpuEngine\";\r\nimport type { WebGPURenderTargetWrapper } from \"../webgpuRenderTargetWrapper\";\r\nimport type { WebGPUHardwareTexture } from \"../webgpuHardwareTexture\";\r\n\r\nWebGPUEngine.prototype.unBindMultiColorAttachmentFramebuffer = function (\r\n rtWrapper: RenderTargetWrapper,\r\n disableGenerateMipMaps: boolean = false,\r\n onBeforeUnbind?: () => void\r\n): void {\r\n if (onBeforeUnbind) {\r\n onBeforeUnbind();\r\n }\r\n\r\n const attachments = rtWrapper._attachments!;\r\n const count = attachments.length;\r\n\r\n this._endCurrentRenderPass();\r\n\r\n for (let i = 0; i < count; i++) {\r\n const texture = rtWrapper.textures![i];\r\n if (texture.generateMipMaps && !disableGenerateMipMaps && !texture.isCube && !texture.is3D) {\r\n this._generateMipmaps(texture);\r\n }\r\n }\r\n\r\n this._currentRenderTarget = null;\r\n\r\n this._mrtAttachments = [];\r\n this._cacheRenderPipeline.setMRT([]);\r\n this._cacheRenderPipeline.setMRTAttachments(this._mrtAttachments);\r\n};\r\n\r\nWebGPUEngine.prototype.createMultipleRenderTarget = function (size: TextureSize, options: IMultiRenderTargetOptions, initializeBuffers?: boolean): RenderTargetWrapper {\r\n let generateMipMaps = false;\r\n let generateDepthBuffer = true;\r\n let generateStencilBuffer = false;\r\n let generateDepthTexture = false;\r\n let depthTextureFormat = Constants.TEXTUREFORMAT_DEPTH16;\r\n let textureCount = 1;\r\n\r\n const defaultType = Constants.TEXTURETYPE_UNSIGNED_INT;\r\n const defaultSamplingMode = Constants.TEXTURE_TRILINEAR_SAMPLINGMODE;\r\n const defaultUseSRGBBuffer = false;\r\n const defaultFormat = Constants.TEXTUREFORMAT_RGBA;\r\n const defaultTarget = Constants.TEXTURE_2D;\r\n\r\n let types: number[] = [];\r\n let samplingModes: number[] = [];\r\n let useSRGBBuffers: boolean[] = [];\r\n let formats: number[] = [];\r\n let targets: number[] = [];\r\n let faceIndex: number[] = [];\r\n let layerIndex: number[] = [];\r\n let layers: number[] = [];\r\n let labels: string[] = [];\r\n\r\n const rtWrapper = this._createHardwareRenderTargetWrapper(true, false, size) as WebGPURenderTargetWrapper;\r\n\r\n if (options !== undefined) {\r\n generateMipMaps = options.generateMipMaps === undefined ? false : options.generateMipMaps;\r\n generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;\r\n generateStencilBuffer = options.generateStencilBuffer === undefined ? false : options.generateStencilBuffer;\r\n generateDepthTexture = options.generateDepthTexture === undefined ? false : options.generateDepthTexture;\r\n textureCount = options.textureCount || 1;\r\n depthTextureFormat = options.depthTextureFormat ?? Constants.TEXTUREFORMAT_DEPTH16;\r\n\r\n if (options.types) {\r\n types = options.types;\r\n }\r\n if (options.samplingModes) {\r\n samplingModes = options.samplingModes;\r\n }\r\n if (options.useSRGBBuffers) {\r\n useSRGBBuffers = options.useSRGBBuffers;\r\n }\r\n if (options.formats) {\r\n formats = options.formats;\r\n }\r\n if (options.targetTypes) {\r\n targets = options.targetTypes;\r\n }\r\n if (options.faceIndex) {\r\n faceIndex = options.faceIndex;\r\n }\r\n if (options.layerIndex) {\r\n layerIndex = options.layerIndex;\r\n }\r\n if (options.layerCounts) {\r\n layers = options.layerCounts;\r\n }\r\n\r\n labels = options.labels ?? labels;\r\n }\r\n\r\n rtWrapper.label = options?.label ?? \"MultiRenderTargetWrapper\";\r\n\r\n const width = (<{ width: number; height: number }>size).width || <number>size;\r\n const height = (<{ width: number; height: number }>size).height || <number>size;\r\n\r\n let depthStencilTexture = null;\r\n if (generateDepthBuffer || generateStencilBuffer || generateDepthTexture) {\r\n if (!generateDepthTexture) {\r\n // The caller doesn't want a depth texture, so we are free to use the depth texture format we want.\r\n // So, we will align with what the WebGL engine does\r\n if (generateDepthBuffer && generateStencilBuffer) {\r\n depthTextureFormat = Constants.TEXTUREFORMAT_DEPTH24_STENCIL8;\r\n } else if (generateDepthBuffer) {\r\n depthTextureFormat = Constants.TEXTUREFORMAT_DEPTH32_FLOAT;\r\n } else {\r\n depthTextureFormat = Constants.TEXTUREFORMAT_STENCIL8;\r\n }\r\n }\r\n depthStencilTexture = rtWrapper.createDepthStencilTexture(0, false, generateStencilBuffer, 1, depthTextureFormat, \"MultipleRenderTargetDepthStencil\");\r\n }\r\n\r\n const textures: InternalTexture[] = [];\r\n const attachments: number[] = [];\r\n const defaultAttachments: number[] = [];\r\n\r\n rtWrapper._generateDepthBuffer = generateDepthBuffer;\r\n rtWrapper._generateStencilBuffer = generateStencilBuffer;\r\n rtWrapper._attachments = attachments;\r\n rtWrapper._defaultAttachments = defaultAttachments;\r\n\r\n for (let i = 0; i < textureCount; i++) {\r\n let samplingMode = samplingModes[i] || defaultSamplingMode;\r\n let type = types[i] || defaultType;\r\n\r\n const format = formats[i] || defaultFormat;\r\n const useSRGBBuffer = (useSRGBBuffers[i] || defaultUseSRGBBuffer) && this._caps.supportSRGBBuffers;\r\n\r\n const target = targets[i] || defaultTarget;\r\n const layerCount = layers[i] ?? 1;\r\n\r\n if (type === Constants.TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering) {\r\n // if floating point linear (FLOAT) then force to NEAREST_SAMPLINGMODE\r\n samplingMode = Constants.TEXTURE_NEAREST_SAMPLINGMODE;\r\n } else if (type === Constants.TEXTURETYPE_HALF_FLOAT && !this._caps.textureHalfFloatLinearFiltering) {\r\n // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE\r\n samplingMode = Constants.TEXTURE_NEAREST_SAMPLINGMODE;\r\n }\r\n\r\n if (type === Constants.TEXTURETYPE_FLOAT && !this._caps.textureFloat) {\r\n type = Constants.TEXTURETYPE_UNSIGNED_INT;\r\n Logger.Warn(\"Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type\");\r\n }\r\n\r\n attachments.push(i + 1);\r\n defaultAttachments.push(initializeBuffers ? i + 1 : i === 0 ? 1 : 0);\r\n\r\n if (target === -1) {\r\n continue;\r\n }\r\n\r\n const texture = new InternalTexture(this, InternalTextureSource.MultiRenderTarget);\r\n textures[i] = texture;\r\n\r\n switch (target) {\r\n case Constants.TEXTURE_CUBE_MAP:\r\n texture.isCube = true;\r\n break;\r\n case Constants.TEXTURE_3D:\r\n texture.is3D = true;\r\n texture.baseDepth = texture.depth = layerCount;\r\n break;\r\n case Constants.TEXTURE_2D_ARRAY:\r\n texture.is2DArray = true;\r\n texture.baseDepth = texture.depth = layerCount;\r\n break;\r\n }\r\n\r\n texture.baseWidth = width;\r\n texture.baseHeight = height;\r\n texture.width = width;\r\n texture.height = height;\r\n texture.isReady = true;\r\n texture.samples = 1;\r\n texture.generateMipMaps = generateMipMaps;\r\n texture.samplingMode = samplingMode;\r\n texture.type = type;\r\n texture._cachedWrapU = Constants.TEXTURE_CLAMP_ADDRESSMODE;\r\n texture._cachedWrapV = Constants.TEXTURE_CLAMP_ADDRESSMODE;\r\n texture._useSRGBBuffer = useSRGBBuffer;\r\n texture.format = format;\r\n texture.label = labels[i];\r\n\r\n this._internalTexturesCache.push(texture);\r\n\r\n this._textureHelper.createGPUTextureForInternalTexture(texture);\r\n }\r\n\r\n if (depthStencilTexture) {\r\n depthStencilTexture.incrementReferences();\r\n textures[textureCount] = depthStencilTexture;\r\n this._internalTexturesCache.push(depthStencilTexture);\r\n }\r\n\r\n rtWrapper.setTextures(textures);\r\n rtWrapper.setLayerAndFaceIndices(layerIndex, faceIndex);\r\n\r\n return rtWrapper;\r\n};\r\n\r\nWebGPUEngine.prototype.updateMultipleRenderTargetTextureSampleCount = function (rtWrapper: Nullable<RenderTargetWrapper>, samples: number): number {\r\n if (!rtWrapper || !rtWrapper.textures || rtWrapper.textures[0].samples === samples) {\r\n return samples;\r\n }\r\n\r\n const count = rtWrapper.textures.length;\r\n\r\n if (count === 0) {\r\n return 1;\r\n }\r\n\r\n samples = Math.min(samples, this.getCaps().maxMSAASamples);\r\n\r\n for (let i = 0; i < count; ++i) {\r\n const texture = rtWrapper.textures[i];\r\n const gpuTextureWrapper = texture._hardwareTexture as Nullable<WebGPUHardwareTexture>;\r\n\r\n gpuTextureWrapper?.releaseMSAATexture();\r\n }\r\n\r\n // Note that rtWrapper.textures can't have null textures, lastTextureIsDepthTexture can't be true if rtWrapper._depthStencilTexture is null\r\n const lastTextureIsDepthTexture = rtWrapper._depthStencilTexture === rtWrapper.textures[count - 1];\r\n\r\n for (let i = 0; i < count; ++i) {\r\n const texture = rtWrapper.textures[i];\r\n this._textureHelper.createMSAATexture(texture, samples, false, i === count - 1 && lastTextureIsDepthTexture ? 0 : i);\r\n texture.samples = samples;\r\n }\r\n\r\n // Note that the last texture of textures is the depth texture if the depth texture has been generated by the MRT class and so the MSAA texture\r\n // will be recreated for this texture by the loop above: in that case, there's no need to create the MSAA texture for rtWrapper._depthStencilTexture\r\n // because rtWrapper._depthStencilTexture is the same texture than the depth texture\r\n if (rtWrapper._depthStencilTexture && !lastTextureIsDepthTexture) {\r\n this._textureHelper.createMSAATexture(rtWrapper._depthStencilTexture, samples);\r\n rtWrapper._depthStencilTexture.samples = samples;\r\n }\r\n\r\n return samples;\r\n};\r\n\r\nWebGPUEngine.prototype.bindAttachments = function (attachments: number[]): void {\r\n if (attachments.length === 0 || !this._currentRenderTarget) {\r\n return;\r\n }\r\n\r\n this._mrtAttachments = attachments;\r\n if (this._currentRenderPass) {\r\n // the render pass has already been created, we need to call setMRTAttachments to update the state of the attachments\r\n this._cacheRenderPipeline.setMRTAttachments(attachments);\r\n } else {\r\n // the render pass is not created yet so we don't need to call setMRTAttachments: it will be called as part of the render pass creation (see WebGPUEngine._startRenderTargetRenderPass)\r\n }\r\n};\r\n\r\nWebGPUEngine.prototype.buildTextureLayout = function (textureStatus: boolean[]): number[] {\r\n const result = [];\r\n\r\n for (let i = 0; i < textureStatus.length; i++) {\r\n if (textureStatus[i]) {\r\n result.push(i + 1);\r\n } else {\r\n result.push(0);\r\n }\r\n }\r\n\r\n return result;\r\n};\r\n\r\nWebGPUEngine.prototype.restoreSingleAttachment = function (): void {\r\n // not sure what to do, probably nothing... This function and restoreSingleAttachmentForRenderTarget are not called in Babylon.js so it's hard to know the use case\r\n};\r\n\r\nWebGPUEngine.prototype.restoreSingleAttachmentForRenderTarget = function (): void {\r\n // not sure what to do, probably nothing... This function and restoreSingleAttachment are not called in Babylon.js so it's hard to know the use case\r\n};\r\n"]}
@@ -73,13 +73,16 @@ 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
- const layers = size.layers || 0;
76
+ // Only 2D textures are supported for depth/stencil
77
+ const layers = 0;
78
+ const depth = 0;
77
79
  internalTexture.baseWidth = width;
78
80
  internalTexture.baseHeight = height;
79
81
  internalTexture.width = width;
80
82
  internalTexture.height = height;
81
83
  internalTexture.is2DArray = layers > 0;
82
- internalTexture.depth = layers;
84
+ internalTexture.is3D = depth > 0;
85
+ internalTexture.depth = layers || depth;
83
86
  internalTexture.isReady = true;
84
87
  internalTexture.samples = samples;
85
88
  internalTexture.generateMipMaps = false;
@@ -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,GAAG,IAAI,CAAC,kCAAkC,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI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ClB;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 const layers = (<{ width: number; height: number; layers?: number }>size).layers || 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.depth = layers;\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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AEpC,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"]}
@@ -3,8 +3,8 @@ import type { IColor4Like } from "../../Maths/math.like";
3
3
  import type { VertexBuffer } from "../../Buffers/buffer";
4
4
  import type { Nullable } from "../../types";
5
5
  import type { WebGPUEngine } from "../webgpuEngine";
6
- import "../../Shaders/clearQuad.vertex";
7
- import "../../Shaders/clearQuad.fragment";
6
+ import "../../ShadersWGSL/clearQuad.vertex";
7
+ import "../../ShadersWGSL/clearQuad.fragment";
8
8
  /** @internal */
9
9
  export declare class WebGPUClearQuad {
10
10
  private _device;
@@ -3,8 +3,9 @@ import { WebGPUCacheRenderPipelineTree } from "./webgpuCacheRenderPipelineTree.j
3
3
  import { WebGPUShaderProcessingContext } from "./webgpuShaderProcessingContext.js";
4
4
  import { WebGPUTextureHelper } from "./webgpuTextureHelper.js";
5
5
  import { renderableTextureFormatToIndex } from "./webgpuTextureManager.js";
6
- import "../../Shaders/clearQuad.vertex.js";
7
- import "../../Shaders/clearQuad.fragment.js";
6
+ import "../../ShadersWGSL/clearQuad.vertex.js";
7
+ import "../../ShadersWGSL/clearQuad.fragment.js";
8
+ import { ShaderLanguage } from "../../Materials/shaderLanguage.js";
8
9
  /** @internal */
9
10
  export class WebGPUClearQuad {
10
11
  setDepthStencilFormat(format) {
@@ -27,7 +28,7 @@ export class WebGPUClearQuad {
27
28
  this._cacheRenderPipeline = new WebGPUCacheRenderPipelineTree(this._device, emptyVertexBuffer);
28
29
  this._cacheRenderPipeline.setDepthTestEnabled(false);
29
30
  this._cacheRenderPipeline.setStencilReadMask(0xff);
30
- this._effect = engine.createEffect("clearQuad", [], ["color", "depthValue"]);
31
+ this._effect = engine.createEffect("clearQuad", [], ["color", "depthValue"], undefined, undefined, undefined, undefined, undefined, undefined, ShaderLanguage.WGSL);
31
32
  }
32
33
  clear(renderPass, clearColor, clearDepth, clearStencil, sampleCount = 1) {
33
34
  let renderPass2;
@@ -58,6 +59,7 @@ export class WebGPUClearQuad {
58
59
  return bundle;
59
60
  }
60
61
  renderPass2 = this._device.createRenderBundleEncoder({
62
+ label: "clearQuadRenderBundle",
61
63
  colorFormats: this._cacheRenderPipeline.colorFormats,
62
64
  depthStencilFormat: this._depthTextureFormat,
63
65
  sampleCount: WebGPUTextureHelper.GetSample(sampleCount),
@@ -84,16 +86,19 @@ export class WebGPUClearQuad {
84
86
  const bindGroupLayouts = webgpuPipelineContext.bindGroupLayouts[0];
85
87
  bindGroups = this._bindGroups[key] = [];
86
88
  bindGroups.push(this._device.createBindGroup({
89
+ label: `clearQuadBindGroup0-${key}`,
87
90
  layout: bindGroupLayouts[0],
88
91
  entries: [],
89
92
  }));
90
93
  if (!WebGPUShaderProcessingContext._SimplifiedKnownBindings) {
91
94
  bindGroups.push(this._device.createBindGroup({
95
+ label: `clearQuadBindGroup1-${key}`,
92
96
  layout: bindGroupLayouts[1],
93
97
  entries: [],
94
98
  }));
95
99
  }
96
100
  bindGroups.push(this._device.createBindGroup({
101
+ label: `clearQuadBindGroup${WebGPUShaderProcessingContext._SimplifiedKnownBindings ? 1 : 2}-${key}`,
97
102
  layout: bindGroupLayouts[WebGPUShaderProcessingContext._SimplifiedKnownBindings ? 1 : 2],
98
103
  entries: [
99
104
  {
@@ -1 +1 @@
1
- {"version":3,"file":"webgpuClearQuad.js","sourceRoot":"","sources":["../../../../../dev/core/src/Engines/WebGPU/webgpuClearQuad.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAGzC,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAEhF,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAChF,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,8BAA8B,EAAE,MAAM,wBAAwB,CAAC;AAExE,OAAO,gCAAgC,CAAC;AACxC,OAAO,kCAAkC,CAAC;AAE1C,gBAAgB;AAChB,MAAM,OAAO,eAAe;IAUjB,qBAAqB,CAAC,MAAoC;QAC7D,IAAI,CAAC,mBAAmB,GAAG,MAAM,CAAC;QAClC,IAAI,CAAC,oBAAoB,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC;IAC5D,CAAC;IAEM,cAAc,CAAC,MAA+B;QACjD,IAAI,CAAC,oBAAoB,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;IACrD,CAAC;IAEM,iBAAiB,CAAC,WAAqB,EAAE,YAA+B,EAAE,YAAoB;QACjG,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;QAC7D,IAAI,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,WAAW,CAAC,CAAC;IAC7D,CAAC;IAED,YAAY,MAAiB,EAAE,MAAoB,EAAE,iBAA+B;QAnB5E,gBAAW,GAAqC,EAAE,CAAC;QAEnD,iBAAY,GAAuC,EAAE,CAAC;QACtD,aAAQ,GAAa,EAAE,CAAC;QAiB5B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC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BACjC;qBACJ;oBACD;wBACI,OAAO,EAAE,CAAC;wBACV,QAAQ,EAAE;4BACN,MAAM,EAAE,cAAc,CAAC,kBAAkB;4BACzC,IAAI,EAAE,cAAc,CAAC,QAAQ;yBAChC;qBACJ;iBACJ;aACJ,CAAC,CACL,CAAC;SACL;QAED,WAAW,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;QAClC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE;YACxC,WAAW,CAAC,YAAY,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;SAC9C;QACD,WAAW,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QAE7B,IAAI,CAAC,UAAU,EAAE;YACb,MAAM,GAAI,WAAsC,CAAC,MAAM,EAAE,CAAC;YAC1D,IAAI,CAAC,YAAY,CAAC,SAAU,CAAC,GAAG,MAAM,CAAC;SAC1C;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ","sourcesContent":["import type { Effect } from \"../../Materials/effect\";\r\nimport type { InternalTexture } from \"../../Materials/Textures/internalTexture\";\r\nimport type { IColor4Like } from \"../../Maths/math.like\";\r\nimport type { VertexBuffer } from \"../../Buffers/buffer\";\r\nimport type { WebGPUDataBuffer } from \"../../Meshes/WebGPU/webgpuDataBuffer\";\r\nimport type { Nullable } from \"../../types\";\r\nimport { Constants } from \"../constants\";\r\nimport type { WebGPUEngine } from \"../webgpuEngine\";\r\nimport type { WebGPUCacheRenderPipeline } from \"./webgpuCacheRenderPipeline\";\r\nimport { WebGPUCacheRenderPipelineTree } from \"./webgpuCacheRenderPipelineTree\";\r\nimport type { WebGPUPipelineContext } from \"./webgpuPipelineContext\";\r\nimport { WebGPUShaderProcessingContext } from \"./webgpuShaderProcessingContext\";\r\nimport { WebGPUTextureHelper } from \"./webgpuTextureHelper\";\r\nimport { renderableTextureFormatToIndex } from \"./webgpuTextureManager\";\r\n\r\nimport \"../../Shaders/clearQuad.vertex\";\r\nimport \"../../Shaders/clearQuad.fragment\";\r\n\r\n/** @internal */\r\nexport class WebGPUClearQuad {\r\n private _device: GPUDevice;\r\n private _engine: WebGPUEngine;\r\n private _cacheRenderPipeline: WebGPUCacheRenderPipeline;\r\n private _effect: Effect;\r\n private _bindGroups: { [id: string]: GPUBindGroup[] } = {};\r\n private _depthTextureFormat: GPUTextureFormat | undefined;\r\n private _bundleCache: { [key: string]: GPURenderBundle } = {};\r\n private _keyTemp: number[] = [];\r\n\r\n public setDepthStencilFormat(format: GPUTextureFormat | undefined): void {\r\n this._depthTextureFormat = format;\r\n this._cacheRenderPipeline.setDepthStencilFormat(format);\r\n }\r\n\r\n public setColorFormat(format: GPUTextureFormat | null): void {\r\n this._cacheRenderPipeline.setColorFormat(format);\r\n }\r\n\r\n public setMRTAttachments(attachments: number[], textureArray: InternalTexture[], textureCount: number): void {\r\n this._cacheRenderPipeline.setMRT(textureArray, textureCount);\r\n this._cacheRenderPipeline.setMRTAttachments(attachments);\r\n }\r\n\r\n constructor(device: GPUDevice, engine: WebGPUEngine, emptyVertexBuffer: VertexBuffer) {\r\n this._device = device;\r\n this._engine = engine;\r\n\r\n this._cacheRenderPipeline = new WebGPUCacheRenderPipelineTree(this._device, emptyVertexBuffer);\r\n this._cacheRenderPipeline.setDepthTestEnabled(false);\r\n this._cacheRenderPipeline.setStencilReadMask(0xff);\r\n\r\n this._effect = engine.createEffect(\"clearQuad\", [], [\"color\", \"depthValue\"]);\r\n }\r\n\r\n public clear(\r\n renderPass: Nullable<GPURenderPassEncoder>,\r\n clearColor?: Nullable<IColor4Like>,\r\n clearDepth?: boolean,\r\n clearStencil?: boolean,\r\n sampleCount = 1\r\n ): Nullable<GPURenderBundle> {\r\n let renderPass2: GPURenderPassEncoder | GPURenderBundleEncoder;\r\n let bundle: Nullable<GPURenderBundle> = null;\r\n let bundleKey: string;\r\n\r\n const isRTTPass = !!this._engine._currentRenderTarget;\r\n\r\n if (renderPass) {\r\n renderPass2 = renderPass;\r\n } else {\r\n let idx = 0;\r\n this._keyTemp.length = 0;\r\n for (let i = 0; i < this._cacheRenderPipeline.colorFormats.length; ++i) {\r\n this._keyTemp[idx++] = renderableTextureFormatToIndex[this._cacheRenderPipeline.colorFormats[i] ?? \"\"];\r\n }\r\n\r\n const depthStencilFormatIndex = renderableTextureFormatToIndex[this._depthTextureFormat ?? 0];\r\n\r\n this._keyTemp[idx] =\r\n (clearColor ? clearColor.r + clearColor.g * 256 + clearColor.b * 256 * 256 + clearColor.a * 256 * 256 * 256 : 0) +\r\n (clearDepth ? 2 ** 32 : 0) +\r\n (clearStencil ? 2 ** 33 : 0) +\r\n (this._engine.useReverseDepthBuffer ? 2 ** 34 : 0) +\r\n (isRTTPass ? 2 ** 35 : 0) +\r\n (sampleCount > 1 ? 2 ** 36 : 0) +\r\n depthStencilFormatIndex * 2 ** 37;\r\n\r\n bundleKey = this._keyTemp.join(\"_\");\r\n bundle = this._bundleCache[bundleKey];\r\n\r\n if (bundle) {\r\n return bundle;\r\n }\r\n\r\n renderPass2 = this._device.createRenderBundleEncoder({\r\n colorFormats: this._cacheRenderPipeline.colorFormats,\r\n depthStencilFormat: this._depthTextureFormat,\r\n sampleCount: WebGPUTextureHelper.GetSample(sampleCount),\r\n });\r\n }\r\n\r\n this._cacheRenderPipeline.setDepthWriteEnabled(!!clearDepth);\r\n this._cacheRenderPipeline.setStencilEnabled(!!clearStencil && !!this._depthTextureFormat && WebGPUTextureHelper.HasStencilAspect(this._depthTextureFormat));\r\n this._cacheRenderPipeline.setStencilWriteMask(clearStencil ? 0xff : 0);\r\n this._cacheRenderPipeline.setStencilCompare(clearStencil ? Constants.ALWAYS : Constants.NEVER);\r\n this._cacheRenderPipeline.setStencilPassOp(clearStencil ? Constants.REPLACE : Constants.KEEP);\r\n this._cacheRenderPipeline.setWriteMask(clearColor ? 0xf : 0);\r\n\r\n const pipeline = this._cacheRenderPipeline.getRenderPipeline(Constants.MATERIAL_TriangleStripDrawMode, this._effect, sampleCount);\r\n\r\n const webgpuPipelineContext = this._effect._pipelineContext as WebGPUPipelineContext;\r\n\r\n if (clearColor) {\r\n this._effect.setDirectColor4(\"color\", clearColor);\r\n }\r\n\r\n this._effect.setFloat(\"depthValue\", this._engine.useReverseDepthBuffer ? this._engine._clearReverseDepthValue : this._engine._clearDepthValue);\r\n\r\n webgpuPipelineContext.uniformBuffer!.update();\r\n\r\n const bufferInternals = isRTTPass ? this._engine._ubInvertY : this._engine._ubDontInvertY;\r\n const bufferLeftOver = webgpuPipelineContext.uniformBuffer!.getBuffer() as WebGPUDataBuffer;\r\n\r\n const key = bufferLeftOver.uniqueId + \"-\" + bufferInternals.uniqueId;\r\n\r\n let bindGroups = this._bindGroups[key];\r\n\r\n if (!bindGroups) {\r\n const bindGroupLayouts = webgpuPipelineContext.bindGroupLayouts[0];\r\n bindGroups = this._bindGroups[key] = [];\r\n bindGroups.push(\r\n this._device.createBindGroup({\r\n layout: bindGroupLayouts[0],\r\n entries: [],\r\n })\r\n );\r\n if (!WebGPUShaderProcessingContext._SimplifiedKnownBindings) {\r\n bindGroups.push(\r\n this._device.createBindGroup({\r\n layout: bindGroupLayouts[1],\r\n entries: [],\r\n })\r\n );\r\n }\r\n bindGroups.push(\r\n this._device.createBindGroup({\r\n layout: bindGroupLayouts[WebGPUShaderProcessingContext._SimplifiedKnownBindings ? 1 : 2],\r\n entries: [\r\n {\r\n binding: 0,\r\n resource: {\r\n buffer: bufferInternals.underlyingResource,\r\n size: bufferInternals.capacity,\r\n },\r\n },\r\n {\r\n binding: 1,\r\n resource: {\r\n buffer: bufferLeftOver.underlyingResource,\r\n size: bufferLeftOver.capacity,\r\n },\r\n },\r\n ],\r\n })\r\n );\r\n }\r\n\r\n renderPass2.setPipeline(pipeline);\r\n for (let i = 0; i < bindGroups.length; ++i) {\r\n renderPass2.setBindGroup(i, bindGroups[i]);\r\n }\r\n renderPass2.draw(4, 1, 0, 0);\r\n\r\n if (!renderPass) {\r\n bundle = (renderPass2 as GPURenderBundleEncoder).finish();\r\n this._bundleCache[bundleKey!] = bundle;\r\n }\r\n\r\n return bundle;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"webgpuClearQuad.js","sourceRoot":"","sources":["../../../../../dev/core/src/Engines/WebGPU/webgpuClearQuad.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAGzC,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAEhF,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAChF,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,8BAA8B,EAAE,MAAM,wBAAwB,CAAC;AAExE,OAAO,oCAAoC,CAAC;AAC5C,OAAO,sCAAsC,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAEhE,gBAAgB;AAChB,MAAM,OAAO,eAAe;IAUjB,qBAAqB,CAAC,MAAoC;QAC7D,IAAI,CAAC,mBAAmB,GAAG,MAAM,CAAC;QAClC,IAAI,CAAC,oBAAoB,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC;IAC5D,CAAC;IAEM,cAAc,CAAC,MAA+B;QACjD,IAAI,CAAC,oBAAoB,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;IACrD,CAAC;IAEM,iBAAiB,CAAC,WAAqB,EAAE,YAA+B,EAAE,YAAoB;QACjG,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;QAC7D,IAAI,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,WAAW,CAAC,CAAC;IAC7D,CAAC;IAED,YAAY,MAAiB,EAAE,MAAoB,EAAE,iBAA+B;QAnB5E,gBAAW,GAAqC,EAAE,CAAC;QAEnD,iBAAY,GAAuC,EAA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AAC,OAAO,CAAC,eAAe,CAAC;gBACzB,KAAK,EAAE,qBAAqB,6BAA6B,CAAC,wBAAwB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,EAAE;gBACnG,MAAM,EAAE,gBAAgB,CAAC,6BAA6B,CAAC,wBAAwB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBACxF,OAAO,EAAE;oBACL;wBACI,OAAO,EAAE,CAAC;wBACV,QAAQ,EAAE;4BACN,MAAM,EAAE,eAAe,CAAC,kBAAkB;4BAC1C,IAAI,EAAE,eAAe,CAAC,QAAQ;yBACjC;qBACJ;oBACD;wBACI,OAAO,EAAE,CAAC;wBACV,QAAQ,EAAE;4BACN,MAAM,EAAE,cAAc,CAAC,kBAAkB;4BACzC,IAAI,EAAE,cAAc,CAAC,QAAQ;yBAChC;qBACJ;iBACJ;aACJ,CAAC,CACL,CAAC;SACL;QAED,WAAW,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;QAClC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE;YACxC,WAAW,CAAC,YAAY,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;SAC9C;QACD,WAAW,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QAE7B,IAAI,CAAC,UAAU,EAAE;YACb,MAAM,GAAI,WAAsC,CAAC,MAAM,EAAE,CAAC;YAC1D,IAAI,CAAC,YAAY,CAAC,SAAU,CAAC,GAAG,MAAM,CAAC;SAC1C;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ","sourcesContent":["import type { Effect } from \"../../Materials/effect\";\r\nimport type { InternalTexture } from \"../../Materials/Textures/internalTexture\";\r\nimport type { IColor4Like } from \"../../Maths/math.like\";\r\nimport type { VertexBuffer } from \"../../Buffers/buffer\";\r\nimport type { WebGPUDataBuffer } from \"../../Meshes/WebGPU/webgpuDataBuffer\";\r\nimport type { Nullable } from \"../../types\";\r\nimport { Constants } from \"../constants\";\r\nimport type { WebGPUEngine } from \"../webgpuEngine\";\r\nimport type { WebGPUCacheRenderPipeline } from \"./webgpuCacheRenderPipeline\";\r\nimport { WebGPUCacheRenderPipelineTree } from \"./webgpuCacheRenderPipelineTree\";\r\nimport type { WebGPUPipelineContext } from \"./webgpuPipelineContext\";\r\nimport { WebGPUShaderProcessingContext } from \"./webgpuShaderProcessingContext\";\r\nimport { WebGPUTextureHelper } from \"./webgpuTextureHelper\";\r\nimport { renderableTextureFormatToIndex } from \"./webgpuTextureManager\";\r\n\r\nimport \"../../ShadersWGSL/clearQuad.vertex\";\r\nimport \"../../ShadersWGSL/clearQuad.fragment\";\r\nimport { ShaderLanguage } from \"../../Materials/shaderLanguage\";\r\n\r\n/** @internal */\r\nexport class WebGPUClearQuad {\r\n private _device: GPUDevice;\r\n private _engine: WebGPUEngine;\r\n private _cacheRenderPipeline: WebGPUCacheRenderPipeline;\r\n private _effect: Effect;\r\n private _bindGroups: { [id: string]: GPUBindGroup[] } = {};\r\n private _depthTextureFormat: GPUTextureFormat | undefined;\r\n private _bundleCache: { [key: string]: GPURenderBundle } = {};\r\n private _keyTemp: number[] = [];\r\n\r\n public setDepthStencilFormat(format: GPUTextureFormat | undefined): void {\r\n this._depthTextureFormat = format;\r\n this._cacheRenderPipeline.setDepthStencilFormat(format);\r\n }\r\n\r\n public setColorFormat(format: GPUTextureFormat | null): void {\r\n this._cacheRenderPipeline.setColorFormat(format);\r\n }\r\n\r\n public setMRTAttachments(attachments: number[], textureArray: InternalTexture[], textureCount: number): void {\r\n this._cacheRenderPipeline.setMRT(textureArray, textureCount);\r\n this._cacheRenderPipeline.setMRTAttachments(attachments);\r\n }\r\n\r\n constructor(device: GPUDevice, engine: WebGPUEngine, emptyVertexBuffer: VertexBuffer) {\r\n this._device = device;\r\n this._engine = engine;\r\n\r\n this._cacheRenderPipeline = new WebGPUCacheRenderPipelineTree(this._device, emptyVertexBuffer);\r\n this._cacheRenderPipeline.setDepthTestEnabled(false);\r\n this._cacheRenderPipeline.setStencilReadMask(0xff);\r\n\r\n this._effect = engine.createEffect(\"clearQuad\", [], [\"color\", \"depthValue\"], undefined, undefined, undefined, undefined, undefined, undefined, ShaderLanguage.WGSL);\r\n }\r\n\r\n public clear(\r\n renderPass: Nullable<GPURenderPassEncoder>,\r\n clearColor?: Nullable<IColor4Like>,\r\n clearDepth?: boolean,\r\n clearStencil?: boolean,\r\n sampleCount = 1\r\n ): Nullable<GPURenderBundle> {\r\n let renderPass2: GPURenderPassEncoder | GPURenderBundleEncoder;\r\n let bundle: Nullable<GPURenderBundle> = null;\r\n let bundleKey: string;\r\n\r\n const isRTTPass = !!this._engine._currentRenderTarget;\r\n\r\n if (renderPass) {\r\n renderPass2 = renderPass;\r\n } else {\r\n let idx = 0;\r\n this._keyTemp.length = 0;\r\n for (let i = 0; i < this._cacheRenderPipeline.colorFormats.length; ++i) {\r\n this._keyTemp[idx++] = renderableTextureFormatToIndex[this._cacheRenderPipeline.colorFormats[i] ?? \"\"];\r\n }\r\n\r\n const depthStencilFormatIndex = renderableTextureFormatToIndex[this._depthTextureFormat ?? 0];\r\n\r\n this._keyTemp[idx] =\r\n (clearColor ? clearColor.r + clearColor.g * 256 + clearColor.b * 256 * 256 + clearColor.a * 256 * 256 * 256 : 0) +\r\n (clearDepth ? 2 ** 32 : 0) +\r\n (clearStencil ? 2 ** 33 : 0) +\r\n (this._engine.useReverseDepthBuffer ? 2 ** 34 : 0) +\r\n (isRTTPass ? 2 ** 35 : 0) +\r\n (sampleCount > 1 ? 2 ** 36 : 0) +\r\n depthStencilFormatIndex * 2 ** 37;\r\n\r\n bundleKey = this._keyTemp.join(\"_\");\r\n bundle = this._bundleCache[bundleKey];\r\n\r\n if (bundle) {\r\n return bundle;\r\n }\r\n\r\n renderPass2 = this._device.createRenderBundleEncoder({\r\n label: \"clearQuadRenderBundle\",\r\n colorFormats: this._cacheRenderPipeline.colorFormats,\r\n depthStencilFormat: this._depthTextureFormat,\r\n sampleCount: WebGPUTextureHelper.GetSample(sampleCount),\r\n });\r\n }\r\n\r\n this._cacheRenderPipeline.setDepthWriteEnabled(!!clearDepth);\r\n this._cacheRenderPipeline.setStencilEnabled(!!clearStencil && !!this._depthTextureFormat && WebGPUTextureHelper.HasStencilAspect(this._depthTextureFormat));\r\n this._cacheRenderPipeline.setStencilWriteMask(clearStencil ? 0xff : 0);\r\n this._cacheRenderPipeline.setStencilCompare(clearStencil ? Constants.ALWAYS : Constants.NEVER);\r\n this._cacheRenderPipeline.setStencilPassOp(clearStencil ? Constants.REPLACE : Constants.KEEP);\r\n this._cacheRenderPipeline.setWriteMask(clearColor ? 0xf : 0);\r\n\r\n const pipeline = this._cacheRenderPipeline.getRenderPipeline(Constants.MATERIAL_TriangleStripDrawMode, this._effect, sampleCount);\r\n\r\n const webgpuPipelineContext = this._effect._pipelineContext as WebGPUPipelineContext;\r\n\r\n if (clearColor) {\r\n this._effect.setDirectColor4(\"color\", clearColor);\r\n }\r\n\r\n this._effect.setFloat(\"depthValue\", this._engine.useReverseDepthBuffer ? this._engine._clearReverseDepthValue : this._engine._clearDepthValue);\r\n\r\n webgpuPipelineContext.uniformBuffer!.update();\r\n\r\n const bufferInternals = isRTTPass ? this._engine._ubInvertY : this._engine._ubDontInvertY;\r\n const bufferLeftOver = webgpuPipelineContext.uniformBuffer!.getBuffer() as WebGPUDataBuffer;\r\n\r\n const key = bufferLeftOver.uniqueId + \"-\" + bufferInternals.uniqueId;\r\n\r\n let bindGroups = this._bindGroups[key];\r\n\r\n if (!bindGroups) {\r\n const bindGroupLayouts = webgpuPipelineContext.bindGroupLayouts[0];\r\n bindGroups = this._bindGroups[key] = [];\r\n bindGroups.push(\r\n this._device.createBindGroup({\r\n label: `clearQuadBindGroup0-${key}`,\r\n layout: bindGroupLayouts[0],\r\n entries: [],\r\n })\r\n );\r\n if (!WebGPUShaderProcessingContext._SimplifiedKnownBindings) {\r\n bindGroups.push(\r\n this._device.createBindGroup({\r\n label: `clearQuadBindGroup1-${key}`,\r\n layout: bindGroupLayouts[1],\r\n entries: [],\r\n })\r\n );\r\n }\r\n bindGroups.push(\r\n this._device.createBindGroup({\r\n label: `clearQuadBindGroup${WebGPUShaderProcessingContext._SimplifiedKnownBindings ? 1 : 2}-${key}`,\r\n layout: bindGroupLayouts[WebGPUShaderProcessingContext._SimplifiedKnownBindings ? 1 : 2],\r\n entries: [\r\n {\r\n binding: 0,\r\n resource: {\r\n buffer: bufferInternals.underlyingResource,\r\n size: bufferInternals.capacity,\r\n },\r\n },\r\n {\r\n binding: 1,\r\n resource: {\r\n buffer: bufferLeftOver.underlyingResource,\r\n size: bufferLeftOver.capacity,\r\n },\r\n },\r\n ],\r\n })\r\n );\r\n }\r\n\r\n renderPass2.setPipeline(pipeline);\r\n for (let i = 0; i < bindGroups.length; ++i) {\r\n renderPass2.setBindGroup(i, bindGroups[i]);\r\n }\r\n renderPass2.draw(4, 1, 0, 0);\r\n\r\n if (!renderPass) {\r\n bundle = (renderPass2 as GPURenderBundleEncoder).finish();\r\n this._bundleCache[bundleKey!] = bundle;\r\n }\r\n\r\n return bundle;\r\n }\r\n}\r\n"]}
@@ -48,6 +48,7 @@ export class WebGPUHardwareTexture {
48
48
  }
49
49
  else if (is3D) {
50
50
  viewDimension = WebGPUConstants.TextureViewDimension.E3d;
51
+ arrayLayerCount = 1;
51
52
  }
52
53
  else if (is2DArray) {
53
54
  viewDimension = WebGPUConstants.TextureViewDimension.E2dArray;
@@ -1 +1 @@
1
- {"version":3,"file":"webgpuHardwareTexture.js","sourceRoot":"","sources":["../../../../../dev/core/src/Engines/WebGPU/webgpuHardwareTexture.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEjD,gEAAgE;AAChE,OAAO,KAAK,eAAe,MAAM,mBAAmB,CA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TextureWrapper } from \"../../Materials/Textures/hardwareTextureWrapper\";\r\nimport { Scalar } from \"../../Maths/math.scalar\";\r\nimport type { Nullable } from \"../../types\";\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nimport * as WebGPUConstants from \"./webgpuConstants\";\r\nimport { WebGPUTextureHelper } from \"./webgpuTextureHelper\";\r\n\r\n/** @internal */\r\nexport class WebGPUHardwareTexture implements HardwareTextureWrapper {\r\n /**\r\n * Cache of RenderPassDescriptor and BindGroup used when generating mipmaps (see WebGPUTextureHelper.generateMipmaps)\r\n * @internal\r\n */\r\n public _mipmapGenRenderPassDescr: GPURenderPassDescriptor[][];\r\n /** @internal */\r\n public _mipmapGenBindGroup: GPUBindGroup[][];\r\n\r\n /**\r\n * Cache for the invertYPreMultiplyAlpha function (see WebGPUTextureHelper)\r\n * @internal\r\n */\r\n public _copyInvertYTempTexture?: GPUTexture;\r\n /** @internal */\r\n public _copyInvertYRenderPassDescr: GPURenderPassDescriptor;\r\n /** @internal */\r\n public _copyInvertYBindGroup: GPUBindGroup;\r\n /** @internal */\r\n public _copyInvertYBindGroupWithOfst: GPUBindGroup;\r\n\r\n private _webgpuTexture: Nullable<GPUTexture>;\r\n // There can be multiple MSAA textures for a single WebGPU texture because different layers of a 2DArrayTexture / 3DTexture\r\n // or different faces of a cube texture can be bound to different render targets at the same time (in a multi RenderTargetWrapper)\r\n private _webgpuMSAATexture: Nullable<GPUTexture[]>;\r\n\r\n public get underlyingResource(): Nullable<GPUTexture> {\r\n return this._webgpuTexture;\r\n }\r\n\r\n public getMSAATexture(index = 0): Nullable<GPUTexture> {\r\n return this._webgpuMSAATexture?.[index] ?? null;\r\n }\r\n\r\n public setMSAATexture(texture: GPUTexture, index = -1) {\r\n if (!this._webgpuMSAATexture) {\r\n this._webgpuMSAATexture = [];\r\n }\r\n\r\n if (index === -1) {\r\n index = this._webgpuMSAATexture.length;\r\n }\r\n\r\n this._webgpuMSAATexture![index] = texture;\r\n }\r\n\r\n public releaseMSAATexture() {\r\n if (this._webgpuMSAATexture) {\r\n for (const texture of this._webgpuMSAATexture) {\r\n texture?.destroy();\r\n }\r\n this._webgpuMSAATexture = null;\r\n }\r\n }\r\n\r\n public view: Nullable<GPUTextureView>;\r\n public viewForWriting: Nullable<GPUTextureView>;\r\n public format: GPUTextureFormat = WebGPUConstants.TextureFormat.RGBA8Unorm;\r\n public textureUsages = 0;\r\n public textureAdditionalUsages = 0;\r\n\r\n constructor(existingTexture: Nullable<GPUTexture> = null) {\r\n this._webgpuTexture = existingTexture;\r\n this._webgpuMSAATexture = null;\r\n this.view = null;\r\n this.viewForWriting = null;\r\n }\r\n\r\n public set(hardwareTexture: GPUTexture): void {\r\n this._webgpuTexture = hardwareTexture;\r\n }\r\n\r\n public setUsage(_textureSource: number, generateMipMaps: boolean, is2DArray: boolean, isCube: boolean, is3D: boolean, width: number, height: number, depth: number): void {\r\n let viewDimension: GPUTextureViewDimension = WebGPUConstants.TextureViewDimension.E2d;\r\n let arrayLayerCount = 1;\r\n if (isCube) {\r\n viewDimension = is2DArray ? WebGPUConstants.TextureViewDimension.CubeArray : WebGPUConstants.TextureViewDimension.Cube;\r\n arrayLayerCount = 6 * (depth || 1);\r\n } else if (is3D) {\r\n viewDimension = WebGPUConstants.TextureViewDimension.E3d;\r\n } else if (is2DArray) {\r\n viewDimension = WebGPUConstants.TextureViewDimension.E2dArray;\r\n arrayLayerCount = depth;\r\n }\r\n\r\n const format = WebGPUTextureHelper.GetDepthFormatOnly(this.format);\r\n const aspect = WebGPUTextureHelper.HasDepthAndStencilAspects(this.format) ? WebGPUConstants.TextureAspect.DepthOnly : WebGPUConstants.TextureAspect.All;\r\n\r\n this.createView({\r\n label: `TextureView${is3D ? \"3D\" : isCube ? \"Cube\" : \"2D\"}${is2DArray ? \"_Array\" + arrayLayerCount : \"\"}_${width}x${height}_${generateMipMaps ? \"wmips\" : \"womips\"}_${\r\n this.format\r\n }_${viewDimension}`,\r\n format,\r\n dimension: viewDimension,\r\n mipLevelCount: generateMipMaps ? Scalar.ILog2(Math.max(width, height)) + 1 : 1,\r\n baseArrayLayer: 0,\r\n baseMipLevel: 0,\r\n arrayLayerCount,\r\n aspect,\r\n });\r\n }\r\n\r\n public createView(descriptor?: GPUTextureViewDescriptor, createViewForWriting = false): void {\r\n this.view = this._webgpuTexture!.createView(descriptor);\r\n if (createViewForWriting && descriptor) {\r\n const saveNumMipMaps = descriptor.mipLevelCount;\r\n descriptor.mipLevelCount = 1;\r\n this.viewForWriting = this._webgpuTexture!.createView(descriptor);\r\n descriptor.mipLevelCount = saveNumMipMaps;\r\n }\r\n }\r\n\r\n public reset(): void {\r\n this._webgpuTexture = null;\r\n this._webgpuMSAATexture = null;\r\n this.view = null;\r\n this.viewForWriting = null;\r\n }\r\n\r\n public release(): void {\r\n this._webgpuTexture?.destroy();\r\n this.releaseMSAATexture();\r\n this._copyInvertYTempTexture?.destroy();\r\n this.reset();\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"webgpuHardwareTexture.js","sourceRoot":"","sources":["../../../../../dev/core/src/Engines/WebGPU/webgpuHardwareTexture.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEjD,gEAAgE;AAChE,OAAO,KAAK,eAAe,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,gBAAgB;AAChB,MAAM,OAAO,qBAAqB;IA0B9B,IAAW,kBAAkB;QACzB,OAAO,IAAI,CAAC,cAAc,CAAC;IAC/B,CAAC;IAEM,cAAc,CAAC,KAAK,GAAG,CAAC;QAC3B,OAAO,IAAI,CAAC,kBAAkB,EAAE,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC;IACpD,CAAC;IAEM,cAAc,CAAC,OAAmB,EAAE,KAAK,GAAG,CAAC,CAAC;QACjD,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE;YAC1B,IAAI,CAAC,kBAAkB,GAA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QACjF,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,cAAe,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;QACxD,IAAI,oBAAoB,IAAI,UAAU,EAAE;YACpC,MAAM,cAAc,GAAG,UAAU,CAAC,aAAa,CAAC;YAChD,UAAU,CAAC,aAAa,GAAG,CAAC,CAAC;YAC7B,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,cAAe,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;YAClE,UAAU,CAAC,aAAa,GAAG,cAAc,CAAC;SAC7C;IACL,CAAC;IAEM,KAAK;QACR,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;QAC3B,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC;QAC/B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;IAC/B,CAAC;IAEM,OAAO;QACV,IAAI,CAAC,cAAc,EAAE,OAAO,EAAE,CAAC;QAC/B,IAAI,CAAC,kBAAkB,EAAE,CAAC;QAC1B,IAAI,CAAC,uBAAuB,EAAE,OAAO,EAAE,CAAC;QACxC,IAAI,CAAC,KAAK,EAAE,CAAC;IACjB,CAAC;CACJ","sourcesContent":["/* eslint-disable jsdoc/require-jsdoc */\r\n/* eslint-disable babylonjs/available */\r\nimport type { HardwareTextureWrapper } from \"../../Materials/Textures/hardwareTextureWrapper\";\r\nimport { Scalar } from \"../../Maths/math.scalar\";\r\nimport type { Nullable } from \"../../types\";\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nimport * as WebGPUConstants from \"./webgpuConstants\";\r\nimport { WebGPUTextureHelper } from \"./webgpuTextureHelper\";\r\n\r\n/** @internal */\r\nexport class WebGPUHardwareTexture implements HardwareTextureWrapper {\r\n /**\r\n * Cache of RenderPassDescriptor and BindGroup used when generating mipmaps (see WebGPUTextureHelper.generateMipmaps)\r\n * @internal\r\n */\r\n public _mipmapGenRenderPassDescr: GPURenderPassDescriptor[][];\r\n /** @internal */\r\n public _mipmapGenBindGroup: GPUBindGroup[][];\r\n\r\n /**\r\n * Cache for the invertYPreMultiplyAlpha function (see WebGPUTextureHelper)\r\n * @internal\r\n */\r\n public _copyInvertYTempTexture?: GPUTexture;\r\n /** @internal */\r\n public _copyInvertYRenderPassDescr: GPURenderPassDescriptor;\r\n /** @internal */\r\n public _copyInvertYBindGroup: GPUBindGroup;\r\n /** @internal */\r\n public _copyInvertYBindGroupWithOfst: GPUBindGroup;\r\n\r\n private _webgpuTexture: Nullable<GPUTexture>;\r\n // There can be multiple MSAA textures for a single WebGPU texture because different layers of a 2DArrayTexture / 3DTexture\r\n // or different faces of a cube texture can be bound to different render targets at the same time (in a multi RenderTargetWrapper)\r\n private _webgpuMSAATexture: Nullable<GPUTexture[]>;\r\n\r\n public get underlyingResource(): Nullable<GPUTexture> {\r\n return this._webgpuTexture;\r\n }\r\n\r\n public getMSAATexture(index = 0): Nullable<GPUTexture> {\r\n return this._webgpuMSAATexture?.[index] ?? null;\r\n }\r\n\r\n public setMSAATexture(texture: GPUTexture, index = -1) {\r\n if (!this._webgpuMSAATexture) {\r\n this._webgpuMSAATexture = [];\r\n }\r\n\r\n if (index === -1) {\r\n index = this._webgpuMSAATexture.length;\r\n }\r\n\r\n this._webgpuMSAATexture![index] = texture;\r\n }\r\n\r\n public releaseMSAATexture() {\r\n if (this._webgpuMSAATexture) {\r\n for (const texture of this._webgpuMSAATexture) {\r\n texture?.destroy();\r\n }\r\n this._webgpuMSAATexture = null;\r\n }\r\n }\r\n\r\n public view: Nullable<GPUTextureView>;\r\n public viewForWriting: Nullable<GPUTextureView>;\r\n public format: GPUTextureFormat = WebGPUConstants.TextureFormat.RGBA8Unorm;\r\n public textureUsages = 0;\r\n public textureAdditionalUsages = 0;\r\n\r\n constructor(existingTexture: Nullable<GPUTexture> = null) {\r\n this._webgpuTexture = existingTexture;\r\n this._webgpuMSAATexture = null;\r\n this.view = null;\r\n this.viewForWriting = null;\r\n }\r\n\r\n public set(hardwareTexture: GPUTexture): void {\r\n this._webgpuTexture = hardwareTexture;\r\n }\r\n\r\n public setUsage(_textureSource: number, generateMipMaps: boolean, is2DArray: boolean, isCube: boolean, is3D: boolean, width: number, height: number, depth: number): void {\r\n let viewDimension: GPUTextureViewDimension = WebGPUConstants.TextureViewDimension.E2d;\r\n let arrayLayerCount = 1;\r\n if (isCube) {\r\n viewDimension = is2DArray ? WebGPUConstants.TextureViewDimension.CubeArray : WebGPUConstants.TextureViewDimension.Cube;\r\n arrayLayerCount = 6 * (depth || 1);\r\n } else if (is3D) {\r\n viewDimension = WebGPUConstants.TextureViewDimension.E3d;\r\n arrayLayerCount = 1;\r\n } else if (is2DArray) {\r\n viewDimension = WebGPUConstants.TextureViewDimension.E2dArray;\r\n arrayLayerCount = depth;\r\n }\r\n\r\n const format = WebGPUTextureHelper.GetDepthFormatOnly(this.format);\r\n const aspect = WebGPUTextureHelper.HasDepthAndStencilAspects(this.format) ? WebGPUConstants.TextureAspect.DepthOnly : WebGPUConstants.TextureAspect.All;\r\n\r\n this.createView({\r\n label: `TextureView${is3D ? \"3D\" : isCube ? \"Cube\" : \"2D\"}${is2DArray ? \"_Array\" + arrayLayerCount : \"\"}_${width}x${height}_${generateMipMaps ? \"wmips\" : \"womips\"}_${\r\n this.format\r\n }_${viewDimension}`,\r\n format,\r\n dimension: viewDimension,\r\n mipLevelCount: generateMipMaps ? Scalar.ILog2(Math.max(width, height)) + 1 : 1,\r\n baseArrayLayer: 0,\r\n baseMipLevel: 0,\r\n arrayLayerCount,\r\n aspect,\r\n });\r\n }\r\n\r\n public createView(descriptor?: GPUTextureViewDescriptor, createViewForWriting = false): void {\r\n this.view = this._webgpuTexture!.createView(descriptor);\r\n if (createViewForWriting && descriptor) {\r\n const saveNumMipMaps = descriptor.mipLevelCount;\r\n descriptor.mipLevelCount = 1;\r\n this.viewForWriting = this._webgpuTexture!.createView(descriptor);\r\n descriptor.mipLevelCount = saveNumMipMaps;\r\n }\r\n }\r\n\r\n public reset(): void {\r\n this._webgpuTexture = null;\r\n this._webgpuMSAATexture = null;\r\n this.view = null;\r\n this.viewForWriting = null;\r\n }\r\n\r\n public release(): void {\r\n this._webgpuTexture?.destroy();\r\n this.releaseMSAATexture();\r\n this._copyInvertYTempTexture?.destroy();\r\n this.reset();\r\n }\r\n}\r\n"]}
@@ -243,6 +243,21 @@ WebGPUShaderProcessor.UniformSizes = {
243
243
  mat2x2: 4,
244
244
  mat3x3: 12,
245
245
  mat4x4: 16,
246
+ mat2x2f: 4,
247
+ mat3x3f: 12,
248
+ mat4x4f: 16,
249
+ vec2i: 2,
250
+ vec3i: 3,
251
+ vec4i: 4,
252
+ vec2u: 2,
253
+ vec3u: 3,
254
+ vec4u: 4,
255
+ vec2f: 2,
256
+ vec3f: 3,
257
+ vec4f: 4,
258
+ vec2h: 1,
259
+ vec3h: 2,
260
+ vec4h: 2,
246
261
  };
247
262
  // eslint-disable-next-line @typescript-eslint/naming-convention
248
263
  WebGPUShaderProcessor._SamplerFunctionByWebGLSamplerType = {
@@ -1 +1 @@
1
- {"version":3,"file":"webgpuShaderProcessor.js","sourceRoot":"","sources":["../../../../../dev/core/src/Engines/WebGPU/webgpuShaderProcessor.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,wCAAwC;AACxC,OAAO,EAAE,MAAM,EAAE,6BAAyB;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAGhE,OAAO,KAAK,eAAe,MAAM,mBAAmB,CAAC;AAGrD,gBAAgB;AAChB,MAAM,OAAgB,qBAAqB;IAA3C;QA4EW,mBAAc,GAAG,cAAc,CAAC,IAAI,CAAC;QAE5C,sKAAsK;QACtK,qDAAqD;QAC9C,yCAAoC,GAA+B,EAAE,CAAC;IAsOjF,CAAC;IA/Na,wBAAwB,CAAC,IAAY,EAAE,WAAmB,EAAE,aAAwC;QAC1G,IAAI,MAAM,GAAG,CAAC,CAAC;QAEf,CAAC,IAAI,EAAE,WAAW,EA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AAE,WAAW;IACtB,cAAc,EAAE,gBAAgB;IAChC,eAAe,EAAE,iBAAiB;IAClC,oBAAoB,EAAE,sBAAsB;IAC5C,WAAW,EAAE,aAAa;IAC1B,SAAS,EAAE,WAAW;CACzB,AAPkD,CAOjD;AAEF,gEAAgE;AAC/C,oDAA8B,GAA8B;IACzE,SAAS,EAAE,WAAW;IACtB,cAAc,EAAE,gBAAgB;IAChC,eAAe,EAAE,WAAW;IAC5B,oBAAoB,EAAE,gBAAgB;IACtC,WAAW,EAAE,aAAa;IAC1B,gBAAgB,EAAE,kBAAkB;IACpC,SAAS,EAAE,WAAW;CACzB,AAR8C,CAQ7C;AAEF,gEAAgE;AAC/C,iEAA2C,GAA+C;IACvG,WAAW,EAAE,eAAe,CAAC,oBAAoB,CAAC,IAAI;IACtD,gBAAgB,EAAE,eAAe,CAAC,oBAAoB,CAAC,SAAS;IAChE,SAAS,EAAE,eAAe,CAAC,oBAAoB,CAAC,GAAG;IACnD,cAAc,EAAE,eAAe,CAAC,oBAAoB,CAAC,QAAQ;IAC7D,SAAS,EAAE,eAAe,CAAC,oBAAoB,CAAC,GAAG;CACtD,AAN2D,CAM1D;AAEF,uFAAuF;AACvF,gEAAgE;AAC/C,oDAA8B,GAA8B;IACzE,eAAe,EAAE,eAAe;IAChC,oBAAoB,EAAE,eAAe;CACxC,AAH8C,CAG7C;AAEF,gEAAgE;AAC/C,6DAAuC,GAA+B;IACnF,aAAa,EAAE,IAAI;IACnB,kBAAkB,EAAE,IAAI;IACxB,OAAO,EAAE,KAAK;CACjB,AAJuD,CAItD","sourcesContent":["/* eslint-disable babylonjs/available */\r\n/* eslint-disable jsdoc/require-jsdoc */\r\nimport { Logger } from \"core/Misc/logger\";\r\nimport { ShaderLanguage } from \"../../Materials/shaderLanguage\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { IShaderProcessor } from \"../Processors/iShaderProcessor\";\r\nimport * as WebGPUConstants from \"./webgpuConstants\";\r\nimport type { WebGPUSamplerDescription, WebGPUShaderProcessingContext, WebGPUTextureDescription, WebGPUBufferDescription } from \"./webgpuShaderProcessingContext\";\r\n\r\n/** @internal */\r\nexport abstract class WebGPUShaderProcessor implements IShaderProcessor {\r\n public static readonly AutoSamplerSuffix = \"Sampler\";\r\n public static readonly LeftOvertUBOName = \"LeftOver\";\r\n public static readonly InternalsUBOName = \"Internals\";\r\n\r\n public static UniformSizes: { [type: string]: number } = {\r\n // GLSL types\r\n bool: 1,\r\n int: 1,\r\n float: 1,\r\n vec2: 2,\r\n ivec2: 2,\r\n uvec2: 2,\r\n vec3: 3,\r\n ivec3: 3,\r\n uvec3: 3,\r\n vec4: 4,\r\n ivec4: 4,\r\n uvec4: 4,\r\n mat2: 4,\r\n mat3: 12,\r\n mat4: 16,\r\n\r\n // WGSL types\r\n i32: 1,\r\n u32: 1,\r\n f32: 1,\r\n mat2x2: 4,\r\n mat3x3: 12,\r\n mat4x4: 16,\r\n };\r\n\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n protected static _SamplerFunctionByWebGLSamplerType: { [key: string]: string } = {\r\n sampler2D: \"sampler2D\",\r\n sampler2DArray: \"sampler2DArray\",\r\n sampler2DShadow: \"sampler2DShadow\",\r\n sampler2DArrayShadow: \"sampler2DArrayShadow\",\r\n samplerCube: \"samplerCube\",\r\n sampler3D: \"sampler3D\",\r\n };\r\n\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n protected static _TextureTypeByWebGLSamplerType: { [key: string]: string } = {\r\n sampler2D: \"texture2D\",\r\n sampler2DArray: \"texture2DArray\",\r\n sampler2DShadow: \"texture2D\",\r\n sampler2DArrayShadow: \"texture2DArray\",\r\n samplerCube: \"textureCube\",\r\n samplerCubeArray: \"textureCubeArray\",\r\n sampler3D: \"texture3D\",\r\n };\r\n\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n protected static _GpuTextureViewDimensionByWebGPUTextureType: { [key: string]: GPUTextureViewDimension } = {\r\n textureCube: WebGPUConstants.TextureViewDimension.Cube,\r\n textureCubeArray: WebGPUConstants.TextureViewDimension.CubeArray,\r\n texture2D: WebGPUConstants.TextureViewDimension.E2d,\r\n texture2DArray: WebGPUConstants.TextureViewDimension.E2dArray,\r\n texture3D: WebGPUConstants.TextureViewDimension.E3d,\r\n };\r\n\r\n // if the webgl sampler type is not listed in this array, \"sampler\" is taken by default\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n protected static _SamplerTypeByWebGLSamplerType: { [key: string]: string } = {\r\n sampler2DShadow: \"samplerShadow\",\r\n sampler2DArrayShadow: \"samplerShadow\",\r\n };\r\n\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n protected static _IsComparisonSamplerByWebGPUSamplerType: { [key: string]: boolean } = {\r\n samplerShadow: true,\r\n samplerArrayShadow: true,\r\n sampler: false,\r\n };\r\n\r\n public shaderLanguage = ShaderLanguage.GLSL;\r\n\r\n // this object is populated only with vertex kinds known by the engine (position, uv, ...) and only if the type of the corresponding vertex buffer is an integer type)\r\n // if the type is a signed type, the value is negated\r\n public vertexBufferKindToNumberOfComponents: { [kind: string]: number } = {};\r\n\r\n protected _webgpuProcessingContext: WebGPUShaderProcessingContext;\r\n\r\n protected abstract _getArraySize(name: string, type: string, preProcessors: { [key: string]: string }): [string, string, number];\r\n protected abstract _generateLeftOverUBOCode(name: string, uniformBufferDescription: WebGPUBufferDescription): string;\r\n\r\n protected _addUniformToLeftOverUBO(name: string, uniformType: string, preProcessors: { [key: string]: string }): void {\r\n let length = 0;\r\n\r\n [name, uniformType, length] = this._getArraySize(name, uniformType, preProcessors);\r\n\r\n for (let i = 0; i < this._webgpuProcessingContext.leftOverUniforms.length; i++) {\r\n if (this._webgpuProcessingContext.leftOverUniforms[i].name === name) {\r\n return;\r\n }\r\n }\r\n\r\n this._webgpuProcessingContext.leftOverUniforms.push({\r\n name,\r\n type: uniformType,\r\n length,\r\n });\r\n }\r\n\r\n protected _buildLeftOverUBO(): string {\r\n if (!this._webgpuProcessingContext.leftOverUniforms.length) {\r\n return \"\";\r\n }\r\n const name = WebGPUShaderProcessor.LeftOvertUBOName;\r\n let availableUBO = this._webgpuProcessingContext.availableBuffers[name];\r\n if (!availableUBO) {\r\n availableUBO = {\r\n binding: this._webgpuProcessingContext.getNextFreeUBOBinding(),\r\n };\r\n this._webgpuProcessingContext.availableBuffers[name] = availableUBO;\r\n this._addBufferBindingDescription(name, availableUBO, WebGPUConstants.BufferBindingType.Uniform, true);\r\n this._addBufferBindingDescription(name, availableUBO, WebGPUConstants.BufferBindingType.Uniform, false);\r\n }\r\n\r\n return this._generateLeftOverUBOCode(name, availableUBO);\r\n }\r\n\r\n protected _collectBindingNames(): void {\r\n // collect all the binding names for faster processing in WebGPUCacheBindGroup\r\n for (let i = 0; i < this._webgpuProcessingContext.bindGroupLayoutEntries.length; i++) {\r\n const setDefinition = this._webgpuProcessingContext.bindGroupLayoutEntries[i];\r\n if (setDefinition === undefined) {\r\n this._webgpuProcessingContext.bindGroupLayoutEntries[i] = [];\r\n continue;\r\n }\r\n for (let j = 0; j < setDefinition.length; j++) {\r\n const entry = this._webgpuProcessingContext.bindGroupLayoutEntries[i][j];\r\n const name = this._webgpuProcessingContext.bindGroupLayoutEntryInfo[i][entry.binding].name;\r\n const nameInArrayOfTexture = this._webgpuProcessingContext.bindGroupLayoutEntryInfo[i][entry.binding].nameInArrayOfTexture;\r\n if (entry) {\r\n if (entry.texture || entry.externalTexture || entry.storageTexture) {\r\n this._webgpuProcessingContext.textureNames.push(nameInArrayOfTexture!);\r\n } else if (entry.sampler) {\r\n this._webgpuProcessingContext.samplerNames.push(name);\r\n } else if (entry.buffer) {\r\n this._webgpuProcessingContext.bufferNames.push(name);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n protected _preCreateBindGroupEntries(): void {\r\n const bindGroupEntries = this._webgpuProcessingContext.bindGroupEntries;\r\n\r\n for (let i = 0; i < this._webgpuProcessingContext.bindGroupLayoutEntries.length; i++) {\r\n const setDefinition = this._webgpuProcessingContext.bindGroupLayoutEntries[i];\r\n\r\n const entries: GPUBindGroupEntry[] = [];\r\n for (let j = 0; j < setDefinition.length; j++) {\r\n const entry = this._webgpuProcessingContext.bindGroupLayoutEntries[i][j];\r\n\r\n if (entry.sampler || entry.texture || entry.storageTexture || entry.externalTexture) {\r\n entries.push({\r\n binding: entry.binding,\r\n resource: undefined as any,\r\n });\r\n } else if (entry.buffer) {\r\n entries.push({\r\n binding: entry.binding,\r\n resource: {\r\n buffer: undefined as any,\r\n offset: 0,\r\n size: 0,\r\n },\r\n });\r\n }\r\n }\r\n\r\n bindGroupEntries[i] = entries;\r\n }\r\n }\r\n\r\n protected _addTextureBindingDescription(\r\n name: string,\r\n textureInfo: WebGPUTextureDescription,\r\n textureIndex: number,\r\n dimension: Nullable<GPUTextureViewDimension>,\r\n format: Nullable<GPUTextureFormat>,\r\n isVertex: boolean\r\n ): void {\r\n // eslint-disable-next-line prefer-const\r\n let { groupIndex, bindingIndex } = textureInfo.textures[textureIndex];\r\n if (!this._webgpuProcessingContext.bindGroupLayoutEntries[groupIndex]) {\r\n this._webgpuProcessingContext.bindGroupLayoutEntries[groupIndex] = [];\r\n this._webgpuProcessingContext.bindGroupLayoutEntryInfo[groupIndex] = [];\r\n }\r\n if (!this._webgpuProcessingContext.bindGroupLayoutEntryInfo[groupIndex][bindingIndex]) {\r\n let len;\r\n if (dimension === null) {\r\n len = this._webgpuProcessingContext.bindGroupLayoutEntries[groupIndex].push({\r\n binding: bindingIndex,\r\n visibility: 0,\r\n externalTexture: {},\r\n });\r\n } else if (format) {\r\n len = this._webgpuProcessingContext.bindGroupLayoutEntries[groupIndex].push({\r\n binding: bindingIndex,\r\n visibility: 0,\r\n storageTexture: {\r\n access: WebGPUConstants.StorageTextureAccess.WriteOnly,\r\n format,\r\n viewDimension: dimension,\r\n },\r\n });\r\n } else {\r\n len = this._webgpuProcessingContext.bindGroupLayoutEntries[groupIndex].push({\r\n binding: bindingIndex,\r\n visibility: 0,\r\n texture: {\r\n sampleType: textureInfo.sampleType,\r\n viewDimension: dimension,\r\n multisampled: false,\r\n },\r\n });\r\n }\r\n const textureName = textureInfo.isTextureArray ? name + textureIndex : name;\r\n this._webgpuProcessingContext.bindGroupLayoutEntryInfo[groupIndex][bindingIndex] = { name, index: len - 1, nameInArrayOfTexture: textureName };\r\n }\r\n\r\n bindingIndex = this._webgpuProcessingContext.bindGroupLayoutEntryInfo[groupIndex][bindingIndex].index;\r\n if (isVertex) {\r\n this._webgpuProcessingContext.bindGroupLayoutEntries[groupIndex][bindingIndex].visibility |= WebGPUConstants.ShaderStage.Vertex;\r\n } else {\r\n this._webgpuProcessingContext.bindGroupLayoutEntries[groupIndex][bindingIndex].visibility |= WebGPUConstants.ShaderStage.Fragment;\r\n }\r\n }\r\n\r\n protected _addSamplerBindingDescription(name: string, samplerInfo: WebGPUSamplerDescription, isVertex: boolean): void {\r\n // eslint-disable-next-line prefer-const\r\n let { groupIndex, bindingIndex } = samplerInfo.binding;\r\n if (!this._webgpuProcessingContext.bindGroupLayoutEntries[groupIndex]) {\r\n this._webgpuProcessingContext.bindGroupLayoutEntries[groupIndex] = [];\r\n this._webgpuProcessingContext.bindGroupLayoutEntryInfo[groupIndex] = [];\r\n }\r\n if (!this._webgpuProcessingContext.bindGroupLayoutEntryInfo[groupIndex][bindingIndex]) {\r\n const len = this._webgpuProcessingContext.bindGroupLayoutEntries[groupIndex].push({\r\n binding: bindingIndex,\r\n visibility: 0,\r\n sampler: {\r\n type: samplerInfo.type,\r\n },\r\n });\r\n this._webgpuProcessingContext.bindGroupLayoutEntryInfo[groupIndex][bindingIndex] = { name, index: len - 1 };\r\n }\r\n\r\n bindingIndex = this._webgpuProcessingContext.bindGroupLayoutEntryInfo[groupIndex][bindingIndex].index;\r\n if (isVertex) {\r\n this._webgpuProcessingContext.bindGroupLayoutEntries[groupIndex][bindingIndex].visibility |= WebGPUConstants.ShaderStage.Vertex;\r\n } else {\r\n this._webgpuProcessingContext.bindGroupLayoutEntries[groupIndex][bindingIndex].visibility |= WebGPUConstants.ShaderStage.Fragment;\r\n }\r\n }\r\n\r\n protected _addBufferBindingDescription(name: string, uniformBufferInfo: WebGPUBufferDescription, bufferType: GPUBufferBindingType, isVertex: boolean): void {\r\n // eslint-disable-next-line prefer-const\r\n let { groupIndex, bindingIndex } = uniformBufferInfo.binding;\r\n if (!this._webgpuProcessingContext.bindGroupLayoutEntries[groupIndex]) {\r\n this._webgpuProcessingContext.bindGroupLayoutEntries[groupIndex] = [];\r\n this._webgpuProcessingContext.bindGroupLayoutEntryInfo[groupIndex] = [];\r\n }\r\n if (!this._webgpuProcessingContext.bindGroupLayoutEntryInfo[groupIndex][bindingIndex]) {\r\n const len = this._webgpuProcessingContext.bindGroupLayoutEntries[groupIndex].push({\r\n binding: bindingIndex,\r\n visibility: 0,\r\n buffer: {\r\n type: bufferType,\r\n },\r\n });\r\n this._webgpuProcessingContext.bindGroupLayoutEntryInfo[groupIndex][bindingIndex] = { name, index: len - 1 };\r\n }\r\n\r\n bindingIndex = this._webgpuProcessingContext.bindGroupLayoutEntryInfo[groupIndex][bindingIndex].index;\r\n if (isVertex) {\r\n this._webgpuProcessingContext.bindGroupLayoutEntries[groupIndex][bindingIndex].visibility |= WebGPUConstants.ShaderStage.Vertex;\r\n } else {\r\n this._webgpuProcessingContext.bindGroupLayoutEntries[groupIndex][bindingIndex].visibility |= WebGPUConstants.ShaderStage.Fragment;\r\n }\r\n }\r\n\r\n protected _injectStartingAndEndingCode(code: string, mainFuncDecl: string, startingCode?: string, endingCode?: string): string {\r\n let idx = code.indexOf(mainFuncDecl);\r\n if (idx < 0) {\r\n Logger.Error(`No \"main\" function found in shader code! Processing aborted.`);\r\n return code;\r\n }\r\n if (startingCode) {\r\n // eslint-disable-next-line no-empty\r\n while (idx++ < code.length && code.charAt(idx) != \"{\") {}\r\n if (idx < code.length) {\r\n const part1 = code.substring(0, idx + 1);\r\n const part2 = code.substring(idx + 1);\r\n code = part1 + startingCode + part2;\r\n }\r\n }\r\n\r\n if (endingCode) {\r\n const lastClosingCurly = code.lastIndexOf(\"}\");\r\n code = code.substring(0, lastClosingCurly);\r\n code += endingCode + \"\\n}\";\r\n }\r\n\r\n return code;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"webgpuShaderProcessor.js","sourceRoot":"","sources":["../../../../../dev/core/src/Engines/WebGPU/webgpuShaderProcessor.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,wCAAwC;AACxC,OAAO,EAAE,MAAM,EAAE,6BAAyB;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAGhE,OAAO,KAAK,eAAe,MAAM,mBAAmB,CAAC;AAGrD,gBAAgB;AAChB,MAAM,OAAgB,qBAAqB;IAA3C;QA2FW,mBAAc,GAAG,cAAc,CAAC,IAAI,CAAC;QAE5C,sKAAsK;QACtK,qDAAqD;QAC9C,yCAAoC,GAA+B,EAAE,CAAC;IAsOjF,CAAC;IA/Na,wBAAwB,CAAC,IAAY,EAAE,WAAmB,EAAE,aAAwC;QAC1G,IAAI,MAAM,GAAG,CAAC,CAAC;QAEf,CAAC,IAAI,EAAE,WAAW,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,WAAW,EAAE,aAAa,CAAC,CAAC;QAEnF,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,wBAAwB,CAAC,gBAAgB,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YAC5E,IAAI,IAAI,CAAC,wBAAwB,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,EAAE;gBACjE,OAAO;aACV;SACJ;QAED,IAAI,CAAC,wBAAwB,CAAC,gBAAgB,CAAC,IAAI,CAAC;YAChD,IAAI;YACJ,IAAI,EAAE,WAAW;YACjB,MAAM;SACT,CAAC,CAAC;IACP,CAAC;IAES,iBAAiB;QACvB,IAAI,CAAC,IAAI,CAAC,wBAAwB,CAA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AAC/C,oDAA8B,GAA8B;IACzE,SAAS,EAAE,WAAW;IACtB,cAAc,EAAE,gBAAgB;IAChC,eAAe,EAAE,WAAW;IAC5B,oBAAoB,EAAE,gBAAgB;IACtC,WAAW,EAAE,aAAa;IAC1B,gBAAgB,EAAE,kBAAkB;IACpC,SAAS,EAAE,WAAW;CACzB,AAR8C,CAQ7C;AAEF,gEAAgE;AAC/C,iEAA2C,GAA+C;IACvG,WAAW,EAAE,eAAe,CAAC,oBAAoB,CAAC,IAAI;IACtD,gBAAgB,EAAE,eAAe,CAAC,oBAAoB,CAAC,SAAS;IAChE,SAAS,EAAE,eAAe,CAAC,oBAAoB,CAAC,GAAG;IACnD,cAAc,EAAE,eAAe,CAAC,oBAAoB,CAAC,QAAQ;IAC7D,SAAS,EAAE,eAAe,CAAC,oBAAoB,CAAC,GAAG;CACtD,AAN2D,CAM1D;AAEF,uFAAuF;AACvF,gEAAgE;AAC/C,oDAA8B,GAA8B;IACzE,eAAe,EAAE,eAAe;IAChC,oBAAoB,EAAE,eAAe;CACxC,AAH8C,CAG7C;AAEF,gEAAgE;AAC/C,6DAAuC,GAA+B;IACnF,aAAa,EAAE,IAAI;IACnB,kBAAkB,EAAE,IAAI;IACxB,OAAO,EAAE,KAAK;CACjB,AAJuD,CAItD","sourcesContent":["/* eslint-disable babylonjs/available */\r\n/* eslint-disable jsdoc/require-jsdoc */\r\nimport { Logger } from \"core/Misc/logger\";\r\nimport { ShaderLanguage } from \"../../Materials/shaderLanguage\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { IShaderProcessor } from \"../Processors/iShaderProcessor\";\r\nimport * as WebGPUConstants from \"./webgpuConstants\";\r\nimport type { WebGPUSamplerDescription, WebGPUShaderProcessingContext, WebGPUTextureDescription, WebGPUBufferDescription } from \"./webgpuShaderProcessingContext\";\r\n\r\n/** @internal */\r\nexport abstract class WebGPUShaderProcessor implements IShaderProcessor {\r\n public static readonly AutoSamplerSuffix = \"Sampler\";\r\n public static readonly LeftOvertUBOName = \"LeftOver\";\r\n public static readonly InternalsUBOName = \"Internals\";\r\n\r\n public static UniformSizes: { [type: string]: number } = {\r\n // GLSL types\r\n bool: 1,\r\n int: 1,\r\n float: 1,\r\n vec2: 2,\r\n ivec2: 2,\r\n uvec2: 2,\r\n vec3: 3,\r\n ivec3: 3,\r\n uvec3: 3,\r\n vec4: 4,\r\n ivec4: 4,\r\n uvec4: 4,\r\n mat2: 4,\r\n mat3: 12,\r\n mat4: 16,\r\n\r\n // WGSL types\r\n i32: 1,\r\n u32: 1,\r\n f32: 1,\r\n mat2x2: 4,\r\n mat3x3: 12,\r\n mat4x4: 16,\r\n mat2x2f: 4,\r\n mat3x3f: 12,\r\n mat4x4f: 16,\r\n vec2i: 2,\r\n vec3i: 3,\r\n vec4i: 4,\r\n vec2u: 2,\r\n vec3u: 3,\r\n vec4u: 4,\r\n vec2f: 2,\r\n vec3f: 3,\r\n vec4f: 4,\r\n vec2h: 1,\r\n vec3h: 2,\r\n vec4h: 2,\r\n };\r\n\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n protected static _SamplerFunctionByWebGLSamplerType: { [key: string]: string } = {\r\n sampler2D: \"sampler2D\",\r\n sampler2DArray: \"sampler2DArray\",\r\n sampler2DShadow: \"sampler2DShadow\",\r\n sampler2DArrayShadow: \"sampler2DArrayShadow\",\r\n samplerCube: \"samplerCube\",\r\n sampler3D: \"sampler3D\",\r\n };\r\n\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n protected static _TextureTypeByWebGLSamplerType: { [key: string]: string } = {\r\n sampler2D: \"texture2D\",\r\n sampler2DArray: \"texture2DArray\",\r\n sampler2DShadow: \"texture2D\",\r\n sampler2DArrayShadow: \"texture2DArray\",\r\n samplerCube: \"textureCube\",\r\n samplerCubeArray: \"textureCubeArray\",\r\n sampler3D: \"texture3D\",\r\n };\r\n\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n protected static _GpuTextureViewDimensionByWebGPUTextureType: { [key: string]: GPUTextureViewDimension } = {\r\n textureCube: WebGPUConstants.TextureViewDimension.Cube,\r\n textureCubeArray: WebGPUConstants.TextureViewDimension.CubeArray,\r\n texture2D: WebGPUConstants.TextureViewDimension.E2d,\r\n texture2DArray: WebGPUConstants.TextureViewDimension.E2dArray,\r\n texture3D: WebGPUConstants.TextureViewDimension.E3d,\r\n };\r\n\r\n // if the webgl sampler type is not listed in this array, \"sampler\" is taken by default\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n protected static _SamplerTypeByWebGLSamplerType: { [key: string]: string } = {\r\n sampler2DShadow: \"samplerShadow\",\r\n sampler2DArrayShadow: \"samplerShadow\",\r\n };\r\n\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n protected static _IsComparisonSamplerByWebGPUSamplerType: { [key: string]: boolean } = {\r\n samplerShadow: true,\r\n samplerArrayShadow: true,\r\n sampler: false,\r\n };\r\n\r\n public shaderLanguage = ShaderLanguage.GLSL;\r\n\r\n // this object is populated only with vertex kinds known by the engine (position, uv, ...) and only if the type of the corresponding vertex buffer is an integer type)\r\n // if the type is a signed type, the value is negated\r\n public vertexBufferKindToNumberOfComponents: { [kind: string]: number } = {};\r\n\r\n protected _webgpuProcessingContext: WebGPUShaderProcessingContext;\r\n\r\n protected abstract _getArraySize(name: string, type: string, preProcessors: { [key: string]: string }): [string, string, number];\r\n protected abstract _generateLeftOverUBOCode(name: string, uniformBufferDescription: WebGPUBufferDescription): string;\r\n\r\n protected _addUniformToLeftOverUBO(name: string, uniformType: string, preProcessors: { [key: string]: string }): void {\r\n let length = 0;\r\n\r\n [name, uniformType, length] = this._getArraySize(name, uniformType, preProcessors);\r\n\r\n for (let i = 0; i < this._webgpuProcessingContext.leftOverUniforms.length; i++) {\r\n if (this._webgpuProcessingContext.leftOverUniforms[i].name === name) {\r\n return;\r\n }\r\n }\r\n\r\n this._webgpuProcessingContext.leftOverUniforms.push({\r\n name,\r\n type: uniformType,\r\n length,\r\n });\r\n }\r\n\r\n protected _buildLeftOverUBO(): string {\r\n if (!this._webgpuProcessingContext.leftOverUniforms.length) {\r\n return \"\";\r\n }\r\n const name = WebGPUShaderProcessor.LeftOvertUBOName;\r\n let availableUBO = this._webgpuProcessingContext.availableBuffers[name];\r\n if (!availableUBO) {\r\n availableUBO = {\r\n binding: this._webgpuProcessingContext.getNextFreeUBOBinding(),\r\n };\r\n this._webgpuProcessingContext.availableBuffers[name] = availableUBO;\r\n this._addBufferBindingDescription(name, availableUBO, WebGPUConstants.BufferBindingType.Uniform, true);\r\n this._addBufferBindingDescription(name, availableUBO, WebGPUConstants.BufferBindingType.Uniform, false);\r\n }\r\n\r\n return this._generateLeftOverUBOCode(name, availableUBO);\r\n }\r\n\r\n protected _collectBindingNames(): void {\r\n // collect all the binding names for faster processing in WebGPUCacheBindGroup\r\n for (let i = 0; i < this._webgpuProcessingContext.bindGroupLayoutEntries.length; i++) {\r\n const setDefinition = this._webgpuProcessingContext.bindGroupLayoutEntries[i];\r\n if (setDefinition === undefined) {\r\n this._webgpuProcessingContext.bindGroupLayoutEntries[i] = [];\r\n continue;\r\n }\r\n for (let j = 0; j < setDefinition.length; j++) {\r\n const entry = this._webgpuProcessingContext.bindGroupLayoutEntries[i][j];\r\n const name = this._webgpuProcessingContext.bindGroupLayoutEntryInfo[i][entry.binding].name;\r\n const nameInArrayOfTexture = this._webgpuProcessingContext.bindGroupLayoutEntryInfo[i][entry.binding].nameInArrayOfTexture;\r\n if (entry) {\r\n if (entry.texture || entry.externalTexture || entry.storageTexture) {\r\n this._webgpuProcessingContext.textureNames.push(nameInArrayOfTexture!);\r\n } else if (entry.sampler) {\r\n this._webgpuProcessingContext.samplerNames.push(name);\r\n } else if (entry.buffer) {\r\n this._webgpuProcessingContext.bufferNames.push(name);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n protected _preCreateBindGroupEntries(): void {\r\n const bindGroupEntries = this._webgpuProcessingContext.bindGroupEntries;\r\n\r\n for (let i = 0; i < this._webgpuProcessingContext.bindGroupLayoutEntries.length; i++) {\r\n const setDefinition = this._webgpuProcessingContext.bindGroupLayoutEntries[i];\r\n\r\n const entries: GPUBindGroupEntry[] = [];\r\n for (let j = 0; j < setDefinition.length; j++) {\r\n const entry = this._webgpuProcessingContext.bindGroupLayoutEntries[i][j];\r\n\r\n if (entry.sampler || entry.texture || entry.storageTexture || entry.externalTexture) {\r\n entries.push({\r\n binding: entry.binding,\r\n resource: undefined as any,\r\n });\r\n } else if (entry.buffer) {\r\n entries.push({\r\n binding: entry.binding,\r\n resource: {\r\n buffer: undefined as any,\r\n offset: 0,\r\n size: 0,\r\n },\r\n });\r\n }\r\n }\r\n\r\n bindGroupEntries[i] = entries;\r\n }\r\n }\r\n\r\n protected _addTextureBindingDescription(\r\n name: string,\r\n textureInfo: WebGPUTextureDescription,\r\n textureIndex: number,\r\n dimension: Nullable<GPUTextureViewDimension>,\r\n format: Nullable<GPUTextureFormat>,\r\n isVertex: boolean\r\n ): void {\r\n // eslint-disable-next-line prefer-const\r\n let { groupIndex, bindingIndex } = textureInfo.textures[textureIndex];\r\n if (!this._webgpuProcessingContext.bindGroupLayoutEntries[groupIndex]) {\r\n this._webgpuProcessingContext.bindGroupLayoutEntries[groupIndex] = [];\r\n this._webgpuProcessingContext.bindGroupLayoutEntryInfo[groupIndex] = [];\r\n }\r\n if (!this._webgpuProcessingContext.bindGroupLayoutEntryInfo[groupIndex][bindingIndex]) {\r\n let len;\r\n if (dimension === null) {\r\n len = this._webgpuProcessingContext.bindGroupLayoutEntries[groupIndex].push({\r\n binding: bindingIndex,\r\n visibility: 0,\r\n externalTexture: {},\r\n });\r\n } else if (format) {\r\n len = this._webgpuProcessingContext.bindGroupLayoutEntries[groupIndex].push({\r\n binding: bindingIndex,\r\n visibility: 0,\r\n storageTexture: {\r\n access: WebGPUConstants.StorageTextureAccess.WriteOnly,\r\n format,\r\n viewDimension: dimension,\r\n },\r\n });\r\n } else {\r\n len = this._webgpuProcessingContext.bindGroupLayoutEntries[groupIndex].push({\r\n binding: bindingIndex,\r\n visibility: 0,\r\n texture: {\r\n sampleType: textureInfo.sampleType,\r\n viewDimension: dimension,\r\n multisampled: false,\r\n },\r\n });\r\n }\r\n const textureName = textureInfo.isTextureArray ? name + textureIndex : name;\r\n this._webgpuProcessingContext.bindGroupLayoutEntryInfo[groupIndex][bindingIndex] = { name, index: len - 1, nameInArrayOfTexture: textureName };\r\n }\r\n\r\n bindingIndex = this._webgpuProcessingContext.bindGroupLayoutEntryInfo[groupIndex][bindingIndex].index;\r\n if (isVertex) {\r\n this._webgpuProcessingContext.bindGroupLayoutEntries[groupIndex][bindingIndex].visibility |= WebGPUConstants.ShaderStage.Vertex;\r\n } else {\r\n this._webgpuProcessingContext.bindGroupLayoutEntries[groupIndex][bindingIndex].visibility |= WebGPUConstants.ShaderStage.Fragment;\r\n }\r\n }\r\n\r\n protected _addSamplerBindingDescription(name: string, samplerInfo: WebGPUSamplerDescription, isVertex: boolean): void {\r\n // eslint-disable-next-line prefer-const\r\n let { groupIndex, bindingIndex } = samplerInfo.binding;\r\n if (!this._webgpuProcessingContext.bindGroupLayoutEntries[groupIndex]) {\r\n this._webgpuProcessingContext.bindGroupLayoutEntries[groupIndex] = [];\r\n this._webgpuProcessingContext.bindGroupLayoutEntryInfo[groupIndex] = [];\r\n }\r\n if (!this._webgpuProcessingContext.bindGroupLayoutEntryInfo[groupIndex][bindingIndex]) {\r\n const len = this._webgpuProcessingContext.bindGroupLayoutEntries[groupIndex].push({\r\n binding: bindingIndex,\r\n visibility: 0,\r\n sampler: {\r\n type: samplerInfo.type,\r\n },\r\n });\r\n this._webgpuProcessingContext.bindGroupLayoutEntryInfo[groupIndex][bindingIndex] = { name, index: len - 1 };\r\n }\r\n\r\n bindingIndex = this._webgpuProcessingContext.bindGroupLayoutEntryInfo[groupIndex][bindingIndex].index;\r\n if (isVertex) {\r\n this._webgpuProcessingContext.bindGroupLayoutEntries[groupIndex][bindingIndex].visibility |= WebGPUConstants.ShaderStage.Vertex;\r\n } else {\r\n this._webgpuProcessingContext.bindGroupLayoutEntries[groupIndex][bindingIndex].visibility |= WebGPUConstants.ShaderStage.Fragment;\r\n }\r\n }\r\n\r\n protected _addBufferBindingDescription(name: string, uniformBufferInfo: WebGPUBufferDescription, bufferType: GPUBufferBindingType, isVertex: boolean): void {\r\n // eslint-disable-next-line prefer-const\r\n let { groupIndex, bindingIndex } = uniformBufferInfo.binding;\r\n if (!this._webgpuProcessingContext.bindGroupLayoutEntries[groupIndex]) {\r\n this._webgpuProcessingContext.bindGroupLayoutEntries[groupIndex] = [];\r\n this._webgpuProcessingContext.bindGroupLayoutEntryInfo[groupIndex] = [];\r\n }\r\n if (!this._webgpuProcessingContext.bindGroupLayoutEntryInfo[groupIndex][bindingIndex]) {\r\n const len = this._webgpuProcessingContext.bindGroupLayoutEntries[groupIndex].push({\r\n binding: bindingIndex,\r\n visibility: 0,\r\n buffer: {\r\n type: bufferType,\r\n },\r\n });\r\n this._webgpuProcessingContext.bindGroupLayoutEntryInfo[groupIndex][bindingIndex] = { name, index: len - 1 };\r\n }\r\n\r\n bindingIndex = this._webgpuProcessingContext.bindGroupLayoutEntryInfo[groupIndex][bindingIndex].index;\r\n if (isVertex) {\r\n this._webgpuProcessingContext.bindGroupLayoutEntries[groupIndex][bindingIndex].visibility |= WebGPUConstants.ShaderStage.Vertex;\r\n } else {\r\n this._webgpuProcessingContext.bindGroupLayoutEntries[groupIndex][bindingIndex].visibility |= WebGPUConstants.ShaderStage.Fragment;\r\n }\r\n }\r\n\r\n protected _injectStartingAndEndingCode(code: string, mainFuncDecl: string, startingCode?: string, endingCode?: string): string {\r\n let idx = code.indexOf(mainFuncDecl);\r\n if (idx < 0) {\r\n Logger.Error(`No \"main\" function found in shader code! Processing aborted.`);\r\n return code;\r\n }\r\n if (startingCode) {\r\n // eslint-disable-next-line no-empty\r\n while (idx++ < code.length && code.charAt(idx) != \"{\") {}\r\n if (idx < code.length) {\r\n const part1 = code.substring(0, idx + 1);\r\n const part2 = code.substring(idx + 1);\r\n code = part1 + startingCode + part2;\r\n }\r\n }\r\n\r\n if (endingCode) {\r\n const lastClosingCurly = code.lastIndexOf(\"}\");\r\n code = code.substring(0, lastClosingCurly);\r\n code += endingCode + \"\\n}\";\r\n }\r\n\r\n return code;\r\n }\r\n}\r\n"]}