@onerjs/core 8.33.5 → 8.33.6

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 (73) hide show
  1. package/Engines/WebGPU/Extensions/engine.multiRender.js +5 -10
  2. package/Engines/WebGPU/Extensions/engine.multiRender.js.map +1 -1
  3. package/Engines/WebGPU/Extensions/engine.renderTarget.js +4 -2
  4. package/Engines/WebGPU/Extensions/engine.renderTarget.js.map +1 -1
  5. package/Engines/WebGPU/webgpuHardwareTexture.d.ts +4 -3
  6. package/Engines/WebGPU/webgpuHardwareTexture.js +27 -21
  7. package/Engines/WebGPU/webgpuHardwareTexture.js.map +1 -1
  8. package/Engines/WebGPU/webgpuTextureManager.d.ts +5 -4
  9. package/Engines/WebGPU/webgpuTextureManager.js +20 -30
  10. package/Engines/WebGPU/webgpuTextureManager.js.map +1 -1
  11. package/Engines/engine.d.ts +1 -0
  12. package/Engines/thinEngine.js +9 -1
  13. package/Engines/thinEngine.js.map +1 -1
  14. package/Engines/thinWebGPUEngine.js +2 -3
  15. package/Engines/thinWebGPUEngine.js.map +1 -1
  16. package/Engines/webgpuEngine.js +28 -13
  17. package/Engines/webgpuEngine.js.map +1 -1
  18. package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js +2 -2
  19. package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js.map +1 -1
  20. package/FrameGraph/Node/Blocks/Textures/clearBlock.d.ts +1 -1
  21. package/FrameGraph/Node/Blocks/Textures/clearBlock.js +2 -2
  22. package/FrameGraph/Node/Blocks/Textures/clearBlock.js.map +1 -1
  23. package/FrameGraph/Node/Blocks/inputBlock.js +4 -0
  24. package/FrameGraph/Node/Blocks/inputBlock.js.map +1 -1
  25. package/FrameGraph/Node/nodeRenderGraphBlock.d.ts +1 -0
  26. package/FrameGraph/Node/nodeRenderGraphBlock.js +19 -0
  27. package/FrameGraph/Node/nodeRenderGraphBlock.js.map +1 -1
  28. package/FrameGraph/Passes/renderPass.d.ts +16 -0
  29. package/FrameGraph/Passes/renderPass.js +12 -0
  30. package/FrameGraph/Passes/renderPass.js.map +1 -1
  31. package/FrameGraph/Tasks/Rendering/objectRendererTask.d.ts +3 -3
  32. package/FrameGraph/Tasks/Rendering/objectRendererTask.js +3 -2
  33. package/FrameGraph/Tasks/Rendering/objectRendererTask.js.map +1 -1
  34. package/FrameGraph/Tasks/Texture/clearTextureTask.d.ts +2 -2
  35. package/FrameGraph/Tasks/Texture/clearTextureTask.js +3 -2
  36. package/FrameGraph/Tasks/Texture/clearTextureTask.js.map +1 -1
  37. package/FrameGraph/frameGraphRenderContext.js +4 -15
  38. package/FrameGraph/frameGraphRenderContext.js.map +1 -1
  39. package/FrameGraph/frameGraphTask.d.ts +2 -2
  40. package/FrameGraph/frameGraphTask.js +6 -6
  41. package/FrameGraph/frameGraphTask.js.map +1 -1
  42. package/FrameGraph/frameGraphTaskMultiRenderTarget.d.ts +15 -0
  43. package/FrameGraph/frameGraphTaskMultiRenderTarget.js +25 -0
  44. package/FrameGraph/frameGraphTaskMultiRenderTarget.js.map +1 -0
  45. package/FrameGraph/frameGraphTextureManager.js +13 -2
  46. package/FrameGraph/frameGraphTextureManager.js.map +1 -1
  47. package/FrameGraph/frameGraphTypes.d.ts +9 -1
  48. package/FrameGraph/frameGraphTypes.js.map +1 -1
  49. package/Loading/Plugins/babylonFileLoader.js +13 -0
  50. package/Loading/Plugins/babylonFileLoader.js.map +1 -1
  51. package/Materials/Textures/baseTexture.d.ts +4 -0
  52. package/Materials/Textures/baseTexture.js +4 -0
  53. package/Materials/Textures/baseTexture.js.map +1 -1
  54. package/Materials/Textures/textureCreationOptions.d.ts +2 -0
  55. package/Materials/Textures/textureCreationOptions.js +0 -1
  56. package/Materials/Textures/textureCreationOptions.js.map +1 -1
  57. package/Meshes/abstractMesh.js +1 -1
  58. package/Meshes/abstractMesh.js.map +1 -1
  59. package/Meshes/geometry.js +1 -0
  60. package/Meshes/geometry.js.map +1 -1
  61. package/Misc/decorators.serialization.js +1 -1
  62. package/Misc/decorators.serialization.js.map +1 -1
  63. package/Particles/solidParticleSystem.d.ts +2 -1
  64. package/Particles/solidParticleSystem.js.map +1 -1
  65. package/Shaders/ShadersInclude/shadowsFragmentFunctions.js +4 -12
  66. package/Shaders/ShadersInclude/shadowsFragmentFunctions.js.map +1 -1
  67. package/Shaders/picking.vertex.js +2 -2
  68. package/Shaders/picking.vertex.js.map +1 -1
  69. package/ShadersWGSL/ShadersInclude/shadowsFragmentFunctions.js +8 -14
  70. package/ShadersWGSL/ShadersInclude/shadowsFragmentFunctions.js.map +1 -1
  71. package/ShadersWGSL/picking.vertex.js +2 -2
  72. package/ShadersWGSL/picking.vertex.js.map +1 -1
  73. package/package.json +1 -1
@@ -97,7 +97,6 @@ export class ThinWebGPUEngine extends AbstractEngine {
97
97
  // We must close the current pass (if any) because we are going to use the render encoder to generate the mipmaps (so, we are going to create a new render pass)
98
98
  this._endCurrentRenderPass();
99
99
  }
100
- const format = texture._hardwareTexture.format;
101
100
  const mipmapCount = WebGPUTextureHelper.ComputeNumMipmapLevels(texture.width, texture.height);
102
101
  if (this.dbgVerboseLogsForFirstFrames) {
103
102
  if (this._count === undefined) {
@@ -117,10 +116,10 @@ export class ThinWebGPUEngine extends AbstractEngine {
117
116
  }
118
117
  }
119
118
  if (texture.isCube) {
120
- this._textureHelper.generateCubeMipmaps(gpuHardwareTexture, format, mipmapCount, commandEncoder);
119
+ this._textureHelper.generateCubeMipmaps(gpuHardwareTexture, mipmapCount, commandEncoder);
121
120
  }
122
121
  else {
123
- this._textureHelper.generateMipmaps(gpuHardwareTexture, format, mipmapCount, 0, texture.is3D, commandEncoder);
122
+ this._textureHelper.generateMipmaps(gpuHardwareTexture, mipmapCount, 0, commandEncoder);
124
123
  }
125
124
  }
126
125
  }
@@ -1 +1 @@
1
- {"version":3,"file":"thinWebGPUEngine.js","sourceRoot":"","sources":["../../../../dev/core/src/Engines/thinWebGPUEngine.ts"],"names":[],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AAE,CAAC;gBACpC,IAAY,CAAC,MAAM,GAAG,CAAC,CAAC;YAC7B,CAAC;YACD,IAAI,CAAE,IAAY,CAAC,MAAM,IAAK,IAAY,CAAC,MAAM,GAAG,IAAI,CAAC,uBAAuB,EAAE,CAAC;gBAC/E,MAAM,CAAC,GAAG,CACN,SAAS;oBACJ,IAAY,CAAC,MAAM;oBACpB,8BAA8B;oBAC9B,OAAO,CAAC,KAAK;oBACb,WAAW;oBACX,OAAO,CAAC,MAAM;oBACd,WAAW;oBACX,OAAO,CAAC,MAAM;oBACd,oBAAoB;oBACpB,CAAC,cAAc,KAAK,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CACnE,CAAC;YACN,CAAC;QACL,CAAC;QAED,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;YACjB,IAAI,CAAC,cAAc,CAAC,mBAAmB,CAAC,kBAAkB,EAAE,MAAM,EAAE,WAAW,EAAE,cAAc,CAAC,CAAC;QACrG,CAAC;aAAM,CAAC;YACJ,IAAI,CAAC,cAAc,CAAC,eAAe,CAAC,kBAAkB,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC,EAAE,OAAO,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;QAClH,CAAC;IACL,CAAC;CACJ","sourcesContent":["import type { InternalTexture } from \"core/Materials/Textures/internalTexture\";\r\nimport { AbstractEngine } from \"./abstractEngine\";\r\nimport type { WebGPUCacheRenderPipeline } from \"./WebGPU/webgpuCacheRenderPipeline\";\r\nimport type { WebGPUTextureManager } from \"./WebGPU/webgpuTextureManager\";\r\nimport type { WebGPUHardwareTexture } from \"./WebGPU/webgpuHardwareTexture\";\r\nimport type { Nullable } from \"core/types\";\r\nimport { Logger } from \"core/Misc/logger\";\r\nimport { WebGPUTextureHelper } from \"./WebGPU/webgpuTextureHelper\";\r\nimport type { WebGPURenderTargetWrapper } from \"./WebGPU/webgpuRenderTargetWrapper\";\r\nimport { WebGPUPerfCounter } from \"./WebGPU/webgpuPerfCounter\";\r\nimport type { WebGPUSnapshotRendering } from \"./WebGPU/webgpuSnapshotRendering\";\r\nimport { Constants } from \"./constants\";\r\nimport type { WebGPUBundleList } from \"./WebGPU/webgpuBundleList\";\r\nimport type { WebGPUTimestampQuery } from \"./WebGPU/webgpuTimestampQuery\";\r\nimport type { WebGPUOcclusionQuery } from \"./WebGPU/webgpuOcclusionQuery\";\r\n\r\n/**\r\n * The base engine class for WebGPU\r\n */\r\nexport abstract class ThinWebGPUEngine extends AbstractEngine {\r\n // TODO WEBGPU remove those variables when code stabilized\r\n /** @internal */\r\n public dbgShowShaderCode = false;\r\n /** @internal */\r\n public dbgSanityChecks = true;\r\n /** @internal */\r\n public dbgVerboseLogsNumFrames = 10;\r\n /** @internal */\r\n public dbgLogIfNotDrawWrapper = true;\r\n /** @internal */\r\n public dbgShowEmptyEnableEffectCalls = true;\r\n /** @internal */\r\n public dbgVerboseLogsForFirstFrames = false;\r\n\r\n /** @internal */\r\n public _textureHelper: WebGPUTextureManager;\r\n /** @internal */\r\n public _cacheRenderPipeline: WebGPUCacheRenderPipeline;\r\n /** @internal */\r\n public _occlusionQuery: WebGPUOcclusionQuery;\r\n\r\n // Frame Life Cycle (recreated each frame)\r\n /** @internal */\r\n public _renderEncoder: GPUCommandEncoder;\r\n /** @internal */\r\n public _uploadEncoder: GPUCommandEncoder;\r\n\r\n /** @internal */\r\n public _currentRenderPass: Nullable<GPURenderPassEncoder> = null;\r\n\r\n protected _snapshotRendering: WebGPUSnapshotRendering;\r\n protected _snapshotRenderingMode = Constants.SNAPSHOTRENDERING_STANDARD;\r\n\r\n /** @internal */\r\n public _timestampQuery: WebGPUTimestampQuery;\r\n /** @internal */\r\n public _timestampIndex = 0;\r\n\r\n /** @internal */\r\n public _debugStackRenderPass: string[] = [];\r\n\r\n /**\r\n * Gets the GPU time spent in the main render pass for the last frame rendered (in nanoseconds).\r\n * You have to enable the \"timestamp-query\" extension in the engine constructor options and set engine.enableGPUTimingMeasurements = true.\r\n * It will only return time spent in the main pass, not additional render target / compute passes (if any)!\r\n */\r\n public readonly gpuTimeInFrameForMainPass?: WebGPUPerfCounter;\r\n\r\n /**\r\n * Used for both the compatibilityMode=false and the snapshot rendering modes (as both can't be enabled at the same time)\r\n * @internal\r\n */\r\n public _bundleList: WebGPUBundleList;\r\n\r\n /**\r\n * Enables or disables GPU timing measurements.\r\n * Note that this is only supported if the \"timestamp-query\" extension is enabled in the options.\r\n */\r\n public get enableGPUTimingMeasurements(): boolean {\r\n return this._timestampQuery.enable;\r\n }\r\n\r\n public set enableGPUTimingMeasurements(enable: boolean) {\r\n if (this._timestampQuery.enable === enable) {\r\n return;\r\n }\r\n (this.gpuTimeInFrameForMainPass as any) = enable ? new WebGPUPerfCounter() : undefined;\r\n this._timestampQuery.enable = enable;\r\n }\r\n\r\n protected _currentPassIsMainPass() {\r\n return this._currentRenderTarget === null;\r\n }\r\n\r\n /** @internal */\r\n public _endCurrentRenderPass(): number {\r\n if (!this._currentRenderPass) {\r\n return 0;\r\n }\r\n\r\n if (this._debugStackRenderPass.length !== 0) {\r\n for (let i = 0; i < this._debugStackRenderPass.length; ++i) {\r\n this._currentRenderPass.popDebugGroup();\r\n }\r\n }\r\n\r\n const currentPassIndex = this._currentPassIsMainPass() ? 2 : 1;\r\n\r\n if (!this._snapshotRendering.endRenderPass(this._currentRenderPass) && !this.compatibilityMode) {\r\n this._bundleList.run(this._currentRenderPass);\r\n this._bundleList.reset();\r\n }\r\n this._currentRenderPass.end();\r\n\r\n this._timestampQuery.endPass(\r\n this._timestampIndex,\r\n (this._currentRenderTarget && (this._currentRenderTarget as WebGPURenderTargetWrapper).gpuTimeInFrame\r\n ? (this._currentRenderTarget as WebGPURenderTargetWrapper).gpuTimeInFrame\r\n : this.gpuTimeInFrameForMainPass) as WebGPUPerfCounter\r\n );\r\n this._timestampIndex += 2;\r\n\r\n if (this.dbgVerboseLogsForFirstFrames) {\r\n if ((this as any)._count === undefined) {\r\n (this as any)._count = 0;\r\n }\r\n if (!(this as any)._count || (this as any)._count < this.dbgVerboseLogsNumFrames) {\r\n Logger.Log(\r\n \"frame #\" +\r\n (this as any)._count +\r\n \" - \" +\r\n (currentPassIndex === 2 ? \"main\" : \"render target\") +\r\n \" end pass\" +\r\n (currentPassIndex === 1 ? \" - internalTexture.uniqueId=\" + this._currentRenderTarget?.texture?.uniqueId : \"\")\r\n );\r\n }\r\n }\r\n this._debugPopGroup?.(0);\r\n this._currentRenderPass = null;\r\n\r\n return currentPassIndex;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _generateMipmaps(texture: InternalTexture, commandEncoder?: GPUCommandEncoder) {\r\n commandEncoder = commandEncoder ?? this._renderEncoder;\r\n\r\n const gpuHardwareTexture = texture._hardwareTexture as Nullable<WebGPUHardwareTexture>;\r\n\r\n if (!gpuHardwareTexture) {\r\n return;\r\n }\r\n\r\n if (commandEncoder === this._renderEncoder) {\r\n // We must close the current pass (if any) because we are going to use the render encoder to generate the mipmaps (so, we are going to create a new render pass)\r\n this._endCurrentRenderPass();\r\n }\r\n\r\n const format = (texture._hardwareTexture as WebGPUHardwareTexture).format;\r\n const mipmapCount = WebGPUTextureHelper.ComputeNumMipmapLevels(texture.width, texture.height);\r\n\r\n if (this.dbgVerboseLogsForFirstFrames) {\r\n if ((this as any)._count === undefined) {\r\n (this as any)._count = 0;\r\n }\r\n if (!(this as any)._count || (this as any)._count < this.dbgVerboseLogsNumFrames) {\r\n Logger.Log(\r\n \"frame #\" +\r\n (this as any)._count +\r\n \" - generate mipmaps - width=\" +\r\n texture.width +\r\n \", height=\" +\r\n texture.height +\r\n \", isCube=\" +\r\n texture.isCube +\r\n \", command encoder=\" +\r\n (commandEncoder === this._renderEncoder ? \"render\" : \"copy\")\r\n );\r\n }\r\n }\r\n\r\n if (texture.isCube) {\r\n this._textureHelper.generateCubeMipmaps(gpuHardwareTexture, format, mipmapCount, commandEncoder);\r\n } else {\r\n this._textureHelper.generateMipmaps(gpuHardwareTexture, format, mipmapCount, 0, texture.is3D, commandEncoder);\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"thinWebGPUEngine.js","sourceRoot":"","sources":["../../../../dev/core/src/Engines/thinWebGPUEngine.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAKlD,OAAO,EAAE,MAAM,EAAE,0BAAyB;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAEnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAE/D,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAKxC;;GAEG;AACH,MAAM,OAAgB,gBAAiB,SAAQ,cAAc;IAA7D;;QACI,0DAA0D;QAC1D,gBAAgB;QACT,sBAAiB,GAAG,KAAK,CAAC;QACjC,gBAAgB;QACT,oBAAe,GAAG,IAAI,CAAC;QAC9B,gBAAgB;QACT,4BAAuB,GAAG,EAAE,CAAC;QACpC,gBAAgB;QACT,2BAAsB,GAAG,IAAI,CAAC;QACrC,gBAAgB;QACT,kCAA6B,GAAG,IAAI,CAAC;QAC5C,gBAAgB;QACT,iCAA4B,GAAG,KAAK,CAAC;QAe5C,gBAAgB;QACT,uBAAkB,GAAmC,IAAI,CAAC;QAGvD,2BAAsB,GAAG,SAAS,CAAC,0BAA0B,CAAC;QAIxE,gBAAgB;QACT,oBAAe,GAAG,CAAC,CAAC;QAE3B,gBAAgB;QACT,0BAAqB,GAAa,EAAE,CAAC;IAiIhD,CAAC;IAlHG;;;OAGG;IACH,IAAW,2BAA2B;QAClC,OAAO,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC;IACvC,CAAC;IAED,IAAW,2BAA2B,CAAC,MAAe;QAClD,IAAI,IAAI,CAAC,eAAe,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;YACzC,OAAO;QACX,CAAC;QACA,IAAI,CAAC,yBAAiC,GAAG,MAAM,CAA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,CAAC,CAAC;QAE9F,IAAI,IAAI,CAAC,4BAA4B,EAAE,CAAC;YACpC,IAAK,IAAY,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;gBACpC,IAAY,CAAC,MAAM,GAAG,CAAC,CAAC;YAC7B,CAAC;YACD,IAAI,CAAE,IAAY,CAAC,MAAM,IAAK,IAAY,CAAC,MAAM,GAAG,IAAI,CAAC,uBAAuB,EAAE,CAAC;gBAC/E,MAAM,CAAC,GAAG,CACN,SAAS;oBACJ,IAAY,CAAC,MAAM;oBACpB,8BAA8B;oBAC9B,OAAO,CAAC,KAAK;oBACb,WAAW;oBACX,OAAO,CAAC,MAAM;oBACd,WAAW;oBACX,OAAO,CAAC,MAAM;oBACd,oBAAoB;oBACpB,CAAC,cAAc,KAAK,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CACnE,CAAC;YACN,CAAC;QACL,CAAC;QAED,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;YACjB,IAAI,CAAC,cAAc,CAAC,mBAAmB,CAAC,kBAAkB,EAAE,WAAW,EAAE,cAAc,CAAC,CAAC;QAC7F,CAAC;aAAM,CAAC;YACJ,IAAI,CAAC,cAAc,CAAC,eAAe,CAAC,kBAAkB,EAAE,WAAW,EAAE,CAAC,EAAE,cAAc,CAAC,CAAC;QAC5F,CAAC;IACL,CAAC;CACJ","sourcesContent":["import type { InternalTexture } from \"core/Materials/Textures/internalTexture\";\r\nimport { AbstractEngine } from \"./abstractEngine\";\r\nimport type { WebGPUCacheRenderPipeline } from \"./WebGPU/webgpuCacheRenderPipeline\";\r\nimport type { WebGPUTextureManager } from \"./WebGPU/webgpuTextureManager\";\r\nimport type { WebGPUHardwareTexture } from \"./WebGPU/webgpuHardwareTexture\";\r\nimport type { Nullable } from \"core/types\";\r\nimport { Logger } from \"core/Misc/logger\";\r\nimport { WebGPUTextureHelper } from \"./WebGPU/webgpuTextureHelper\";\r\nimport type { WebGPURenderTargetWrapper } from \"./WebGPU/webgpuRenderTargetWrapper\";\r\nimport { WebGPUPerfCounter } from \"./WebGPU/webgpuPerfCounter\";\r\nimport type { WebGPUSnapshotRendering } from \"./WebGPU/webgpuSnapshotRendering\";\r\nimport { Constants } from \"./constants\";\r\nimport type { WebGPUBundleList } from \"./WebGPU/webgpuBundleList\";\r\nimport type { WebGPUTimestampQuery } from \"./WebGPU/webgpuTimestampQuery\";\r\nimport type { WebGPUOcclusionQuery } from \"./WebGPU/webgpuOcclusionQuery\";\r\n\r\n/**\r\n * The base engine class for WebGPU\r\n */\r\nexport abstract class ThinWebGPUEngine extends AbstractEngine {\r\n // TODO WEBGPU remove those variables when code stabilized\r\n /** @internal */\r\n public dbgShowShaderCode = false;\r\n /** @internal */\r\n public dbgSanityChecks = true;\r\n /** @internal */\r\n public dbgVerboseLogsNumFrames = 10;\r\n /** @internal */\r\n public dbgLogIfNotDrawWrapper = true;\r\n /** @internal */\r\n public dbgShowEmptyEnableEffectCalls = true;\r\n /** @internal */\r\n public dbgVerboseLogsForFirstFrames = false;\r\n\r\n /** @internal */\r\n public _textureHelper: WebGPUTextureManager;\r\n /** @internal */\r\n public _cacheRenderPipeline: WebGPUCacheRenderPipeline;\r\n /** @internal */\r\n public _occlusionQuery: WebGPUOcclusionQuery;\r\n\r\n // Frame Life Cycle (recreated each frame)\r\n /** @internal */\r\n public _renderEncoder: GPUCommandEncoder;\r\n /** @internal */\r\n public _uploadEncoder: GPUCommandEncoder;\r\n\r\n /** @internal */\r\n public _currentRenderPass: Nullable<GPURenderPassEncoder> = null;\r\n\r\n protected _snapshotRendering: WebGPUSnapshotRendering;\r\n protected _snapshotRenderingMode = Constants.SNAPSHOTRENDERING_STANDARD;\r\n\r\n /** @internal */\r\n public _timestampQuery: WebGPUTimestampQuery;\r\n /** @internal */\r\n public _timestampIndex = 0;\r\n\r\n /** @internal */\r\n public _debugStackRenderPass: string[] = [];\r\n\r\n /**\r\n * Gets the GPU time spent in the main render pass for the last frame rendered (in nanoseconds).\r\n * You have to enable the \"timestamp-query\" extension in the engine constructor options and set engine.enableGPUTimingMeasurements = true.\r\n * It will only return time spent in the main pass, not additional render target / compute passes (if any)!\r\n */\r\n public readonly gpuTimeInFrameForMainPass?: WebGPUPerfCounter;\r\n\r\n /**\r\n * Used for both the compatibilityMode=false and the snapshot rendering modes (as both can't be enabled at the same time)\r\n * @internal\r\n */\r\n public _bundleList: WebGPUBundleList;\r\n\r\n /**\r\n * Enables or disables GPU timing measurements.\r\n * Note that this is only supported if the \"timestamp-query\" extension is enabled in the options.\r\n */\r\n public get enableGPUTimingMeasurements(): boolean {\r\n return this._timestampQuery.enable;\r\n }\r\n\r\n public set enableGPUTimingMeasurements(enable: boolean) {\r\n if (this._timestampQuery.enable === enable) {\r\n return;\r\n }\r\n (this.gpuTimeInFrameForMainPass as any) = enable ? new WebGPUPerfCounter() : undefined;\r\n this._timestampQuery.enable = enable;\r\n }\r\n\r\n protected _currentPassIsMainPass() {\r\n return this._currentRenderTarget === null;\r\n }\r\n\r\n /** @internal */\r\n public _endCurrentRenderPass(): number {\r\n if (!this._currentRenderPass) {\r\n return 0;\r\n }\r\n\r\n if (this._debugStackRenderPass.length !== 0) {\r\n for (let i = 0; i < this._debugStackRenderPass.length; ++i) {\r\n this._currentRenderPass.popDebugGroup();\r\n }\r\n }\r\n\r\n const currentPassIndex = this._currentPassIsMainPass() ? 2 : 1;\r\n\r\n if (!this._snapshotRendering.endRenderPass(this._currentRenderPass) && !this.compatibilityMode) {\r\n this._bundleList.run(this._currentRenderPass);\r\n this._bundleList.reset();\r\n }\r\n this._currentRenderPass.end();\r\n\r\n this._timestampQuery.endPass(\r\n this._timestampIndex,\r\n (this._currentRenderTarget && (this._currentRenderTarget as WebGPURenderTargetWrapper).gpuTimeInFrame\r\n ? (this._currentRenderTarget as WebGPURenderTargetWrapper).gpuTimeInFrame\r\n : this.gpuTimeInFrameForMainPass) as WebGPUPerfCounter\r\n );\r\n this._timestampIndex += 2;\r\n\r\n if (this.dbgVerboseLogsForFirstFrames) {\r\n if ((this as any)._count === undefined) {\r\n (this as any)._count = 0;\r\n }\r\n if (!(this as any)._count || (this as any)._count < this.dbgVerboseLogsNumFrames) {\r\n Logger.Log(\r\n \"frame #\" +\r\n (this as any)._count +\r\n \" - \" +\r\n (currentPassIndex === 2 ? \"main\" : \"render target\") +\r\n \" end pass\" +\r\n (currentPassIndex === 1 ? \" - internalTexture.uniqueId=\" + this._currentRenderTarget?.texture?.uniqueId : \"\")\r\n );\r\n }\r\n }\r\n this._debugPopGroup?.(0);\r\n this._currentRenderPass = null;\r\n\r\n return currentPassIndex;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _generateMipmaps(texture: InternalTexture, commandEncoder?: GPUCommandEncoder) {\r\n commandEncoder = commandEncoder ?? this._renderEncoder;\r\n\r\n const gpuHardwareTexture = texture._hardwareTexture as Nullable<WebGPUHardwareTexture>;\r\n\r\n if (!gpuHardwareTexture) {\r\n return;\r\n }\r\n\r\n if (commandEncoder === this._renderEncoder) {\r\n // We must close the current pass (if any) because we are going to use the render encoder to generate the mipmaps (so, we are going to create a new render pass)\r\n this._endCurrentRenderPass();\r\n }\r\n\r\n const mipmapCount = WebGPUTextureHelper.ComputeNumMipmapLevels(texture.width, texture.height);\r\n\r\n if (this.dbgVerboseLogsForFirstFrames) {\r\n if ((this as any)._count === undefined) {\r\n (this as any)._count = 0;\r\n }\r\n if (!(this as any)._count || (this as any)._count < this.dbgVerboseLogsNumFrames) {\r\n Logger.Log(\r\n \"frame #\" +\r\n (this as any)._count +\r\n \" - generate mipmaps - width=\" +\r\n texture.width +\r\n \", height=\" +\r\n texture.height +\r\n \", isCube=\" +\r\n texture.isCube +\r\n \", command encoder=\" +\r\n (commandEncoder === this._renderEncoder ? \"render\" : \"copy\")\r\n );\r\n }\r\n }\r\n\r\n if (texture.isCube) {\r\n this._textureHelper.generateCubeMipmaps(gpuHardwareTexture, mipmapCount, commandEncoder);\r\n } else {\r\n this._textureHelper.generateMipmaps(gpuHardwareTexture, mipmapCount, 0, commandEncoder);\r\n }\r\n }\r\n}\r\n"]}
@@ -1807,6 +1807,7 @@ export class WebGPUEngine extends ThinWebGPUEngine {
1807
1807
  fullOptions.creationFlags = options.creationFlags ?? 0;
1808
1808
  fullOptions.useSRGBBuffer = options.useSRGBBuffer ?? false;
1809
1809
  fullOptions.label = options.label;
1810
+ fullOptions.isCube = !!options.isCube;
1810
1811
  }
1811
1812
  else {
1812
1813
  fullOptions.generateMipMaps = options;
@@ -1816,6 +1817,7 @@ export class WebGPUEngine extends ThinWebGPUEngine {
1816
1817
  fullOptions.samples = 1;
1817
1818
  fullOptions.creationFlags = 0;
1818
1819
  fullOptions.useSRGBBuffer = false;
1820
+ fullOptions.isCube = false;
1819
1821
  }
1820
1822
  if (fullOptions.type === 1 && !this._caps.textureFloatLinearFiltering) {
1821
1823
  fullOptions.samplingMode = 1;
@@ -1845,6 +1847,7 @@ export class WebGPUEngine extends ThinWebGPUEngine {
1845
1847
  texture.format = fullOptions.format;
1846
1848
  texture.is2DArray = layers > 0;
1847
1849
  texture.is3D = depth > 0;
1850
+ texture.isCube = fullOptions.isCube;
1848
1851
  texture._cachedWrapU = 0;
1849
1852
  texture._cachedWrapV = 0;
1850
1853
  texture._useSRGBBuffer = fullOptions.useSRGBBuffer;
@@ -1856,7 +1859,7 @@ export class WebGPUEngine extends ThinWebGPUEngine {
1856
1859
  // So that the call to createGPUTextureForInternalTexture creates the mipmaps
1857
1860
  texture.generateMipMaps = true;
1858
1861
  }
1859
- this._textureHelper.createGPUTextureForInternalTexture(texture, width, height, layers || 1, fullOptions.creationFlags);
1862
+ this._textureHelper.createGPUTextureForInternalTexture(texture, width, height, texture.depth || 1, fullOptions.creationFlags);
1860
1863
  if (createMipMapsOnly) {
1861
1864
  // So that we don't automatically generate mipmaps when the render target is unbound
1862
1865
  texture.generateMipMaps = false;
@@ -2037,7 +2040,7 @@ export class WebGPUEngine extends ThinWebGPUEngine {
2037
2040
  }
2038
2041
  const texture = loadData.texture;
2039
2042
  if (!createPolynomials) {
2040
- texture._sphericalPolynomial = new SphericalPolynomial();
2043
+ texture._sphericalPolynomial = texture._sphericalPolynomial ?? new SphericalPolynomial();
2041
2044
  }
2042
2045
  else if (loadData.info.sphericalPolynomial) {
2043
2046
  texture._sphericalPolynomial = loadData.info.sphericalPolynomial;
@@ -2254,7 +2257,7 @@ export class WebGPUEngine extends ThinWebGPUEngine {
2254
2257
  * @param data defines the data to fill with the read pixels (if not provided, a new one will be created)
2255
2258
  * @returns a ArrayBufferView promise (Uint8Array) containing RGBA colors
2256
2259
  */
2257
- // eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/promise-function-async
2260
+ // eslint-disable-next-line @typescript-eslint/promise-function-async
2258
2261
  readPixels(x, y, width, height, _hasAlpha = true, flushRenderer = true, data = null) {
2259
2262
  const renderPassWrapper = this._getCurrentRenderPassWrapper();
2260
2263
  const hardwareTexture = renderPassWrapper.colorAttachmentGPUTextures[0];
@@ -2378,16 +2381,28 @@ export class WebGPUEngine extends ThinWebGPUEngine {
2378
2381
  _startRenderTargetRenderPass(renderTargetWrapper, setClearStates, clearColor, clearDepth, clearStencil) {
2379
2382
  this._endCurrentRenderPass();
2380
2383
  const rtWrapper = renderTargetWrapper;
2384
+ const sampleCount = renderTargetWrapper.samples;
2385
+ const useMSAA = sampleCount > 1;
2381
2386
  const depthStencilTexture = rtWrapper._depthStencilTexture;
2382
2387
  const gpuDepthStencilWrapper = depthStencilTexture?._hardwareTexture;
2383
2388
  const gpuDepthStencilTexture = gpuDepthStencilWrapper?.underlyingResource;
2384
- const gpuDepthStencilMSAATexture = gpuDepthStencilWrapper?.getMSAATexture(0);
2385
- const depthMSAATextureView = gpuDepthStencilMSAATexture?.createView(this._rttRenderPassWrapper.depthAttachmentViewDescriptor);
2386
- const depthTextureView = depthMSAATextureView ? undefined : gpuDepthStencilTexture?.createView(this._rttRenderPassWrapper.depthAttachmentViewDescriptor);
2387
- // We use the MSAA texture format (if available) to determine if it has a stencil aspect or not because, for MSAA depth textures,
2389
+ // We use the MSAA texture format first (if available) to determine if it has a stencil aspect or not because, for MSAA depth textures,
2388
2390
  // the format of the "resolve" texture (gpuDepthStencilWrapper.format) is a single red channel format, not a depth-stencil format.
2389
- const depthTextureHasStencil = gpuDepthStencilWrapper ? WebGPUTextureHelper.HasStencilAspect(gpuDepthStencilMSAATexture?.format ?? gpuDepthStencilWrapper.format) : false;
2390
- const depthTextureHasDepth = gpuDepthStencilWrapper ? WebGPUTextureHelper.HasDepthAspect(gpuDepthStencilMSAATexture?.format ?? gpuDepthStencilWrapper.format) : false;
2391
+ let depthStencilView;
2392
+ let format;
2393
+ if (useMSAA) {
2394
+ const gpuMSAATexture = gpuDepthStencilWrapper?.getMSAATexture(sampleCount);
2395
+ depthStencilView = gpuMSAATexture?.createView(this._rttRenderPassWrapper.depthAttachmentViewDescriptor);
2396
+ format = gpuMSAATexture?.format;
2397
+ }
2398
+ if (!depthStencilView && gpuDepthStencilTexture) {
2399
+ depthStencilView = gpuDepthStencilTexture.createView(this._rttRenderPassWrapper.depthAttachmentViewDescriptor);
2400
+ }
2401
+ if (!format && gpuDepthStencilWrapper) {
2402
+ format = gpuDepthStencilWrapper.format;
2403
+ }
2404
+ const depthTextureHasStencil = format ? WebGPUTextureHelper.HasStencilAspect(format) : false;
2405
+ const depthTextureHasDepth = format ? WebGPUTextureHelper.HasDepthAspect(format) : false;
2391
2406
  const colorAttachments = [];
2392
2407
  if (this.useReverseDepthBuffer) {
2393
2408
  this.setDepthFunctionToGreaterOrEqual();
@@ -2414,7 +2429,7 @@ export class WebGPUEngine extends ThinWebGPUEngine {
2414
2429
  const gpuMRTTexture = gpuMRTWrapper?.underlyingResource;
2415
2430
  if (gpuMRTWrapper && gpuMRTTexture) {
2416
2431
  const baseArrayLayer = rtWrapper.getBaseArrayLayer(i);
2417
- const gpuMSAATexture = gpuMRTWrapper.getMSAATexture(baseArrayLayer);
2432
+ const gpuMSAATexture = useMSAA ? gpuMRTWrapper.getMSAATexture(sampleCount, i) : undefined;
2418
2433
  const viewDescriptor = {
2419
2434
  ...this._rttRenderPassWrapper.colorAttachmentViewDescriptor,
2420
2435
  dimension: mrtTexture.is3D ? "3d" /* WebGPUConstants.TextureViewDimension.E3d */ : "2d" /* WebGPUConstants.TextureViewDimension.E2d */,
@@ -2454,7 +2469,7 @@ export class WebGPUEngine extends ThinWebGPUEngine {
2454
2469
  depthSlice = this._rttRenderPassWrapper.colorAttachmentViewDescriptor.baseArrayLayer;
2455
2470
  this._rttRenderPassWrapper.colorAttachmentViewDescriptor.baseArrayLayer = 0;
2456
2471
  }
2457
- const gpuMSAATexture = gpuWrapper.getMSAATexture(0);
2472
+ const gpuMSAATexture = useMSAA ? gpuWrapper.getMSAATexture(sampleCount) : undefined;
2458
2473
  const colorTextureView = gpuTexture.createView(this._rttRenderPassWrapper.colorAttachmentViewDescriptor);
2459
2474
  const colorMSAATextureView = gpuMSAATexture?.createView(this._rttRenderPassWrapper.colorAttachmentViewDescriptor);
2460
2475
  const isRtInteger = internalTexture.type === 7 || internalTexture.type === 5;
@@ -2477,7 +2492,7 @@ export class WebGPUEngine extends ThinWebGPUEngine {
2477
2492
  colorAttachments,
2478
2493
  depthStencilAttachment: depthStencilTexture && gpuDepthStencilTexture
2479
2494
  ? {
2480
- view: depthMSAATextureView ? depthMSAATextureView : depthTextureView,
2495
+ view: depthStencilView,
2481
2496
  depthClearValue: mustClearDepth ? (this.useReverseDepthBuffer ? this._clearReverseDepthValue : this._clearDepthValue) : undefined,
2482
2497
  depthLoadOp: rtWrapper.depthReadOnly || !depthTextureHasDepth ? undefined : mustClearDepth ? "clear" /* WebGPUConstants.LoadOp.Clear */ : "load" /* WebGPUConstants.LoadOp.Load */,
2483
2498
  depthStoreOp: rtWrapper.depthReadOnly || !depthTextureHasDepth ? undefined : "store" /* WebGPUConstants.StoreOp.Store */,
@@ -2752,7 +2767,7 @@ export class WebGPUEngine extends ThinWebGPUEngine {
2752
2767
  }
2753
2768
  if (texture.resolveMSAADepth && texture._depthStencilTexture) {
2754
2769
  const gpuTextureWrapper = texture._depthStencilTexture._hardwareTexture;
2755
- this._textureHelper.resolveMSAADepthTexture(gpuTextureWrapper.getMSAATexture(0), gpuTextureWrapper.underlyingResource, this._renderEncoder);
2770
+ this._textureHelper.resolveMSAADepthTexture(gpuTextureWrapper.getMSAATexture(texture.samples), gpuTextureWrapper.underlyingResource, this._renderEncoder);
2756
2771
  }
2757
2772
  }
2758
2773
  /**