@luma.gl/core 9.3.0-alpha.2 → 9.3.0-alpha.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapter/canvas-context.d.ts +6 -181
- package/dist/adapter/canvas-context.d.ts.map +1 -1
- package/dist/adapter/canvas-context.js +5 -450
- package/dist/adapter/canvas-context.js.map +1 -1
- package/dist/adapter/canvas-observer.d.ts +32 -0
- package/dist/adapter/canvas-observer.d.ts.map +1 -0
- package/dist/adapter/canvas-observer.js +90 -0
- package/dist/adapter/canvas-observer.js.map +1 -0
- package/dist/adapter/canvas-surface.d.ts +150 -0
- package/dist/adapter/canvas-surface.d.ts.map +1 -0
- package/dist/adapter/canvas-surface.js +392 -0
- package/dist/adapter/canvas-surface.js.map +1 -0
- package/dist/adapter/device.d.ts +64 -9
- package/dist/adapter/device.d.ts.map +1 -1
- package/dist/adapter/device.js +108 -4
- package/dist/adapter/device.js.map +1 -1
- package/dist/adapter/luma.js +1 -1
- package/dist/adapter/presentation-context.d.ts +11 -0
- package/dist/adapter/presentation-context.d.ts.map +1 -0
- package/dist/adapter/presentation-context.js +12 -0
- package/dist/adapter/presentation-context.js.map +1 -0
- package/dist/adapter/resources/buffer.d.ts +1 -1
- package/dist/adapter/resources/buffer.d.ts.map +1 -1
- package/dist/adapter/resources/buffer.js +14 -6
- package/dist/adapter/resources/buffer.js.map +1 -1
- package/dist/adapter/resources/command-encoder.d.ts +27 -6
- package/dist/adapter/resources/command-encoder.d.ts.map +1 -1
- package/dist/adapter/resources/command-encoder.js +65 -1
- package/dist/adapter/resources/command-encoder.js.map +1 -1
- package/dist/adapter/resources/fence.d.ts +1 -1
- package/dist/adapter/resources/fence.d.ts.map +1 -1
- package/dist/adapter/resources/fence.js +3 -1
- package/dist/adapter/resources/fence.js.map +1 -1
- package/dist/adapter/resources/framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/framebuffer.js +9 -11
- package/dist/adapter/resources/framebuffer.js.map +1 -1
- package/dist/adapter/resources/query-set.d.ts +17 -1
- package/dist/adapter/resources/query-set.d.ts.map +1 -1
- package/dist/adapter/resources/query-set.js.map +1 -1
- package/dist/adapter/resources/render-pipeline.d.ts +19 -7
- package/dist/adapter/resources/render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/render-pipeline.js +20 -2
- package/dist/adapter/resources/render-pipeline.js.map +1 -1
- package/dist/adapter/resources/resource.d.ts +8 -0
- package/dist/adapter/resources/resource.d.ts.map +1 -1
- package/dist/adapter/resources/resource.js +240 -14
- package/dist/adapter/resources/resource.js.map +1 -1
- package/dist/adapter/resources/shader.js +27 -25
- package/dist/adapter/resources/shader.js.map +1 -1
- package/dist/adapter/resources/shared-render-pipeline.d.ts +22 -0
- package/dist/adapter/resources/shared-render-pipeline.d.ts.map +1 -0
- package/dist/adapter/resources/shared-render-pipeline.js +25 -0
- package/dist/adapter/resources/shared-render-pipeline.js.map +1 -0
- package/dist/adapter/resources/texture.d.ts +78 -12
- package/dist/adapter/resources/texture.d.ts.map +1 -1
- package/dist/adapter/resources/texture.js +182 -30
- package/dist/adapter/resources/texture.js.map +1 -1
- package/dist/adapter-utils/format-compiler-log.d.ts.map +1 -1
- package/dist/adapter-utils/format-compiler-log.js +23 -15
- package/dist/adapter-utils/format-compiler-log.js.map +1 -1
- package/dist/dist.dev.js +1265 -362
- package/dist/dist.min.js +10 -9
- package/dist/index.cjs +1027 -243
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/shadertypes/data-types/decode-shader-types.d.ts +2 -2
- package/dist/shadertypes/data-types/decode-shader-types.d.ts.map +1 -1
- package/dist/shadertypes/data-types/decode-shader-types.js +11 -2
- package/dist/shadertypes/data-types/decode-shader-types.js.map +1 -1
- package/dist/shadertypes/textures/pixel-utils.js +4 -4
- package/dist/shadertypes/textures/pixel-utils.js.map +1 -1
- package/dist/shadertypes/textures/texture-format-decoder.d.ts.map +1 -1
- package/dist/shadertypes/textures/texture-format-decoder.js +53 -8
- package/dist/shadertypes/textures/texture-format-decoder.js.map +1 -1
- package/dist/shadertypes/textures/texture-format-table.d.ts.map +1 -1
- package/dist/shadertypes/textures/texture-format-table.js +10 -9
- package/dist/shadertypes/textures/texture-format-table.js.map +1 -1
- package/dist/shadertypes/textures/texture-formats.d.ts +5 -2
- package/dist/shadertypes/textures/texture-formats.d.ts.map +1 -1
- package/dist/shadertypes/textures/texture-formats.js.map +1 -1
- package/dist/shadertypes/textures/texture-layout.d.ts +1 -1
- package/dist/utils/array-equal.d.ts +1 -1
- package/dist/utils/array-equal.d.ts.map +1 -1
- package/dist/utils/array-equal.js +15 -9
- package/dist/utils/array-equal.js.map +1 -1
- package/dist/utils/assert.d.ts +5 -0
- package/dist/utils/assert.d.ts.map +1 -0
- package/dist/utils/assert.js +17 -0
- package/dist/utils/assert.js.map +1 -0
- package/dist/utils/stats-manager.d.ts.map +1 -1
- package/dist/utils/stats-manager.js +61 -1
- package/dist/utils/stats-manager.js.map +1 -1
- package/package.json +6 -6
- package/src/adapter/canvas-context.ts +7 -590
- package/src/adapter/canvas-observer.ts +130 -0
- package/src/adapter/canvas-surface.ts +521 -0
- package/src/adapter/device.ts +174 -13
- package/src/adapter/presentation-context.ts +16 -0
- package/src/adapter/resources/buffer.ts +13 -5
- package/src/adapter/resources/command-encoder.ts +96 -7
- package/src/adapter/resources/fence.ts +3 -1
- package/src/adapter/resources/framebuffer.ts +9 -11
- package/src/adapter/resources/query-set.ts +17 -1
- package/src/adapter/resources/render-pipeline.ts +42 -13
- package/src/adapter/resources/resource.ts +284 -14
- package/src/adapter/resources/shader.ts +28 -28
- package/src/adapter/resources/shared-render-pipeline.ts +40 -0
- package/src/adapter/resources/texture.ts +269 -40
- package/src/adapter-utils/format-compiler-log.ts +23 -15
- package/src/index.ts +8 -0
- package/src/shadertypes/data-types/decode-shader-types.ts +13 -4
- package/src/shadertypes/textures/pixel-utils.ts +4 -4
- package/src/shadertypes/textures/texture-format-decoder.ts +73 -8
- package/src/shadertypes/textures/texture-format-table.ts +10 -9
- package/src/shadertypes/textures/texture-formats.ts +6 -1
- package/src/utils/array-equal.ts +21 -9
- package/src/utils/assert.ts +18 -0
- package/src/utils/stats-manager.ts +76 -2
|
@@ -11,7 +11,8 @@ export type QuerySetProps = ResourceProps & {
|
|
|
11
11
|
/**
|
|
12
12
|
* The type of query set
|
|
13
13
|
* occlusion - query the number of fragment samples that pass all the per-fragment tests for a set of drawing commands, including scissor, sample mask, alpha to coverage, stencil, and depth tests
|
|
14
|
-
* timestamp - query the GPU timestamp counter
|
|
14
|
+
* timestamp - query the GPU timestamp counter. Timestamp queries are available if the
|
|
15
|
+
* `timestamp-query` feature is present.
|
|
15
16
|
*/
|
|
16
17
|
type: 'occlusion' | 'timestamp';
|
|
17
18
|
/** The number of queries managed by the query set */
|
|
@@ -22,5 +23,20 @@ export declare abstract class QuerySet extends Resource<QuerySetProps> {
|
|
|
22
23
|
get [Symbol.toStringTag](): string;
|
|
23
24
|
constructor(device: Device, props: QuerySetProps);
|
|
24
25
|
static defaultProps: Required<QuerySetProps>;
|
|
26
|
+
/**
|
|
27
|
+
* Returns true if the requested result has been captured and can be read without blocking.
|
|
28
|
+
* Backends may implement this conservatively.
|
|
29
|
+
*/
|
|
30
|
+
abstract isResultAvailable(queryIndex?: number): boolean;
|
|
31
|
+
/** Reads query results as 64-bit values. */
|
|
32
|
+
abstract readResults(options?: {
|
|
33
|
+
firstQuery?: number;
|
|
34
|
+
queryCount?: number;
|
|
35
|
+
}): Promise<bigint[]>;
|
|
36
|
+
/**
|
|
37
|
+
* Reads a timestamp duration in milliseconds between a begin and end query index.
|
|
38
|
+
* Portable duration profiling requires adjacent indices that identify one logical pair.
|
|
39
|
+
*/
|
|
40
|
+
abstract readTimestampDuration(beginIndex: number, endIndex: number): Promise<number>;
|
|
25
41
|
}
|
|
26
42
|
//# sourceMappingURL=query-set.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-set.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/query-set.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,MAAM,EAAC,qBAAkB;AACtC,OAAO,EAAC,QAAQ,EAAE,aAAa,EAAC,sBAAmB;AAEnD;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,GAAG,aAAa,GAAG;IAC1C
|
|
1
|
+
{"version":3,"file":"query-set.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/query-set.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,MAAM,EAAC,qBAAkB;AACtC,OAAO,EAAC,QAAQ,EAAE,aAAa,EAAC,sBAAmB;AAEnD;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,GAAG,aAAa,GAAG;IAC1C;;;;;OAKG;IACH,IAAI,EAAE,WAAW,GAAG,WAAW,CAAC;IAChC,qDAAqD;IACrD,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,gCAAgC;AAChC,8BAAsB,QAAS,SAAQ,QAAQ,CAAC,aAAa,CAAC;IAC5D,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,MAAM,CAEjC;gBAEW,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa;IAIhD,OAAgB,YAAY,EAAE,QAAQ,CAAC,aAAa,CAAC,CAInD;IAEF;;;OAGG;IACH,QAAQ,CAAC,iBAAiB,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO;IAExD,4CAA4C;IAC5C,QAAQ,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE;QAAC,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAE7F;;;OAGG;IACH,QAAQ,CAAC,qBAAqB,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CACtF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-set.js","sourceRoot":"","sources":["../../../src/adapter/resources/query-set.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAGpC,OAAO,EAAC,QAAQ,EAAgB,sBAAmB;
|
|
1
|
+
{"version":3,"file":"query-set.js","sourceRoot":"","sources":["../../../src/adapter/resources/query-set.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAGpC,OAAO,EAAC,QAAQ,EAAgB,sBAAmB;AAqBnD,gCAAgC;AAChC,MAAM,OAAgB,QAAS,SAAQ,QAAuB;IAC5D,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;QACtB,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,YAAY,MAAc,EAAE,KAAoB;QAC9C,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,QAAQ,CAAC,YAAY,CAAC,CAAC;IAC9C,CAAC;IAED,MAAM,CAAU,YAAY,GAA4B;QACtD,GAAG,QAAQ,CAAC,YAAY;QACxB,IAAI,EAAE,SAAU;QAChB,KAAK,EAAE,SAAU;KAClB,CAAC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { Device } from "../device.js";
|
|
2
|
-
import type { UniformValue } from "../types/uniforms.js";
|
|
3
2
|
import type { PrimitiveTopology, RenderPipelineParameters } from "../types/parameters.js";
|
|
4
3
|
import type { ShaderLayout, Binding } from "../types/shader-layout.js";
|
|
5
4
|
import type { BufferLayout } from "../types/buffer-layout.js";
|
|
6
5
|
import type { TextureFormatColor, TextureFormatDepthStencil } from '@luma.gl/core/shadertypes/textures/texture-formats';
|
|
7
6
|
import type { Shader } from "./shader.js";
|
|
7
|
+
import type { SharedRenderPipeline } from "./shared-render-pipeline.js";
|
|
8
8
|
import type { RenderPass } from "./render-pass.js";
|
|
9
9
|
import { Resource, ResourceProps } from "./resource.js";
|
|
10
10
|
import { VertexArray } from "./vertex-array.js";
|
|
@@ -34,10 +34,16 @@ export type RenderPipelineProps = ResourceProps & {
|
|
|
34
34
|
depthStencilAttachmentFormat?: TextureFormatDepthStencil;
|
|
35
35
|
/** Parameters that are controlled by pipeline */
|
|
36
36
|
parameters?: RenderPipelineParameters;
|
|
37
|
+
/** Transform feedback varyings captured when linking a WebGL render pipeline. WebGL only. */
|
|
38
|
+
varyings?: string[];
|
|
39
|
+
/** Transform feedback buffer mode used when linking a WebGL render pipeline. WebGL only. */
|
|
40
|
+
bufferMode?: number;
|
|
41
|
+
/** Some applications intentionally supply unused attributes and bindings, and want to disable warnings */
|
|
42
|
+
disableWarnings?: boolean;
|
|
43
|
+
/** Internal hook for backend-specific shared pipeline implementations. */
|
|
44
|
+
_sharedRenderPipeline?: SharedRenderPipeline;
|
|
37
45
|
/** Buffers, Textures, Samplers for the shader bindings */
|
|
38
46
|
bindings?: Record<string, Binding>;
|
|
39
|
-
/** @deprecated uniforms (WebGL only) */
|
|
40
|
-
uniforms?: Record<string, UniformValue>;
|
|
41
47
|
};
|
|
42
48
|
/**
|
|
43
49
|
* A compiled and linked shader program
|
|
@@ -54,11 +60,13 @@ export declare abstract class RenderPipeline extends Resource<RenderPipelineProp
|
|
|
54
60
|
linkStatus: 'pending' | 'success' | 'error';
|
|
55
61
|
/** The hash of the pipeline */
|
|
56
62
|
hash: string;
|
|
63
|
+
/** Optional shared backend implementation */
|
|
64
|
+
sharedRenderPipeline: SharedRenderPipeline | null;
|
|
65
|
+
/** Whether shader or pipeline compilation/linking is still in progress */
|
|
66
|
+
get isPending(): boolean;
|
|
67
|
+
/** Whether shader or pipeline compilation/linking has failed */
|
|
68
|
+
get isErrored(): boolean;
|
|
57
69
|
constructor(device: Device, props: RenderPipelineProps);
|
|
58
|
-
/** Set bindings (stored on pipeline and set before each call) */
|
|
59
|
-
abstract setBindings(bindings: Record<string, Binding>, options?: {
|
|
60
|
-
disableWarnings?: boolean;
|
|
61
|
-
}): void;
|
|
62
70
|
/** Draw call. Returns false if the draw call was aborted (due to resources still initializing) */
|
|
63
71
|
abstract draw(options: {
|
|
64
72
|
/** Render pass to draw into (targeting screen or framebuffer) */
|
|
@@ -86,6 +94,10 @@ export declare abstract class RenderPipeline extends Resource<RenderPipelineProp
|
|
|
86
94
|
baseVertex?: number;
|
|
87
95
|
/** Transform feedback. WebGL only. */
|
|
88
96
|
transformFeedback?: TransformFeedback;
|
|
97
|
+
/** Bindings applied for this draw (textures, samplers, uniform buffers) */
|
|
98
|
+
bindings?: Record<string, Binding>;
|
|
99
|
+
/** WebGL-only uniforms */
|
|
100
|
+
uniforms?: Record<string, unknown>;
|
|
89
101
|
}): boolean;
|
|
90
102
|
static defaultProps: Required<RenderPipelineProps>;
|
|
91
103
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render-pipeline.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/render-pipeline.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,MAAM,EAAC,qBAAkB;AACtC,OAAO,KAAK,EAAC,
|
|
1
|
+
{"version":3,"file":"render-pipeline.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/render-pipeline.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,MAAM,EAAC,qBAAkB;AACtC,OAAO,KAAK,EAAC,iBAAiB,EAAE,wBAAwB,EAAC,+BAA4B;AACrF,OAAO,KAAK,EAAC,YAAY,EAAE,OAAO,EAAC,kCAA+B;AAClE,OAAO,KAAK,EAAC,YAAY,EAAC,kCAA+B;AACzD,OAAO,KAAK,EACV,kBAAkB,EAClB,yBAAyB,EAC1B,MAAM,oDAAoD,CAAC;AAC5D,OAAO,KAAK,EAAC,MAAM,EAAC,oBAAiB;AACrC,OAAO,KAAK,EAAC,oBAAoB,EAAC,oCAAiC;AACnE,OAAO,KAAK,EAAC,UAAU,EAAC,yBAAsB;AAC9C,OAAO,EAAC,QAAQ,EAAE,aA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B;QAC/B,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,kCAAkC;QAClC,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,sCAAsC;QACtC,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;QACtC,2EAA2E;QAC3E,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACnC,0BAA0B;QAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACpC,GAAG,OAAO;IAEX,OAAgB,YAAY,EAAE,QAAQ,CAAC,mBAAmB,CAAC,CAwBzD;CACH"}
|
|
@@ -17,10 +17,25 @@ export class RenderPipeline extends Resource {
|
|
|
17
17
|
linkStatus = 'pending';
|
|
18
18
|
/** The hash of the pipeline */
|
|
19
19
|
hash = '';
|
|
20
|
+
/** Optional shared backend implementation */
|
|
21
|
+
sharedRenderPipeline = null;
|
|
22
|
+
/** Whether shader or pipeline compilation/linking is still in progress */
|
|
23
|
+
get isPending() {
|
|
24
|
+
return (this.linkStatus === 'pending' ||
|
|
25
|
+
this.vs.compilationStatus === 'pending' ||
|
|
26
|
+
this.fs?.compilationStatus === 'pending');
|
|
27
|
+
}
|
|
28
|
+
/** Whether shader or pipeline compilation/linking has failed */
|
|
29
|
+
get isErrored() {
|
|
30
|
+
return (this.linkStatus === 'error' ||
|
|
31
|
+
this.vs.compilationStatus === 'error' ||
|
|
32
|
+
this.fs?.compilationStatus === 'error');
|
|
33
|
+
}
|
|
20
34
|
constructor(device, props) {
|
|
21
35
|
super(device, props, RenderPipeline.defaultProps);
|
|
22
36
|
this.shaderLayout = this.props.shaderLayout;
|
|
23
37
|
this.bufferLayout = this.props.bufferLayout || [];
|
|
38
|
+
this.sharedRenderPipeline = this.props._sharedRenderPipeline || null;
|
|
24
39
|
}
|
|
25
40
|
static defaultProps = {
|
|
26
41
|
...Resource.defaultProps,
|
|
@@ -36,8 +51,11 @@ export class RenderPipeline extends Resource {
|
|
|
36
51
|
colorAttachmentFormats: undefined,
|
|
37
52
|
depthStencilAttachmentFormat: undefined,
|
|
38
53
|
parameters: {},
|
|
39
|
-
|
|
40
|
-
|
|
54
|
+
varyings: undefined,
|
|
55
|
+
bufferMode: undefined,
|
|
56
|
+
disableWarnings: false,
|
|
57
|
+
_sharedRenderPipeline: undefined,
|
|
58
|
+
bindings: undefined
|
|
41
59
|
};
|
|
42
60
|
}
|
|
43
61
|
//# sourceMappingURL=render-pipeline.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render-pipeline.js","sourceRoot":"","sources":["../../../src/adapter/resources/render-pipeline.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAapC,OAAO,EAAC,QAAQ,EAAgB,sBAAmB;
|
|
1
|
+
{"version":3,"file":"render-pipeline.js","sourceRoot":"","sources":["../../../src/adapter/resources/render-pipeline.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAapC,OAAO,EAAC,QAAQ,EAAgB,sBAAmB;AAsDnD;;GAEG;AACH,MAAM,OAAgB,cAAe,SAAQ,QAA6B;IACxE,IAAa,CAAC,MAAM,CAAC,WAAW,CAAC;QAC/B,OAAO,gBAAgB,CAAC;IAC1B,CAAC;IAKD,wBAAwB;IACxB,YAAY,CAAe;IAC3B,oDAAoD;IAC3C,YAAY,CAAiB;IACtC,kGAAkG;IAClG,UAAU,GAAoC,SAAS,CAAC;IACxD,+BAA+B;IAC/B,IAAI,GAAW,EAAE,CAAC;IAClB,6CAA6C;IAC7C,oBAAoB,GAAgC,IAAI,CAAC;IAEzD,0EAA0E;IAC1E,IAAI,SAAS;QACX,OAAO,CACL,IAAI,CAAC,UAAU,KAAK,SAAS;YAC7B,IAAI,CAAC,EAAE,CAAC,iBAAiB,KAAK,SAAS;YACvC,IAAI,CAAC,EAAE,EAAE,iBAAiB,KAAK,SAAS,CACzC,CAAC;IACJ,CAAC;IAED,gEAAgE;IAChE,IAAI,SAAS;QACX,OAAO,CACL,IAAI,CAAC,UAAU,KAAK,OAAO;YAC3B,IAAI,CAAC,EAAE,CAAC,iBAAiB,KAAK,OAAO;YACrC,IAAI,CAAC,EAAE,EAAE,iBAAiB,KAAK,OAAO,CACvC,CAAC;IACJ,CAAC;IAED,YAAY,MAAc,EAAE,KAA0B;QACpD,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,cAAc,CAAC,YAAY,CAAC,CAAC;QAClD,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,YAAa,CAAC;QAC7C,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,IAAI,EAAE,CAAC;QAClD,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC,KAAK,CAAC,qBAAqB,IAAI,IAAI,CAAC;IACvE,CAAC;IAmCD,MAAM,CAAU,YAAY,GAAkC;QAC5D,GAAG,QAAQ,CAAC,YAAY;QAExB,EAAE,EAAE,IAAI;QACR,gBAAgB,EAAE,YAAY;QAC9B,WAAW,EAAE,EAAE;QAEf,EAAE,EAAE,IAAI;QACR,kBAAkB,EAAE,cAAc;QAClC,WAAW,EAAE,EAAE;QAEf,YAAY,EAAE,IAAI;QAClB,YAAY,EAAE,EAAE;QAChB,QAAQ,EAAE,eAAe;QAEzB,sBAAsB,EAAE,SAAU;QAClC,4BAA4B,EAAE,SAAU;QAExC,UAAU,EAAE,EAAE;QACd,QAAQ,EAAE,SAAU;QACpB,UAAU,EAAE,SAAU;QACtB,eAAe,EAAE,KAAK;QACtB,qBAAqB,EAAE,SAAU;QACjC,QAAQ,EAAE,SAAU;KACrB,CAAC"}
|
|
@@ -33,6 +33,8 @@ export declare abstract class Resource<Props extends ResourceProps> {
|
|
|
33
33
|
destroyed: boolean;
|
|
34
34
|
/** For resources that allocate GPU memory */
|
|
35
35
|
private allocatedBytes;
|
|
36
|
+
/** Stats bucket currently holding the tracked allocation */
|
|
37
|
+
private allocatedBytesName;
|
|
36
38
|
/** Attached resources will be destroyed when this resource is destroyed. Tracks auto-created "sub" resources. */
|
|
37
39
|
private _attachedResources;
|
|
38
40
|
/**
|
|
@@ -71,9 +73,15 @@ export declare abstract class Resource<Props extends ResourceProps> {
|
|
|
71
73
|
protected removeStats(): void;
|
|
72
74
|
/** Called by subclass to track memory allocations */
|
|
73
75
|
protected trackAllocatedMemory(bytes: number, name?: string): void;
|
|
76
|
+
/** Called by subclass to track handle-backed memory allocations separately from owned allocations */
|
|
77
|
+
protected trackReferencedMemory(bytes: number, name?: string): void;
|
|
74
78
|
/** Called by subclass to track memory deallocations */
|
|
75
79
|
protected trackDeallocatedMemory(name?: string): void;
|
|
80
|
+
/** Called by subclass to deallocate handle-backed memory tracked via trackReferencedMemory() */
|
|
81
|
+
protected trackDeallocatedReferencedMemory(name?: string): void;
|
|
76
82
|
/** Called by resource constructor to track object creation */
|
|
77
83
|
private addStats;
|
|
84
|
+
/** Canonical resource name used for stats buckets. */
|
|
85
|
+
protected getStatsName(): string;
|
|
78
86
|
}
|
|
79
87
|
//# sourceMappingURL=resource.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/resource.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,MAAM,EAAC,qBAAkB;
|
|
1
|
+
{"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/resource.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,MAAM,EAAC,qBAAkB;AAuEtC,MAAM,MAAM,aAAa,GAAG;IAC1B,sGAAsG;IACtG,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,0EAA0E;IAC1E,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,kDAAkD;IAClD,QAAQ,CAAC,EAAE;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA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vD;;OAEG;IACH,uBAAuB,CAAC,QAAQ,EAAE,QAAQ,CAAC,aAAa,CAAC,GAAG,IAAI;IAMhE,gGAAgG;IAChG,wBAAwB,IAAI,IAAI;IAUhC,8FAA8F;IAC9F,SAAS,CAAC,eAAe,IAAI,IAAI;IASjC,mGAAmG;IACnG,SAAS,CAAC,WAAW,IAAI,IAAI;IAuB7B,qDAAqD;IACrD,SAAS,CAAC,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,SAAsB,GAAG,IAAI;IAqB/E,qGAAqG;IACrG,SAAS,CAAC,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,SAAsB,GAAG,IAAI;IAIhF,uDAAuD;IACvD,SAAS,CAAC,sBAAsB,CAAC,IAAI,SAAsB,GAAG,IAAI;IAoBlE,gGAAgG;IAChG,SAAS,CAAC,gCAAgC,CAAC,IAAI,SAAsB,GAAG,IAAI;IAI5E,8DAA8D;IAC9D,OAAO,CAAC,QAAQ;IA0BhB,sDAAsD;IACtD,SAAS,CAAC,YAAY,IAAI,MAAM;CAGjC"}
|
|
@@ -2,6 +2,57 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
import { uid } from "../../utils/uid.js";
|
|
5
|
+
const CPU_HOTSPOT_PROFILER_MODULE = 'cpu-hotspot-profiler';
|
|
6
|
+
const RESOURCE_COUNTS_STATS = 'GPU Resource Counts';
|
|
7
|
+
const LEGACY_RESOURCE_COUNTS_STATS = 'Resource Counts';
|
|
8
|
+
const GPU_TIME_AND_MEMORY_STATS = 'GPU Time and Memory';
|
|
9
|
+
const BASE_RESOURCE_COUNT_ORDER = [
|
|
10
|
+
'Resources',
|
|
11
|
+
'Buffers',
|
|
12
|
+
'Textures',
|
|
13
|
+
'Samplers',
|
|
14
|
+
'TextureViews',
|
|
15
|
+
'Framebuffers',
|
|
16
|
+
'QuerySets',
|
|
17
|
+
'Shaders',
|
|
18
|
+
'RenderPipelines',
|
|
19
|
+
'ComputePipelines',
|
|
20
|
+
'PipelineLayouts',
|
|
21
|
+
'VertexArrays',
|
|
22
|
+
'RenderPasss',
|
|
23
|
+
'ComputePasss',
|
|
24
|
+
'CommandEncoders',
|
|
25
|
+
'CommandBuffers'
|
|
26
|
+
];
|
|
27
|
+
const WEBGL_RESOURCE_COUNT_ORDER = [
|
|
28
|
+
'Resources',
|
|
29
|
+
'Buffers',
|
|
30
|
+
'Textures',
|
|
31
|
+
'Samplers',
|
|
32
|
+
'TextureViews',
|
|
33
|
+
'Framebuffers',
|
|
34
|
+
'QuerySets',
|
|
35
|
+
'Shaders',
|
|
36
|
+
'RenderPipelines',
|
|
37
|
+
'SharedRenderPipelines',
|
|
38
|
+
'ComputePipelines',
|
|
39
|
+
'PipelineLayouts',
|
|
40
|
+
'VertexArrays',
|
|
41
|
+
'RenderPasss',
|
|
42
|
+
'ComputePasss',
|
|
43
|
+
'CommandEncoders',
|
|
44
|
+
'CommandBuffers'
|
|
45
|
+
];
|
|
46
|
+
const BASE_RESOURCE_COUNT_STAT_ORDER = BASE_RESOURCE_COUNT_ORDER.flatMap(resourceType => [
|
|
47
|
+
`${resourceType} Created`,
|
|
48
|
+
`${resourceType} Active`
|
|
49
|
+
]);
|
|
50
|
+
const WEBGL_RESOURCE_COUNT_STAT_ORDER = WEBGL_RESOURCE_COUNT_ORDER.flatMap(resourceType => [
|
|
51
|
+
`${resourceType} Created`,
|
|
52
|
+
`${resourceType} Active`
|
|
53
|
+
]);
|
|
54
|
+
const ORDERED_STATS_CACHE = new WeakMap();
|
|
55
|
+
const ORDERED_STAT_NAME_SET_CACHE = new WeakMap();
|
|
5
56
|
/**
|
|
6
57
|
* Base class for GPU (WebGPU/WebGL) Resources
|
|
7
58
|
*/
|
|
@@ -27,6 +78,8 @@ export class Resource {
|
|
|
27
78
|
destroyed = false;
|
|
28
79
|
/** For resources that allocate GPU memory */
|
|
29
80
|
allocatedBytes = 0;
|
|
81
|
+
/** Stats bucket currently holding the tracked allocation */
|
|
82
|
+
allocatedBytesName = null;
|
|
30
83
|
/** Attached resources will be destroyed when this resource is destroyed. Tracks auto-created "sub" resources. */
|
|
31
84
|
_attachedResources = new Set();
|
|
32
85
|
/**
|
|
@@ -48,6 +101,9 @@ export class Resource {
|
|
|
48
101
|
* destroy can be called on any resource to release it before it is garbage collected.
|
|
49
102
|
*/
|
|
50
103
|
destroy() {
|
|
104
|
+
if (this.destroyed) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
51
107
|
this.destroyResource();
|
|
52
108
|
}
|
|
53
109
|
/** @deprecated Use destroy() */
|
|
@@ -86,7 +142,7 @@ export class Resource {
|
|
|
86
142
|
}
|
|
87
143
|
/** Destroy all owned resources. Make sure the resources are no longer needed before calling. */
|
|
88
144
|
destroyAttachedResources() {
|
|
89
|
-
for (const resource of
|
|
145
|
+
for (const resource of this._attachedResources) {
|
|
90
146
|
resource.destroy();
|
|
91
147
|
}
|
|
92
148
|
// don't remove while we are iterating
|
|
@@ -95,37 +151,111 @@ export class Resource {
|
|
|
95
151
|
// PROTECTED METHODS
|
|
96
152
|
/** Perform all destroy steps. Can be called by derived resources when overriding destroy() */
|
|
97
153
|
destroyResource() {
|
|
154
|
+
if (this.destroyed) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
98
157
|
this.destroyAttachedResources();
|
|
99
158
|
this.removeStats();
|
|
100
159
|
this.destroyed = true;
|
|
101
160
|
}
|
|
102
161
|
/** Called by .destroy() to track object destruction. Subclass must call if overriding destroy() */
|
|
103
162
|
removeStats() {
|
|
104
|
-
const
|
|
105
|
-
const
|
|
106
|
-
|
|
163
|
+
const profiler = getCpuHotspotProfiler(this._device);
|
|
164
|
+
const startTime = profiler ? getTimestamp() : 0;
|
|
165
|
+
const statsObjects = [
|
|
166
|
+
this._device.statsManager.getStats(RESOURCE_COUNTS_STATS),
|
|
167
|
+
this._device.statsManager.getStats(LEGACY_RESOURCE_COUNTS_STATS)
|
|
168
|
+
];
|
|
169
|
+
const orderedStatNames = getResourceCountStatOrder(this._device);
|
|
170
|
+
for (const stats of statsObjects) {
|
|
171
|
+
initializeStats(stats, orderedStatNames);
|
|
172
|
+
}
|
|
173
|
+
const name = this.getStatsName();
|
|
174
|
+
for (const stats of statsObjects) {
|
|
175
|
+
stats.get('Resources Active').decrementCount();
|
|
176
|
+
stats.get(`${name}s Active`).decrementCount();
|
|
177
|
+
}
|
|
178
|
+
if (profiler) {
|
|
179
|
+
profiler.statsBookkeepingCalls = (profiler.statsBookkeepingCalls || 0) + 1;
|
|
180
|
+
profiler.statsBookkeepingTimeMs =
|
|
181
|
+
(profiler.statsBookkeepingTimeMs || 0) + (getTimestamp() - startTime);
|
|
182
|
+
}
|
|
107
183
|
}
|
|
108
184
|
/** Called by subclass to track memory allocations */
|
|
109
|
-
trackAllocatedMemory(bytes, name = this
|
|
110
|
-
const
|
|
185
|
+
trackAllocatedMemory(bytes, name = this.getStatsName()) {
|
|
186
|
+
const profiler = getCpuHotspotProfiler(this._device);
|
|
187
|
+
const startTime = profiler ? getTimestamp() : 0;
|
|
188
|
+
const stats = this._device.statsManager.getStats(GPU_TIME_AND_MEMORY_STATS);
|
|
189
|
+
if (this.allocatedBytes > 0 && this.allocatedBytesName) {
|
|
190
|
+
stats.get('GPU Memory').subtractCount(this.allocatedBytes);
|
|
191
|
+
stats.get(`${this.allocatedBytesName} Memory`).subtractCount(this.allocatedBytes);
|
|
192
|
+
}
|
|
111
193
|
stats.get('GPU Memory').addCount(bytes);
|
|
112
194
|
stats.get(`${name} Memory`).addCount(bytes);
|
|
195
|
+
if (profiler) {
|
|
196
|
+
profiler.statsBookkeepingCalls = (profiler.statsBookkeepingCalls || 0) + 1;
|
|
197
|
+
profiler.statsBookkeepingTimeMs =
|
|
198
|
+
(profiler.statsBookkeepingTimeMs || 0) + (getTimestamp() - startTime);
|
|
199
|
+
}
|
|
113
200
|
this.allocatedBytes = bytes;
|
|
201
|
+
this.allocatedBytesName = name;
|
|
202
|
+
}
|
|
203
|
+
/** Called by subclass to track handle-backed memory allocations separately from owned allocations */
|
|
204
|
+
trackReferencedMemory(bytes, name = this.getStatsName()) {
|
|
205
|
+
this.trackAllocatedMemory(bytes, `Referenced ${name}`);
|
|
114
206
|
}
|
|
115
207
|
/** Called by subclass to track memory deallocations */
|
|
116
|
-
trackDeallocatedMemory(name = this
|
|
117
|
-
|
|
208
|
+
trackDeallocatedMemory(name = this.getStatsName()) {
|
|
209
|
+
if (this.allocatedBytes === 0) {
|
|
210
|
+
this.allocatedBytesName = null;
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
const profiler = getCpuHotspotProfiler(this._device);
|
|
214
|
+
const startTime = profiler ? getTimestamp() : 0;
|
|
215
|
+
const stats = this._device.statsManager.getStats(GPU_TIME_AND_MEMORY_STATS);
|
|
118
216
|
stats.get('GPU Memory').subtractCount(this.allocatedBytes);
|
|
119
|
-
stats.get(`${name} Memory`).subtractCount(this.allocatedBytes);
|
|
217
|
+
stats.get(`${this.allocatedBytesName || name} Memory`).subtractCount(this.allocatedBytes);
|
|
218
|
+
if (profiler) {
|
|
219
|
+
profiler.statsBookkeepingCalls = (profiler.statsBookkeepingCalls || 0) + 1;
|
|
220
|
+
profiler.statsBookkeepingTimeMs =
|
|
221
|
+
(profiler.statsBookkeepingTimeMs || 0) + (getTimestamp() - startTime);
|
|
222
|
+
}
|
|
120
223
|
this.allocatedBytes = 0;
|
|
224
|
+
this.allocatedBytesName = null;
|
|
225
|
+
}
|
|
226
|
+
/** Called by subclass to deallocate handle-backed memory tracked via trackReferencedMemory() */
|
|
227
|
+
trackDeallocatedReferencedMemory(name = this.getStatsName()) {
|
|
228
|
+
this.trackDeallocatedMemory(`Referenced ${name}`);
|
|
121
229
|
}
|
|
122
230
|
/** Called by resource constructor to track object creation */
|
|
123
231
|
addStats() {
|
|
124
|
-
const
|
|
125
|
-
const
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
232
|
+
const name = this.getStatsName();
|
|
233
|
+
const profiler = getCpuHotspotProfiler(this._device);
|
|
234
|
+
const startTime = profiler ? getTimestamp() : 0;
|
|
235
|
+
const statsObjects = [
|
|
236
|
+
this._device.statsManager.getStats(RESOURCE_COUNTS_STATS),
|
|
237
|
+
this._device.statsManager.getStats(LEGACY_RESOURCE_COUNTS_STATS)
|
|
238
|
+
];
|
|
239
|
+
const orderedStatNames = getResourceCountStatOrder(this._device);
|
|
240
|
+
for (const stats of statsObjects) {
|
|
241
|
+
initializeStats(stats, orderedStatNames);
|
|
242
|
+
}
|
|
243
|
+
for (const stats of statsObjects) {
|
|
244
|
+
stats.get('Resources Created').incrementCount();
|
|
245
|
+
stats.get('Resources Active').incrementCount();
|
|
246
|
+
stats.get(`${name}s Created`).incrementCount();
|
|
247
|
+
stats.get(`${name}s Active`).incrementCount();
|
|
248
|
+
}
|
|
249
|
+
if (profiler) {
|
|
250
|
+
profiler.statsBookkeepingCalls = (profiler.statsBookkeepingCalls || 0) + 1;
|
|
251
|
+
profiler.statsBookkeepingTimeMs =
|
|
252
|
+
(profiler.statsBookkeepingTimeMs || 0) + (getTimestamp() - startTime);
|
|
253
|
+
}
|
|
254
|
+
recordTransientCanvasResourceCreate(this._device, name);
|
|
255
|
+
}
|
|
256
|
+
/** Canonical resource name used for stats buckets. */
|
|
257
|
+
getStatsName() {
|
|
258
|
+
return getCanonicalResourceName(this);
|
|
129
259
|
}
|
|
130
260
|
}
|
|
131
261
|
/**
|
|
@@ -143,4 +273,100 @@ function selectivelyMerge(props, defaultProps) {
|
|
|
143
273
|
}
|
|
144
274
|
return mergedProps;
|
|
145
275
|
}
|
|
276
|
+
function initializeStats(stats, orderedStatNames) {
|
|
277
|
+
const statsMap = stats.stats;
|
|
278
|
+
let addedOrderedStat = false;
|
|
279
|
+
for (const statName of orderedStatNames) {
|
|
280
|
+
if (!statsMap[statName]) {
|
|
281
|
+
stats.get(statName);
|
|
282
|
+
addedOrderedStat = true;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
const statCount = Object.keys(statsMap).length;
|
|
286
|
+
const cachedStats = ORDERED_STATS_CACHE.get(stats);
|
|
287
|
+
if (!addedOrderedStat &&
|
|
288
|
+
cachedStats?.orderedStatNames === orderedStatNames &&
|
|
289
|
+
cachedStats.statCount === statCount) {
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
const reorderedStats = {};
|
|
293
|
+
let orderedStatNamesSet = ORDERED_STAT_NAME_SET_CACHE.get(orderedStatNames);
|
|
294
|
+
if (!orderedStatNamesSet) {
|
|
295
|
+
orderedStatNamesSet = new Set(orderedStatNames);
|
|
296
|
+
ORDERED_STAT_NAME_SET_CACHE.set(orderedStatNames, orderedStatNamesSet);
|
|
297
|
+
}
|
|
298
|
+
for (const statName of orderedStatNames) {
|
|
299
|
+
if (statsMap[statName]) {
|
|
300
|
+
reorderedStats[statName] = statsMap[statName];
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
for (const [statName, stat] of Object.entries(statsMap)) {
|
|
304
|
+
if (!orderedStatNamesSet.has(statName)) {
|
|
305
|
+
reorderedStats[statName] = stat;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
for (const statName of Object.keys(statsMap)) {
|
|
309
|
+
delete statsMap[statName];
|
|
310
|
+
}
|
|
311
|
+
Object.assign(statsMap, reorderedStats);
|
|
312
|
+
ORDERED_STATS_CACHE.set(stats, { orderedStatNames, statCount });
|
|
313
|
+
}
|
|
314
|
+
function getResourceCountStatOrder(device) {
|
|
315
|
+
return device.type === 'webgl' ? WEBGL_RESOURCE_COUNT_STAT_ORDER : BASE_RESOURCE_COUNT_STAT_ORDER;
|
|
316
|
+
}
|
|
317
|
+
function getCpuHotspotProfiler(device) {
|
|
318
|
+
const profiler = device.userData[CPU_HOTSPOT_PROFILER_MODULE];
|
|
319
|
+
return profiler?.enabled ? profiler : null;
|
|
320
|
+
}
|
|
321
|
+
function getTimestamp() {
|
|
322
|
+
return globalThis.performance?.now?.() ?? Date.now();
|
|
323
|
+
}
|
|
324
|
+
function recordTransientCanvasResourceCreate(device, name) {
|
|
325
|
+
const profiler = getCpuHotspotProfiler(device);
|
|
326
|
+
if (!profiler || !profiler.activeDefaultFramebufferAcquireDepth) {
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
329
|
+
profiler.transientCanvasResourceCreates = (profiler.transientCanvasResourceCreates || 0) + 1;
|
|
330
|
+
switch (name) {
|
|
331
|
+
case 'Texture':
|
|
332
|
+
profiler.transientCanvasTextureCreates = (profiler.transientCanvasTextureCreates || 0) + 1;
|
|
333
|
+
break;
|
|
334
|
+
case 'TextureView':
|
|
335
|
+
profiler.transientCanvasTextureViewCreates =
|
|
336
|
+
(profiler.transientCanvasTextureViewCreates || 0) + 1;
|
|
337
|
+
break;
|
|
338
|
+
case 'Sampler':
|
|
339
|
+
profiler.transientCanvasSamplerCreates = (profiler.transientCanvasSamplerCreates || 0) + 1;
|
|
340
|
+
break;
|
|
341
|
+
case 'Framebuffer':
|
|
342
|
+
profiler.transientCanvasFramebufferCreates =
|
|
343
|
+
(profiler.transientCanvasFramebufferCreates || 0) + 1;
|
|
344
|
+
break;
|
|
345
|
+
default:
|
|
346
|
+
break;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
function getCanonicalResourceName(resource) {
|
|
350
|
+
let prototype = Object.getPrototypeOf(resource);
|
|
351
|
+
while (prototype) {
|
|
352
|
+
const parentPrototype = Object.getPrototypeOf(prototype);
|
|
353
|
+
if (!parentPrototype || parentPrototype === Resource.prototype) {
|
|
354
|
+
return (getPrototypeToStringTag(prototype) ||
|
|
355
|
+
resource[Symbol.toStringTag] ||
|
|
356
|
+
resource.constructor.name);
|
|
357
|
+
}
|
|
358
|
+
prototype = parentPrototype;
|
|
359
|
+
}
|
|
360
|
+
return resource[Symbol.toStringTag] || resource.constructor.name;
|
|
361
|
+
}
|
|
362
|
+
function getPrototypeToStringTag(prototype) {
|
|
363
|
+
const descriptor = Object.getOwnPropertyDescriptor(prototype, Symbol.toStringTag);
|
|
364
|
+
if (typeof descriptor?.get === 'function') {
|
|
365
|
+
return descriptor.get.call(prototype);
|
|
366
|
+
}
|
|
367
|
+
if (typeof descriptor?.value === 'string') {
|
|
368
|
+
return descriptor.value;
|
|
369
|
+
}
|
|
370
|
+
return null;
|
|
371
|
+
}
|
|
146
372
|
//# sourceMappingURL=resource.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource.js","sourceRoot":"","sources":["../../../src/adapter/resources/resource.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAGpC,OAAO,EAAC,GAAG,EAAC,2BAAwB;AAWpC;;GAEG;AACH,MAAM,OAAgB,QAAQ;IAC5B,sCAAsC;IACtC,MAAM,CAAC,YAAY,GAA4B;QAC7C,EAAE,EAAE,WAAW;QACf,MAAM,EAAE,SAAS;QACjB,QAAQ,EAAE,SAAU;KACrB,CAAC;IAIF,QAAQ;QACN,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,IAAI,CAAC,WAAW,CAAC,IAAI,KAAK,IAAI,CAAC,EAAE,GAAG,CAAC;IAC7E,CAAC;IAED,+BAA+B;IAC/B,EAAE,CAAS;IACX,oDAAoD;IAC3C,KAAK,CAAkB;IAChC,qDAAqD;IAC5C,QAAQ,GAA4B,EAAE,CAAC;IAKhD,sFAAsF;IAC9E,OAAO,CAAS;IAExB,+CAA+C;IAC/C,SAAS,GAAY,KAAK,CAAC;IAC3B,6CAA6C;IACrC,cAAc,GAAW,CAAC,CAAC;IACnC,iHAAiH;IACzG,kBAAkB,GAAG,IAAI,GAAG,EAA2B,CAAC;IAEhE;;OAEG;IACH,YAAY,MAAc,EAAE,KAAY,EAAE,YAA6B;QACrE,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CAAC,WAAW,CAAC,CAAC;QAC/B,CAAC;QACD,IAAI,CAAC,OAAO,GAAG,MAAM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CAAC;IAC9B,CAAC;IAED,OAAO,QAAQ,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC;AACnE,CAAC;AAED,SAAS,uBAAuB,CAAC,SAAiB;IAChD,MAAM,UAAU,GAAG,MAAM,CAAC,wBAAwB,CAAC,SAAS,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;IAClF,IAAI,OAAO,UAAU,EAAE,GAAG,KAAK,UAAU,EAAE,CAAC;QAC1C,OAAO,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACxC,CAAC;IACD,IAAI,OAAO,UAAU,EAAE,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC1C,OAAO,UAAU,CAAC,KAAK,CAAC;IAC1B,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -69,35 +69,37 @@ export class Shader extends Resource {
|
|
|
69
69
|
}
|
|
70
70
|
const shaderName = shaderId; // getShaderName(this.source) || ;
|
|
71
71
|
const shaderTitle = `${this.stage} shader "${shaderName}"`;
|
|
72
|
-
|
|
72
|
+
const htmlLog = formatCompilerLog(messages, this.source, { showSourceCode: 'all', html: true });
|
|
73
73
|
// Show translated source if available
|
|
74
74
|
const translatedSource = this.getTranslatedSource();
|
|
75
|
+
const container = document.createElement('div');
|
|
76
|
+
container.innerHTML = `\
|
|
77
|
+
<h1>Compilation error in ${shaderTitle}</h1>
|
|
78
|
+
<div style="display:flex;position:fixed;top:10px;right:20px;gap:2px;">
|
|
79
|
+
<button id="copy">Copy source</button><br/>
|
|
80
|
+
<button id="close">Close</button>
|
|
81
|
+
</div>
|
|
82
|
+
<code><pre>${htmlLog}</pre></code>`;
|
|
75
83
|
if (translatedSource) {
|
|
76
|
-
|
|
84
|
+
container.innerHTML += `<br /><h1>Translated Source</h1><br /><br /><code><pre>${translatedSource}</pre></code>`;
|
|
77
85
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
button.
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
// TODO - add a small embedded copy button (instead of main button)
|
|
95
|
-
button.onclick = () => {
|
|
96
|
-
// const source = this.source.replaceAll('\n', '<br />');
|
|
97
|
-
const dataURI = `data:text/plain,${encodeURIComponent(this.source)}`;
|
|
98
|
-
navigator.clipboard.writeText(dataURI);
|
|
86
|
+
container.style.top = '0';
|
|
87
|
+
container.style.left = '0';
|
|
88
|
+
container.style.background = 'white';
|
|
89
|
+
container.style.position = 'fixed';
|
|
90
|
+
container.style.zIndex = '9999';
|
|
91
|
+
container.style.maxWidth = '100vw';
|
|
92
|
+
container.style.maxHeight = '100vh';
|
|
93
|
+
container.style.overflowY = 'auto';
|
|
94
|
+
document.body.appendChild(container);
|
|
95
|
+
const error = container.querySelector('.luma-compiler-log-error');
|
|
96
|
+
error?.scrollIntoView();
|
|
97
|
+
container.querySelector('button#close').onclick = () => {
|
|
98
|
+
container.remove();
|
|
99
|
+
};
|
|
100
|
+
container.querySelector('button#copy').onclick = () => {
|
|
101
|
+
navigator.clipboard.writeText(this.source);
|
|
99
102
|
};
|
|
100
|
-
// TODO - add a small embedded close button
|
|
101
103
|
}
|
|
102
104
|
static defaultProps = {
|
|
103
105
|
...Resource.defaultProps,
|
|
@@ -118,6 +120,6 @@ function getShaderIdFromProps(props) {
|
|
|
118
120
|
function getShaderName(shader, defaultName = 'unnamed') {
|
|
119
121
|
const SHADER_NAME_REGEXP = /#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/;
|
|
120
122
|
const match = SHADER_NAME_REGEXP.exec(shader);
|
|
121
|
-
return match
|
|
123
|
+
return match?.[1] ?? defaultName;
|
|
122
124
|
}
|
|
123
125
|
//# sourceMappingURL=shader.js.map
|