@woosh/meep-engine 2.127.0 → 2.127.1

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 CHANGED
@@ -5,7 +5,7 @@
5
5
  "description": "Pure JavaScript game engine. Fully featured and production ready.",
6
6
  "type": "module",
7
7
  "author": "Alexander Goldring",
8
- "version": "2.127.0",
8
+ "version": "2.127.1",
9
9
  "main": "build/meep.module.js",
10
10
  "module": "build/meep.module.js",
11
11
  "exports": {
@@ -1 +1 @@
1
- {"version":3,"file":"EntityComponentDataset.d.ts","sourceRoot":"","sources":["../../../../src/engine/ecs/EntityComponentDataset.js"],"names":[],"mappings":"AAyHA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wDAfyB,MAAM;IAiB3B;;;;OAIG;IACH,wBAA+B;IAE/B;;;;;OAKG;IACH,yBAAsC;IAEtC;;;;;;;;;OASG;IACH,2BAAkC;IAElC;;;;;OAKG;IACH,yBAAsB;IAEtB;;;;OAIG;IACH,4BAAgC;IAEhC;;;;OAIG;IACH,2BAAuB;IAEvB;;;;OAIG;IACH,mBAAgB;IAEhB;;;;OAIG;IACH,oBAAgB;IAEhB;;;;;;;OAOG;IACH,mBAAe;IAEf;;;OAGG;IACH,0BAFU,OAAO,MAAM,CAAC,CAEO;IAE/B;;;OAGG;IACH,0BAFU,OAAO,MAAM,CAAC,CAEO;IAG/B;;;;OAIG;IACH,+BAA4B;IAE5B;;;;OAIG;IACH,kCAA+B;IAE/B;;;OAGG;IACH,kBAAe;IAGf;;;;;;OAMG;IACH,mEAkCC;IAED;;;;;OAKG;IACH,kDAHW,OAAO,GACL,OAAO,CAqDnB;IAED;;;;;OAKG;IACH,qDAHW,OAAO,GACL,OAAO,CA6DnB;IAED;;;OAGG;IACH,kBAFa,MAAM,CAIlB;IAED;;;OAGG;IACH,yBAFa,MAAM,CAIlB;IAED;;;;;OAKG;IACH,sBAJW,MAAM,qBACN,EAAE,SAmCZ;IAED;;;;O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G;IACH,oDAFa,IAAI,CAgBhB;IAGL;;;;;OAKG;IACH,mCAFU,OAAO,CAEwC;IAIzD;;OAEG;IACH,4BA/mBgB,UAAU,MAAM,CAAC,CA+mBoB;IAErD;;OAEG;IACH,iCAjZe,MAAM,wCAGJ,OAAO,CA8Y+B;IAtnBnD;;;OAGG;IACH,qBAFY,UAAU,MAAM,CAAC,CAY5B;CAolBJ;mBAh+DkB,oCAAoC"}
1
+ {"version":3,"file":"EntityComponentDataset.d.ts","sourceRoot":"","sources":["../../../../src/engine/ecs/EntityComponentDataset.js"],"names":[],"mappings":"AAyHA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wDAfyB,MAAM;IAiB3B;;;;OAIG;IACH,wBAA+B;IAE/B;;;;;OAKG;IACH,yBAAsC;IAEtC;;;;;;;;;OASG;IACH,2BAAkC;IAElC;;;;;OAKG;IACH,yBAAsB;IAEtB;;;;OAIG;IACH,4BAAgC;IAEhC;;;;OAIG;IACH,2BAAuB;IAEvB;;;;OAIG;IACH,mBAAgB;IAEhB;;;;OAIG;IACH,oBAAgB;IAEhB;;;;;;;OAOG;IACH,mBAAe;IAEf;;;OAGG;IACH,0BAFU,OAAO,MAAM,CAAC,CAEO;IAE/B;;;OAGG;IACH,0BAFU,OAAO,MAAM,CAAC,CAEO;IAG/B;;;;OAIG;IACH,+BAA4B;IAE5B;;;;OAIG;IACH,kCAA+B;IAE/B;;;OAGG;IACH,kBAAe;IAGf;;;;;;OAMG;IACH,mEAkCC;IAED;;;;;OAKG;IACH,kDAHW,OAAO,GACL,OAAO,CAqDnB;IAED;;;;;OAKG;IACH,qDAHW,OAAO,GACL,OAAO,CA6DnB;IAED;;;OAGG;IACH,kBAFa,MAAM,CAIlB;IAED;;;OAGG;IACH,yBAFa,MAAM,CAIlB;IAED;;;;;OAKG;IACH,sBAJW,MAAM,qBACN,EAAE,SAmCZ;IAED;;;;;OAKG;IACH,4BAHW,MAAM,GACJ,EAAE,CAyBd;IAED;;;;;OAKG;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OAAO,CAEwC;IAIzD;;OAEG;IACH,4BA/mBgB,UAAU,MAAM,CAAC,CA+mBoB;IAErD;;OAEG;IACH,iCAjZe,MAAM,wCAGJ,OAAO,CA8Y+B;IAtnBnD;;;OAGG;IACH,qBAFY,UAAU,MAAM,CAAC,CAY5B;CAolBJ;mBAj+DkB,oCAAoC"}
@@ -477,7 +477,8 @@ export class EntityComponentDataset {
477
477
  }
478
478
 
479
479
  /**
480
- * Get all components associated with a given entity
480
+ * Get all components associated with a given entity.
481
+ * Note that this method allocates. If performance is important - prefer alternatives.
481
482
  * @param {number} entity_id
482
483
  * @returns {[]} all components attached to the entity, array is not compacted
483
484
  */
@@ -1,6 +1,35 @@
1
1
  /**
2
2
  * Based on the Frostbite's GDC paper "FrameGraph: Extensible Rendering Architecture in Frostbite" by Yuriy O'Donnell
3
- * @see https://github.com/skaarj1989/FrameGraph
3
+ * @example
4
+ * const graph = new RenderGraph("My Graph");
5
+ *
6
+ * const pass_data = {};
7
+ * const pass = graph.add("GBuffer Pass", pass_data, (data, resources, context) => {
8
+ *
9
+ * context.beginRenderPass({
10
+ * depth_attachment: resources.get(data.depth),
11
+ * color_attachments:[
12
+ * resources.get(data.normal),
13
+ * resources.get(data.albedo),
14
+ * ]
15
+ * });
16
+ *
17
+ * for (const renderable in renderables){
18
+ * drawMesh(context, renderable.mesh, renderable.material);
19
+ * }
20
+ *
21
+ * context.endRenderPass();
22
+ *
23
+ * });
24
+ *
25
+ * pass_data.depth = pass.create("depth", {...});
26
+ * pass_data.albedo = pass.create("albedo", {...});
27
+ * pass_data.normal = pass.create("normal", {...});
28
+ *
29
+ *
30
+ * graph.compile();
31
+ * graph.execute(context);
32
+ *
4
33
  */
5
34
  export class RenderGraph {
6
35
  /**
@@ -54,6 +83,7 @@ export class RenderGraph {
54
83
  * @template T
55
84
  * @param {string} name
56
85
  * @param {T} descriptor
86
+ * @returns {number}
57
87
  */
58
88
  create_resource<T_1>(name: string, descriptor: T_1): number;
59
89
  /**
@@ -73,10 +103,10 @@ export class RenderGraph {
73
103
  private _createResourceNode;
74
104
  /**
75
105
  *
76
- * @param {number} res
77
- * @returns {number}
106
+ * @param {number} node_id
107
+ * @returns {number} ID of the cloned resource node
78
108
  */
79
- clone_resource(res: number): number;
109
+ clone_resource(node_id: number): number;
80
110
  /**
81
111
  * @template T
82
112
  * @param {string} name
@@ -91,13 +121,14 @@ export class RenderGraph {
91
121
  */
92
122
  is_valid_resource(id: any): boolean;
93
123
  /**
124
+ * Add a new pass to the graph.
94
125
  * @template T
95
126
  * @param {string} name
96
127
  * @param {T} data
97
128
  * @param {function(data:T, resources: RenderPassResources, context:IRenderContext):void} execute
98
- * @returns {RenderGraphBuilder}
129
+ * @returns {RenderPassBuilder}
99
130
  */
100
- add<T_3>(name: string, data: T_3, execute: any): RenderGraphBuilder;
131
+ add<T_3>(name: string, data: T_3, execute: any): RenderPassBuilder;
101
132
  /**
102
133
  * Perform validation, useful for debugging
103
134
  * Typically done before compilation
@@ -113,6 +144,18 @@ export class RenderGraph {
113
144
  */
114
145
  execute(context: IRenderContext): void;
115
146
  /**
147
+ * Should only call after {@link compile}
148
+ *
149
+ * @see https://github.com/skaarj1989/FrameGraph/blob/viewer/JsonWriter.hpp
150
+ * @return {{passes: [], resources: []}}
151
+ */
152
+ exportToJson(): {
153
+ passes: [];
154
+ resources: [];
155
+ };
156
+ /**
157
+ * Export the graph diagram in GraphViz DOT format.
158
+ * Useful for debugging.
116
159
  * @see https://en.wikipedia.org/wiki/DOT_(graph_description_language)
117
160
  * @return {string}
118
161
  */
@@ -125,5 +168,5 @@ export class RenderGraph {
125
168
  }
126
169
  import { ResourceEntry } from "./ResourceEntry.js";
127
170
  import { ResourceNode } from "./ResourceNode.js";
128
- import { RenderGraphBuilder } from "./RenderGraphBuilder.js";
171
+ import { RenderPassBuilder } from "./RenderPassBuilder.js";
129
172
  //# sourceMappingURL=RenderGraph.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"RenderGraph.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/render/frame_graph/RenderGraph.js"],"names":[],"mappings":"AAQA;;;GAGG;AACH;IA6BI;;;OAGG;IACH,mBAFW,MAAM,EAOhB;IArCD;;;;OAIG;IACH,MAFU,MAAM,CAEN;IAEV;;;;OAIG;IACH,qBAAkB;IAElB;;;;OAIG;IACH,yBAAsB;IAEtB;;;;OAIG;IACH,4BAAyB;IAazB;;;;OAIG;IACH,qBAHW,MAAM,sBAahB;IAED;;;;OAIG;IACH,oBAHW,MAAM,qBAmBhB;IAED;;;;OAIG;IACH,qBAHW,MAAM,KAKhB;IAED;;;;OAIG;IACH,2BAHW,MAAM,2BAWhB;IAED;;;;;OAKG;IACH,6BAYC;IAED;;;;;;OAMG;IACH,4BAeC;IAED;;;;OAIG;IACH,oBAHW,MAAM,GACJ,MAAM,CAkBlB;IAED;;;;;;OAMG;IACH,2BALW,MAAM,wDAGJ,MAAM,CAUlB;IAED;;;OAGG;IACH,4BAHa,OAAO,CAQnB;IAED;;;;;;OAMG;IACH,eALW,MAAM,4BAGJ,kBAAkB,CA2B9B;IAED;;;;;;OAMG;IACH,iEAFa,OAAO,CAOnB;IAED,gBA6FC;IAED;;;OAGG;IACH,uCA2CC;IAED;;;OAGG;IACH,eAFY,MAAM,CAiEjB;IAGL;;;OAGG;IACH,wBAFU,OAAO,CAEkB;CANlC;8BAld6B,oBAAoB;6BACrB,mBAAmB;mCAJb,yBAAyB"}
1
+ {"version":3,"file":"RenderGraph.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/render/frame_graph/RenderGraph.js"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH;IA6BI;;;OAGG;IACH,mBAFW,MAAM,EAOhB;IArCD;;;;OAIG;IACH,MAFU,MAAM,CAEN;IAEV;;;;OAIG;IACH,qBAAkB;IAElB;;;;OAIG;IACH,yBAAsB;IAEtB;;;;OAIG;IACH,4BAAyB;IAazB;;;;OAIG;IACH,qBAHW,MAAM,sBAahB;IAED;;;;OAIG;IACH,oBAHW,MAAM,qBAmBhB;IAED;;;;OAIG;IACH,qBAHW,MAAM,KAKhB;IAED;;;;;OAKG;IACH,2BAJW,MAAM,oBAEJ,MAAM,CAWlB;IAED;;;;;OAKG;IACH,6BAYC;IAED;;;;;;OAMG;IACH,4BAeC;IAED;;;;OAIG;IACH,wBAHW,MAAM,GACJ,MAAM,CAkBlB;IAED;;;;;;OAMG;IACH,2BALW,MAAM,wDAGJ,MAAM,CAUlB;IAED;;;OAGG;IACH,4BAHa,OAAO,CAQnB;IAED;;;;;;;OAOG;IACH,eALW,MAAM,4BAGJ,iBAAiB,CA2B7B;IAED;;;;;;OAMG;IACH,iEAFa,OAAO,CAQnB;IAED,gBA6FC;IAED;;;OAGG;IACH,uCA2CC;IAED;;;;;OAKG;IACH;gBAFqB,EAAE;mBAAa,EAAE;MA2DrC;IAED;;;;;OAKG;IACH,eAFY,MAAM,CAiEjB;IAGL;;;OAGG;IACH,wBAFU,OAAO,CAEkB;CANlC;8BAtjB6B,oBAAoB;6BACrB,mBAAmB;kCAJd,wBAAwB"}
@@ -1,6 +1,6 @@
1
1
  import { assert } from "../../../../core/assert.js";
2
2
  import LineBuilder from "../../../../core/codegen/LineBuilder.js";
3
- import { RenderGraphBuilder } from "./RenderGraphBuilder.js";
3
+ import { RenderPassBuilder } from "./RenderPassBuilder.js";
4
4
  import { RenderPassNode } from "./RenderPassNode.js";
5
5
  import { RenderPassResources } from "./RenderPassResources.js";
6
6
  import { ResourceEntry } from "./ResourceEntry.js";
@@ -8,7 +8,36 @@ import { ResourceNode } from "./ResourceNode.js";
8
8
 
9
9
  /**
10
10
  * Based on the Frostbite's GDC paper "FrameGraph: Extensible Rendering Architecture in Frostbite" by Yuriy O'Donnell
11
- * @see https://github.com/skaarj1989/FrameGraph
11
+ * @example
12
+ * const graph = new RenderGraph("My Graph");
13
+ *
14
+ * const pass_data = {};
15
+ * const pass = graph.add("GBuffer Pass", pass_data, (data, resources, context) => {
16
+ *
17
+ * context.beginRenderPass({
18
+ * depth_attachment: resources.get(data.depth),
19
+ * color_attachments:[
20
+ * resources.get(data.normal),
21
+ * resources.get(data.albedo),
22
+ * ]
23
+ * });
24
+ *
25
+ * for (const renderable in renderables){
26
+ * drawMesh(context, renderable.mesh, renderable.material);
27
+ * }
28
+ *
29
+ * context.endRenderPass();
30
+ *
31
+ * });
32
+ *
33
+ * pass_data.depth = pass.create("depth", {...});
34
+ * pass_data.albedo = pass.create("albedo", {...});
35
+ * pass_data.normal = pass.create("normal", {...});
36
+ *
37
+ *
38
+ * graph.compile();
39
+ * graph.execute(context);
40
+ *
12
41
  */
13
42
  export class RenderGraph {
14
43
  /**
@@ -103,11 +132,13 @@ export class RenderGraph {
103
132
  * @template T
104
133
  * @param {string} name
105
134
  * @param {T} descriptor
135
+ * @returns {number}
106
136
  */
107
137
  create_resource(name, descriptor) {
108
138
  assert.isString(name, 'name');
109
139
  assert.defined(descriptor, 'descriptor');
110
140
  assert.notNull(descriptor, 'descriptor');
141
+ assert.isObject(descriptor, 'descriptor');
111
142
 
112
143
  const resource = this._createResourceEntry(descriptor);
113
144
 
@@ -160,11 +191,11 @@ export class RenderGraph {
160
191
 
161
192
  /**
162
193
  *
163
- * @param {number} res
164
- * @returns {number}
194
+ * @param {number} node_id
195
+ * @returns {number} ID of the cloned resource node
165
196
  */
166
- clone_resource(res) {
167
- const node = this.getResourceNode(res);
197
+ clone_resource(node_id) {
198
+ const node = this.getResourceNode(node_id);
168
199
 
169
200
  const entry = this.__resource_registry[node.resource_id];
170
201
 
@@ -210,11 +241,12 @@ export class RenderGraph {
210
241
  }
211
242
 
212
243
  /**
244
+ * Add a new pass to the graph.
213
245
  * @template T
214
246
  * @param {string} name
215
247
  * @param {T} data
216
248
  * @param {function(data:T, resources: RenderPassResources, context:IRenderContext):void} execute
217
- * @returns {RenderGraphBuilder}
249
+ * @returns {RenderPassBuilder}
218
250
  */
219
251
  add(name, data, execute) {
220
252
  assert.isString(name, 'name');
@@ -227,7 +259,7 @@ export class RenderGraph {
227
259
 
228
260
  const pass_nodes = this.__pass_nodes;
229
261
 
230
- const builder = new RenderGraphBuilder();
262
+ const builder = new RenderPassBuilder();
231
263
  const node = new RenderPassNode();
232
264
 
233
265
  node.id = pass_nodes.length;
@@ -253,6 +285,7 @@ export class RenderGraph {
253
285
  validate(problem_consumer, problem_consumer_context) {
254
286
 
255
287
  // TODO implement
288
+ // TODO check for "read before write"
256
289
 
257
290
  return true;
258
291
  }
@@ -402,6 +435,73 @@ export class RenderGraph {
402
435
  }
403
436
 
404
437
  /**
438
+ * Should only call after {@link compile}
439
+ *
440
+ * @see https://github.com/skaarj1989/FrameGraph/blob/viewer/JsonWriter.hpp
441
+ * @return {{passes: [], resources: []}}
442
+ */
443
+ exportToJson() {
444
+
445
+ const resources = [];
446
+
447
+ this.__resource_registry.forEach((entry, entry_id) => {
448
+ const node = this.getResourceNode(entry.resource_id);
449
+
450
+ const j = {
451
+ id: entry_id,
452
+ name: node.name,
453
+ transient: entry.isTransient(),
454
+ };
455
+
456
+ const description = entry.resource_descriptor?.toString();
457
+
458
+ if (description) {
459
+ j.description = description;
460
+ }
461
+
462
+ if (entry.producer !== null) {
463
+ j.createdBy = entry.producer.id;
464
+ }
465
+
466
+ const readers = [];
467
+ const writers = [];
468
+
469
+ this.__pass_nodes.forEach(pass => {
470
+ if (pass.reads(entry.resource_id)) {
471
+ readers.push(pass.id);
472
+ }
473
+ if (pass.writes(entry.resource_id)) {
474
+ writers.push(pass.id);
475
+ }
476
+ })
477
+
478
+ if (readers.length > 0) {
479
+ j.readers = readers;
480
+ }
481
+ if (writers.length > 0) {
482
+ j.writers = writers;
483
+ }
484
+
485
+ resources[entry_id] = j;
486
+ })
487
+
488
+ return {
489
+ passes: this.__pass_nodes.map(node => {
490
+ return {
491
+ id: node.id,
492
+ name: node.name,
493
+ culled: !node.can_execute(),
494
+ reads: node.resource_reads,
495
+ writes: node.resource_writes,
496
+ }
497
+ }),
498
+ resources
499
+ }
500
+ }
501
+
502
+ /**
503
+ * Export the graph diagram in GraphViz DOT format.
504
+ * Useful for debugging.
405
505
  * @see https://en.wikipedia.org/wiki/DOT_(graph_description_language)
406
506
  * @return {string}
407
507
  */
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Allows you to declare resources for the pass, reading/writing/creating resources that will be used by the pass.
3
+ *
4
+ * @example
5
+ * const pass_data = {};
6
+ * const pass_builder = graph.add("pass", pass_data, (data, resources, context) => { ... });
7
+ * pass_data.resource_a = pass_builder.create("A", {});
8
+ */
9
+ export class RenderPassBuilder {
10
+ /**
11
+ *
12
+ * @param {RenderGraph} graph
13
+ * @param {RenderPassNode} node
14
+ */
15
+ init(graph: RenderGraph, node: RenderPassNode): void;
16
+ /**
17
+ * Create a new resource.
18
+ * Creation implies writing as well.
19
+ * @param {string} name
20
+ * @param {ResourceDescriptor} descriptor
21
+ * @returns {number} resource ID
22
+ */
23
+ create(name: string, descriptor: ResourceDescriptor): number;
24
+ /**
25
+ * Read an existing resource
26
+ * @param {number} resource
27
+ * @returns {number} resource ID same as the input
28
+ */
29
+ read(resource: number): number;
30
+ /**
31
+ * Write a resource
32
+ * @param {number} resource
33
+ * @returns {number} resource ID
34
+ */
35
+ write(resource: number): number;
36
+ /**
37
+ * Indicate that this pass has side effects.
38
+ * Will force the node to always be executed, regardless if it contributes to the final outputs of the graph or not.
39
+ * Useful for debug purposes or cases where some of the resources written are not part of the graph.
40
+ */
41
+ make_side_effect(): void;
42
+ #private;
43
+ }
44
+ //# sourceMappingURL=RenderPassBuilder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RenderPassBuilder.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/render/frame_graph/RenderPassBuilder.js"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH;IAgBI;;;;OAIG;IACH,qDAMC;IAED;;;;;;OAMG;IACH,aAJW,MAAM,mCAEJ,MAAM,CAYlB;IAED;;;;OAIG;IACH,eAHW,MAAM,GACJ,MAAM,CASlB;IAED;;;;OAIG;IACH,gBAHW,MAAM,GACJ,MAAM,CAsBlB;IAED;;;;OAIG;IACH,yBAEC;;CACJ"}
@@ -1,12 +1,22 @@
1
1
  import { assert } from "../../../../core/assert.js";
2
2
 
3
- export class RenderGraphBuilder {
3
+ /**
4
+ * Allows you to declare resources for the pass, reading/writing/creating resources that will be used by the pass.
5
+ *
6
+ * @example
7
+ * const pass_data = {};
8
+ * const pass_builder = graph.add("pass", pass_data, (data, resources, context) => { ... });
9
+ * pass_data.resource_a = pass_builder.create("A", {});
10
+ */
11
+ export class RenderPassBuilder {
12
+
4
13
  /**
5
14
  *
6
15
  * @type {RenderGraph}
7
16
  * @private
8
17
  */
9
18
  #graph = null;
19
+
10
20
  /**
11
21
  *
12
22
  * @type {RenderPassNode}
@@ -20,12 +30,16 @@ export class RenderGraphBuilder {
20
30
  * @param {RenderPassNode} node
21
31
  */
22
32
  init(graph, node) {
33
+ assert.defined(graph, 'graph');
34
+ assert.defined(node, 'node');
35
+
23
36
  this.#graph = graph;
24
37
  this.#node = node;
25
38
  }
26
39
 
27
40
  /**
28
- * Create a new resource
41
+ * Create a new resource.
42
+ * Creation implies writing as well.
29
43
  * @param {string} name
30
44
  * @param {ResourceDescriptor} descriptor
31
45
  * @returns {number} resource ID
@@ -45,18 +59,21 @@ export class RenderGraphBuilder {
45
59
  /**
46
60
  * Read an existing resource
47
61
  * @param {number} resource
48
- * @returns {number}
62
+ * @returns {number} resource ID same as the input
49
63
  */
50
64
  read(resource) {
51
65
  assert.isNonNegativeInteger(resource, 'resource');
66
+ assert.defined(this.#graph.getResourceEntry(resource), 'resource node');
52
67
 
53
- return this.#node.read(resource);
68
+ const node = this.#node;
69
+
70
+ return node.read(resource);
54
71
  }
55
72
 
56
73
  /**
57
74
  * Write a resource
58
75
  * @param {number} resource
59
- * @returns {number}
76
+ * @returns {number} resource ID
60
77
  */
61
78
  write(resource) {
62
79
  assert.isNonNegativeInteger(resource, 'resource');
@@ -81,7 +98,9 @@ export class RenderGraphBuilder {
81
98
  }
82
99
 
83
100
  /**
84
- * Will force the node to be executed
101
+ * Indicate that this pass has side effects.
102
+ * Will force the node to always be executed, regardless if it contributes to the final outputs of the graph or not.
103
+ * Useful for debug purposes or cases where some of the resources written are not part of the graph.
85
104
  */
86
105
  make_side_effect() {
87
106
  this.#node.has_side_effects = true;
@@ -51,6 +51,7 @@ export class RenderPassNode extends GraphNode {
51
51
  /**
52
52
  *
53
53
  * @param {number} resource
54
+ * @returns {number} same as the input
54
55
  */
55
56
  read(resource: number): number;
56
57
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"RenderPassNode.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/render/frame_graph/RenderPassNode.js"],"names":[],"mappings":"AAIA;IAEI;;;OAGG;IACH,kBAAc;IAEd;;;OAGG;IACH,kBAFU,OAAO,CAEQ;IAEzB;;;OAGG;IACH,UAAU;IAEV;;;OAGG;IACH,kBAFU,MAAM,EAAE,CAEI;IAEtB;;;OAGG;IACH,gBAFU,MAAM,EAAE,CAEE;IAEpB;;;OAGG;IACH,iBAFU,MAAM,EAAE,CAEG;IAErB;;;;OAIG;IACH,YAHW,MAAM,GACL,OAAO,CAMlB;IAED;;;;OAIG;IACH,UAHW,MAAM,GACL,OAAO,CAMlB;IAED;;;;OAIG;IACH,WAHW,MAAM,GACL,OAAO,CAMlB;IAED,0BAOC;IAED;;;OAGG;IACH,eAFW,MAAM,UAUhB;IAED;;;OAGG;IACH,eAFY,OAAO,CAIlB;CACJ;0BAvGyB,gBAAgB"}
1
+ {"version":3,"file":"RenderPassNode.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/render/frame_graph/RenderPassNode.js"],"names":[],"mappings":"AAIA;IAEI;;;OAGG;IACH,kBAAc;IAEd;;;OAGG;IACH,kBAFU,OAAO,CAEQ;IAEzB;;;OAGG;IACH,UAAU;IAEV;;;OAGG;IACH,kBAFU,MAAM,EAAE,CAEI;IAEtB;;;OAGG;IACH,gBAFU,MAAM,EAAE,CAEE;IAEpB;;;OAGG;IACH,iBAFU,MAAM,EAAE,CAEG;IAErB;;;;OAIG;IACH,YAHW,MAAM,GACL,OAAO,CAMlB;IAED;;;;OAIG;IACH,UAHW,MAAM,GACL,OAAO,CAMlB;IAED;;;;OAIG;IACH,WAHW,MAAM,GACL,OAAO,CAMlB;IAED,0BAOC;IAED;;;;OAIG;IACH,eAHW,MAAM,GACJ,MAAM,CAUlB;IAED;;;OAGG;IACH,eAFY,OAAO,CAIlB;CACJ;0BAxGyB,gBAAgB"}
@@ -85,6 +85,7 @@ export class RenderPassNode extends GraphNode {
85
85
  /**
86
86
  *
87
87
  * @param {number} resource
88
+ * @returns {number} same as the input
88
89
  */
89
90
  read(resource) {
90
91
  if (this.reads(resource)) {
@@ -48,7 +48,15 @@ export class ResourceEntry<T> {
48
48
  * @param {RenderResourceManager} resources
49
49
  */
50
50
  destroy(resources: RenderResourceManager): void;
51
+ /**
52
+ *
53
+ * @return {boolean}
54
+ */
51
55
  isImported(): boolean;
56
+ /**
57
+ *
58
+ * @return {boolean}
59
+ */
52
60
  isTransient(): boolean;
53
61
  toString(): any;
54
62
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ResourceEntry.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/render/frame_graph/ResourceEntry.js"],"names":[],"mappings":"AAIA;;GAEG;AACH;IACI;;;OAGG;IACH,aAFU,MAAM,CAEW;IAE3B;;;OAGG;IACH,qBAFU,wBAAsB,IAAI,CAET;IAE3B;;;OAGG;IACH,kBAFU,MAAM,CAEK;IAErB;;;OAGG;IACH,UAFU,CAAC,GAAC,IAAI,CAEA;IAEhB;;;;OAIG;IACH,UAFU,OAAO,CAEA;IAEjB;;;OAGG;IACH,UAFU,iBAAe,IAAI,CAEb;IAEhB;;;OAGG;IACH,MAFU,iBAAe,IAAI,CAEjB;IAEZ;;;OAGG;IACH,+CAIC;IAED;;;OAGG;IACH,gDAIC;IAED,sBAEC;IAED,uBAEC;IAED,gBAQC;CACJ"}
1
+ {"version":3,"file":"ResourceEntry.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/render/frame_graph/ResourceEntry.js"],"names":[],"mappings":"AAIA;;GAEG;AACH;IACI;;;OAGG;IACH,aAFU,MAAM,CAEW;IAE3B;;;OAGG;IACH,qBAFU,wBAAsB,IAAI,CAET;IAE3B;;;OAGG;IACH,kBAFU,MAAM,CAEK;IAErB;;;OAGG;IACH,UAFU,CAAC,GAAC,IAAI,CAEA;IAEhB;;;;OAIG;IACH,UAFU,OAAO,CAEA;IAEjB;;;OAGG;IACH,UAFU,iBAAe,IAAI,CAEb;IAEhB;;;OAGG;IACH,MAFU,iBAAe,IAAI,CAEjB;IAEZ;;;OAGG;IACH,+CAIC;IAED;;;OAGG;IACH,gDAIC;IAED;;;OAGG;IACH,cAFY,OAAO,CAIlB;IAED;;;OAGG;IACH,eAFY,OAAO,CAIlB;IAED,gBAQC;CACJ"}
@@ -69,10 +69,18 @@ export class ResourceEntry {
69
69
  resources.release(this.resource);
70
70
  }
71
71
 
72
+ /**
73
+ *
74
+ * @return {boolean}
75
+ */
72
76
  isImported() {
73
77
  return this.imported;
74
78
  }
75
79
 
80
+ /**
81
+ *
82
+ * @return {boolean}
83
+ */
76
84
  isTransient() {
77
85
  return !this.imported;
78
86
  }
@@ -1,33 +0,0 @@
1
- export class RenderGraphBuilder {
2
- /**
3
- *
4
- * @param {RenderGraph} graph
5
- * @param {RenderPassNode} node
6
- */
7
- init(graph: RenderGraph, node: RenderPassNode): void;
8
- /**
9
- * Create a new resource
10
- * @param {string} name
11
- * @param {ResourceDescriptor} descriptor
12
- * @returns {number} resource ID
13
- */
14
- create(name: string, descriptor: ResourceDescriptor): number;
15
- /**
16
- * Read an existing resource
17
- * @param {number} resource
18
- * @returns {number}
19
- */
20
- read(resource: number): number;
21
- /**
22
- * Write a resource
23
- * @param {number} resource
24
- * @returns {number}
25
- */
26
- write(resource: number): number;
27
- /**
28
- * Will force the node to be executed
29
- */
30
- make_side_effect(): void;
31
- #private;
32
- }
33
- //# sourceMappingURL=RenderGraphBuilder.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"RenderGraphBuilder.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/render/frame_graph/RenderGraphBuilder.js"],"names":[],"mappings":"AAEA;IAcI;;;;OAIG;IACH,qDAGC;IAED;;;;;OAKG;IACH,aAJW,MAAM,mCAEJ,MAAM,CAYlB;IAED;;;;OAIG;IACH,eAHW,MAAM,GACJ,MAAM,CAMlB;IAED;;;;OAIG;IACH,gBAHW,MAAM,GACJ,MAAM,CAsBlB;IAED;;OAEG;IACH,yBAEC;;CACJ"}
@@ -1,50 +0,0 @@
1
- /**
2
- * @deprecated new syntax does not require a separate data structure, use lambda functions instead
3
- * @template [DATA=Object<number>]
4
- * @class
5
- */
6
- export class RenderPass<DATA = any> {
7
- /**
8
- *
9
- * @param [inputs]
10
- */
11
- constructor(inputs?: any);
12
- /**
13
- * Used for debug and visualisation
14
- * @type {string}
15
- */
16
- name: string;
17
- /**
18
- *
19
- * @type {number|RenderPassFlags}
20
- */
21
- flags: number | RenderPassFlags;
22
- /**
23
- * Arbitrary dictionary of data
24
- * @deprecated
25
- * @type {Object<number>}
26
- */
27
- inputs: any;
28
- /**
29
- *
30
- * @param {RenderGraphBuilder} builder
31
- * @returns {DATA} resources/handles that are used by the pass, includes both inputs and outputs
32
- */
33
- setup(builder: RenderGraphBuilder): DATA;
34
- /**
35
- * @param {DATA} data
36
- * @param {RenderPassResources} resources
37
- * @param {IRenderContext} render_context
38
- * @returns {void}
39
- */
40
- execute(data: DATA, resources: RenderPassResources, render_context: IRenderContext): void;
41
- /**
42
- * Validate render pass internal structure
43
- * This is an optional method, mainly useful for debugging purposes
44
- * Default behaviour is to report pass as "valid" (true)
45
- * @param {function(problem:string)} problem_consumer when returning false, reasons are supplied here
46
- * @return {boolean} true for valid, false for invalid
47
- */
48
- validate(problem_consumer: any): boolean;
49
- }
50
- //# sourceMappingURL=RenderPass.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"RenderPass.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/render/frame_graph/RenderPass.js"],"names":[],"mappings":"AAEA;;;;GAIG;AACH;IAsBI;;;OAGG;IACH,0BAQC;IAhCD;;;OAGG;IACH,MAFU,MAAM,CAEK;IAErB;;;OAGG;IACH,OAFU,MAAM,kBAAgB,CAEV;IAGtB;;;;OAIG;IACH,YAAY;IAiBZ;;;;OAIG;IACH,oCAFa,IAAI,CAIhB;IAED;;;;;OAKG;IACH,cALW,IAAI,mEAGF,IAAI,CAIhB;IAED;;;;;;OAMG;IACH,iCAFY,OAAO,CAIlB;CACJ"}
@@ -1,74 +0,0 @@
1
- const DEFAULT_FLAGS = 0;
2
-
3
- /**
4
- * @deprecated new syntax does not require a separate data structure, use lambda functions instead
5
- * @template [DATA=Object<number>]
6
- * @class
7
- */
8
- export class RenderPass {
9
-
10
- /**
11
- * Used for debug and visualisation
12
- * @type {string}
13
- */
14
- name = "Render Pass";
15
-
16
- /**
17
- *
18
- * @type {number|RenderPassFlags}
19
- */
20
- flags = DEFAULT_FLAGS;
21
-
22
-
23
- /**
24
- * Arbitrary dictionary of data
25
- * @deprecated
26
- * @type {Object<number>}
27
- */
28
- inputs = {};
29
-
30
- /**
31
- *
32
- * @param [inputs]
33
- */
34
- constructor(inputs ) {
35
-
36
- if(inputs !== undefined){
37
- console.warn("Default inputs are deprecated, please use class fields instead");
38
-
39
- this.inputs = inputs;
40
- }
41
-
42
- }
43
-
44
-
45
- /**
46
- *
47
- * @param {RenderGraphBuilder} builder
48
- * @returns {DATA} resources/handles that are used by the pass, includes both inputs and outputs
49
- */
50
- setup(builder) {
51
- throw new Error('Not Implemented');
52
- }
53
-
54
- /**
55
- * @param {DATA} data
56
- * @param {RenderPassResources} resources
57
- * @param {IRenderContext} render_context
58
- * @returns {void}
59
- */
60
- execute(data, resources, render_context) {
61
- throw new Error('Not Implemented');
62
- }
63
-
64
- /**
65
- * Validate render pass internal structure
66
- * This is an optional method, mainly useful for debugging purposes
67
- * Default behaviour is to report pass as "valid" (true)
68
- * @param {function(problem:string)} problem_consumer when returning false, reasons are supplied here
69
- * @return {boolean} true for valid, false for invalid
70
- */
71
- validate(problem_consumer) {
72
- return true;
73
- }
74
- }