@woosh/meep-engine 3.60.7 → 3.60.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/engine/graphics3/AnimationGraphSystem.d.ts +4 -1
- package/src/engine/graphics3/AnimationGraphSystem.d.ts.map +1 -1
- package/src/engine/graphics3/AnimationGraphSystem.js +35 -5
- package/src/engine/graphics3/AnimationSystem.d.ts +1 -1
- package/src/engine/graphics3/AnimationSystem.d.ts.map +1 -1
- package/src/engine/graphics3/AnimationSystem.js +34 -5
- package/src/engine/graphics3/FoliageWindSystem.d.ts +2 -1
- package/src/engine/graphics3/FoliageWindSystem.d.ts.map +1 -1
- package/src/engine/graphics3/FoliageWindSystem.js +50 -3
- package/src/engine/graphics3/GPUFluidSystem.d.ts.map +1 -1
- package/src/engine/graphics3/GPUFluidSystem.js +16 -14
- package/src/engine/graphics3/GPUParticleEmitterSystem.d.ts +2 -2
- package/src/engine/graphics3/GPUParticleEmitterSystem.d.ts.map +1 -1
- package/src/engine/graphics3/GPUParticleEmitterSystem.js +84 -32
- package/src/engine/graphics3/LightSystem.d.ts +4 -0
- package/src/engine/graphics3/LightSystem.d.ts.map +1 -1
- package/src/engine/graphics3/LightSystem.js +23 -6
- package/src/engine/graphics3/MeshSkinSystem.d.ts +1 -1
- package/src/engine/graphics3/MeshSkinSystem.d.ts.map +1 -1
- package/src/engine/graphics3/MeshSkinSystem.js +50 -5
- package/src/engine/graphics3/MeshSystem.d.ts +1 -0
- package/src/engine/graphics3/MeshSystem.d.ts.map +1 -1
- package/src/engine/graphics3/MeshSystem.js +22 -8
- package/src/engine/graphics3/ShadedGeometrySystem.d.ts +5 -1
- package/src/engine/graphics3/ShadedGeometrySystem.d.ts.map +1 -1
- package/src/engine/graphics3/ShadedGeometrySystem.js +56 -7
- package/src/engine/graphics3/WaterSystem.d.ts +3 -0
- package/src/engine/graphics3/WaterSystem.d.ts.map +1 -1
- package/src/engine/graphics3/WaterSystem.js +10 -2
- package/src/engine/graphics3/animation/AnimationClipsSink.d.ts +15 -7
- package/src/engine/graphics3/animation/AnimationClipsSink.d.ts.map +1 -1
- package/src/engine/graphics3/animation/AnimationClipsSink.js +42 -8
- package/src/engine/network/state/ReplicationSlotTable.d.ts +9 -5
- package/src/engine/network/state/ReplicationSlotTable.d.ts.map +1 -1
- package/src/engine/network/state/ReplicationSlotTable.js +36 -8
- package/src/engine/physics/fluid/ecs/FluidObstacleSystem.d.ts +4 -4
- package/src/generation/markers/GridActionRuleSet.d.ts.map +1 -1
- package/src/generation/markers/GridActionRuleSet.js +12 -3
- package/src/shade/renderer/GraphicsContext.d.ts +8 -0
- package/src/shade/renderer/GraphicsContext.d.ts.map +1 -1
- package/src/shade/renderer/GraphicsContext.js +29 -0
- package/src/shade/renderer/Renderer.d.ts +10 -0
- package/src/shade/renderer/Renderer.d.ts.map +1 -1
- package/src/shade/renderer/Renderer.js +22 -2
- package/src/shade/renderer/fluid/GPUFluidCascade.d.ts +3 -3
- package/src/shade/renderer/fluid/GPUFluidCascadeStack.d.ts +1 -1
- package/src/shade/renderer/fluid/forcing/GPUFluidForcing.d.ts +6 -6
- package/src/shade/renderer/fluid/pressure/GPUFluidPressureSolve.d.ts +1 -1
- package/src/shade/renderer/fluid/query/GPUFluidQueries.d.ts +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/GPUProbeClipmapGI.d.ts +1 -1
- package/src/shade/renderer/light/GPULightCollection.d.ts +3 -1
- package/src/shade/renderer/light/GPULightCollection.d.ts.map +1 -1
- package/src/shade/renderer/light/GPULightCollection.js +34 -9
- package/src/shade/renderer/light/LightCollection.d.ts +13 -3
- package/src/shade/renderer/light/LightCollection.d.ts.map +1 -1
- package/src/shade/renderer/light/LightCollection.js +19 -3
- package/src/shade/renderer/loader/gltf/tiny-gltf.d.ts +1 -1
- package/src/shade/renderer/material/GPUMaterialManager.d.ts +22 -0
- package/src/shade/renderer/material/GPUMaterialManager.d.ts.map +1 -1
- package/src/shade/renderer/material/GPUMaterialManager.js +30 -0
- package/src/shade/renderer/material/dispatch/GPUMaterialComputeDispatch.d.ts +75 -0
- package/src/shade/renderer/material/dispatch/GPUMaterialComputeDispatch.d.ts.map +1 -0
- package/src/shade/renderer/material/dispatch/GPUMaterialComputeDispatch.js +338 -0
- package/src/shade/renderer/material/dispatch/MATERIAL_DISPATCH_CONSTANTS.d.ts +50 -0
- package/src/shade/renderer/material/dispatch/MATERIAL_DISPATCH_CONSTANTS.d.ts.map +1 -0
- package/src/shade/renderer/material/dispatch/MATERIAL_DISPATCH_CONSTANTS.js +54 -0
- package/src/shade/renderer/material/dispatch/MaterialDispatch.d.ts +37 -0
- package/src/shade/renderer/material/dispatch/MaterialDispatch.d.ts.map +1 -0
- package/src/shade/renderer/material/dispatch/MaterialDispatch.js +31 -0
- package/src/shade/renderer/material/dispatch/MaterialDispatchRecords.d.ts +42 -0
- package/src/shade/renderer/material/dispatch/MaterialDispatchRecords.d.ts.map +1 -0
- package/src/shade/renderer/material/dispatch/MaterialDispatchRecords.js +132 -0
- package/src/shade/renderer/material/dispatch/chunk_material_mesh_key.d.ts +21 -0
- package/src/shade/renderer/material/dispatch/chunk_material_mesh_key.d.ts.map +1 -0
- package/src/shade/renderer/material/dispatch/chunk_material_mesh_key.js +46 -0
- package/src/shade/renderer/material/dispatch/chunk_material_quad_keys.d.ts +20 -0
- package/src/shade/renderer/material/dispatch/chunk_material_quad_keys.d.ts.map +1 -0
- package/src/shade/renderer/material/dispatch/chunk_material_quad_keys.js +111 -0
- package/src/shade/renderer/material/dispatch/chunk_material_quad_pack.d.ts +18 -0
- package/src/shade/renderer/material/dispatch/chunk_material_quad_pack.d.ts.map +1 -0
- package/src/shade/renderer/material/dispatch/chunk_material_quad_pack.js +33 -0
- package/src/shade/renderer/material/dispatch/gbuffer_compute.d.ts +116 -0
- package/src/shade/renderer/material/dispatch/gbuffer_compute.d.ts.map +1 -0
- package/src/shade/renderer/material/dispatch/gbuffer_compute.js +249 -0
- package/src/shade/renderer/material/dispatch/graph_material_dispatch_compute.d.ts +56 -0
- package/src/shade/renderer/material/dispatch/graph_material_dispatch_compute.d.ts.map +1 -0
- package/src/shade/renderer/material/dispatch/graph_material_dispatch_compute.js +315 -0
- package/src/shade/renderer/material/dispatch/shader_material_dispatch_commands.d.ts +16 -0
- package/src/shade/renderer/material/dispatch/shader_material_dispatch_commands.d.ts.map +1 -0
- package/src/shade/renderer/material/dispatch/shader_material_dispatch_commands.js +83 -0
- package/src/shade/renderer/material/dispatch/shader_material_pixel_count.d.ts +22 -0
- package/src/shade/renderer/material/dispatch/shader_material_pixel_count.d.ts.map +1 -0
- package/src/shade/renderer/material/dispatch/shader_material_pixel_count.js +133 -0
- package/src/shade/renderer/material/dispatch/shader_material_pixel_scatter.d.ts +14 -0
- package/src/shade/renderer/material/dispatch/shader_material_pixel_scatter.d.ts.map +1 -0
- package/src/shade/renderer/material/dispatch/shader_material_pixel_scatter.js +98 -0
- package/src/shade/renderer/material/standard/VT_MATERIAL_TEMPLATE.d.ts +1 -0
- package/src/shade/renderer/material/standard/VT_MATERIAL_TEMPLATE.d.ts.map +1 -1
- package/src/shade/renderer/material/standard/VT_MATERIAL_TEMPLATE.js +11 -0
- package/src/shade/renderer/material/standard/fragment_gbuffer.d.ts +41 -6
- package/src/shade/renderer/material/standard/fragment_gbuffer.d.ts.map +1 -1
- package/src/shade/renderer/material/standard/fragment_gbuffer.js +88 -29
- package/src/shade/renderer/material/template/ShadeMaterialTemplate.d.ts +13 -1
- package/src/shade/renderer/material/template/ShadeMaterialTemplate.d.ts.map +1 -1
- package/src/shade/renderer/material/template/ShadeMaterialTemplate.js +18 -1
- package/src/shade/renderer/postprocess/nss/NSS.d.ts +1 -1
- package/src/shade/renderer/scene/GPUSceneContext.d.ts +6 -0
- package/src/shade/renderer/scene/GPUSceneContext.d.ts.map +1 -1
- package/src/shade/renderer/scene/GPUSceneContext.js +17 -7
- package/src/shade/renderer/scene/Scene.d.ts +4 -3
- package/src/shade/renderer/scene/Scene.d.ts.map +1 -1
- package/src/shade/renderer/scene/Scene.js +54 -53
- package/src/shade/renderer/scene/rows/GPUSceneRows.d.ts +16 -0
- package/src/shade/renderer/scene/rows/GPUSceneRows.d.ts.map +1 -1
- package/src/shade/renderer/scene/rows/GPUSceneRows.js +34 -0
- package/src/shade/renderer/shader/chunk/geometry/normal/chunk_anti_alias_roughness_kaplanyan.d.ts +19 -0
- package/src/shade/renderer/shader/chunk/geometry/normal/chunk_anti_alias_roughness_kaplanyan.d.ts.map +1 -1
- package/src/shade/renderer/shader/chunk/geometry/normal/chunk_anti_alias_roughness_kaplanyan.js +55 -20
- package/src/shade/renderer/shader/chunk/subgroup/chunk_subgroup_keyed_append.d.ts +31 -0
- package/src/shade/renderer/shader/chunk/subgroup/chunk_subgroup_keyed_append.d.ts.map +1 -0
- package/src/shade/renderer/shader/chunk/subgroup/chunk_subgroup_keyed_append.js +77 -0
- package/src/shade/renderer/texture/virtual/VirtualTextureManager.d.ts +6 -0
- package/src/shade/renderer/texture/virtual/VirtualTextureManager.d.ts.map +1 -1
- package/src/shade/renderer/texture/virtual/VirtualTextureManager.js +15 -1
- package/src/shade/renderer/water/query/GPUWaterQueries.d.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LightCollection.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/light/LightCollection.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"LightCollection.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/light/LightCollection.js"],"names":[],"mappings":"AAIA;;;GAGG;AAEH;;;;;;;;;;GAUG;AACH;IAeI;;;OAGG;IACH,mDAEC;IAgBD;;;OAGG;IACH,sEAMC;IAlBD;;;OAGG;IACH,qEAEC;IAiBD;;;OAGG;IACH,sBAEC;IAED;;;OAGG;IACH,4BAIC;IAED;;;;;;;;;;OAUG;IACH,WAHW,KAAK,UACL,MAAM,QAYhB;IAED;;;;;;OAMG;IACH,eAAyB;IAEzB;;;;;OAKG;IACH,cAHW,KAAK,GACH,OAAO,CAgBnB;IAED;;;OAGG;IACH,WAHW,KAAK,GACH,OAAO,CAInB;IAED;;;;;OAKG;IACH,iBAHW,KAAK,GACH,MAAM,GAAC,SAAS,CAI5B;;CACJ;2BA5JY,OAAO,4BAA4B,EAAE,YAAY;oBACjD,OAAO,kBAAkB,EAAE,KAAK"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { assert } from "../../../core/assert.js";
|
|
2
2
|
import { array_remove_first } from "../../../core/collection/array/array_remove_first.js";
|
|
3
|
+
import Signal from "../../../core/events/signal/Signal.js";
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* @typedef {import("../texture/ShadeTexture.js").ShadeTexture} ShadeTexture
|
|
@@ -11,9 +12,11 @@ import { array_remove_first } from "../../../core/collection/array/array_remove_
|
|
|
11
12
|
*
|
|
12
13
|
* A light is placed by naming the entity it stands at: the entity's `transforms` row is where the
|
|
13
14
|
* GPU reads the light's pose from, and the scene's GPU context holds that row on the collection's
|
|
14
|
-
* behalf for as long as the light is here
|
|
15
|
-
*
|
|
16
|
-
*
|
|
15
|
+
* behalf for as long as the light is here: taken by the next build, let go as the light leaves
|
|
16
|
+
* ({@link onRemoved}), since the entity may go next and its id be handed on. The collection itself
|
|
17
|
+
* is CPU data — the renderer's mirror of it (`GPULightCollection`) is rebuilt whenever
|
|
18
|
+
* {@link version} moves, which adding and removing do on their own and a change in place does
|
|
19
|
+
* through {@link needsUpdate}.
|
|
17
20
|
*/
|
|
18
21
|
export class LightCollection {
|
|
19
22
|
|
|
@@ -108,6 +111,15 @@ export class LightCollection {
|
|
|
108
111
|
this.#version++;
|
|
109
112
|
}
|
|
110
113
|
|
|
114
|
+
/**
|
|
115
|
+
* A light has left, and the entity it stood at with it — sent from {@link remove}, before the
|
|
116
|
+
* caller can remove that entity and its dataset hand the id to another. Whatever holds the
|
|
117
|
+
* entity's row for the light lets go here.
|
|
118
|
+
*
|
|
119
|
+
* @type {Signal<Light, number>} the light, its entity
|
|
120
|
+
*/
|
|
121
|
+
onRemoved = new Signal();
|
|
122
|
+
|
|
111
123
|
/**
|
|
112
124
|
* Remove a light. Returns true if it was found and dropped.
|
|
113
125
|
*
|
|
@@ -118,9 +130,13 @@ export class LightCollection {
|
|
|
118
130
|
const removed = array_remove_first(this.#elements, light);
|
|
119
131
|
|
|
120
132
|
if (removed) {
|
|
133
|
+
const entity = this.#entities.get(light);
|
|
134
|
+
|
|
121
135
|
this.#entities.delete(light);
|
|
122
136
|
|
|
123
137
|
this.#version++;
|
|
138
|
+
|
|
139
|
+
this.onRemoved.send2(light, entity);
|
|
124
140
|
}
|
|
125
141
|
|
|
126
142
|
return removed;
|
|
@@ -13,7 +13,7 @@ export class TinyGltf {
|
|
|
13
13
|
* @readonly
|
|
14
14
|
* @type {TextureFormat}
|
|
15
15
|
*/
|
|
16
|
-
static readonly "__#
|
|
16
|
+
static readonly "__#306@#UNCOMPRESSED_TARGET": TextureFormat;
|
|
17
17
|
/**
|
|
18
18
|
* @param {AssetManager} assetManager
|
|
19
19
|
* @param {AssetRequestScope} [scope]
|
|
@@ -118,6 +118,27 @@ export class GPUMaterialManager {
|
|
|
118
118
|
* @returns {ShadeMaterial[]}
|
|
119
119
|
*/
|
|
120
120
|
forward_drawable(drawn: ShadeMaterial[]): ShadeMaterial[];
|
|
121
|
+
/**
|
|
122
|
+
* The contexts the G-buffer pass draws for a scene's drawn materials: every one that is not
|
|
123
|
+
* transparent and has a context, grouped by template, in the order {@link graph_viz_render} draws
|
|
124
|
+
* them. The array is kept and rebuilt in place — {@link gbuffer_contexts_version} says when.
|
|
125
|
+
*
|
|
126
|
+
* @param {ShadeMaterial[]} drawn a scene's {@link GPUSceneContext#drawn_materials}
|
|
127
|
+
* @returns {GPUMaterialContext[]}
|
|
128
|
+
*/
|
|
129
|
+
gbuffer_contexts(drawn: ShadeMaterial[]): GPUMaterialContext[];
|
|
130
|
+
/**
|
|
131
|
+
* Moves whenever {@link gbuffer_contexts} may answer differently for the same drawn set.
|
|
132
|
+
*
|
|
133
|
+
* @returns {number}
|
|
134
|
+
*/
|
|
135
|
+
get gbuffer_contexts_version(): number;
|
|
136
|
+
/**
|
|
137
|
+
* What every template's hooks are handed, for a pass that calls them itself.
|
|
138
|
+
*
|
|
139
|
+
* @returns {GPUMaterialServices}
|
|
140
|
+
*/
|
|
141
|
+
get services(): GPUMaterialServices;
|
|
121
142
|
/**
|
|
122
143
|
*
|
|
123
144
|
* @param {ShadeGPUCommandContext} ctx
|
|
@@ -138,4 +159,5 @@ export type ShadeMaterial = import("./ShadeMaterial.js").ShadeMaterial;
|
|
|
138
159
|
export type ShadeMaterialTemplate = import("./template/ShadeMaterialTemplate.js").ShadeMaterialTemplate;
|
|
139
160
|
import { GPUMaterialContext } from "./GPUMaterialContext.js";
|
|
140
161
|
import { GPUSingleTypeTable } from "../buffer/table/single/GPUSingleTypeTable.js";
|
|
162
|
+
import { GPUMaterialServices } from "./template/GPUMaterialServices.js";
|
|
141
163
|
//# sourceMappingURL=GPUMaterialManager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GPUMaterialManager.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/material/GPUMaterialManager.js"],"names":[],"mappings":"AA4NA;IA4FI;;;;;;;;OAQG;IACH,yCANW,cAAc,oBACd,qBAAqB,YACrB,gBAAgB,qBAChB,qBAAqB,aACrB,iBAAiB,EAiD3B;IAlJD;;;;;OAKG;IACH,wBAAkC;IAOlC;;;OAGG;IACH,UAFU,IAAI,aAAa,EAAE,kBAAkB,CAAC,CAE3B;IAyBrB;;;OAGG;IACH,yCAEC;IAID;;;OAGG;IACH,sBAEC;IAsLD;;;;;;;;;;OAUG;IACH;QAR+B,KAAK,EAAzB,UAAU;QACc,IAAI,EAA5B,cAAc;QACE,gBAAgB,EAAhC,MAAM;QACU,oBAAoB,EAApC,MAAM;QACU,cAAc,EAA9B,MAAM;QAEJ;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAC,CA4LnF;IAED;;;;OAIG;IACH,iBAHW,aAAa,GACX,kBAAkB,CAqB9B;IAED;;;;;;;;;;;;OAYG;IACH,kBAHW,aAAa,GACX,OAAO,CAyBnB;IAED;;;;OAIG;IACH,gBAaC;IAED;;;;;;;OAOG;IACH,0BAFW,eAAe,QAazB;IAED;;;;;;;;;;;OAWG;IACH,kBAHW,qBAAqB,GACnB,QAAQ,IAAI,CAAC,CAMzB;IAsBD;;;;;;OAMG;IACH,0BAHW,aAAa,EAAE,GACb,aAAa,EAAE,CAI3B;IAED;;;;;;OAMG;IACH,wBAHW,aAAa,EAAE,GACb,aAAa,EAAE,CAI3B;IAuED;;;OAGG;IACH,YAFW,sBAAsB,QAmChC;;CAEJ;
|
|
1
|
+
{"version":3,"file":"GPUMaterialManager.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/material/GPUMaterialManager.js"],"names":[],"mappings":"AA4NA;IA4FI;;;;;;;;OAQG;IACH,yCANW,cAAc,oBACd,qBAAqB,YACrB,gBAAgB,qBAChB,qBAAqB,aACrB,iBAAiB,EAiD3B;IAlJD;;;;;OAKG;IACH,wBAAkC;IAOlC;;;OAGG;IACH,UAFU,IAAI,aAAa,EAAE,kBAAkB,CAAC,CAE3B;IAyBrB;;;OAGG;IACH,yCAEC;IAID;;;OAGG;IACH,sBAEC;IAsLD;;;;;;;;;;OAUG;IACH;QAR+B,KAAK,EAAzB,UAAU;QACc,IAAI,EAA5B,cAAc;QACE,gBAAgB,EAAhC,MAAM;QACU,oBAAoB,EAApC,MAAM;QACU,cAAc,EAA9B,MAAM;QAEJ;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAC,CA4LnF;IAED;;;;OAIG;IACH,iBAHW,aAAa,GACX,kBAAkB,CAqB9B;IAED;;;;;;;;;;;;OAYG;IACH,kBAHW,aAAa,GACX,OAAO,CAyBnB;IAED;;;;OAIG;IACH,gBAaC;IAED;;;;;;;OAOG;IACH,0BAFW,eAAe,QAazB;IAED;;;;;;;;;;;OAWG;IACH,kBAHW,qBAAqB,GACnB,QAAQ,IAAI,CAAC,CAMzB;IAsBD;;;;;;OAMG;IACH,0BAHW,aAAa,EAAE,GACb,aAAa,EAAE,CAI3B;IAED;;;;;;OAMG;IACH,wBAHW,aAAa,EAAE,GACb,aAAa,EAAE,CAI3B;IAED;;;;;;;OAOG;IACH,wBAHW,aAAa,EAAE,GACb,kBAAkB,EAAE,CAIhC;IAED;;;;OAIG;IACH,uCAEC;IAED;;;;OAIG;IACH,oCAEC;IAuED;;;OAGG;IACH,YAFW,sBAAsB,QAmChC;;CAEJ;8BAh6BY,OAAO,0CAA0C,EAAE,eAAe;6BAClE,OAAO,2BAA2B,EAAE,cAAc;yBAIlD,OAAO,2DAA2D,EAAE,UAAU;qCAC9E,OAAO,wCAAwC,EAAE,sBAAsB;oCACvE,OAAO,gDAAgD,EAAE,qBAAqB;+BAC9E,OAAO,gCAAgC,EAAE,gBAAgB;gCACzD,OAAO,yBAAyB,EAAE,iBAAiB;6BACnD,OAAO,8BAA8B,EAAE,cAAc;oCACrD,OAAO,6CAA6C,EAAE,qBAAqB;4BAC3E,OAAO,oBAAoB,EAAE,aAAa;oCAC1C,OAAO,qCAAqC,EAAE,qBAAqB;mCAtBzE,yBAAyB;mCAjBG,8CAA8C;oCAoBxB,mCAAmC"}
|
|
@@ -824,6 +824,36 @@ export class GPUMaterialManager {
|
|
|
824
824
|
return this.#lists_of(drawn).forward;
|
|
825
825
|
}
|
|
826
826
|
|
|
827
|
+
/**
|
|
828
|
+
* The contexts the G-buffer pass draws for a scene's drawn materials: every one that is not
|
|
829
|
+
* transparent and has a context, grouped by template, in the order {@link graph_viz_render} draws
|
|
830
|
+
* them. The array is kept and rebuilt in place — {@link gbuffer_contexts_version} says when.
|
|
831
|
+
*
|
|
832
|
+
* @param {ShadeMaterial[]} drawn a scene's {@link GPUSceneContext#drawn_materials}
|
|
833
|
+
* @returns {GPUMaterialContext[]}
|
|
834
|
+
*/
|
|
835
|
+
gbuffer_contexts(drawn) {
|
|
836
|
+
return this.#gbuffer_contexts(drawn);
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
/**
|
|
840
|
+
* Moves whenever {@link gbuffer_contexts} may answer differently for the same drawn set.
|
|
841
|
+
*
|
|
842
|
+
* @returns {number}
|
|
843
|
+
*/
|
|
844
|
+
get gbuffer_contexts_version() {
|
|
845
|
+
return this.#list_version;
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
/**
|
|
849
|
+
* What every template's hooks are handed, for a pass that calls them itself.
|
|
850
|
+
*
|
|
851
|
+
* @returns {GPUMaterialServices}
|
|
852
|
+
*/
|
|
853
|
+
get services() {
|
|
854
|
+
return this.#services;
|
|
855
|
+
}
|
|
856
|
+
|
|
827
857
|
/**
|
|
828
858
|
* @param {ShadeMaterial[]} drawn
|
|
829
859
|
* @returns {GPUMaterialContext[]}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The G-buffer pass as {@link MaterialDispatch.Compute} runs it — **experimental, off by default, not
|
|
3
|
+
* the main path**; why, with the measurements, is in `COMPUTE_MATERIAL_DISPATCH.md` beside this file.
|
|
4
|
+
* Everything that path holds is here, kept apart from {@link GPUMaterialManager}, whose fragment
|
|
5
|
+
* dispatch is the default and knows nothing of this one.
|
|
6
|
+
*
|
|
7
|
+
* What it reads of the manager is public and read-only: the contexts the G-buffer pass draws, the
|
|
8
|
+
* version that says when those change, the services templates are handed, and every context there
|
|
9
|
+
* is, to offer their templates' pipelines. A context's fragment bind group is read only as a token
|
|
10
|
+
* that says when the template rebuilt it. What it makes is its
|
|
11
|
+
* own: each template's compute pipeline, each material's group 0 for it (by the template's own
|
|
12
|
+
* {@link ShadeMaterialTemplate#create_bind_group}, over the compute layout), the material id → slot
|
|
13
|
+
* tables, and the per-material dispatch records.
|
|
14
|
+
*/
|
|
15
|
+
export class GPUMaterialComputeDispatch {
|
|
16
|
+
/**
|
|
17
|
+
* @param {Object} options
|
|
18
|
+
* @param {GPUDevice} options.device
|
|
19
|
+
* @param {GPUMaterialManager} options.materials whose materials it shades
|
|
20
|
+
* @param {ComputePipelineManager} options.compute_pipelines
|
|
21
|
+
* @param {BindGroupManager} options.bindings
|
|
22
|
+
*/
|
|
23
|
+
constructor({ device, materials, compute_pipelines, bindings }: {
|
|
24
|
+
device: GPUDevice;
|
|
25
|
+
materials: GPUMaterialManager;
|
|
26
|
+
compute_pipelines: ComputePipelineManager;
|
|
27
|
+
bindings: BindGroupManager;
|
|
28
|
+
});
|
|
29
|
+
/**
|
|
30
|
+
* Lay the G-buffer of `view` down — what {@link GPUMaterialManager#graph_viz_render} does, by
|
|
31
|
+
* {@link graph_material_dispatch_compute}, and with the same arguments and result.
|
|
32
|
+
*
|
|
33
|
+
* @param {Object} options
|
|
34
|
+
* @param {FrameGraph} options.graph
|
|
35
|
+
* @param {GPUViewContext} options.view
|
|
36
|
+
* @param {number} options.texture_viz_mesh
|
|
37
|
+
* @param {number} options.texture_viz_triangle
|
|
38
|
+
* @param {number} options.texture_normal the normal target to write, `rgba16uint` at the view's
|
|
39
|
+
* resolution, with `STORAGE_BINDING`
|
|
40
|
+
* @returns {{g_pbr: number, g_normal: number, g_albedo: number, g_emissive: number}}
|
|
41
|
+
*/
|
|
42
|
+
graph_viz_render({ graph, view, texture_viz_mesh, texture_viz_triangle, texture_normal, }: {
|
|
43
|
+
graph: FrameGraph;
|
|
44
|
+
view: GPUViewContext;
|
|
45
|
+
texture_viz_mesh: number;
|
|
46
|
+
texture_viz_triangle: number;
|
|
47
|
+
texture_normal: number;
|
|
48
|
+
}): {
|
|
49
|
+
g_pbr: number;
|
|
50
|
+
g_normal: number;
|
|
51
|
+
g_albedo: number;
|
|
52
|
+
g_emissive: number;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Offer the pipelines this path dispatches — see {@link PipelineEnquiry}: the classification's,
|
|
56
|
+
* and the compute G-buffer pipeline of the standard template and of every template a material
|
|
57
|
+
* has brought.
|
|
58
|
+
*
|
|
59
|
+
* @param {PipelineEnquiry} enquiry
|
|
60
|
+
*/
|
|
61
|
+
enquirePipelines(enquiry: PipelineEnquiry): void;
|
|
62
|
+
destroy(): void;
|
|
63
|
+
#private;
|
|
64
|
+
}
|
|
65
|
+
export type FrameGraph = import("../../../../engine/graphics/render/frame_graph/FrameGraph.js").FrameGraph;
|
|
66
|
+
export type ComputePipelineDescriptor = import("../../../descriptor/pipeline/compute/ComputePipelineDescriptor.js").ComputePipelineDescriptor;
|
|
67
|
+
export type ComputePipelineManager = import("../../../device/pipeline/ComputePipelineManager.js").ComputePipelineManager;
|
|
68
|
+
export type PipelineEnquiry = import("../../../device/pipeline/PipelineEnquiry.js").PipelineEnquiry;
|
|
69
|
+
export type BindGroupManager = import("../../binding/BindGroupManager.js").BindGroupManager;
|
|
70
|
+
export type GPUViewContext = import("../../view/GPUViewContext.js").GPUViewContext;
|
|
71
|
+
export type GPUMaterialContext = import("../GPUMaterialContext.js").GPUMaterialContext;
|
|
72
|
+
export type GPUMaterialManager = import("../GPUMaterialManager.js").GPUMaterialManager;
|
|
73
|
+
export type ShadeMaterial = import("../ShadeMaterial.js").ShadeMaterial;
|
|
74
|
+
export type ShadeMaterialTemplate = import("../template/ShadeMaterialTemplate.js").ShadeMaterialTemplate;
|
|
75
|
+
//# sourceMappingURL=GPUMaterialComputeDispatch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GPUMaterialComputeDispatch.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/material/dispatch/GPUMaterialComputeDispatch.js"],"names":[],"mappings":"AA0DA;;;;;;;;;;;;;GAaG;AACH;IA8DI;;;;;;OAMG;IACH;QAL8B,MAAM;QACG,SAAS,EAArC,kBAAkB;QACc,iBAAiB,EAAjD,sBAAsB;QACI,QAAQ,EAAlC,gBAAgB;OAa1B;IAED;;;;;;;;;;;;OAYG;IACH;QAR+B,KAAK,EAAzB,UAAU;QACc,IAAI,EAA5B,cAAc;QACE,gBAAgB,EAAhC,MAAM;QACU,oBAAoB,EAApC,MAAM;QACU,cAAc,EAA9B,MAAM;QAEJ;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAC,CA0BnF;IAED;;;;;;OAMG;IACH,0BAFW,eAAe,QAazB;IAED,gBAOC;;CAqHJ;yBAlUY,OAAO,8DAA8D,EAAE,UAAU;wCACjF,OAAO,mEAAmE,EAAE,yBAAyB;qCACrG,OAAO,oDAAoD,EAAE,sBAAsB;8BACnF,OAAO,6CAA6C,EAAE,eAAe;+BACrE,OAAO,mCAAmC,EAAE,gBAAgB;6BAC5D,OAAO,8BAA8B,EAAE,cAAc;iCACrD,OAAO,0BAA0B,EAAE,kBAAkB;iCACrD,OAAO,0BAA0B,EAAE,kBAAkB;4BACrD,OAAO,qBAAqB,EAAE,aAAa;oCAC3C,OAAO,sCAAsC,EAAE,qBAAqB"}
|
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
import { assert } from "../../../../core/assert.js";
|
|
2
|
+
import {
|
|
3
|
+
cpu_hash_table_create,
|
|
4
|
+
cpu_hash_table_word_count
|
|
5
|
+
} from "../../gpu_primitive/hash_table/cpu_build_hash_table.js";
|
|
6
|
+
import { enquire_prefix_scan_csdldf_pipelines } from "../../gpu_primitive/prefix_sum/v1/graph_prefix_scan_csdldf.js";
|
|
7
|
+
import { STANDARD_MATERIAL_TEMPLATE } from "../standard/STANDARD_MATERIAL_TEMPLATE.js";
|
|
8
|
+
import { build_gbuffer_compute_pipeline_descriptor } from "./gbuffer_compute.js";
|
|
9
|
+
import { graph_material_dispatch_compute } from "./graph_material_dispatch_compute.js";
|
|
10
|
+
import { MaterialDispatchRecords } from "./MaterialDispatchRecords.js";
|
|
11
|
+
import { shader_material_dispatch_commands } from "./shader_material_dispatch_commands.js";
|
|
12
|
+
import { shader_material_pixel_count } from "./shader_material_pixel_count.js";
|
|
13
|
+
import { shader_material_pixel_scatter } from "./shader_material_pixel_scatter.js";
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @typedef {import("../../../../engine/graphics/render/frame_graph/FrameGraph.js").FrameGraph} FrameGraph
|
|
17
|
+
* @typedef {import("../../../descriptor/pipeline/compute/ComputePipelineDescriptor.js").ComputePipelineDescriptor} ComputePipelineDescriptor
|
|
18
|
+
* @typedef {import("../../../device/pipeline/ComputePipelineManager.js").ComputePipelineManager} ComputePipelineManager
|
|
19
|
+
* @typedef {import("../../../device/pipeline/PipelineEnquiry.js").PipelineEnquiry} PipelineEnquiry
|
|
20
|
+
* @typedef {import("../../binding/BindGroupManager.js").BindGroupManager} BindGroupManager
|
|
21
|
+
* @typedef {import("../../view/GPUViewContext.js").GPUViewContext} GPUViewContext
|
|
22
|
+
* @typedef {import("../GPUMaterialContext.js").GPUMaterialContext} GPUMaterialContext
|
|
23
|
+
* @typedef {import("../GPUMaterialManager.js").GPUMaterialManager} GPUMaterialManager
|
|
24
|
+
* @typedef {import("../ShadeMaterial.js").ShadeMaterial} ShadeMaterial
|
|
25
|
+
* @typedef {import("../template/ShadeMaterialTemplate.js").ShadeMaterialTemplate} ShadeMaterialTemplate
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* A material's group 0 for its template's compute pipeline, and the fragment bind group it was made
|
|
30
|
+
* beside — when the template rebuilds that one, this one is made again.
|
|
31
|
+
*/
|
|
32
|
+
class ComputeMaterialGroup {
|
|
33
|
+
/**
|
|
34
|
+
* @type {GPUBindGroup}
|
|
35
|
+
*/
|
|
36
|
+
source;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @type {GPUBindGroup}
|
|
40
|
+
*/
|
|
41
|
+
group;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* The material id → slot table of one drawn set, and the list version it was built at.
|
|
46
|
+
*/
|
|
47
|
+
class MaterialSlotTable {
|
|
48
|
+
/**
|
|
49
|
+
* @type {Uint32Array}
|
|
50
|
+
*/
|
|
51
|
+
table = new Uint32Array(0);
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* @type {number}
|
|
55
|
+
*/
|
|
56
|
+
version = -1;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* The G-buffer pass as {@link MaterialDispatch.Compute} runs it — **experimental, off by default, not
|
|
61
|
+
* the main path**; why, with the measurements, is in `COMPUTE_MATERIAL_DISPATCH.md` beside this file.
|
|
62
|
+
* Everything that path holds is here, kept apart from {@link GPUMaterialManager}, whose fragment
|
|
63
|
+
* dispatch is the default and knows nothing of this one.
|
|
64
|
+
*
|
|
65
|
+
* What it reads of the manager is public and read-only: the contexts the G-buffer pass draws, the
|
|
66
|
+
* version that says when those change, the services templates are handed, and every context there
|
|
67
|
+
* is, to offer their templates' pipelines. A context's fragment bind group is read only as a token
|
|
68
|
+
* that says when the template rebuilt it. What it makes is its
|
|
69
|
+
* own: each template's compute pipeline, each material's group 0 for it (by the template's own
|
|
70
|
+
* {@link ShadeMaterialTemplate#create_bind_group}, over the compute layout), the material id → slot
|
|
71
|
+
* tables, and the per-material dispatch records.
|
|
72
|
+
*/
|
|
73
|
+
export class GPUMaterialComputeDispatch {
|
|
74
|
+
/**
|
|
75
|
+
* @type {GPUMaterialManager}
|
|
76
|
+
*/
|
|
77
|
+
#materials;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* @type {ComputePipelineManager}
|
|
81
|
+
*/
|
|
82
|
+
#compute_pipelines;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* @type {BindGroupManager}
|
|
86
|
+
*/
|
|
87
|
+
#bindings;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* @type {MaterialDispatchRecords}
|
|
91
|
+
*/
|
|
92
|
+
#records;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* @type {Map<ShadeMaterialTemplate, ComputePipelineDescriptor>}
|
|
96
|
+
*/
|
|
97
|
+
#pipeline_descriptors = new Map();
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* @type {Map<ShadeMaterialTemplate, GPUComputePipeline>}
|
|
101
|
+
*/
|
|
102
|
+
#pipelines = new Map();
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Weak, so a released context takes its group with it.
|
|
106
|
+
*
|
|
107
|
+
* @type {WeakMap<GPUMaterialContext, ComputeMaterialGroup>}
|
|
108
|
+
*/
|
|
109
|
+
#groups = new WeakMap();
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Per drawn set, which the scene replaces when it changes. Weak, as the manager's lists are.
|
|
113
|
+
*
|
|
114
|
+
* @type {WeakMap<ShadeMaterial[], MaterialSlotTable>}
|
|
115
|
+
*/
|
|
116
|
+
#slot_tables = new WeakMap();
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* The table being built, kept to build the next one in.
|
|
120
|
+
*
|
|
121
|
+
* @type {number[]}
|
|
122
|
+
*/
|
|
123
|
+
#slot_ids = [];
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* @type {function(GPUMaterialContext):GPUComputePipeline}
|
|
127
|
+
*/
|
|
128
|
+
#pipeline_of = material_ctx => this.#pipeline(material_ctx.template);
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* @type {function(GPUMaterialContext):GPUBindGroup}
|
|
132
|
+
*/
|
|
133
|
+
#group_of = material_ctx => this.#group(material_ctx);
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* @param {Object} options
|
|
137
|
+
* @param {GPUDevice} options.device
|
|
138
|
+
* @param {GPUMaterialManager} options.materials whose materials it shades
|
|
139
|
+
* @param {ComputePipelineManager} options.compute_pipelines
|
|
140
|
+
* @param {BindGroupManager} options.bindings
|
|
141
|
+
*/
|
|
142
|
+
constructor({ device, materials, compute_pipelines, bindings }) {
|
|
143
|
+
assert.defined(device, 'device');
|
|
144
|
+
assert.defined(materials, 'materials');
|
|
145
|
+
assert.defined(compute_pipelines, 'compute_pipelines');
|
|
146
|
+
assert.defined(bindings, 'bindings');
|
|
147
|
+
|
|
148
|
+
this.#materials = materials;
|
|
149
|
+
this.#compute_pipelines = compute_pipelines;
|
|
150
|
+
this.#bindings = bindings;
|
|
151
|
+
|
|
152
|
+
this.#records = new MaterialDispatchRecords(device, bindings);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Lay the G-buffer of `view` down — what {@link GPUMaterialManager#graph_viz_render} does, by
|
|
157
|
+
* {@link graph_material_dispatch_compute}, and with the same arguments and result.
|
|
158
|
+
*
|
|
159
|
+
* @param {Object} options
|
|
160
|
+
* @param {FrameGraph} options.graph
|
|
161
|
+
* @param {GPUViewContext} options.view
|
|
162
|
+
* @param {number} options.texture_viz_mesh
|
|
163
|
+
* @param {number} options.texture_viz_triangle
|
|
164
|
+
* @param {number} options.texture_normal the normal target to write, `rgba16uint` at the view's
|
|
165
|
+
* resolution, with `STORAGE_BINDING`
|
|
166
|
+
* @returns {{g_pbr: number, g_normal: number, g_albedo: number, g_emissive: number}}
|
|
167
|
+
*/
|
|
168
|
+
graph_viz_render({
|
|
169
|
+
graph,
|
|
170
|
+
view,
|
|
171
|
+
texture_viz_mesh,
|
|
172
|
+
texture_viz_triangle,
|
|
173
|
+
texture_normal,
|
|
174
|
+
}) {
|
|
175
|
+
const drawn = view.scene.drawn_materials;
|
|
176
|
+
|
|
177
|
+
const contexts = this.#materials.gbuffer_contexts(drawn);
|
|
178
|
+
|
|
179
|
+
return graph_material_dispatch_compute({
|
|
180
|
+
graph,
|
|
181
|
+
view,
|
|
182
|
+
contexts,
|
|
183
|
+
material_slots: this.#slot_table(drawn, contexts),
|
|
184
|
+
records: this.#records,
|
|
185
|
+
bindings: this.#bindings,
|
|
186
|
+
pipeline_of: this.#pipeline_of,
|
|
187
|
+
group_of: this.#group_of,
|
|
188
|
+
texture_viz_mesh,
|
|
189
|
+
texture_viz_triangle,
|
|
190
|
+
texture_normal,
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Offer the pipelines this path dispatches — see {@link PipelineEnquiry}: the classification's,
|
|
196
|
+
* and the compute G-buffer pipeline of the standard template and of every template a material
|
|
197
|
+
* has brought.
|
|
198
|
+
*
|
|
199
|
+
* @param {PipelineEnquiry} enquiry
|
|
200
|
+
*/
|
|
201
|
+
enquirePipelines(enquiry) {
|
|
202
|
+
enquiry.compute.push(shader_material_pixel_count.pipeline);
|
|
203
|
+
enquiry.compute.push(shader_material_pixel_scatter.pipeline);
|
|
204
|
+
enquiry.compute.push(shader_material_dispatch_commands.pipeline);
|
|
205
|
+
enquire_prefix_scan_csdldf_pipelines(enquiry);
|
|
206
|
+
|
|
207
|
+
enquiry.compute.push(this.#pipeline_descriptor(STANDARD_MATERIAL_TEMPLATE));
|
|
208
|
+
|
|
209
|
+
for (const material_ctx of this.#materials.contexts.values()) {
|
|
210
|
+
enquiry.compute.push(this.#pipeline_descriptor(material_ctx.template));
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
destroy() {
|
|
215
|
+
this.#records.destroy();
|
|
216
|
+
|
|
217
|
+
this.#pipelines.clear();
|
|
218
|
+
this.#pipeline_descriptors.clear();
|
|
219
|
+
this.#groups = new WeakMap();
|
|
220
|
+
this.#slot_tables = new WeakMap();
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* @param {ShadeMaterialTemplate} template
|
|
225
|
+
* @returns {ComputePipelineDescriptor}
|
|
226
|
+
*/
|
|
227
|
+
#pipeline_descriptor(template) {
|
|
228
|
+
let descriptor = this.#pipeline_descriptors.get(template);
|
|
229
|
+
|
|
230
|
+
if (descriptor === undefined) {
|
|
231
|
+
descriptor = build_gbuffer_compute_pipeline_descriptor({
|
|
232
|
+
label: `${template.name} material / Viz-Buffer to G-Buffer compute laydown`,
|
|
233
|
+
material_group: template.resources,
|
|
234
|
+
surface: template.gbuffer_surface(this.#materials.services),
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
this.#pipeline_descriptors.set(template, descriptor);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
return descriptor;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* @param {ShadeMaterialTemplate} template
|
|
245
|
+
* @returns {GPUComputePipeline}
|
|
246
|
+
*/
|
|
247
|
+
#pipeline(template) {
|
|
248
|
+
let pipeline = this.#pipelines.get(template);
|
|
249
|
+
|
|
250
|
+
if (pipeline === undefined) {
|
|
251
|
+
pipeline = this.#compute_pipelines.obtain(this.#pipeline_descriptor(template));
|
|
252
|
+
|
|
253
|
+
this.#pipelines.set(template, pipeline);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
return pipeline;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* The material's group 0 for its template's compute pipeline, made by the template from the same
|
|
261
|
+
* resources as its fragment bind group, and made again whenever the template has rebuilt that one.
|
|
262
|
+
*
|
|
263
|
+
* @param {GPUMaterialContext} material_ctx
|
|
264
|
+
* @returns {GPUBindGroup}
|
|
265
|
+
*/
|
|
266
|
+
#group(material_ctx) {
|
|
267
|
+
const source = material_ctx.material_binding;
|
|
268
|
+
|
|
269
|
+
let entry = this.#groups.get(material_ctx);
|
|
270
|
+
|
|
271
|
+
if (entry === undefined) {
|
|
272
|
+
entry = new ComputeMaterialGroup();
|
|
273
|
+
|
|
274
|
+
this.#groups.set(material_ctx, entry);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
if (entry.source !== source) {
|
|
278
|
+
const template = material_ctx.template;
|
|
279
|
+
|
|
280
|
+
entry.group = template.create_bind_group(
|
|
281
|
+
material_ctx,
|
|
282
|
+
this.#pipeline(template).getBindGroupLayout(0),
|
|
283
|
+
this.#materials.services
|
|
284
|
+
);
|
|
285
|
+
|
|
286
|
+
entry.source = source;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
return entry.group;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Each context's place among `contexts`, by material id, rebuilt when the manager's list moves.
|
|
294
|
+
*
|
|
295
|
+
* @param {ShadeMaterial[]} drawn
|
|
296
|
+
* @param {GPUMaterialContext[]} contexts what the manager answers for `drawn`
|
|
297
|
+
* @returns {Uint32Array}
|
|
298
|
+
*/
|
|
299
|
+
#slot_table(drawn, contexts) {
|
|
300
|
+
let slots = this.#slot_tables.get(drawn);
|
|
301
|
+
|
|
302
|
+
if (slots === undefined) {
|
|
303
|
+
slots = new MaterialSlotTable();
|
|
304
|
+
|
|
305
|
+
this.#slot_tables.set(drawn, slots);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
const version = this.#materials.gbuffer_contexts_version;
|
|
309
|
+
|
|
310
|
+
if (slots.version !== version) {
|
|
311
|
+
const count = contexts.length;
|
|
312
|
+
const ids = this.#slot_ids;
|
|
313
|
+
|
|
314
|
+
ids.length = count;
|
|
315
|
+
|
|
316
|
+
for (let i = 0; i < count; i++) {
|
|
317
|
+
ids[i] = contexts[i].material_id;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
let table = slots.table;
|
|
321
|
+
|
|
322
|
+
const word_count = cpu_hash_table_word_count(count);
|
|
323
|
+
|
|
324
|
+
if (table.length < word_count) {
|
|
325
|
+
table = new Uint32Array(word_count);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
while (!cpu_hash_table_create(table, ids, count)) {
|
|
329
|
+
table = new Uint32Array(table.length * 2);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
slots.table = table;
|
|
333
|
+
slots.version = version;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
return slots.table;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Side of the square screen tiles a material's pixel list is ordered by, in pixels. Each
|
|
3
|
+
* (material, tile) pair has its own counter, so the classification's atomics spread over
|
|
4
|
+
* `materials × tiles` addresses rather than piling onto one per material, and a material's list
|
|
5
|
+
* comes out tile by tile, so consecutive workgroups shade neighbouring pixels.
|
|
6
|
+
*
|
|
7
|
+
* 256 is the tile size id Software classify DOOM: The Dark Ages' visibility buffer by.
|
|
8
|
+
*
|
|
9
|
+
* @type {number}
|
|
10
|
+
*/
|
|
11
|
+
export const MATERIAL_DISPATCH_TILE_SIZE: number;
|
|
12
|
+
/**
|
|
13
|
+
* Lanes in one workgroup of the compute material dispatch, a lane per pixel. A workgroup only ever
|
|
14
|
+
* holds quads of the one material its dispatch is for, so every resource the material binds is
|
|
15
|
+
* uniform across it; the last workgroup of each material is the only partial one, and the workgroups
|
|
16
|
+
* a folded grid launches past it leave at once.
|
|
17
|
+
*
|
|
18
|
+
* @type {number}
|
|
19
|
+
*/
|
|
20
|
+
export const MATERIAL_DISPATCH_GROUP_SIZE: number;
|
|
21
|
+
/**
|
|
22
|
+
* 2×2 quads of pixels one workgroup of the compute material dispatch shades: the lists hold quads,
|
|
23
|
+
* because the laydown takes a screen-space derivative across one, as a fragment does.
|
|
24
|
+
*
|
|
25
|
+
* @type {number}
|
|
26
|
+
*/
|
|
27
|
+
export const MATERIAL_DISPATCH_QUADS_PER_GROUP: number;
|
|
28
|
+
/**
|
|
29
|
+
* Side, in 2×2 quads, of the square block one classification workgroup reads, a lane per quad. A
|
|
30
|
+
* subgroup covers a few rows of neighbouring quads, so most hold one or two materials and aggregate
|
|
31
|
+
* their atomics to as many.
|
|
32
|
+
*
|
|
33
|
+
* @type {number}
|
|
34
|
+
*/
|
|
35
|
+
export const MATERIAL_CLASSIFY_GROUP_SIDE: number;
|
|
36
|
+
/**
|
|
37
|
+
* Side, in pixels, of the block one classification workgroup reads.
|
|
38
|
+
*
|
|
39
|
+
* @type {number}
|
|
40
|
+
*/
|
|
41
|
+
export const MATERIAL_CLASSIFY_BLOCK_SIZE: number;
|
|
42
|
+
/**
|
|
43
|
+
* Bytes between consecutive materials' records in the dispatch record buffer: each record is bound
|
|
44
|
+
* as its own uniform, and a uniform binding's offset must be a multiple of
|
|
45
|
+
* `minUniformBufferOffsetAlignment`, which WebGPU guarantees to be at most 256.
|
|
46
|
+
*
|
|
47
|
+
* @type {number}
|
|
48
|
+
*/
|
|
49
|
+
export const MATERIAL_DISPATCH_RECORD_STRIDE: number;
|
|
50
|
+
//# sourceMappingURL=MATERIAL_DISPATCH_CONSTANTS.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MATERIAL_DISPATCH_CONSTANTS.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/material/dispatch/MATERIAL_DISPATCH_CONSTANTS.js"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,0CAFU,MAAM,CAE+B;AAE/C;;;;;;;GAOG;AACH,2CAFU,MAAM,CAE+B;AAE/C;;;;;GAKG;AACH,gDAFU,MAAM,CAEkE;AAElF;;;;;;GAMG;AACH,2CAFU,MAAM,CAE8B;AAE9C;;;;GAIG;AACH,2CAFU,MAAM,CAE6D;AAE7E;;;;;;GAMG;AACH,8CAFU,MAAM,CAEmC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Side of the square screen tiles a material's pixel list is ordered by, in pixels. Each
|
|
3
|
+
* (material, tile) pair has its own counter, so the classification's atomics spread over
|
|
4
|
+
* `materials × tiles` addresses rather than piling onto one per material, and a material's list
|
|
5
|
+
* comes out tile by tile, so consecutive workgroups shade neighbouring pixels.
|
|
6
|
+
*
|
|
7
|
+
* 256 is the tile size id Software classify DOOM: The Dark Ages' visibility buffer by.
|
|
8
|
+
*
|
|
9
|
+
* @type {number}
|
|
10
|
+
*/
|
|
11
|
+
export const MATERIAL_DISPATCH_TILE_SIZE = 256;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Lanes in one workgroup of the compute material dispatch, a lane per pixel. A workgroup only ever
|
|
15
|
+
* holds quads of the one material its dispatch is for, so every resource the material binds is
|
|
16
|
+
* uniform across it; the last workgroup of each material is the only partial one, and the workgroups
|
|
17
|
+
* a folded grid launches past it leave at once.
|
|
18
|
+
*
|
|
19
|
+
* @type {number}
|
|
20
|
+
*/
|
|
21
|
+
export const MATERIAL_DISPATCH_GROUP_SIZE = 64;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* 2×2 quads of pixels one workgroup of the compute material dispatch shades: the lists hold quads,
|
|
25
|
+
* because the laydown takes a screen-space derivative across one, as a fragment does.
|
|
26
|
+
*
|
|
27
|
+
* @type {number}
|
|
28
|
+
*/
|
|
29
|
+
export const MATERIAL_DISPATCH_QUADS_PER_GROUP = MATERIAL_DISPATCH_GROUP_SIZE / 4;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Side, in 2×2 quads, of the square block one classification workgroup reads, a lane per quad. A
|
|
33
|
+
* subgroup covers a few rows of neighbouring quads, so most hold one or two materials and aggregate
|
|
34
|
+
* their atomics to as many.
|
|
35
|
+
*
|
|
36
|
+
* @type {number}
|
|
37
|
+
*/
|
|
38
|
+
export const MATERIAL_CLASSIFY_GROUP_SIDE = 8;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Side, in pixels, of the block one classification workgroup reads.
|
|
42
|
+
*
|
|
43
|
+
* @type {number}
|
|
44
|
+
*/
|
|
45
|
+
export const MATERIAL_CLASSIFY_BLOCK_SIZE = MATERIAL_CLASSIFY_GROUP_SIDE * 2;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Bytes between consecutive materials' records in the dispatch record buffer: each record is bound
|
|
49
|
+
* as its own uniform, and a uniform binding's offset must be a multiple of
|
|
50
|
+
* `minUniformBufferOffsetAlignment`, which WebGPU guarantees to be at most 256.
|
|
51
|
+
*
|
|
52
|
+
* @type {number}
|
|
53
|
+
*/
|
|
54
|
+
export const MATERIAL_DISPATCH_RECORD_STRIDE = 256;
|