@onerjs/core 8.46.1 → 8.46.3

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 (54) hide show
  1. package/Collisions/gpuPicker.js +9 -1
  2. package/Collisions/gpuPicker.js.map +1 -1
  3. package/Engines/WebGPU/webgpuCacheRenderPipeline.d.ts +20 -0
  4. package/Engines/WebGPU/webgpuCacheRenderPipeline.js +58 -13
  5. package/Engines/WebGPU/webgpuCacheRenderPipeline.js.map +1 -1
  6. package/Engines/WebGPU/webgpuConstants.d.ts +5 -2
  7. package/Engines/WebGPU/webgpuConstants.js +3 -0
  8. package/Engines/WebGPU/webgpuConstants.js.map +1 -1
  9. package/Engines/abstractEngine.js +2 -2
  10. package/Engines/abstractEngine.js.map +1 -1
  11. package/Engines/engine.d.ts +45 -41
  12. package/Engines/shaderStore.js +2 -2
  13. package/Engines/shaderStore.js.map +1 -1
  14. package/Engines/webgpuEngine.d.ts +84 -0
  15. package/Engines/webgpuEngine.js +80 -1
  16. package/Engines/webgpuEngine.js.map +1 -1
  17. package/Layers/thinHighlightLayer.js.map +1 -1
  18. package/Layers/thinSelectionOutlineLayer.js +20 -5
  19. package/Layers/thinSelectionOutlineLayer.js.map +1 -1
  20. package/Materials/GaussianSplatting/gaussianSplattingGpuPickingMaterialPlugin.d.ts +7 -0
  21. package/Materials/GaussianSplatting/gaussianSplattingGpuPickingMaterialPlugin.js +22 -0
  22. package/Materials/GaussianSplatting/gaussianSplattingGpuPickingMaterialPlugin.js.map +1 -1
  23. package/Materials/GaussianSplatting/gaussianSplattingMaterial.js +2 -28
  24. package/Materials/GaussianSplatting/gaussianSplattingMaterial.js.map +1 -1
  25. package/Materials/Textures/baseTexture.js +3 -0
  26. package/Materials/Textures/baseTexture.js.map +1 -1
  27. package/Materials/Textures/texture.js +1 -0
  28. package/Materials/Textures/texture.js.map +1 -1
  29. package/Meshes/GaussianSplatting/gaussianSplattingCompoundMesh.d.ts +46 -0
  30. package/Meshes/GaussianSplatting/gaussianSplattingCompoundMesh.js +56 -0
  31. package/Meshes/GaussianSplatting/gaussianSplattingCompoundMesh.js.map +1 -0
  32. package/Meshes/GaussianSplatting/gaussianSplattingMesh.d.ts +104 -463
  33. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +553 -2018
  34. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
  35. package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.d.ts +554 -0
  36. package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.js +2017 -0
  37. package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.js.map +1 -0
  38. package/Meshes/index.d.ts +2 -0
  39. package/Meshes/index.js +2 -0
  40. package/Meshes/index.js.map +1 -1
  41. package/Misc/tools.js +1 -1
  42. package/Misc/tools.js.map +1 -1
  43. package/Rendering/depthRenderer.js +2 -1
  44. package/Rendering/depthRenderer.js.map +1 -1
  45. package/node.d.ts +7 -0
  46. package/node.js +17 -0
  47. package/node.js.map +1 -1
  48. package/package.json +2 -2
  49. package/Shaders/ShadersInclude/openpbrBlockAmbientOcclusion.d.ts +0 -5
  50. package/Shaders/ShadersInclude/openpbrBlockAmbientOcclusion.js +0 -35
  51. package/Shaders/ShadersInclude/openpbrBlockAmbientOcclusion.js.map +0 -1
  52. package/ShadersWGSL/ShadersInclude/openpbrBlockAmbientOcclusion.d.ts +0 -5
  53. package/ShadersWGSL/ShadersInclude/openpbrBlockAmbientOcclusion.js +0 -36
  54. package/ShadersWGSL/ShadersInclude/openpbrBlockAmbientOcclusion.js.map +0 -1
@@ -1808,7 +1808,11 @@ interface GPUSupportedLimits {
1808
1808
  readonly maxSampledTexturesPerShaderStage: number;
1809
1809
  readonly maxSamplersPerShaderStage: number;
1810
1810
  readonly maxStorageBuffersPerShaderStage: number;
1811
+ readonly maxStorageBuffersInVertexStage: number;
1812
+ readonly maxStorageBuffersInFragmentStage: number;
1811
1813
  readonly maxStorageTexturesPerShaderStage: number;
1814
+ readonly maxStorageTexturesInVertexStage: number;
1815
+ readonly maxStorageTexturesInFragmentStage: number;
1812
1816
  readonly maxUniformBuffersPerShaderStage: number;
1813
1817
  readonly maxUniformBufferBindingSize: number;
1814
1818
  readonly maxStorageBufferBindingSize: number;
@@ -1852,7 +1856,7 @@ interface WorkerNavigator {
1852
1856
  }
1853
1857
 
1854
1858
  class GPU {
1855
- requestAdapter(options?: GPURequestAdapterOptions): Promise<GPUAdapter | undefined>;
1859
+ requestAdapter(options?: GPURequestAdapterOptions): Promise<GPUAdapter | null>;
1856
1860
  getPreferredCanvasFormat(): GPUTextureFormat;
1857
1861
 
1858
1862
  readonly wgslLanguageFeatures: WGSLLanguageFeatures;
@@ -1868,8 +1872,6 @@ interface GPURequestAdapterOptions {
1868
1872
  type GPUPowerPreference = "low-power" | "high-performance";
1869
1873
 
1870
1874
  class GPUAdapter {
1871
- // https://michalzalecki.com/nominal-typing-in-typescript/#approach-1-class-with-a-private-property
1872
- readonly name: string;
1873
1875
  readonly features: GPUSupportedFeatures;
1874
1876
  readonly limits: GPUSupportedLimits;
1875
1877
  readonly info: GPUAdapterInfo;
@@ -1903,7 +1905,9 @@ type GPUFeatureName =
1903
1905
  | "dual-source-blending"
1904
1906
  | "subgroups"
1905
1907
  | "texture-formats-tier1"
1906
- | "texture-formats-tier2";
1908
+ | "texture-formats-tier2"
1909
+ | "primitive-index"
1910
+ | "texture-component-swizzle";
1907
1911
 
1908
1912
  class GPUDevice extends EventTarget implements GPUObjectBase {
1909
1913
  label: string | undefined;
@@ -1941,8 +1945,8 @@ class GPUDevice extends EventTarget implements GPUObjectBase {
1941
1945
 
1942
1946
  readonly lost: Promise<GPUDeviceLostInfo>;
1943
1947
  pushErrorScope(filter: GPUErrorFilter): void;
1944
- popErrorScope(): Promise<GPUError | undefined>;
1945
- onuncapturederror: Event | undefined;
1948
+ popErrorScope(): Promise<GPUError | null>;
1949
+ onuncapturederror: ((this: GPUDevice, ev: GPUUncapturedErrorEvent) => any) | null;
1946
1950
  }
1947
1951
 
1948
1952
  class GPUBuffer implements GPUObjectBase {
@@ -1965,7 +1969,7 @@ type GPUBufferMapState = "unmapped" | "pending" | "mapped";
1965
1969
  interface GPUBufferDescriptor extends GPUObjectDescriptorBase {
1966
1970
  size: GPUSize64;
1967
1971
  usage: GPUBufferUsageFlags;
1968
- mappedAtCreation: boolean /* default=false */;
1972
+ mappedAtCreation?: boolean /* default=false */;
1969
1973
  }
1970
1974
 
1971
1975
  type GPUBufferUsageFlags = number;
@@ -1997,6 +2001,7 @@ interface GPUTextureDescriptor extends GPUObjectDescriptorBase {
1997
2001
  format: GPUTextureFormat;
1998
2002
  usage: GPUTextureUsageFlags;
1999
2003
  viewFormats?: GPUTextureFormat[] /* default=[] */;
2004
+ textureBindingViewDimension?: GPUTextureViewDimension;
2000
2005
  }
2001
2006
 
2002
2007
  type GPUTextureDimension = "1d" | "2d" | "3d";
@@ -2008,14 +2013,15 @@ class GPUTextureView implements GPUObjectBase {
2008
2013
  }
2009
2014
 
2010
2015
  interface GPUTextureViewDescriptor extends GPUObjectDescriptorBase {
2011
- format: GPUTextureFormat;
2012
- dimension: GPUTextureViewDimension;
2016
+ format?: GPUTextureFormat;
2017
+ dimension?: GPUTextureViewDimension;
2013
2018
  usage?: GPUTextureUsageFlags /* default=0 */;
2014
2019
  aspect?: GPUTextureAspect /* default="all" */;
2015
2020
  baseMipLevel?: GPUIntegerCoordinate /* default=0 */;
2016
- mipLevelCount: GPUIntegerCoordinate;
2021
+ mipLevelCount?: GPUIntegerCoordinate;
2017
2022
  baseArrayLayer?: GPUIntegerCoordinate /* default=0*/;
2018
- arrayLayerCount: GPUIntegerCoordinate;
2023
+ arrayLayerCount?: GPUIntegerCoordinate;
2024
+ swizzle?: string /* default="rgba" */;
2019
2025
  }
2020
2026
 
2021
2027
  type GPUTextureViewDimension = "1d" | "2d" | "2d-array" | "cube" | "cube-array" | "3d";
@@ -2272,13 +2278,13 @@ class GPUShaderModule implements GPUObjectBase {
2272
2278
  }
2273
2279
 
2274
2280
  interface GPUShaderModuleDescriptor extends GPUObjectDescriptorBase {
2275
- code: string | Uint32Array;
2281
+ code: string;
2276
2282
  compilationHints?: GPUShaderModuleCompilationHint[] /* default=[] */;
2277
2283
  }
2278
2284
 
2279
2285
  interface GPUShaderModuleCompilationHint {
2280
- entryPoint: string | Uint32Array;
2281
- layout: GPUPipelineLayout | GPUAutoLayoutMode;
2286
+ entryPoint: string;
2287
+ layout?: GPUPipelineLayout | GPUAutoLayoutMode;
2282
2288
  }
2283
2289
 
2284
2290
  type GPUCompilationMessageType = "error" | "warning" | "info";
@@ -2319,7 +2325,7 @@ interface GPUPipelineBase {
2319
2325
 
2320
2326
  interface GPUProgrammableStage {
2321
2327
  module: GPUShaderModule;
2322
- entryPoint: string | Uint32Array;
2328
+ entryPoint?: string;
2323
2329
  constants?: { [name: string]: GPUPipelineConstantValue } /* default={} */;
2324
2330
  }
2325
2331
 
@@ -2507,7 +2513,7 @@ interface GPUVertexAttribute {
2507
2513
 
2508
2514
  interface GPUTexelCopyBufferLayout {
2509
2515
  offset?: GPUSize64 /* default=0 */;
2510
- bytesPerRow: GPUSize32;
2516
+ bytesPerRow?: GPUSize32;
2511
2517
  rowsPerImage?: GPUSize32;
2512
2518
  }
2513
2519
 
@@ -2549,22 +2555,20 @@ class GPUCommandEncoder implements GPUObjectBase, GPUCommandsMixin, GPUDebugComm
2549
2555
  beginRenderPass(descriptor: GPURenderPassDescriptor): GPURenderPassEncoder;
2550
2556
  beginComputePass(descriptor?: GPUComputePassDescriptor): GPUComputePassEncoder;
2551
2557
 
2552
- copyBufferToBuffer(source: GPUBuffer, destination: GPUBuffer, size: GPUSize64): void;
2553
- copyBufferToBuffer(source: GPUBuffer, sourceOffset: GPUSize64, destination: GPUBuffer, destinationOffset: GPUSize64, size: GPUSize64): void;
2558
+ copyBufferToBuffer(source: GPUBuffer, destination: GPUBuffer, size?: GPUSize64): void;
2559
+ copyBufferToBuffer(source: GPUBuffer, sourceOffset: GPUSize64, destination: GPUBuffer, destinationOffset: GPUSize64, size?: GPUSize64): void;
2554
2560
  copyBufferToTexture(source: GPUTexelCopyBufferInfo, destination: GPUTexelCopyTextureInfo, copySize: GPUExtent3D): void;
2555
2561
  copyTextureToBuffer(source: GPUTexelCopyTextureInfo, destination: GPUTexelCopyBufferInfo, copySize: GPUExtent3D): void;
2556
2562
  copyTextureToTexture(source: GPUTexelCopyTextureInfo, destination: GPUTexelCopyTextureInfo, copySize: GPUExtent3D): void;
2557
2563
  clearBuffer(buffer: GPUBuffer, offset?: GPUSize64 /* default=0 */, size?: GPUSize64): void;
2558
2564
 
2559
- writeTimestamp?(querySet: GPUQuerySet, queryIndex: GPUSize32): void; // not in the spec anymore, but may come back later, so keep it here for now
2560
-
2561
2565
  resolveQuerySet(querySet: GPUQuerySet, firstQuery: GPUSize32, queryCount: GPUSize32, destination: GPUBuffer, destinationOffset: GPUSize64): void;
2562
2566
 
2563
2567
  finish(descriptor?: GPUCommandBufferDescriptor): GPUCommandBuffer;
2564
2568
 
2565
- pushDebugGroup(groupLabel: string): void;
2569
+ pushDebugGroup(grouplabel: string | undefined): void;
2566
2570
  popDebugGroup(): void;
2567
- insertDebugMarker(markerLabel: string): void;
2571
+ insertDebugMarker(markerlabel: string | undefined): void;
2568
2572
  }
2569
2573
 
2570
2574
  interface GPUCommandEncoderDescriptor extends GPUObjectDescriptorBase {}
@@ -2575,9 +2579,9 @@ interface GPUBindingCommandsMixin {
2575
2579
  }
2576
2580
 
2577
2581
  interface GPUDebugCommandsMixin {
2578
- pushDebugGroup(groupLabel: string): void;
2582
+ pushDebugGroup(grouplabel: string | undefined): void;
2579
2583
  popDebugGroup(): void;
2580
- insertDebugMarker(markerLabel: string): void;
2584
+ insertDebugMarker(markerlabel: string | undefined): void;
2581
2585
  }
2582
2586
 
2583
2587
  class GPUComputePassEncoder implements GPUObjectBase, GPUCommandsMixin, GPUDebugCommandsMixin, GPUBindingCommandsMixin {
@@ -2586,9 +2590,9 @@ class GPUComputePassEncoder implements GPUObjectBase, GPUCommandsMixin, GPUDebug
2586
2590
  setBindGroup(index: number, bindGroup: GPUBindGroup | null, dynamicOffsets?: GPUBufferDynamicOffset[]): void;
2587
2591
  setBindGroup(index: GPUIndex32, bindGroup: GPUBindGroup | null, dynamicOffsetData: Uint32Array, dynamicOffsetsDataStart: GPUSize64, dynamicOffsetsDataLength: GPUSize32): void;
2588
2592
 
2589
- pushDebugGroup(groupLabel: string): void;
2593
+ pushDebugGroup(grouplabel: string | undefined): void;
2590
2594
  popDebugGroup(): void;
2591
- insertDebugMarker(markerLabel: string): void;
2595
+ insertDebugMarker(markerlabel: string | undefined): void;
2592
2596
 
2593
2597
  setPipeline(pipeline: GPUComputePipeline): void;
2594
2598
  dispatchWorkgroups(workgroupCountX: GPUSize32, workgroupCountY?: GPUSize32 /* default=1 */, workgroupCountZ?: GPUSize32 /* default=1 */): void;
@@ -2599,8 +2603,8 @@ class GPUComputePassEncoder implements GPUObjectBase, GPUCommandsMixin, GPUDebug
2599
2603
 
2600
2604
  interface GPUComputePassTimestampWrites {
2601
2605
  querySet: GPUQuerySet;
2602
- beginningOfPassWriteIndex: GPUSize32;
2603
- endOfPassWriteIndex: GPUSize32;
2606
+ beginningOfPassWriteIndex?: GPUSize32;
2607
+ endOfPassWriteIndex?: GPUSize32;
2604
2608
  }
2605
2609
 
2606
2610
  interface GPUComputePassDescriptor extends GPUObjectDescriptorBase {
@@ -2613,14 +2617,14 @@ class GPURenderPassEncoder implements GPUObjectBase, GPUCommandsMixin, GPUDebugC
2613
2617
  setBindGroup(index: GPUIndex32, bindGroup: GPUBindGroup | null, dynamicOffsets?: GPUBufferDynamicOffset[]): void;
2614
2618
  setBindGroup(index: GPUIndex32, bindGroup: GPUBindGroup | null, dynamicOffsetData: Uint32Array, dynamicOffsetsDataStart: GPUSize64, dynamicOffsetsDataLength: GPUSize32): void;
2615
2619
 
2616
- pushDebugGroup(groupLabel: string): void;
2620
+ pushDebugGroup(grouplabel: string | undefined): void;
2617
2621
  popDebugGroup(): void;
2618
- insertDebugMarker(markerLabel: string): void;
2622
+ insertDebugMarker(markerlabel: string | undefined): void;
2619
2623
 
2620
2624
  setPipeline(pipeline: GPURenderPipeline): void;
2621
2625
 
2622
2626
  setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: GPUSize64 /* default=0 */, size?: GPUSize64 /* default=0 */): void;
2623
- setVertexBuffer(slot: GPUIndex32, buffer?: GPUBuffer, offset?: GPUSize64 /* default=0 */, size?: GPUSize64 /* default=0 */): void;
2627
+ setVertexBuffer(slot: GPUIndex32, buffer: GPUBuffer | null, offset?: GPUSize64 /* default=0 */, size?: GPUSize64 /* default=0 */): void;
2624
2628
 
2625
2629
  draw(vertexCount: GPUSize32, instanceCount?: GPUSize32 /* default=1 */, firstVertex?: GPUSize32 /* default=0 */, firstInstance?: GPUSize32 /* default=0 */): void;
2626
2630
  drawIndexed(
@@ -2650,8 +2654,8 @@ class GPURenderPassEncoder implements GPUObjectBase, GPUCommandsMixin, GPUDebugC
2650
2654
 
2651
2655
  interface GPURenderPassTimestampWrites {
2652
2656
  querySet: GPUQuerySet;
2653
- beginningOfPassWriteIndex: GPUSize32;
2654
- endOfPassWriteIndex: GPUSize32;
2657
+ beginningOfPassWriteIndex?: GPUSize32;
2658
+ endOfPassWriteIndex?: GPUSize32;
2655
2659
  }
2656
2660
 
2657
2661
  interface GPURenderPassDescriptor extends GPUObjectDescriptorBase {
@@ -2700,7 +2704,7 @@ interface GPURenderCommandsMixin {
2700
2704
  setPipeline(pipeline: GPURenderPipeline): void;
2701
2705
 
2702
2706
  setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: GPUSize64 /* default=0 */, size?: GPUSize64 /* default=0 */): void;
2703
- setVertexBuffer(slot: GPUIndex32, buffer?: GPUBuffer, offset?: GPUSize64 /* default=0 */, size?: GPUSize64): void;
2707
+ setVertexBuffer(slot: GPUIndex32, buffer: GPUBuffer | null, offset?: GPUSize64 /* default=0 */, size?: GPUSize64): void;
2704
2708
 
2705
2709
  draw(vertexCount: GPUSize32, instanceCount?: GPUSize32 /* default=1 */, firstVertex?: GPUSize32 /* default=0 */, firstInstance?: GPUSize32 /* default=0 */): void;
2706
2710
  drawIndexed(
@@ -2727,14 +2731,14 @@ class GPURenderBundleEncoder implements GPUObjectBase, GPUCommandsMixin, GPUDebu
2727
2731
  setBindGroup(index: GPUIndex32, bindGroup: GPUBindGroup | null, dynamicOffsets?: GPUBufferDynamicOffset[]): void;
2728
2732
  setBindGroup(index: GPUIndex32, bindGroup: GPUBindGroup | null, dynamicOffsetData: Uint32Array, dynamicOffsetsDataStart: GPUSize64, dynamicOffsetsDataLength: GPUSize32): void;
2729
2733
 
2730
- pushDebugGroup(groupLabel: string): void;
2734
+ pushDebugGroup(grouplabel: string | undefined): void;
2731
2735
  popDebugGroup(): void;
2732
- insertDebugMarker(markerLabel: string): void;
2736
+ insertDebugMarker(markerlabel: string | undefined): void;
2733
2737
 
2734
2738
  setPipeline(pipeline: GPURenderPipeline): void;
2735
2739
 
2736
2740
  setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: GPUSize64 /* default=0 */, size?: GPUSize64 /* default=0 */): void;
2737
- setVertexBuffer(slot: GPUIndex32, buffer?: GPUBuffer, offset?: GPUSize64 /* default=0 */, size?: GPUSize64 /* default=0 */): void;
2741
+ setVertexBuffer(slot: GPUIndex32, buffer: GPUBuffer | null, offset?: GPUSize64 /* default=0 */, size?: GPUSize64 /* default=0 */): void;
2738
2742
 
2739
2743
  draw(vertexCount: GPUSize32, instanceCount?: GPUSize32 /* default=1 */, firstVertex?: GPUSize32 /* default=0 */, firstInstance?: GPUSize32 /* default=0 */): void;
2740
2744
  drawIndexed(
@@ -2791,10 +2795,10 @@ type GPUQueryType = "occlusion" | "timestamp";
2791
2795
  class GPUCanvasContext {
2792
2796
  readonly canvas: HTMLCanvasElement | OffscreenCanvas;
2793
2797
 
2794
- configure(configuration?: GPUCanvasConfiguration): void;
2798
+ configure(configuration: GPUCanvasConfiguration): void;
2795
2799
  unconfigure(): void;
2796
2800
 
2797
- getConfiguration(): GPUCanvasConfiguration | undefined;
2801
+ getConfiguration(): GPUCanvasConfiguration | null;
2798
2802
  getCurrentTexture(): GPUTexture;
2799
2803
  }
2800
2804
 
@@ -2803,7 +2807,7 @@ type GPUCanvasAlphaMode = "opaque" | "premultiplied";
2803
2807
  type GPUCanvasToneMappingMode = "standard" | "extended";
2804
2808
 
2805
2809
  interface GPUCanvasToneMapping {
2806
- mode?: GPUCanvasToneMappingMode /* dfault="standard" */;
2810
+ mode?: GPUCanvasToneMappingMode /* default="standard" */;
2807
2811
  }
2808
2812
 
2809
2813
  interface GPUCanvasConfiguration extends GPUObjectDescriptorBase {
@@ -2819,7 +2823,7 @@ interface GPUCanvasConfiguration extends GPUObjectDescriptorBase {
2819
2823
  type GPUDeviceLostReason = "unknown" | "destroyed";
2820
2824
 
2821
2825
  class GPUDeviceLostInfo {
2822
- readonly reason?: GPUDeviceLostReason;
2826
+ readonly reason: GPUDeviceLostReason;
2823
2827
  readonly message: string;
2824
2828
  }
2825
2829
 
@@ -30,7 +30,7 @@ export class ShaderStore {
30
30
  /**
31
31
  * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
32
32
  */
33
- ShaderStore.ShadersRepository = "../Shaders/";
33
+ ShaderStore.ShadersRepository = "src/Shaders/";
34
34
  /**
35
35
  * Store of each shader (The can be looked up using effect.key)
36
36
  */
@@ -42,7 +42,7 @@ ShaderStore.IncludesShadersStore = {};
42
42
  /**
43
43
  * Gets or sets the relative url used to load shaders (WGSL) if using the engine in non-minified mode
44
44
  */
45
- ShaderStore.ShadersRepositoryWGSL = "../ShadersWGSL/";
45
+ ShaderStore.ShadersRepositoryWGSL = "src/ShadersWGSL/";
46
46
  /**
47
47
  * Store of each shader (WGSL)
48
48
  */
@@ -1 +1 @@
1
- {"version":3,"file":"shaderStore.js","sourceRoot":"","sources":["../../../../dev/core/src/Engines/shaderStore.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,OAAO,WAAW;IA2BpB;;;;OAIG;IACI,MAAM,CAAC,oBAAoB,CAAC,cAAc,8BAAsB;QACnE,OAAO,cAAc,gCAAwB,CAAC,CAAC,CAAC,WAAW,CAAC,iBAAiB,CAAC,CAAC,CAAC,WAAW,CAAC,qBAAqB,CAAC;IACtH,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,eAAe,CAAC,cAAc,8BAAsB;QAC9D,OAAO,cAAc,gCAAwB,CAAC,CAAC,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC,CAAC,WAAW,CAAC,gBAAgB,CAAC;IAC5G,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,uBAAuB,CAAC,cAAc,8BAAsB;QACtE,OAAO,cAAc,gCAAwB,CAAC,CAAC,CAAC,WAAW,CAAC,oBAAoB,CAAC,CAAC,CAAC,WAAW,CAAC,wBAAwB,CAAC;IAC5H,CAAC;;AAnDD;;GAEG;AACW,6BAAiB,GAAG,aAAa,CAAC;AAChD;;GAEG;AACW,wBAAY,GAA8B,EAAE,CAAC;AAC3D;;GAEG;AACW,gCAAoB,GAA8B,EAAE,CAAC;AAEnE;;GAEG;AACW,iCAAqB,GAAG,iBAAiB,CAAC;AACxD;;GAEG;AACW,4BAAgB,GAA8B,EAAE,CAAC;AAC/D;;GAEG;AACW,oCAAwB,GAA8B,EAAE,CAAC","sourcesContent":["import { ShaderLanguage } from \"../Materials/shaderLanguage\";\r\n\r\n/**\r\n * Defines the shader related stores and directory\r\n */\r\nexport class ShaderStore {\r\n /**\r\n * Gets or sets the relative url used to load shaders if using the engine in non-minified mode\r\n */\r\n public static ShadersRepository = \"../Shaders/\";\r\n /**\r\n * Store of each shader (The can be looked up using effect.key)\r\n */\r\n public static ShadersStore: { [key: string]: string } = {};\r\n /**\r\n * Store of each included file for a shader (The can be looked up using effect.key)\r\n */\r\n public static IncludesShadersStore: { [key: string]: string } = {};\r\n\r\n /**\r\n * Gets or sets the relative url used to load shaders (WGSL) if using the engine in non-minified mode\r\n */\r\n public static ShadersRepositoryWGSL = \"../ShadersWGSL/\";\r\n /**\r\n * Store of each shader (WGSL)\r\n */\r\n public static ShadersStoreWGSL: { [key: string]: string } = {};\r\n /**\r\n * Store of each included file for a shader (WGSL)\r\n */\r\n public static IncludesShadersStoreWGSL: { [key: string]: string } = {};\r\n\r\n /**\r\n * Gets the shaders repository path for a given shader language\r\n * @param shaderLanguage the shader language\r\n * @returns the path to the shaders repository\r\n */\r\n public static GetShadersRepository(shaderLanguage = ShaderLanguage.GLSL): string {\r\n return shaderLanguage === ShaderLanguage.GLSL ? ShaderStore.ShadersRepository : ShaderStore.ShadersRepositoryWGSL;\r\n }\r\n\r\n /**\r\n * Gets the shaders store of a given shader language\r\n * @param shaderLanguage the shader language\r\n * @returns the shaders store\r\n */\r\n public static GetShadersStore(shaderLanguage = ShaderLanguage.GLSL): { [key: string]: string } {\r\n return shaderLanguage === ShaderLanguage.GLSL ? ShaderStore.ShadersStore : ShaderStore.ShadersStoreWGSL;\r\n }\r\n\r\n /**\r\n * Gets the include shaders store of a given shader language\r\n * @param shaderLanguage the shader language\r\n * @returns the include shaders store\r\n */\r\n public static GetIncludesShadersStore(shaderLanguage = ShaderLanguage.GLSL): { [key: string]: string } {\r\n return shaderLanguage === ShaderLanguage.GLSL ? ShaderStore.IncludesShadersStore : ShaderStore.IncludesShadersStoreWGSL;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"shaderStore.js","sourceRoot":"","sources":["../../../../dev/core/src/Engines/shaderStore.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,OAAO,WAAW;IA2BpB;;;;OAIG;IACI,MAAM,CAAC,oBAAoB,CAAC,cAAc,8BAAsB;QACnE,OAAO,cAAc,gCAAwB,CAAC,CAAC,CAAC,WAAW,CAAC,iBAAiB,CAAC,CAAC,CAAC,WAAW,CAAC,qBAAqB,CAAC;IACtH,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,eAAe,CAAC,cAAc,8BAAsB;QAC9D,OAAO,cAAc,gCAAwB,CAAC,CAAC,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC,CAAC,WAAW,CAAC,gBAAgB,CAAC;IAC5G,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,uBAAuB,CAAC,cAAc,8BAAsB;QACtE,OAAO,cAAc,gCAAwB,CAAC,CAAC,CAAC,WAAW,CAAC,oBAAoB,CAAC,CAAC,CAAC,WAAW,CAAC,wBAAwB,CAAC;IAC5H,CAAC;;AAnDD;;GAEG;AACW,6BAAiB,GAAG,cAAc,CAAC;AACjD;;GAEG;AACW,wBAAY,GAA8B,EAAE,CAAC;AAC3D;;GAEG;AACW,gCAAoB,GAA8B,EAAE,CAAC;AAEnE;;GAEG;AACW,iCAAqB,GAAG,kBAAkB,CAAC;AACzD;;GAEG;AACW,4BAAgB,GAA8B,EAAE,CAAC;AAC/D;;GAEG;AACW,oCAAwB,GAA8B,EAAE,CAAC","sourcesContent":["import { ShaderLanguage } from \"../Materials/shaderLanguage\";\r\n\r\n/**\r\n * Defines the shader related stores and directory\r\n */\r\nexport class ShaderStore {\r\n /**\r\n * Gets or sets the relative url used to load shaders if using the engine in non-minified mode\r\n */\r\n public static ShadersRepository = \"src/Shaders/\";\r\n /**\r\n * Store of each shader (The can be looked up using effect.key)\r\n */\r\n public static ShadersStore: { [key: string]: string } = {};\r\n /**\r\n * Store of each included file for a shader (The can be looked up using effect.key)\r\n */\r\n public static IncludesShadersStore: { [key: string]: string } = {};\r\n\r\n /**\r\n * Gets or sets the relative url used to load shaders (WGSL) if using the engine in non-minified mode\r\n */\r\n public static ShadersRepositoryWGSL = \"src/ShadersWGSL/\";\r\n /**\r\n * Store of each shader (WGSL)\r\n */\r\n public static ShadersStoreWGSL: { [key: string]: string } = {};\r\n /**\r\n * Store of each included file for a shader (WGSL)\r\n */\r\n public static IncludesShadersStoreWGSL: { [key: string]: string } = {};\r\n\r\n /**\r\n * Gets the shaders repository path for a given shader language\r\n * @param shaderLanguage the shader language\r\n * @returns the path to the shaders repository\r\n */\r\n public static GetShadersRepository(shaderLanguage = ShaderLanguage.GLSL): string {\r\n return shaderLanguage === ShaderLanguage.GLSL ? ShaderStore.ShadersRepository : ShaderStore.ShadersRepositoryWGSL;\r\n }\r\n\r\n /**\r\n * Gets the shaders store of a given shader language\r\n * @param shaderLanguage the shader language\r\n * @returns the shaders store\r\n */\r\n public static GetShadersStore(shaderLanguage = ShaderLanguage.GLSL): { [key: string]: string } {\r\n return shaderLanguage === ShaderLanguage.GLSL ? ShaderStore.ShadersStore : ShaderStore.ShadersStoreWGSL;\r\n }\r\n\r\n /**\r\n * Gets the include shaders store of a given shader language\r\n * @param shaderLanguage the shader language\r\n * @returns the include shaders store\r\n */\r\n public static GetIncludesShadersStore(shaderLanguage = ShaderLanguage.GLSL): { [key: string]: string } {\r\n return shaderLanguage === ShaderLanguage.GLSL ? ShaderStore.IncludesShadersStore : ShaderStore.IncludesShadersStoreWGSL;\r\n }\r\n}\r\n"]}
@@ -28,6 +28,7 @@ import { type WebGPUDataBuffer } from "../Meshes/WebGPU/webgpuDataBuffer.js";
28
28
  import "../Buffers/buffer.align.js";
29
29
  import { type RenderTargetWrapper } from "./renderTargetWrapper.js";
30
30
  import { type Scene } from "../scene.js";
31
+ import { type AbstractMesh } from "../Meshes/abstractMesh.js";
31
32
  import { PerformanceMonitor } from "../Misc/performanceMonitor.js";
32
33
  import "./AbstractEngine/abstractEngine.loadingScreen.js";
33
34
  import "./AbstractEngine/abstractEngine.dom.js";
@@ -122,6 +123,73 @@ export interface WebGPUEngineOptions extends AbstractEngineOptions, GPURequestAd
122
123
  */
123
124
  twgslOptions?: TwgslOptions;
124
125
  }
126
+ /**
127
+ * Options for pre-warming a render pipeline asynchronously.
128
+ * All render state properties are optional and default to the most common opaque rendering state.
129
+ */
130
+ export interface IWebGPURenderPipelineAsyncCreationOptions {
131
+ /**
132
+ * The compiled effect (shader stages) for the pipeline.
133
+ */
134
+ effect: Effect;
135
+ /**
136
+ * The mesh whose vertex buffer layout to use.
137
+ */
138
+ mesh: AbstractMesh;
139
+ /**
140
+ * The fill mode / primitive topology. Defaults to Constants.MATERIAL_TriangleFillMode.
141
+ */
142
+ fillMode?: number;
143
+ /**
144
+ * The MSAA sample count. Defaults to the engine's current sample count.
145
+ */
146
+ sampleCount?: number;
147
+ /**
148
+ * The color render target format. Defaults to the engine's current canvas color format.
149
+ */
150
+ colorFormat?: GPUTextureFormat;
151
+ /**
152
+ * The depth-stencil render target format. Defaults to the engine's current depth format.
153
+ */
154
+ depthStencilFormat?: GPUTextureFormat;
155
+ /**
156
+ * The alpha blending mode (e.g. Constants.ALPHA_DISABLE, Constants.ALPHA_COMBINE).
157
+ * Defaults to Constants.ALPHA_DISABLE.
158
+ */
159
+ alphaMode?: number;
160
+ /**
161
+ * Whether depth writing is enabled. Defaults to true.
162
+ */
163
+ depthWrite?: boolean;
164
+ /**
165
+ * Whether depth testing is enabled. Defaults to true.
166
+ */
167
+ depthTest?: boolean;
168
+ /**
169
+ * The depth comparison function (e.g. Constants.LEQUAL). Defaults to Constants.LEQUAL.
170
+ */
171
+ depthCompare?: number;
172
+ /**
173
+ * Whether back-face culling is enabled. Defaults to true.
174
+ */
175
+ cullEnabled?: boolean;
176
+ /**
177
+ * Which face to cull (1 = back, 2 = front). Defaults to 1 (back).
178
+ */
179
+ cullFace?: number;
180
+ /**
181
+ * Front face winding order (1 = CCW, 2 = CW). Defaults to 2 (CW).
182
+ */
183
+ frontFace?: number;
184
+ /**
185
+ * Color channel write mask (bitmask of RGBA channels). Defaults to 0xF (all channels).
186
+ */
187
+ writeMask?: number;
188
+ /**
189
+ * Whether stencil testing is enabled. Defaults to false.
190
+ */
191
+ stencilEnabled?: boolean;
192
+ }
125
193
  /**
126
194
  * The web GPU engine class provides support for WebGPU version of babylon.js.
127
195
  * @since 5.0.0
@@ -952,6 +1020,22 @@ export declare class WebGPUEngine extends ThinWebGPUEngine {
952
1020
  * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
953
1021
  */
954
1022
  drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
1023
+ /**
1024
+ * Asynchronously pre-creates one or more render pipelines so they are cached and ready
1025
+ * to use without any compilation hitch when first rendered.
1026
+ *
1027
+ * Call this for effects and meshes that are not yet rendering but will be soon
1028
+ * (e.g. streaming content, predicted material changes, pre-loading the next level).
1029
+ *
1030
+ * When passing an array, cache state is set once per entry and restored only at the end,
1031
+ * making batch pre-warming efficient.
1032
+ *
1033
+ * @param options - a single options object, an array of options objects,
1034
+ * or a raw GPURenderPipelineDescriptor for complete control
1035
+ * @returns an array of Promises for the pipelines that had cache misses (empty if all were cached).
1036
+ * When a raw GPURenderPipelineDescriptor is provided, always returns a single-element array.
1037
+ */
1038
+ createRenderPipelineAsync(options: IWebGPURenderPipelineAsyncCreationOptions | IWebGPURenderPipelineAsyncCreationOptions[] | GPURenderPipelineDescriptor): Promise<GPURenderPipeline>[];
955
1039
  /**
956
1040
  * Dispose and release all associated resources
957
1041
  */
@@ -412,7 +412,7 @@ export class WebGPUEngine extends ThinWebGPUEngine {
412
412
  .then(async (adapter) => {
413
413
  if (!adapter) {
414
414
  // eslint-disable-next-line no-throw-literal
415
- throw "Could not retrieve a WebGPU adapter (adapter is null).";
415
+ throw "Could not retrieve a WebGPU adapter (adapter is null or undefined).";
416
416
  }
417
417
  else {
418
418
  this._adapter = adapter;
@@ -2874,6 +2874,85 @@ export class WebGPUEngine extends ThinWebGPUEngine {
2874
2874
  this._draw(1, fillMode, verticesStart, verticesCount, instancesCount);
2875
2875
  }
2876
2876
  //------------------------------------------------------------------------------
2877
+ // Async Pipeline Pre-Warming
2878
+ //------------------------------------------------------------------------------
2879
+ /**
2880
+ * Asynchronously pre-creates one or more render pipelines so they are cached and ready
2881
+ * to use without any compilation hitch when first rendered.
2882
+ *
2883
+ * Call this for effects and meshes that are not yet rendering but will be soon
2884
+ * (e.g. streaming content, predicted material changes, pre-loading the next level).
2885
+ *
2886
+ * When passing an array, cache state is set once per entry and restored only at the end,
2887
+ * making batch pre-warming efficient.
2888
+ *
2889
+ * @param options - a single options object, an array of options objects,
2890
+ * or a raw GPURenderPipelineDescriptor for complete control
2891
+ * @returns an array of Promises for the pipelines that had cache misses (empty if all were cached).
2892
+ * When a raw GPURenderPipelineDescriptor is provided, always returns a single-element array.
2893
+ */
2894
+ // eslint-disable-next-line no-restricted-syntax
2895
+ createRenderPipelineAsync(options) {
2896
+ // Raw GPURenderPipelineDescriptor: bypass the cache and create directly
2897
+ if ("vertex" in options) {
2898
+ return [this._device.createRenderPipelineAsync(options)];
2899
+ }
2900
+ const entries = Array.isArray(options) ? options : [options];
2901
+ const promises = [];
2902
+ const cache = this._cacheRenderPipeline;
2903
+ for (const entry of entries) {
2904
+ // Render target formats
2905
+ cache.setColorFormat(entry.colorFormat ?? this._colorFormat);
2906
+ cache.setDepthStencilFormat(entry.depthStencilFormat ?? this._depthTextureFormat);
2907
+ // Vertex / index buffers from mesh
2908
+ const geometry = entry.mesh.geometry;
2909
+ if (!geometry) {
2910
+ throw new Error("WebGPUEngine.createRenderPipelineAsync: mesh has no geometry to derive vertex/index buffers from.");
2911
+ }
2912
+ cache.setBuffers(geometry.getVertexBuffers(), geometry.getIndexBuffer(), null);
2913
+ // Alpha / blend state
2914
+ const alphaMode = entry.alphaMode ?? 0;
2915
+ if (alphaMode === 0) {
2916
+ cache.setAlphaBlendEnabled([false], 0);
2917
+ }
2918
+ else {
2919
+ const prevAlphaMode = this._alphaMode[0];
2920
+ this.setAlphaMode(alphaMode);
2921
+ cache.setAlphaBlendEnabled(this._alphaState._alphaBlend, this._alphaState._numTargetEnabled);
2922
+ cache.setAlphaBlendFactors(this._alphaState._blendFunctionParameters, this._alphaState._blendEquationParameters);
2923
+ this.setAlphaMode(prevAlphaMode);
2924
+ }
2925
+ // Depth / stencil state
2926
+ cache.setDepthWriteEnabled(entry.depthWrite ?? true);
2927
+ cache.setDepthTestEnabled(entry.depthTest ?? true);
2928
+ cache.setDepthCompare(entry.depthCompare ?? 515);
2929
+ // Rasterization state
2930
+ cache.setCullEnabled(entry.cullEnabled ?? true);
2931
+ cache.setCullFace(entry.cullFace ?? 1);
2932
+ cache.setFrontFace(entry.frontFace ?? 2);
2933
+ // Write mask
2934
+ cache.setWriteMask(entry.writeMask ?? 0xf);
2935
+ // Stencil
2936
+ cache.setStencilEnabled(entry.stencilEnabled ?? false);
2937
+ const fillMode = entry.fillMode ?? 0;
2938
+ const sampleCount = entry.sampleCount ?? this.currentSampleCount;
2939
+ const promise = cache.preWarmPipeline(fillMode, entry.effect, sampleCount, 0);
2940
+ if (promise) {
2941
+ promises.push(promise);
2942
+ }
2943
+ }
2944
+ // Restore the cache state to the engine's current tracked state once after the entire batch
2945
+ cache.setColorFormat(this._colorFormat);
2946
+ cache.setDepthStencilFormat(this._depthTextureFormat);
2947
+ cache.setBuffers(this._currentVertexBuffers ?? null, this._currentIndexBuffer, this._currentOverrideVertexBuffers ?? null);
2948
+ cache.setDepthCullingState(this._depthCullingState.cull ?? false, this._depthCullingState.frontFace ?? 2, this._depthCullingState.cullFace ?? 1, this._depthCullingState.zOffset, this._depthCullingState.zOffsetUnits, this._depthCullingState.depthTest ?? true, this._depthCullingState.depthMask ?? true, this._depthCullingState.depthFunc);
2949
+ cache.setAlphaBlendEnabled(this._alphaState._alphaBlend, this._alphaState._numTargetEnabled);
2950
+ cache.setAlphaBlendFactors(this._alphaState._blendFunctionParameters, this._alphaState._blendEquationParameters);
2951
+ cache.setStencilEnabled(this._stencilStateComposer.enabled ?? false);
2952
+ cache.setWriteMask(this._colorWrite ? 0xf : 0);
2953
+ return promises;
2954
+ }
2955
+ //------------------------------------------------------------------------------
2877
2956
  // Dispose
2878
2957
  //------------------------------------------------------------------------------
2879
2958
  /**