rhodonite 0.20.2 → 0.22.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 (89) hide show
  1. package/README.md +10 -2
  2. package/VERSION-FILE +1 -1
  3. package/dist/esm/foundation/components/Camera/CameraComponent.d.ts +15 -0
  4. package/dist/esm/foundation/components/Light/LightComponent.d.ts +109 -4
  5. package/dist/esm/foundation/components/Physics/PhysicsComponent.d.ts +1 -1
  6. package/dist/esm/foundation/core/Component.d.ts +1 -8
  7. package/dist/esm/foundation/core/Config.d.ts +165 -6
  8. package/dist/esm/foundation/core/GlobalDataRepository.d.ts +12 -8
  9. package/dist/esm/foundation/core/MemoryManager.d.ts +12 -0
  10. package/dist/esm/foundation/definitions/ProcessApproach.d.ts +1 -6
  11. package/dist/esm/foundation/definitions/ShaderSemantics.d.ts +0 -1
  12. package/dist/esm/foundation/helpers/Shadow/PointShadowMap.d.ts +3 -1
  13. package/dist/esm/foundation/helpers/Shadow/ShadowSystem.d.ts +13 -0
  14. package/dist/esm/foundation/materials/contents/CustomMaterialContent.d.ts +1 -1
  15. package/dist/esm/foundation/materials/core/AbstractMaterialContent.d.ts +1 -23
  16. package/dist/esm/foundation/materials/core/Material.d.ts +10 -14
  17. package/dist/esm/foundation/materials/core/MaterialRepository.d.ts +5 -0
  18. package/dist/esm/foundation/physics/PhysicsProperty.d.ts +9 -2
  19. package/dist/esm/foundation/physics/index.d.ts +0 -1
  20. package/dist/esm/foundation/renderer/index.d.ts +1 -0
  21. package/dist/esm/foundation/renderer/lightCluster/LightClusterBuilder.d.ts +97 -0
  22. package/dist/esm/foundation/renderer/lightCluster/LightClusterLayout.d.ts +98 -0
  23. package/dist/esm/foundation/renderer/lightCluster/LightClusterSystem.d.ts +171 -0
  24. package/dist/esm/foundation/renderer/lightCluster/index.d.ts +1 -0
  25. package/dist/esm/foundation/system/Engine.d.ts +9 -2
  26. package/dist/esm/foundation/system/EngineState.d.ts +1 -1
  27. package/dist/esm/foundation/textures/TextureArray.d.ts +1 -1
  28. package/dist/esm/index.js +1181 -824
  29. package/dist/esm/webgl/MultiDraw.d.ts +1 -1
  30. package/dist/esm/webgl/WebGLResourceRepository.d.ts +1 -2
  31. package/dist/{esmdev/webgl/WebGLStrategyDataTexture.d.ts → esm/webgl/WebGLStrategyWebGL2.d.ts} +20 -4
  32. package/dist/esm/webgl/debug/BufferLayoutDecoder.d.ts +83 -0
  33. package/dist/esm/webgl/debug/ShaderParameterDebugger.d.ts +47 -0
  34. package/dist/esm/webgl/debug/index.d.ts +3 -0
  35. package/dist/esm/webgl/debug/types.d.ts +114 -0
  36. package/dist/esm/webgl/index.d.ts +2 -2
  37. package/dist/esm/webgl/main.d.ts +2 -4
  38. package/dist/esm/webgl/shaders/StandardShaderPart.d.ts +1 -1
  39. package/dist/esm/webgl/types/CommonTypes.d.ts +0 -1
  40. package/dist/esm/webgpu/WebGpuLightClusterBuilder.d.ts +34 -0
  41. package/dist/esm/webgpu/WebGpuResourceRepository.d.ts +28 -3
  42. package/dist/esm/webgpu/WebGpuStrategyBasic.d.ts +18 -1
  43. package/dist/esmdev/foundation/components/Camera/CameraComponent.d.ts +15 -0
  44. package/dist/esmdev/foundation/components/Light/LightComponent.d.ts +109 -4
  45. package/dist/esmdev/foundation/components/Physics/PhysicsComponent.d.ts +1 -1
  46. package/dist/esmdev/foundation/core/Component.d.ts +1 -8
  47. package/dist/esmdev/foundation/core/Config.d.ts +165 -6
  48. package/dist/esmdev/foundation/core/GlobalDataRepository.d.ts +12 -8
  49. package/dist/esmdev/foundation/core/MemoryManager.d.ts +12 -0
  50. package/dist/esmdev/foundation/definitions/ProcessApproach.d.ts +1 -6
  51. package/dist/esmdev/foundation/definitions/ShaderSemantics.d.ts +0 -1
  52. package/dist/esmdev/foundation/helpers/Shadow/PointShadowMap.d.ts +3 -1
  53. package/dist/esmdev/foundation/helpers/Shadow/ShadowSystem.d.ts +13 -0
  54. package/dist/esmdev/foundation/materials/contents/CustomMaterialContent.d.ts +1 -1
  55. package/dist/esmdev/foundation/materials/core/AbstractMaterialContent.d.ts +1 -23
  56. package/dist/esmdev/foundation/materials/core/Material.d.ts +10 -14
  57. package/dist/esmdev/foundation/materials/core/MaterialRepository.d.ts +5 -0
  58. package/dist/esmdev/foundation/physics/PhysicsProperty.d.ts +9 -2
  59. package/dist/esmdev/foundation/physics/index.d.ts +0 -1
  60. package/dist/esmdev/foundation/renderer/index.d.ts +1 -0
  61. package/dist/esmdev/foundation/renderer/lightCluster/LightClusterBuilder.d.ts +97 -0
  62. package/dist/esmdev/foundation/renderer/lightCluster/LightClusterLayout.d.ts +98 -0
  63. package/dist/esmdev/foundation/renderer/lightCluster/LightClusterSystem.d.ts +171 -0
  64. package/dist/esmdev/foundation/renderer/lightCluster/index.d.ts +1 -0
  65. package/dist/esmdev/foundation/system/Engine.d.ts +9 -2
  66. package/dist/esmdev/foundation/system/EngineState.d.ts +1 -1
  67. package/dist/esmdev/foundation/textures/TextureArray.d.ts +1 -1
  68. package/dist/esmdev/index.js +3419 -2172
  69. package/dist/esmdev/webgl/MultiDraw.d.ts +1 -1
  70. package/dist/esmdev/webgl/WebGLResourceRepository.d.ts +1 -2
  71. package/dist/{esm/webgl/WebGLStrategyDataTexture.d.ts → esmdev/webgl/WebGLStrategyWebGL2.d.ts} +20 -4
  72. package/dist/esmdev/webgl/debug/BufferLayoutDecoder.d.ts +83 -0
  73. package/dist/esmdev/webgl/debug/ShaderParameterDebugger.d.ts +47 -0
  74. package/dist/esmdev/webgl/debug/index.d.ts +3 -0
  75. package/dist/esmdev/webgl/debug/types.d.ts +114 -0
  76. package/dist/esmdev/webgl/index.d.ts +2 -2
  77. package/dist/esmdev/webgl/main.d.ts +2 -4
  78. package/dist/esmdev/webgl/shaders/StandardShaderPart.d.ts +1 -1
  79. package/dist/esmdev/webgl/types/CommonTypes.d.ts +0 -1
  80. package/dist/esmdev/webgpu/WebGpuLightClusterBuilder.d.ts +34 -0
  81. package/dist/esmdev/webgpu/WebGpuResourceRepository.d.ts +28 -3
  82. package/dist/esmdev/webgpu/WebGpuStrategyBasic.d.ts +18 -1
  83. package/package.json +2 -1
  84. package/dist/esm/foundation/physics/Oimo/OimoPhysicsStrategy.d.ts +0 -124
  85. package/dist/esm/foundation/physics/Oimo/index.d.ts +0 -1
  86. package/dist/esm/webgl/WebGLStrategyUniform.d.ts +0 -193
  87. package/dist/esmdev/foundation/physics/Oimo/OimoPhysicsStrategy.d.ts +0 -124
  88. package/dist/esmdev/foundation/physics/Oimo/index.d.ts +0 -1
  89. package/dist/esmdev/webgl/WebGLStrategyUniform.d.ts +0 -193
@@ -120,7 +120,7 @@ export declare function makeMultiDrawRenderStateKey(primitive: Primitive, materi
120
120
  * `Material.stateVersion`, so a cache hit costs a WeakMap lookup plus field compares.
121
121
  */
122
122
  export declare function getMultiDrawStateKeyId(primitive: Primitive, material: Material, meshRendererFingerPrintId: number): number | null;
123
- /** Draw arguments filled by WebGLStrategyDataTexture when a draw is deferred into a batch. */
123
+ /** Draw arguments filled by WebGLStrategyWebGL2 when a draw is deferred into a batch. */
124
124
  export type DeferredMultiDraw = {
125
125
  primitive: Primitive;
126
126
  mesh: Mesh;
@@ -372,10 +372,9 @@ export declare class WebGLResourceRepository extends CGAPIResourceRepository imp
372
372
  * @param config - Configuration for the shader program
373
373
  * @param shaderProgramUid - The handle of the shader program
374
374
  * @param infoArray - Array of shader semantics information
375
- * @param isUniformOnlyMode - Whether to set up only uniform locations
376
375
  * @returns The WebGL program object with configured uniform locations
377
376
  */
378
- setupUniformLocations(config: Config, shaderProgramUid: WebGLResourceHandle, infoArray: ShaderSemanticsInfo[], isUniformOnlyMode: boolean): WebGLProgram;
377
+ setupUniformLocations(config: Config, shaderProgramUid: WebGLResourceHandle, infoArray: ShaderSemanticsInfo[]): WebGLProgram;
379
378
  /**
380
379
  * Sets up basic uniform locations required for data texture operations.
381
380
  *
@@ -19,7 +19,7 @@ import type { ShaderSources, WebGLStrategy } from './WebGLStrategy';
19
19
  * a complete rendering pipeline for WebGL with data texture optimization.
20
20
  * The strategy is particularly useful for rendering many instances with unique properties.
21
21
  */
22
- export declare class WebGLStrategyDataTexture implements CGAPIStrategy, WebGLStrategy {
22
+ export declare class WebGLStrategyWebGL2 implements CGAPIStrategy, WebGLStrategy {
23
23
  private __engine;
24
24
  private __dataTextureUid;
25
25
  private __dataUBOUid;
@@ -56,6 +56,8 @@ export declare class WebGLStrategyDataTexture implements CGAPIStrategy, WebGLStr
56
56
  private __lastBlendShapeComponentsUpdateCountForWeights;
57
57
  private __lastMorphMaxIndex;
58
58
  private __lastMaterialsUpdateCount;
59
+ private __lastLightClusterDataVersion;
60
+ private __lastLightComponentsUpdateCount;
59
61
  private __lastTotalSizeOfGPUShaderDataStorageExceptMorphData;
60
62
  private __lastTransformComponentsUpdateCount;
61
63
  private __lastSceneGraphComponentsUpdateCount;
@@ -232,6 +234,15 @@ export declare class WebGLStrategyDataTexture implements CGAPIStrategy, WebGLStr
232
234
  * - Manages texture alignment and padding requirements
233
235
  */
234
236
  private __createAndUpdateDataTextureInner;
237
+ /**
238
+ * Uploads the bytes `[start, end)` of the GPU instance data (16-byte aligned, in the concatenated layers) to the
239
+ * data texture, where texel `n` holds bytes `16n` to `16n + 15`. The range is split into a partial first row, full
240
+ * rows and a partial last row.
241
+ *
242
+ * @param layerArray - The whole memory of the layer that contains the range
243
+ * @param layerByteOffset - The byte offset of the layer in the concatenated layers
244
+ */
245
+ private __uploadDataTextureTexels;
235
246
  /**
236
247
  * Deletes the current data texture and frees associated GPU resources.
237
248
  * This method should be called when the data texture needs to be recreated
@@ -335,16 +346,16 @@ export declare class WebGLStrategyDataTexture implements CGAPIStrategy, WebGLStr
335
346
  */
336
347
  dettachVertexData(glw: WebGLContextWrapper): void;
337
348
  /**
338
- * Gets the singleton instance of WebGLStrategyDataTexture.
349
+ * Gets the singleton instance of WebGLStrategyWebGL2.
339
350
  * Creates the instance if it doesn't exist and initializes the WebXR system reference.
340
351
  *
341
- * @returns The singleton instance of WebGLStrategyDataTexture
352
+ * @returns The singleton instance of WebGLStrategyWebGL2
342
353
  *
343
354
  * @remarks
344
355
  * This method ensures only one instance of the strategy exists throughout the application
345
356
  * and properly initializes the WebXR system for VR/AR rendering capabilities.
346
357
  */
347
- static init(engine: Engine): WebGLStrategyDataTexture;
358
+ static init(engine: Engine): WebGLStrategyWebGL2;
348
359
  /**
349
360
  * Sets the current component SIDs for each display index in VR/non-VR rendering.
350
361
  * This method configures camera component SIDs based on the rendering mode
@@ -483,6 +494,11 @@ export declare class WebGLStrategyDataTexture implements CGAPIStrategy, WebGLStr
483
494
  * same program by the previous upload. Uniform values persist in the program object, so
484
495
  * consecutive draws of the same material (e.g. a shadow pass) do not need to upload again.
485
496
  */
497
+ /**
498
+ * Uploads the light cluster view of the camera of the draw (`u_lightClusterView`) when the program uses it and
499
+ * the camera or the light cluster data changed since the last upload to the program.
500
+ */
501
+ private __uploadLightClusterView;
486
502
  private __uploadCurrentComponentSIDs;
487
503
  /**
488
504
  * Binds the data texture to the WebGL context for shader access.
@@ -0,0 +1,83 @@
1
+ import { type CompositionTypeEnum } from '../../foundation/definitions/CompositionType';
2
+ import type { ShaderSemanticsInfo } from '../../foundation/definitions/ShaderSemanticsInfo';
3
+ import type { Count, IndexOf16Bytes } from '../../types/CommonTypes';
4
+ import type { BufferLocationInfo, RawVec4 } from './types';
5
+ /**
6
+ * Source of the data texture layout. `readVec4` and `readScalar` read the CPU-side
7
+ * GPUInstanceData buffers, which are the same bytes that are uploaded to the texture.
8
+ */
9
+ export type BufferLayoutSource = {
10
+ width: number;
11
+ readVec4: (vec4Index: number) => RawVec4 | null;
12
+ readScalar: (scalarIndex: number) => number | null;
13
+ };
14
+ type FetchPlan = {
15
+ fetchFunction: string;
16
+ unit: 'vec4' | 'scalar' | 'scalar-weird';
17
+ count: number;
18
+ warning?: string;
19
+ };
20
+ /**
21
+ * Mirrors the `fetch*` helpers in `prerequisites.glsl` for each composition type.
22
+ */
23
+ export declare function getFetchPlan(compositionType: CompositionTypeEnum): FetchPlan;
24
+ /**
25
+ * Decodes the location(s) of a material semantic for a given material SID.
26
+ *
27
+ * Mirrors `WebGLStrategyWebGL2.__getShaderPropertyOfMaterial`:
28
+ * - `bufferViewIndex = floor(materialSID / materialCountPerBufferView)`
29
+ * - `indexInBufferView = materialSID % materialCountPerBufferView`
30
+ * - non-array: `vec4Index = offsets[bv] + vec4Size * indexInBufferView`
31
+ * - array: `offsets[bv] + vec4Size * arrayLength * indexInBufferView + vec4Size * elementIndex`
32
+ */
33
+ export declare function decodeMaterialProperty(args: {
34
+ info: ShaderSemanticsInfo;
35
+ offsets: IndexOf16Bytes[];
36
+ materialSID: number;
37
+ materialCountPerBufferView: number;
38
+ layout: BufferLayoutSource;
39
+ maxArrayElements?: number;
40
+ }): BufferLocationInfo;
41
+ /**
42
+ * Decodes a global property. Global properties use instanceId 0, and array elements
43
+ * use a plain `vec4Size` / `scalarSize` stride (no arrayLength multiplier).
44
+ */
45
+ export declare function decodeGlobalProperty(args: {
46
+ info: ShaderSemanticsInfo;
47
+ offset: IndexOf16Bytes;
48
+ layout: BufferLayoutSource;
49
+ maxArrayElements?: number;
50
+ }): BufferLocationInfo;
51
+ export type ComponentMemberLayoutInfo = {
52
+ compositionType: CompositionTypeEnum;
53
+ arrayLength?: Count;
54
+ isVariableLength?: boolean;
55
+ };
56
+ /**
57
+ * Decodes a component member. Mirrors `processForNonArrayType` / `processForArrayType`
58
+ * in `WebGLStrategyWebGL2`.
59
+ */
60
+ export declare function decodeComponentMember(args: {
61
+ memberInfo: ComponentMemberLayoutInfo;
62
+ offsets: IndexOf16Bytes[];
63
+ componentSID: number;
64
+ componentCountPerBufferView: number;
65
+ layout: BufferLayoutSource;
66
+ maxArrayElements?: number;
67
+ }): BufferLocationInfo;
68
+ /**
69
+ * Decodes a variable-length component member (e.g. SkeletalComponent.boneData).
70
+ * The per-instance location is stored in `${memberName}Location` as
71
+ * `location = x * 65536 + y`, with the element count in `z`.
72
+ */
73
+ export declare function decodeVariableLengthComponentMember(args: {
74
+ memberInfo: ComponentMemberLayoutInfo;
75
+ offsets: IndexOf16Bytes[];
76
+ locationMemberOffsets: IndexOf16Bytes[];
77
+ componentSID: number;
78
+ componentCountPerBufferView: number;
79
+ layout: BufferLayoutSource;
80
+ radix?: number;
81
+ maxArrayElements?: number;
82
+ }): BufferLocationInfo;
83
+ export {};
@@ -0,0 +1,47 @@
1
+ import { Component } from '../../foundation/core/Component';
2
+ import type { IEntity } from '../../foundation/core/Entity';
3
+ import type { Primitive } from '../../foundation/geometry/Primitive';
4
+ import type { Material } from '../../foundation/materials/core/Material';
5
+ import type { Engine } from '../../foundation/system/Engine';
6
+ import type { CGAPIResourceHandle } from '../../types/CommonTypes';
7
+ import type { AllParameterReport, ComponentParameterReport, EntityParameterReport, GlobalParameterReport, MaterialParameterReport, RawVec4, RealUniformInfo, ShaderParameterEntry } from './types';
8
+ /**
9
+ * Converts math classes, typed arrays and texture tuples to plain JSON values.
10
+ */
11
+ export declare function serializeValue(value: unknown): unknown;
12
+ /**
13
+ * Inspector for the values Rhodonite uploads to WebGL2 or WebGPU shaders.
14
+ *
15
+ * It reports both the CPU-side value of a shader semantic and the location/value the
16
+ * shader reads from the WebGL2 data texture or the WebGPU storage buffer, plus the
17
+ * real uniform value when the WebGL2 shader uses one (for
18
+ * `needUniformInDataTextureMode` and sampler uniforms).
19
+ *
20
+ * The decoder reads the CPU-side GPUInstanceData buffers, which are the same bytes
21
+ * that are uploaded to the GPU. It does not read back GPU memory.
22
+ */
23
+ export declare class ShaderParameterDebugger {
24
+ static reportMaterial(engine: Engine, material: Material, primitive?: Primitive): MaterialParameterReport;
25
+ static reportGlobals(engine: Engine, shaderProgramUid?: CGAPIResourceHandle): GlobalParameterReport;
26
+ static reportComponent(engine: Engine, component: Component): ComponentParameterReport;
27
+ static reportEntity(engine: Engine, entity: IEntity): EntityParameterReport;
28
+ static reportAll(engine: Engine): AllParameterReport;
29
+ static readRealUniforms(engine: Engine, shaderProgramUid: CGAPIResourceHandle): Map<string, RealUniformInfo> | null;
30
+ static decode(engine: Engine, vec4Index: number): {
31
+ vec4Index: number;
32
+ byteOffset: number;
33
+ row: number;
34
+ col: number;
35
+ vec4: RawVec4 | null;
36
+ } | null;
37
+ static formatEntries(entries: ShaderParameterEntry[]): Array<Record<string, unknown>>;
38
+ static format(report: MaterialParameterReport | GlobalParameterReport | ComponentParameterReport): unknown;
39
+ static dumpMaterial(engine: Engine, material: Material, primitive?: Primitive): MaterialParameterReport;
40
+ static dumpPrimitive(engine: Engine, primitive: Primitive): MaterialParameterReport;
41
+ static dumpGlobals(engine: Engine, shaderProgramUid?: CGAPIResourceHandle): GlobalParameterReport;
42
+ static dumpEntity(engine: Engine, entity: IEntity): EntityParameterReport;
43
+ static dumpAll(engine: Engine): AllParameterReport;
44
+ static installConsoleHelpers(engine: Engine, target?: any): void;
45
+ private static __getShaderProgramUid;
46
+ private static __isProgramMaterialMismatch;
47
+ }
@@ -0,0 +1,3 @@
1
+ export * from './BufferLayoutDecoder';
2
+ export * from './ShaderParameterDebugger';
3
+ export * from './types';
@@ -0,0 +1,114 @@
1
+ /**
2
+ * Types for the shader parameter debugger.
3
+ *
4
+ * The debugger reports, for each shader semantic, both the CPU-side value and the
5
+ * location/value the shader will read from the WebGL2 data texture or the WebGPU
6
+ * storage buffer.
7
+ */
8
+ export type ShaderParameterBackend = 'WebGL2' | 'WebGPU' | 'None';
9
+ export type ShaderParameterSource = 'dataTexture' | 'storageBuffer' | 'uniform' | 'texture' | 'soloDatum';
10
+ /** One raw vec4 value (a texel in WebGL2, a storage-buffer vec4 in WebGPU). */
11
+ export type RawVec4 = [number, number, number, number];
12
+ /**
13
+ * Location of a value inside the GPU data buffer.
14
+ *
15
+ * `vec4Index` is the global vec4 index the shader computes (or the base vec4 index for
16
+ * scalar-unaligned fetches). `byteOffset` is `vec4Index * 16`. `row` and `col` are the
17
+ * data-texture coordinates in WebGL2 and are `-1` in WebGPU, which has no texture rows.
18
+ */
19
+ export type BufferLocation = {
20
+ bufferViewIndex: number;
21
+ vec4Index: number;
22
+ byteOffset: number;
23
+ row: number;
24
+ col: number;
25
+ fetchFunction: string;
26
+ vec4s: RawVec4[];
27
+ scalarIndex?: number;
28
+ arrayElement?: number;
29
+ warnings: string[];
30
+ };
31
+ export type BufferLocationInfo = {
32
+ bufferViewOffsets: number[];
33
+ bufferViewIndex: number;
34
+ indexInBufferView: number;
35
+ arrayLengthForShader: number;
36
+ locations: BufferLocation[];
37
+ };
38
+ export type RealUniformInfo = {
39
+ locationFound: boolean;
40
+ value: unknown;
41
+ };
42
+ export type TextureBindingInfo = {
43
+ /** WebGL2 sampler unit. Null in WebGPU. */
44
+ unit: number | null;
45
+ /** WebGL2 sampler unit / WebGPU bind-group binding. */
46
+ binding: number | null;
47
+ textureUid: number | null;
48
+ samplerUid: number | null;
49
+ };
50
+ export type ShaderParameterEntry = {
51
+ semantic: string;
52
+ stage: string;
53
+ compositionType: string;
54
+ componentType: string;
55
+ arrayLength?: number;
56
+ isTexture: boolean;
57
+ isInternalSetting: boolean;
58
+ needUniformInDataTextureMode: boolean;
59
+ soloDatum: boolean;
60
+ source: ShaderParameterSource;
61
+ /** Serializable preview of the CPU-side value. */
62
+ valuePreview: unknown;
63
+ buffer?: BufferLocationInfo;
64
+ realUniform?: RealUniformInfo;
65
+ texture?: TextureBindingInfo;
66
+ };
67
+ export type MaterialParameterReport = {
68
+ available: boolean;
69
+ reason?: string;
70
+ backend: ShaderParameterBackend;
71
+ processApproach: string;
72
+ materialTypeName: string;
73
+ materialUID: number;
74
+ materialSID: number;
75
+ materialCountPerBufferView: number;
76
+ bufferViewIndex: number;
77
+ shaderProgramUid: number;
78
+ /** Data-texture width in WebGL2. Zero in WebGPU. */
79
+ bufferWidth: number;
80
+ /**
81
+ * True when the shader program was last used with another material. Uniform values
82
+ * are per program (last-set state), so `realUniform.value` may belong to that material.
83
+ */
84
+ sharedProgramMaterialMismatch: boolean;
85
+ entries: ShaderParameterEntry[];
86
+ };
87
+ export type GlobalParameterReport = {
88
+ available: boolean;
89
+ reason?: string;
90
+ backend: ShaderParameterBackend;
91
+ processApproach: string;
92
+ /** Data-texture width in WebGL2. Zero in WebGPU. */
93
+ bufferWidth: number;
94
+ shaderProgramUid: number;
95
+ entries: ShaderParameterEntry[];
96
+ };
97
+ export type ComponentParameterReport = {
98
+ available: boolean;
99
+ reason?: string;
100
+ backend: ShaderParameterBackend;
101
+ componentClassName: string;
102
+ componentSID: number;
103
+ componentCountPerBufferView: number;
104
+ entries: ShaderParameterEntry[];
105
+ };
106
+ export type EntityParameterReport = {
107
+ entityUID: number;
108
+ materials: MaterialParameterReport[];
109
+ components: ComponentParameterReport[];
110
+ };
111
+ export type AllParameterReport = {
112
+ globals: GlobalParameterReport;
113
+ materials: MaterialParameterReport[];
114
+ };
@@ -1,3 +1,4 @@
1
+ export * from './debug/index';
1
2
  export * from './getRenderingStrategy';
2
3
  export * from './shaders/index';
3
4
  export * from './textureLoader/index';
@@ -8,5 +9,4 @@ export * from './WebGLExtension';
8
9
  export * from './WebGLResourceRepository';
9
10
  export * from './WebGLStrategy';
10
11
  export * from './WebGLStrategyCommonMethod';
11
- export * from './WebGLStrategyDataTexture';
12
- export * from './WebGLStrategyUniform';
12
+ export * from './WebGLStrategyWebGL2';
@@ -3,15 +3,13 @@ import { StandardShaderPart } from './shaders/StandardShaderPart';
3
3
  import { WebGLContextWrapper } from './WebGLContextWrapper';
4
4
  import { type VertexHandles as vertexHandles, WebGLResourceRepository } from './WebGLResourceRepository';
5
5
  import type { WebGLStrategy as webGLStrategy } from './WebGLStrategy';
6
- import { WebGLStrategyDataTexture } from './WebGLStrategyDataTexture';
7
- import { WebGLStrategyUniform } from './WebGLStrategyUniform';
6
+ import { WebGLStrategyWebGL2 } from './WebGLStrategyWebGL2';
8
7
  declare const WebGL: Readonly<{
9
8
  getRenderingStrategy: typeof getRenderingStrategy;
10
9
  StandardShaderPart: typeof StandardShaderPart;
11
10
  WebGLContextWrapper: typeof WebGLContextWrapper;
12
11
  WebGLResourceRepository: typeof WebGLResourceRepository;
13
- WebGLStrategyUniform: typeof WebGLStrategyUniform;
14
- WebGLStrategyDataTexture: typeof WebGLStrategyDataTexture;
12
+ WebGLStrategyWebGL2: typeof WebGLStrategyWebGL2;
15
13
  }>;
16
14
  export default WebGL;
17
15
  export type RnWebGL = typeof WebGL;
@@ -1,6 +1,6 @@
1
1
  import { type ComponentTypeEnum } from '../../foundation/definitions/ComponentType';
2
2
  import type { CompositionTypeEnum } from '../../foundation/definitions/CompositionType';
3
- import { type VertexAttributeEnum } from '../../foundation/definitions/VertexAttribute';
3
+ import type { VertexAttributeEnum } from '../../foundation/definitions/VertexAttribute';
4
4
  import { AbstractShaderNode } from '../../foundation/materials/core/AbstractShaderNode';
5
5
  import type { Socket, SocketDefaultValue } from '../../foundation/materials/core/Socket';
6
6
  import type { Engine } from '../../foundation/system/Engine';
@@ -22,7 +22,6 @@ export type RenderingArgWebGL = {
22
22
  sheenCube?: CubeTexture | RenderTargetTextureCube;
23
23
  isVr: boolean;
24
24
  displayIdx: Index;
25
- setUniform: boolean;
26
25
  };
27
26
  export type RenderingArgWebGpu = {
28
27
  cameraComponentSid: Index;
@@ -0,0 +1,34 @@
1
+ import type { LightClusterGpuBuildParams } from '../foundation/renderer/lightCluster/LightClusterSystem';
2
+ /**
3
+ * Builds the light cluster tables of Clustered Forward rendering with compute shaders.
4
+ * The tables are written into the storage buffer of the GPU instance data, where the CPU build would write them.
5
+ *
6
+ * The sorted light input of the views (spheres, entries and Z slice ranges) is uploaded to a separate storage buffer,
7
+ * because it is small (some tens of KiB) and reused for all views.
8
+ */
9
+ export declare class WebGpuLightClusterBuilder {
10
+ private __device;
11
+ private __bindGroupLayout;
12
+ private __pipeline;
13
+ private __paramsBuffer?;
14
+ private __paramsStride;
15
+ private __paramsCapacity;
16
+ private __paramsArray;
17
+ private __buildDataBuffer?;
18
+ private __buildDataCapacity;
19
+ private __bindGroup?;
20
+ private __bindGroupStorageBuffer?;
21
+ constructor(device: GPUDevice);
22
+ /**
23
+ * Builds the clusters of the views and submits the work immediately, so that it runs after the upload of the
24
+ * GPU instance data (queue.writeBuffer) and before the render commands of the frame.
25
+ *
26
+ * @param storageBuffer - The storage buffer of the GPU instance data
27
+ * @param params - The views to build and their sorted light input
28
+ */
29
+ build(storageBuffer: GPUBuffer, params: LightClusterGpuBuildParams): void;
30
+ /**
31
+ * Releases the GPU resources.
32
+ */
33
+ destroy(): void;
34
+ }
@@ -92,6 +92,8 @@ export declare class WebGpuResourceRepository extends CGAPIResourceRepository im
92
92
  /** Cached `gpuDevice.queue` ([SameObject]), read on every frame by flush(). */
93
93
  private __gpuQueue?;
94
94
  private __renderBundles;
95
+ /** Fragment module of the depth prepass pipelines (it writes nothing; the color targets use writeMask 0). */
96
+ private __depthOnlyFragmentModule?;
95
97
  private __renderBundleEncoder?;
96
98
  private __renderBundleEncoderKey?;
97
99
  private __systemDepthTexture?;
@@ -476,8 +478,13 @@ export declare class WebGpuResourceRepository extends CGAPIResourceRepository im
476
478
  * @param renderPass - The render pass defining render targets and clear operations
477
479
  * @param cameraId - Identifier for the camera used for rendering
478
480
  * @param zWrite - Whether to enable depth writing during rendering
481
+ * @param options - `depthOnly` draws the primitive with a depth-only pipeline (the depth prepass);
482
+ * `allowEqualDepth` lets the color pass pass the depth written by the prepass
479
483
  */
480
- draw(engine: Engine, primitive: Primitive, material: Material, renderPass: RenderPass, cameraId: number, zWrite: boolean, _displayIdx: number): void;
484
+ draw(engine: Engine, primitive: Primitive, material: Material, renderPass: RenderPass, cameraId: number, zWrite: boolean, _displayIdx: number, options?: {
485
+ depthOnly?: boolean;
486
+ allowEqualDepth?: boolean;
487
+ }): void;
481
488
  /**
482
489
  * Creates a render bundle encoder for efficient rendering.
483
490
  * Render bundles allow pre-recording of rendering commands for better performance.
@@ -575,7 +582,11 @@ export declare class WebGpuResourceRepository extends CGAPIResourceRepository im
575
582
  finishRenderBundleEncoderAndKeepRenderPass(engine: Engine, renderPass: RenderPass, displayIdx: number): GPURenderPassEncoder | undefined;
576
583
  getOrCreateRenderPassEncoderForExternalRendering(engine: Engine, renderPass: RenderPass, displayIdx: number): GPURenderPassEncoder | undefined;
577
584
  endRenderPassEncoderForExternalRendering(): void;
578
- getOrCreateRenderPipeline(renderPipelineId: string, pipelineLayoutKey: string, pipelineLayout: GPUPipelineLayout, primitive: Primitive, material: Material, renderPass: RenderPass, zWrite: boolean): [GPURenderPipeline, boolean];
585
+ private __getDepthOnlyFragmentModule;
586
+ getOrCreateRenderPipeline(renderPipelineId: string, pipelineLayoutKey: string, pipelineLayout: GPUPipelineLayout, primitive: Primitive, material: Material, renderPass: RenderPass, zWrite: boolean, options?: {
587
+ depthOnly?: boolean;
588
+ allowEqualDepth?: boolean;
589
+ }): [GPURenderPipeline, boolean];
579
590
  /**
580
591
  * Submits all recorded commands to the GPU queue and resets the command encoder.
581
592
  * This method must be called to execute any recorded rendering commands.
@@ -633,7 +644,21 @@ export declare class WebGpuResourceRepository extends CGAPIResourceRepository im
633
644
  * @param storageBufferHandle - Handle to the storage buffer to update
634
645
  * @param gpuInstanceDataBuffers - New data to write to the buffer
635
646
  */
636
- updateStorageBuffer(storageBufferHandle: WebGPUResourceHandle, gpuInstanceDataBuffers: Buffer[]): void;
647
+ updateStorageBuffer(storageBufferHandle: WebGPUResourceHandle, gpuInstanceDataBuffers: Buffer[], excludedByteRanges?: readonly [number, number][]): void;
648
+ /**
649
+ * Writes byte ranges of the GPU instance data to the storage buffer.
650
+ *
651
+ * @param storageBufferHandle - Handle to the storage buffer
652
+ * @param gpuInstanceDataBuffers - The GPU instance data buffers (layers)
653
+ * @param byteRanges - The ranges `[start, end)` in the concatenated layers. A range must not span layers.
654
+ */
655
+ updateStorageBufferRanges(storageBufferHandle: WebGPUResourceHandle, gpuInstanceDataBuffers: Buffer[], byteRanges: readonly [number, number][]): void;
656
+ /**
657
+ * The storage buffer of the GPU instance data (bound at group 0, binding 0 of the render pipelines).
658
+ *
659
+ * @internal
660
+ */
661
+ _getStorageBuffer(): GPUBuffer | undefined;
637
662
  destroyStorageBuffer(storageBufferHandle: WebGPUResourceHandle): void;
638
663
  /**
639
664
  * Updates a portion of a storage buffer with new data at a specific offset.
@@ -32,6 +32,10 @@ export declare class WebGpuStrategyBasic implements CGAPIStrategy {
32
32
  private __uniformMorphOffsetsTypedArray?;
33
33
  private __uniformMorphWeightsTypedArray?;
34
34
  private __lastMaterialsUpdateCount;
35
+ private __lastLightClusterDataVersion;
36
+ private __lastLightComponentsUpdateCount;
37
+ private __lightClusterBuilder?;
38
+ private __lastLightClusterBuildDataVersion;
35
39
  private __lastTransformComponentsUpdateCount;
36
40
  private __lastSceneGraphComponentsUpdateCount;
37
41
  private __lastCameraComponentsUpdateCount;
@@ -157,6 +161,11 @@ export declare class WebGpuStrategyBasic implements CGAPIStrategy {
157
161
  * @param renderPass - The render pass containing the material and rendering configuration
158
162
  */
159
163
  private __renderWithoutBuffers;
164
+ /**
165
+ * Whether the depth prepass can run for the render pass: it must be enabled, draw the scene itself (render passes
166
+ * with a material override such as shadow maps and post effects are excluded), and write depth.
167
+ */
168
+ private __isDepthPrepassAvailable;
160
169
  /**
161
170
  * Renders a single primitive with the specified material and render settings.
162
171
  * Handles shader setup, uniform buffer updates, and the actual draw call.
@@ -167,13 +176,21 @@ export declare class WebGpuStrategyBasic implements CGAPIStrategy {
167
176
  * @param displayIdx - The index of the display to render to
168
177
  * @returns True if the primitive was successfully rendered
169
178
  */
170
- renderInner(primitiveUid: PrimitiveUID, renderPass: RenderPass, zWrite: boolean, displayIdx: Index): boolean;
179
+ renderInner(primitiveUid: PrimitiveUID, renderPass: RenderPass, zWrite: boolean, displayIdx: Index, options?: {
180
+ depthOnly?: boolean;
181
+ allowEqualDepth?: boolean;
182
+ }): boolean;
171
183
  /**
172
184
  * Creates or updates the main storage buffer containing all GPU instance data.
173
185
  * This buffer holds transform matrices, material properties, and other per-instance data
174
186
  * required for rendering all objects in the scene.
175
187
  */
176
188
  private __createAndUpdateStorageBuffer;
189
+ /**
190
+ * Builds the Clustered Forward light cluster tables with compute shaders when the LightClusterSystem
191
+ * builds them on the GPU. It must run after every upload of the GPU instance data, which overwrites the tables.
192
+ */
193
+ private __buildLightClustersOnGpu;
177
194
  /**
178
195
  * Creates or updates the storage buffer containing blend shape vertex data.
179
196
  * This buffer holds morph target positions and other vertex attributes needed for blend shape animation.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rhodonite",
3
- "version": "0.20.2",
3
+ "version": "0.22.0",
4
4
  "keywords": [
5
5
  "rhodonite",
6
6
  "webgl",
@@ -44,6 +44,7 @@
44
44
  "test-e2e": "npm run test-e2e-part -- ./samples/test_e2e",
45
45
  "test-e2e-serial": "npm run test-e2e-part -- --runInBand ./samples/test_e2e",
46
46
  "test-e2e-part": "npx vitest run --config ./config/test/vitest.config.e2e.ts",
47
+ "test-e2e-update": "npm run test-e2e-part -- --update ./samples/test_e2e",
47
48
  "test-e2e:docker": "bash ./config/e2e/run-in-docker.sh test",
48
49
  "test-e2e:docker:update": "bash ./config/e2e/run-in-docker.sh update",
49
50
  "test-e2e:docker:shell": "bash ./config/e2e/run-in-docker.sh shell",