@luma.gl/webgpu 9.3.0-alpha.4 → 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/helpers/cpu-hotspot-profiler.d.ts +54 -0
- package/dist/adapter/helpers/cpu-hotspot-profiler.d.ts.map +1 -0
- package/dist/adapter/helpers/cpu-hotspot-profiler.js +26 -0
- package/dist/adapter/helpers/cpu-hotspot-profiler.js.map +1 -0
- package/dist/adapter/helpers/generate-mipmaps-webgpu.d.ts +7 -0
- package/dist/adapter/helpers/generate-mipmaps-webgpu.d.ts.map +1 -0
- package/dist/adapter/helpers/generate-mipmaps-webgpu.js +490 -0
- package/dist/adapter/helpers/generate-mipmaps-webgpu.js.map +1 -0
- package/dist/adapter/helpers/get-bind-group.d.ts +2 -1
- package/dist/adapter/helpers/get-bind-group.d.ts.map +1 -1
- package/dist/adapter/helpers/get-bind-group.js +22 -18
- package/dist/adapter/helpers/get-bind-group.js.map +1 -1
- package/dist/adapter/resources/webgpu-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-buffer.js +19 -3
- package/dist/adapter/resources/webgpu-buffer.js.map +1 -1
- package/dist/adapter/resources/webgpu-command-buffer.js +1 -1
- package/dist/adapter/resources/webgpu-command-buffer.js.map +1 -1
- package/dist/adapter/resources/webgpu-command-encoder.d.ts +5 -4
- package/dist/adapter/resources/webgpu-command-encoder.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-command-encoder.js +23 -5
- package/dist/adapter/resources/webgpu-command-encoder.js.map +1 -1
- package/dist/adapter/resources/webgpu-compute-pass.d.ts +1 -1
- package/dist/adapter/resources/webgpu-compute-pass.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-compute-pass.js +14 -6
- package/dist/adapter/resources/webgpu-compute-pass.js.map +1 -1
- package/dist/adapter/resources/webgpu-compute-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-compute-pipeline.js +19 -3
- package/dist/adapter/resources/webgpu-compute-pipeline.js.map +1 -1
- package/dist/adapter/resources/webgpu-framebuffer.d.ts +6 -0
- package/dist/adapter/resources/webgpu-framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-framebuffer.js +16 -0
- package/dist/adapter/resources/webgpu-framebuffer.js.map +1 -1
- package/dist/adapter/resources/webgpu-query-set.d.ts +33 -4
- package/dist/adapter/resources/webgpu-query-set.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-query-set.js +145 -4
- package/dist/adapter/resources/webgpu-query-set.js.map +1 -1
- package/dist/adapter/resources/webgpu-render-pass.d.ts +3 -0
- package/dist/adapter/resources/webgpu-render-pass.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-render-pass.js +74 -30
- package/dist/adapter/resources/webgpu-render-pass.js.map +1 -1
- package/dist/adapter/resources/webgpu-render-pipeline.d.ts +7 -4
- package/dist/adapter/resources/webgpu-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-render-pipeline.js +26 -15
- package/dist/adapter/resources/webgpu-render-pipeline.js.map +1 -1
- package/dist/adapter/resources/webgpu-sampler.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-sampler.js +4 -0
- package/dist/adapter/resources/webgpu-sampler.js.map +1 -1
- package/dist/adapter/resources/webgpu-texture-view.d.ts +6 -0
- package/dist/adapter/resources/webgpu-texture-view.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-texture-view.js +47 -11
- package/dist/adapter/resources/webgpu-texture-view.js.map +1 -1
- package/dist/adapter/resources/webgpu-texture.d.ts +10 -4
- package/dist/adapter/resources/webgpu-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-texture.js +116 -57
- package/dist/adapter/resources/webgpu-texture.js.map +1 -1
- package/dist/adapter/resources/webgpu-vertex-array.js +1 -1
- package/dist/adapter/resources/webgpu-vertex-array.js.map +1 -1
- package/dist/adapter/webgpu-canvas-context.d.ts +2 -0
- package/dist/adapter/webgpu-canvas-context.d.ts.map +1 -1
- package/dist/adapter/webgpu-canvas-context.js +78 -19
- package/dist/adapter/webgpu-canvas-context.js.map +1 -1
- package/dist/adapter/webgpu-device.d.ts +5 -1
- package/dist/adapter/webgpu-device.d.ts.map +1 -1
- package/dist/adapter/webgpu-device.js +113 -9
- package/dist/adapter/webgpu-device.js.map +1 -1
- package/dist/adapter/webgpu-presentation-context.d.ts +25 -0
- package/dist/adapter/webgpu-presentation-context.d.ts.map +1 -0
- package/dist/adapter/webgpu-presentation-context.js +144 -0
- package/dist/adapter/webgpu-presentation-context.js.map +1 -0
- package/dist/dist.dev.js +2815 -1681
- package/dist/dist.min.js +167 -8
- package/dist/index.cjs +1314 -199
- package/dist/index.cjs.map +4 -4
- package/package.json +4 -4
- package/src/adapter/helpers/cpu-hotspot-profiler.ts +70 -0
- package/src/adapter/helpers/generate-mipmaps-webgpu.ts +583 -0
- package/src/adapter/helpers/get-bind-group.ts +26 -24
- package/src/adapter/resources/webgpu-buffer.ts +18 -3
- package/src/adapter/resources/webgpu-command-buffer.ts +1 -1
- package/src/adapter/resources/webgpu-command-encoder.ts +32 -6
- package/src/adapter/resources/webgpu-compute-pass.ts +14 -6
- package/src/adapter/resources/webgpu-compute-pipeline.ts +21 -3
- package/src/adapter/resources/webgpu-framebuffer.ts +21 -0
- package/src/adapter/resources/webgpu-query-set.ts +185 -9
- package/src/adapter/resources/webgpu-render-pass.ts +82 -34
- package/src/adapter/resources/webgpu-render-pipeline.ts +36 -19
- package/src/adapter/resources/webgpu-sampler.ts +5 -0
- package/src/adapter/resources/webgpu-texture-view.ts +51 -11
- package/src/adapter/resources/webgpu-texture.ts +142 -93
- package/src/adapter/resources/webgpu-vertex-array.ts +1 -1
- package/src/adapter/webgpu-canvas-context.ts +91 -26
- package/src/adapter/webgpu-device.ts +128 -9
- package/src/adapter/webgpu-presentation-context.ts +180 -0
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
import { TextureView } from '@luma.gl/core';
|
|
5
|
+
import { getCpuHotspotProfiler, getTimestamp } from "../helpers/cpu-hotspot-profiler.js";
|
|
5
6
|
/**
|
|
6
7
|
*
|
|
7
8
|
*/
|
|
@@ -14,17 +15,15 @@ export class WebGPUTextureView extends TextureView {
|
|
|
14
15
|
this.device = device;
|
|
15
16
|
this.texture = props.texture;
|
|
16
17
|
this.device.pushErrorScope('validation');
|
|
17
|
-
this.handle =
|
|
18
|
-
|
|
19
|
-
this.texture.
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
arrayLayerCount: this.props.arrayLayerCount
|
|
27
|
-
});
|
|
18
|
+
this.handle = this.texture.handle.createView({
|
|
19
|
+
format: (this.props.format || this.texture.format),
|
|
20
|
+
dimension: this.props.dimension || this.texture.dimension,
|
|
21
|
+
aspect: this.props.aspect,
|
|
22
|
+
baseMipLevel: this.props.baseMipLevel,
|
|
23
|
+
mipLevelCount: this.props.mipLevelCount,
|
|
24
|
+
baseArrayLayer: this.props.baseArrayLayer,
|
|
25
|
+
arrayLayerCount: this.props.arrayLayerCount
|
|
26
|
+
});
|
|
28
27
|
this.device.popErrorScope((error) => {
|
|
29
28
|
this.device.reportError(new Error(`TextureView constructor: ${error.message}`), this)();
|
|
30
29
|
this.device.debug();
|
|
@@ -32,10 +31,47 @@ export class WebGPUTextureView extends TextureView {
|
|
|
32
31
|
this.handle.label = this.props.id;
|
|
33
32
|
}
|
|
34
33
|
destroy() {
|
|
34
|
+
if (this.destroyed) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
this.destroyResource();
|
|
35
38
|
// GPUTextureView does not have a destroy method
|
|
36
39
|
// this.handle.destroy();
|
|
37
40
|
// @ts-expect-error readonly
|
|
38
41
|
this.handle = null;
|
|
39
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Internal-only hook for the cached CanvasContext/PresentationContext swapchain path.
|
|
45
|
+
* Rebuilds the default view when the per-frame canvas texture handle changes, without
|
|
46
|
+
* replacing the long-lived luma.gl wrapper object.
|
|
47
|
+
*/
|
|
48
|
+
_reinitialize(texture) {
|
|
49
|
+
// @ts-expect-error readonly
|
|
50
|
+
this.texture = texture;
|
|
51
|
+
const profiler = getCpuHotspotProfiler(this.device);
|
|
52
|
+
this.device.pushErrorScope('validation');
|
|
53
|
+
const createViewStartTime = profiler ? getTimestamp() : 0;
|
|
54
|
+
const handle = this.texture.handle.createView({
|
|
55
|
+
format: (this.props.format || this.texture.format),
|
|
56
|
+
dimension: this.props.dimension || this.texture.dimension,
|
|
57
|
+
aspect: this.props.aspect,
|
|
58
|
+
baseMipLevel: this.props.baseMipLevel,
|
|
59
|
+
mipLevelCount: this.props.mipLevelCount,
|
|
60
|
+
baseArrayLayer: this.props.baseArrayLayer,
|
|
61
|
+
arrayLayerCount: this.props.arrayLayerCount
|
|
62
|
+
});
|
|
63
|
+
if (profiler) {
|
|
64
|
+
profiler.textureViewReinitializeCount = (profiler.textureViewReinitializeCount || 0) + 1;
|
|
65
|
+
profiler.textureViewReinitializeTimeMs =
|
|
66
|
+
(profiler.textureViewReinitializeTimeMs || 0) + (getTimestamp() - createViewStartTime);
|
|
67
|
+
}
|
|
68
|
+
this.device.popErrorScope((error) => {
|
|
69
|
+
this.device.reportError(new Error(`TextureView constructor: ${error.message}`), this)();
|
|
70
|
+
this.device.debug();
|
|
71
|
+
});
|
|
72
|
+
handle.label = this.props.id;
|
|
73
|
+
// @ts-expect-error readonly
|
|
74
|
+
this.handle = handle;
|
|
75
|
+
}
|
|
40
76
|
}
|
|
41
77
|
//# sourceMappingURL=webgpu-texture-view.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgpu-texture-view.js","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-texture-view.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAEpC,OAAO,E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I,CAAC,KAAK,CAAC,cAAc;YACzC,eAAe,EAAE,IAAI,CAAC,KAAK,CAAC,eAAe;SAC5C,CAAC,CAAC;QACH,IAAI,QAAQ,EAAE,CAAC;YACb,QAAQ,CAAC,4BAA4B,GAAG,CAAC,QAAQ,CAAC,4BAA4B,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;YACzF,QAAQ,CAAC,6BAA6B;gBACpC,CAAC,QAAQ,CAAC,6BAA6B,IAAI,CAAC,CAAC,GAAG,CAAC,YAAY,EAAE,GAAG,mBAAmB,CAAC,CAAC;QAC3F,CAAC;QACD,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,KAAe,EAAE,EAAE;YAC5C,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,KAAK,CAAC,4BAA4B,KAAK,CAAC,OAAO,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,CAAC;YACxF,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QACtB,CAAC,CAAC,CAAC;QAEH,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QAC7B,4BAA4B;QAC5B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type TextureProps, type TextureViewProps, type CopyExternalImageOptions, type
|
|
1
|
+
import { type TextureProps, type TextureViewProps, type CopyExternalImageOptions, type TextureReadOptions, type TextureWriteOptions, Buffer, Texture } from '@luma.gl/core';
|
|
2
2
|
import type { WebGPUDevice } from "../webgpu-device.js";
|
|
3
3
|
import { WebGPUSampler } from "./webgpu-sampler.js";
|
|
4
4
|
import { WebGPUTextureView } from "./webgpu-texture-view.js";
|
|
@@ -8,6 +8,7 @@ export declare class WebGPUTexture extends Texture {
|
|
|
8
8
|
readonly handle: GPUTexture;
|
|
9
9
|
sampler: WebGPUSampler;
|
|
10
10
|
view: WebGPUTextureView;
|
|
11
|
+
private _allocatedByteLength;
|
|
11
12
|
constructor(device: WebGPUDevice, props: TextureProps);
|
|
12
13
|
destroy(): void;
|
|
13
14
|
createView(props: TextureViewProps): WebGPUTextureView;
|
|
@@ -15,7 +16,6 @@ export declare class WebGPUTexture extends Texture {
|
|
|
15
16
|
width: number;
|
|
16
17
|
height: number;
|
|
17
18
|
};
|
|
18
|
-
copyImageData(options_: CopyImageDataOptions): void;
|
|
19
19
|
generateMipmapsWebGL(): void;
|
|
20
20
|
getImageDataLayout(options: TextureReadOptions): {
|
|
21
21
|
byteLength: number;
|
|
@@ -24,7 +24,13 @@ export declare class WebGPUTexture extends Texture {
|
|
|
24
24
|
};
|
|
25
25
|
readBuffer(options?: TextureReadOptions, buffer?: Buffer): Buffer;
|
|
26
26
|
readDataAsync(options?: TextureReadOptions): Promise<ArrayBuffer>;
|
|
27
|
-
writeBuffer(buffer: Buffer,
|
|
28
|
-
writeData(data: ArrayBuffer | ArrayBufferView,
|
|
27
|
+
writeBuffer(buffer: Buffer, options_?: TextureWriteOptions): void;
|
|
28
|
+
writeData(data: ArrayBuffer | SharedArrayBuffer | ArrayBufferView, options_?: TextureWriteOptions): void;
|
|
29
|
+
/**
|
|
30
|
+
* Internal-only hook for the cached CanvasContext/PresentationContext swapchain path.
|
|
31
|
+
* Rebinds this handle-backed texture wrapper to the current per-frame canvas texture
|
|
32
|
+
* without allocating a new luma.gl Texture or TextureView wrapper.
|
|
33
|
+
*/
|
|
34
|
+
_reinitialize(handle: GPUTexture, props?: Partial<TextureProps>): void;
|
|
29
35
|
}
|
|
30
36
|
//# sourceMappingURL=webgpu-texture.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgpu-texture.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-texture.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,wBAAwB,EAC7B,KAAK,
|
|
1
|
+
{"version":3,"file":"web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D,SAAS,CAChB,IAAI,EAAE,WAAW,GAAG,iBAAiB,GAAG,eAAe,EACvD,QAAQ,GAAE,mBAAwB,GACjC,IAAI;IAgDP;;;;OAIG;IACH,aAAa,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,IAAI;CAmDvE"}
|
|
@@ -9,9 +9,21 @@ export class WebGPUTexture extends Texture {
|
|
|
9
9
|
handle;
|
|
10
10
|
sampler;
|
|
11
11
|
view;
|
|
12
|
+
_allocatedByteLength = 0;
|
|
12
13
|
constructor(device, props) {
|
|
13
|
-
|
|
14
|
+
// WebGPU buffer copies use 256-byte row alignment. queue.writeTexture() can use tightly packed rows.
|
|
15
|
+
super(device, props, { byteAlignment: 256 });
|
|
14
16
|
this.device = device;
|
|
17
|
+
if (props.sampler instanceof WebGPUSampler) {
|
|
18
|
+
this.sampler = props.sampler;
|
|
19
|
+
}
|
|
20
|
+
else if (props.sampler === undefined) {
|
|
21
|
+
this.sampler = this.device.getDefaultSampler();
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
this.sampler = new WebGPUSampler(this.device, props.sampler || {});
|
|
25
|
+
this.attachResource(this.sampler);
|
|
26
|
+
}
|
|
15
27
|
this.device.pushErrorScope('out-of-memory');
|
|
16
28
|
this.device.pushErrorScope('validation');
|
|
17
29
|
this.handle =
|
|
@@ -37,8 +49,6 @@ export class WebGPUTexture extends Texture {
|
|
|
37
49
|
this.device.reportError(new Error(`${this} out of memory: ${error.message}`), this)();
|
|
38
50
|
this.device.debug();
|
|
39
51
|
});
|
|
40
|
-
// Update props if external handle was supplied - used mainly by CanvasContext.getDefaultFramebuffer()
|
|
41
|
-
// TODO - Read all properties directly from the supplied handle?
|
|
42
52
|
if (this.props.handle) {
|
|
43
53
|
this.handle.label ||= this.id;
|
|
44
54
|
// @ts-expect-error readonly
|
|
@@ -46,10 +56,6 @@ export class WebGPUTexture extends Texture {
|
|
|
46
56
|
// @ts-expect-error readonly
|
|
47
57
|
this.height = this.handle.height;
|
|
48
58
|
}
|
|
49
|
-
this.sampler =
|
|
50
|
-
props.sampler instanceof WebGPUSampler
|
|
51
|
-
? props.sampler
|
|
52
|
-
: new WebGPUSampler(this.device, props.sampler || {});
|
|
53
59
|
this.view = new WebGPUTextureView(this.device, {
|
|
54
60
|
...this.props,
|
|
55
61
|
texture: this,
|
|
@@ -57,12 +63,30 @@ export class WebGPUTexture extends Texture {
|
|
|
57
63
|
// Note: arrayLayerCount controls the view of array textures, but does not apply to 3d texture depths
|
|
58
64
|
arrayLayerCount: this.dimension !== '3d' ? this.depth : 1
|
|
59
65
|
});
|
|
66
|
+
this.attachResource(this.view);
|
|
60
67
|
// Set initial data
|
|
61
68
|
// Texture base class strips out the data prop from this.props, so we need to handle it here
|
|
62
69
|
this._initializeData(props.data);
|
|
70
|
+
this._allocatedByteLength = this.getAllocatedByteLength();
|
|
71
|
+
if (!this.props.handle) {
|
|
72
|
+
this.trackAllocatedMemory(this._allocatedByteLength, 'Texture');
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
this.trackReferencedMemory(this._allocatedByteLength, 'Texture');
|
|
76
|
+
}
|
|
63
77
|
}
|
|
64
78
|
destroy() {
|
|
65
|
-
this.
|
|
79
|
+
if (this.destroyed) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
if (!this.props.handle && this.handle) {
|
|
83
|
+
this.trackDeallocatedMemory('Texture');
|
|
84
|
+
this.handle.destroy();
|
|
85
|
+
}
|
|
86
|
+
else if (this.handle) {
|
|
87
|
+
this.trackDeallocatedReferencedMemory('Texture');
|
|
88
|
+
}
|
|
89
|
+
this.destroyResource();
|
|
66
90
|
// @ts-expect-error readonly
|
|
67
91
|
this.handle = null;
|
|
68
92
|
}
|
|
@@ -98,35 +122,6 @@ export class WebGPUTexture extends Texture {
|
|
|
98
122
|
// TODO - should these be clipped to the texture size minus x,y,z?
|
|
99
123
|
return { width: options.width, height: options.height };
|
|
100
124
|
}
|
|
101
|
-
copyImageData(options_) {
|
|
102
|
-
const { width, height, depth } = this;
|
|
103
|
-
const options = this._normalizeCopyImageDataOptions(options_);
|
|
104
|
-
this.device.pushErrorScope('validation');
|
|
105
|
-
this.device.handle.queue.writeTexture(
|
|
106
|
-
// destination: GPUImageCopyTexture
|
|
107
|
-
{
|
|
108
|
-
// texture subresource
|
|
109
|
-
texture: this.handle,
|
|
110
|
-
mipLevel: options.mipLevel,
|
|
111
|
-
aspect: options.aspect,
|
|
112
|
-
// origin to write to
|
|
113
|
-
origin: [options.x, options.y, options.z]
|
|
114
|
-
},
|
|
115
|
-
// data
|
|
116
|
-
options.data,
|
|
117
|
-
// dataLayout: GPUImageDataLayout
|
|
118
|
-
{
|
|
119
|
-
offset: options.byteOffset,
|
|
120
|
-
bytesPerRow: options.bytesPerRow,
|
|
121
|
-
rowsPerImage: options.rowsPerImage
|
|
122
|
-
},
|
|
123
|
-
// size: GPUExtent3D - extents of the content to write
|
|
124
|
-
[width, height, depth]);
|
|
125
|
-
this.device.popErrorScope((error) => {
|
|
126
|
-
this.device.reportError(new Error(`copyImageData: ${error.message}`), this)();
|
|
127
|
-
this.device.debug();
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
125
|
generateMipmapsWebGL() {
|
|
131
126
|
log.warn(`${this}: generateMipmaps not supported in WebGPU`)();
|
|
132
127
|
}
|
|
@@ -138,8 +133,8 @@ export class WebGPUTexture extends Texture {
|
|
|
138
133
|
};
|
|
139
134
|
}
|
|
140
135
|
readBuffer(options = {}, buffer) {
|
|
141
|
-
const { x
|
|
142
|
-
const layout = this.computeMemoryLayout(
|
|
136
|
+
const { x, y, z, width, height, depthOrArrayLayers, mipLevel, aspect } = this._getSupportedColorReadOptions(options);
|
|
137
|
+
const layout = this.computeMemoryLayout({ x, y, z, width, height, depthOrArrayLayers, mipLevel });
|
|
143
138
|
const { bytesPerRow, rowsPerImage, byteLength } = layout;
|
|
144
139
|
// Create a GPUBuffer to hold the copied pixel data.
|
|
145
140
|
const readBuffer = buffer ||
|
|
@@ -147,6 +142,9 @@ export class WebGPUTexture extends Texture {
|
|
|
147
142
|
byteLength,
|
|
148
143
|
usage: Buffer.COPY_DST | Buffer.MAP_READ
|
|
149
144
|
});
|
|
145
|
+
if (readBuffer.byteLength < byteLength) {
|
|
146
|
+
throw new Error(`${this} readBuffer target is too small (${readBuffer.byteLength} < ${byteLength})`);
|
|
147
|
+
}
|
|
150
148
|
const gpuReadBuffer = readBuffer.handle;
|
|
151
149
|
// Record commands to copy from the texture to the buffer.
|
|
152
150
|
const gpuDevice = this.device.handle;
|
|
@@ -191,18 +189,15 @@ export class WebGPUTexture extends Texture {
|
|
|
191
189
|
buffer.destroy();
|
|
192
190
|
return data.buffer;
|
|
193
191
|
}
|
|
194
|
-
writeBuffer(buffer,
|
|
195
|
-
const
|
|
196
|
-
const
|
|
197
|
-
// Get the data on the CPU.
|
|
198
|
-
// await buffer.mapAndReadAsync();
|
|
199
|
-
const { bytesPerRow, rowsPerImage } = layout;
|
|
192
|
+
writeBuffer(buffer, options_ = {}) {
|
|
193
|
+
const options = this._normalizeTextureWriteOptions(options_);
|
|
194
|
+
const { x, y, z, width, height, depthOrArrayLayers, mipLevel, aspect, byteOffset, bytesPerRow, rowsPerImage } = options;
|
|
200
195
|
const gpuDevice = this.device.handle;
|
|
201
196
|
this.device.pushErrorScope('validation');
|
|
202
197
|
const commandEncoder = gpuDevice.createCommandEncoder();
|
|
203
198
|
commandEncoder.copyBufferToTexture({
|
|
204
199
|
buffer: buffer.handle,
|
|
205
|
-
offset:
|
|
200
|
+
offset: byteOffset,
|
|
206
201
|
bytesPerRow,
|
|
207
202
|
rowsPerImage
|
|
208
203
|
}, {
|
|
@@ -218,32 +213,96 @@ export class WebGPUTexture extends Texture {
|
|
|
218
213
|
this.device.debug();
|
|
219
214
|
});
|
|
220
215
|
}
|
|
221
|
-
writeData(data,
|
|
216
|
+
writeData(data, options_ = {}) {
|
|
222
217
|
const device = this.device;
|
|
223
|
-
const
|
|
224
|
-
const
|
|
218
|
+
const options = this._normalizeTextureWriteOptions(options_);
|
|
219
|
+
const { x, y, z, width, height, depthOrArrayLayers, mipLevel, aspect, byteOffset } = options;
|
|
220
|
+
const source = data;
|
|
221
|
+
const formatInfo = this.device.getTextureFormatInfo(this.format);
|
|
222
|
+
// queue.writeTexture() defaults to tightly packed rows, unlike WebGPU buffer copy paths.
|
|
223
|
+
const packedSourceLayout = textureFormatDecoder.computeMemoryLayout({
|
|
225
224
|
format: this.format,
|
|
226
|
-
width
|
|
227
|
-
height
|
|
228
|
-
depth:
|
|
229
|
-
byteAlignment:
|
|
225
|
+
width,
|
|
226
|
+
height,
|
|
227
|
+
depth: depthOrArrayLayers,
|
|
228
|
+
byteAlignment: 1
|
|
230
229
|
});
|
|
231
|
-
const
|
|
230
|
+
const bytesPerRow = options_.bytesPerRow ?? packedSourceLayout.bytesPerRow;
|
|
231
|
+
const rowsPerImage = options_.rowsPerImage ?? packedSourceLayout.rowsPerImage;
|
|
232
|
+
let copyWidth = width;
|
|
233
|
+
let copyHeight = height;
|
|
234
|
+
if (formatInfo.compressed) {
|
|
235
|
+
const blockWidth = formatInfo.blockWidth || 1;
|
|
236
|
+
const blockHeight = formatInfo.blockHeight || 1;
|
|
237
|
+
copyWidth = Math.ceil(width / blockWidth) * blockWidth;
|
|
238
|
+
copyHeight = Math.ceil(height / blockHeight) * blockHeight;
|
|
239
|
+
}
|
|
232
240
|
this.device.pushErrorScope('validation');
|
|
233
241
|
device.handle.queue.writeTexture({
|
|
234
242
|
texture: this.handle,
|
|
235
243
|
mipLevel,
|
|
236
244
|
aspect,
|
|
237
245
|
origin: { x, y, z }
|
|
238
|
-
},
|
|
239
|
-
offset:
|
|
246
|
+
}, source, {
|
|
247
|
+
offset: byteOffset,
|
|
240
248
|
bytesPerRow,
|
|
241
249
|
rowsPerImage
|
|
242
|
-
}, { width, height, depthOrArrayLayers });
|
|
250
|
+
}, { width: copyWidth, height: copyHeight, depthOrArrayLayers });
|
|
243
251
|
this.device.popErrorScope((error) => {
|
|
244
252
|
this.device.reportError(new Error(`${this} writeData: ${error.message}`), this)();
|
|
245
253
|
this.device.debug();
|
|
246
254
|
});
|
|
247
255
|
}
|
|
256
|
+
/**
|
|
257
|
+
* Internal-only hook for the cached CanvasContext/PresentationContext swapchain path.
|
|
258
|
+
* Rebinds this handle-backed texture wrapper to the current per-frame canvas texture
|
|
259
|
+
* without allocating a new luma.gl Texture or TextureView wrapper.
|
|
260
|
+
*/
|
|
261
|
+
_reinitialize(handle, props) {
|
|
262
|
+
const nextWidth = props?.width ?? handle.width ?? this.width;
|
|
263
|
+
const nextHeight = props?.height ?? handle.height ?? this.height;
|
|
264
|
+
const nextDepth = props?.depth ?? this.depth;
|
|
265
|
+
const nextFormat = props?.format ?? this.format;
|
|
266
|
+
const allocationMayHaveChanged = nextWidth !== this.width ||
|
|
267
|
+
nextHeight !== this.height ||
|
|
268
|
+
nextDepth !== this.depth ||
|
|
269
|
+
nextFormat !== this.format;
|
|
270
|
+
handle.label ||= this.id;
|
|
271
|
+
// @ts-expect-error readonly
|
|
272
|
+
this.handle = handle;
|
|
273
|
+
// @ts-expect-error readonly
|
|
274
|
+
this.width = nextWidth;
|
|
275
|
+
// @ts-expect-error readonly
|
|
276
|
+
this.height = nextHeight;
|
|
277
|
+
if (props?.depth !== undefined) {
|
|
278
|
+
// @ts-expect-error readonly
|
|
279
|
+
this.depth = nextDepth;
|
|
280
|
+
}
|
|
281
|
+
if (props?.format !== undefined) {
|
|
282
|
+
// @ts-expect-error readonly
|
|
283
|
+
this.format = nextFormat;
|
|
284
|
+
}
|
|
285
|
+
this.props.handle = handle;
|
|
286
|
+
if (props?.width !== undefined) {
|
|
287
|
+
this.props.width = props.width;
|
|
288
|
+
}
|
|
289
|
+
if (props?.height !== undefined) {
|
|
290
|
+
this.props.height = props.height;
|
|
291
|
+
}
|
|
292
|
+
if (props?.depth !== undefined) {
|
|
293
|
+
this.props.depth = props.depth;
|
|
294
|
+
}
|
|
295
|
+
if (props?.format !== undefined) {
|
|
296
|
+
this.props.format = props.format;
|
|
297
|
+
}
|
|
298
|
+
if (allocationMayHaveChanged) {
|
|
299
|
+
const nextAllocation = this.getAllocatedByteLength();
|
|
300
|
+
if (nextAllocation !== this._allocatedByteLength) {
|
|
301
|
+
this._allocatedByteLength = nextAllocation;
|
|
302
|
+
this.trackReferencedMemory(nextAllocation, 'Texture');
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
this.view._reinitialize(this);
|
|
306
|
+
}
|
|
248
307
|
}
|
|
249
308
|
//# sourceMappingURL=webgpu-texture.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgpu-texture.js","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-texture.ts"],"names":[],"mappings":"AAAA,uBAAuB;AACvB,OAAO,EAQL,MAAM,EACN,OAAO,EACP,GAAG,EACH,oBAAoB,EACrB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAC,sBAAsB,EAAC,6CAA0C;AAEzE,OAAO,EAAC,aAAa,EAAC,4BAAyB;AAC/C,OAAO,EAAC,iBAAiB,EAAC,iCAA8B;AAExD,iEAAiE;AACjE,MAAM,OAAO,aAAc,SAAQ,OAAO;IAC/B,MAAM,CAAe;IACrB,MAAM,CAAa;IAC5B,OAAO,CAAgB;IACvB,IAAI,CAAoB;IAExB,YAAY,MAAoB,EAAE,KAAmB;QACnD,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,EAAC,aAAa,EAAE,GAAG,EAAC,CAAC,CAAC,CAAC,0DAA0D;QACtG,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAErB,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,eAAe,CAAC,CAAC;QAC5C,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC;QAEzC,IAAI,CAAC,MAAM;YACT,IAAI,CAAC,KAAK,CAAC,MAAM;gBACjB,IAAI,CAAC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AAc,EAAE,SAAS,CAAC,CAAC;YACxD,CAAC;QACH,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;CACF"}
|
|
@@ -6,7 +6,7 @@ import { getBrowser } from '@probe.gl/env';
|
|
|
6
6
|
/** VertexArrayObject wrapper */
|
|
7
7
|
export class WebGPUVertexArray extends VertexArray {
|
|
8
8
|
get [Symbol.toStringTag]() {
|
|
9
|
-
return '
|
|
9
|
+
return 'VertexArray';
|
|
10
10
|
}
|
|
11
11
|
device;
|
|
12
12
|
/** Vertex Array is just a helper class under WebGPU */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgpu-vertex-array.js","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-vertex-array.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAGpC,OAAO,EAAC,WAAW,EAAE,GAAG,EAAC,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;AAOzC,gCAAgC;AAChC,MAAM,OAAO,iBAAkB,SAAQ,WAAW;IAChD,IAAa,CAAC,MAAM,CAAC,WAAW,CAAC;QAC/B,OAAO,
|
|
1
|
+
{"version":3,"file":"webgpu-vertex-array.js","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-vertex-array.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAGpC,OAAO,EAAC,WAAW,EAAE,GAAG,EAAC,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;AAOzC,gCAAgC;AAChC,MAAM,OAAO,iBAAkB,SAAQ,WAAW;IAChD,IAAa,CAAC,MAAM,CAAC,WAAW,CAAC;QAC/B,OAAO,aAAa,CAAC;IACvB,CAAC;IAEQ,MAAM,CAAe;IAC9B,uDAAuD;IAC9C,MAAM,GAAG,IAAI,CAAC;IAE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M,CAAC,EAAE,CAAC;gBACzE,gBAAgB,CAAC,MAAM,CAAC,eAAe,CAAC,QAAQ,EAAE,YAAY,EAAE,MAAM,CAAC,CAAC;YAC1E,CAAC;QACH,CAAC;QACD,oFAAoF;IACtF,CAAC;IAEQ,iBAAiB,CAAC,UAAsB;QAC/C,qCAAqC;QACrC,mFAAmF;QACnF,4EAA4E;IAC9E,CAAC;IAED,qBAAqB;IAErB;;;OAGG;IACH,MAAM,CAAC,gCAAgC,CAAC,MAAc;QACpD,OAAO,UAAU,EAAE,KAAK,QAAQ,CAAC;IACnC,CAAC;CACF"}
|
|
@@ -11,7 +11,9 @@ import { WebGPUTexture } from "./resources/webgpu-texture.js";
|
|
|
11
11
|
export declare class WebGPUCanvasContext extends CanvasContext {
|
|
12
12
|
readonly device: WebGPUDevice;
|
|
13
13
|
readonly handle: GPUCanvasContext;
|
|
14
|
+
private colorAttachment;
|
|
14
15
|
private depthStencilAttachment;
|
|
16
|
+
private framebuffer;
|
|
15
17
|
get [Symbol.toStringTag](): string;
|
|
16
18
|
constructor(device: WebGPUDevice, adapter: GPUAdapter, props: CanvasContextProps);
|
|
17
19
|
/** Destroy any textures produced while configured and remove the context configuration. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgpu-canvas-context.d.ts","sourceRoot":"","sources":["../../src/adapter/webgpu-canvas-context.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAC,yBAAyB,EAAE,kBAAkB,EAAC,MAAM,eAAe,CAAC;AACjF,OAAO,EAAC,aAAa,EAAe,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAC,YAAY,EAAC,2BAAwB;AAC7C,OAAO,EAAC,iBAAiB,EAAC,0CAAuC;AACjE,OAAO,EAAC,aAAa,EAAC,sCAAmC;
|
|
1
|
+
{"version":3,"file":"webgpu-canvas-context.d.ts","sourceRoot":"","sources":["../../src/adapter/webgpu-canvas-context.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAC,yBAAyB,EAAE,kBAAkB,EAAC,MAAM,eAAe,CAAC;AACjF,OAAO,EAAC,aAAa,EAAe,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAC,YAAY,EAAC,2BAAwB;AAC7C,OAAO,EAAC,iBAAiB,EAAC,0CAAuC;AACjE,OAAO,EAAC,aAAa,EAAC,sCAAmC;AAGzD;;;;GAIG;AACH,qBAAa,mBAAoB,SAAQ,aAAa;IACpD,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC;IAElC,OAAO,CAAC,eAAe,CAA8B;IACrD,OAAO,CAAC,sBAAsB,CAA8B;IAC5D,OAAO,CAAC,WAAW,CAAkC;IAErD,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,MAAM,CAEjC;gBAEW,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,kBAAkB;IAgBhF,2FAA2F;IAClF,OAAO,IAAI,IAAI;IAmBxB,8DAA8D;IAC9D,gBAAgB,IAAI,IAAI;IAmBxB,0EAA0E;IAC1E,sBAAsB,CACpB,OAAO,GAAE;QAAC,kBAAkB,CAAC,EAAE,yBAAyB,GAAG,KAAK,CAAA;KAE/D,GACA,iBAAiB;IAqDpB,mEAAmE;IACnE,kBAAkB,IAAI,aAAa;IA6BnC,8FAA8F;IAC9F,6BAA6B,CAAC,kBAAkB,EAAE,yBAAyB,GAAG,aAAa;CAkB5F"}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
import { CanvasContext, Texture, log } from '@luma.gl/core';
|
|
5
5
|
import { WebGPUFramebuffer } from "./resources/webgpu-framebuffer.js";
|
|
6
|
+
import { getCpuHotspotProfiler, getTimestamp } from "./helpers/cpu-hotspot-profiler.js";
|
|
6
7
|
/**
|
|
7
8
|
* Holds a WebGPU Canvas Context
|
|
8
9
|
* The primary job of the CanvasContext is to generate textures for rendering into the current canvas
|
|
@@ -11,7 +12,9 @@ import { WebGPUFramebuffer } from "./resources/webgpu-framebuffer.js";
|
|
|
11
12
|
export class WebGPUCanvasContext extends CanvasContext {
|
|
12
13
|
device;
|
|
13
14
|
handle;
|
|
15
|
+
colorAttachment = null;
|
|
14
16
|
depthStencilAttachment = null;
|
|
17
|
+
framebuffer = null;
|
|
15
18
|
get [Symbol.toStringTag]() {
|
|
16
19
|
return 'WebGPUCanvasContext';
|
|
17
20
|
}
|
|
@@ -26,9 +29,22 @@ export class WebGPUCanvasContext extends CanvasContext {
|
|
|
26
29
|
// Base class constructor cannot access derived methods/fields, so we need to call these functions in the subclass constructor
|
|
27
30
|
this._setAutoCreatedCanvasId(`${this.device.id}-canvas`);
|
|
28
31
|
this._configureDevice();
|
|
32
|
+
this._startObservers();
|
|
29
33
|
}
|
|
30
34
|
/** Destroy any textures produced while configured and remove the context configuration. */
|
|
31
35
|
destroy() {
|
|
36
|
+
if (this.framebuffer) {
|
|
37
|
+
this.framebuffer.destroy();
|
|
38
|
+
this.framebuffer = null;
|
|
39
|
+
}
|
|
40
|
+
if (this.colorAttachment) {
|
|
41
|
+
this.colorAttachment.destroy();
|
|
42
|
+
this.colorAttachment = null;
|
|
43
|
+
}
|
|
44
|
+
if (this.depthStencilAttachment) {
|
|
45
|
+
this.depthStencilAttachment.destroy();
|
|
46
|
+
this.depthStencilAttachment = null;
|
|
47
|
+
}
|
|
32
48
|
this.handle.unconfigure();
|
|
33
49
|
super.destroy();
|
|
34
50
|
}
|
|
@@ -48,45 +64,88 @@ export class WebGPUCanvasContext extends CanvasContext {
|
|
|
48
64
|
colorSpace: this.props.colorSpace,
|
|
49
65
|
alphaMode: this.props.alphaMode
|
|
50
66
|
});
|
|
67
|
+
this._createDepthStencilAttachment(this.device.preferredDepthFormat);
|
|
51
68
|
}
|
|
52
69
|
/** Update framebuffer with properly resized "swap chain" texture views */
|
|
53
70
|
_getCurrentFramebuffer(options = {
|
|
54
71
|
depthStencilFormat: 'depth24plus'
|
|
55
72
|
}) {
|
|
56
|
-
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
this.drawingBufferWidth = currentColorAttachment.width;
|
|
63
|
-
this.drawingBufferHeight = currentColorAttachment.height;
|
|
64
|
-
log.log(1, `${this}: Resized to compensate for initial canvas size mismatch ${oldWidth}x${oldHeight} => ${this.drawingBufferWidth}x${this.drawingBufferHeight}px`)();
|
|
73
|
+
const profiler = getCpuHotspotProfiler(this.device);
|
|
74
|
+
const startTime = profiler ? getTimestamp() : 0;
|
|
75
|
+
if (profiler) {
|
|
76
|
+
profiler.framebufferAcquireCount = (profiler.framebufferAcquireCount || 0) + 1;
|
|
77
|
+
profiler.activeDefaultFramebufferAcquireDepth =
|
|
78
|
+
(profiler.activeDefaultFramebufferAcquireDepth || 0) + 1;
|
|
65
79
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
this.
|
|
80
|
+
try {
|
|
81
|
+
// Wrap the current canvas context texture in a luma.gl texture
|
|
82
|
+
const currentColorAttachment = this._getCurrentTexture();
|
|
83
|
+
// TODO - temporary debug code
|
|
84
|
+
if (currentColorAttachment.width !== this.drawingBufferWidth ||
|
|
85
|
+
currentColorAttachment.height !== this.drawingBufferHeight) {
|
|
86
|
+
const [oldWidth, oldHeight] = this.getDrawingBufferSize();
|
|
87
|
+
this.drawingBufferWidth = currentColorAttachment.width;
|
|
88
|
+
this.drawingBufferHeight = currentColorAttachment.height;
|
|
89
|
+
log.log(1, `${this}: Resized to compensate for initial canvas size mismatch ${oldWidth}x${oldHeight} => ${this.drawingBufferWidth}x${this.drawingBufferHeight}px`)();
|
|
90
|
+
}
|
|
91
|
+
// Resize the depth stencil attachment
|
|
92
|
+
if (options?.depthStencilFormat) {
|
|
93
|
+
this._createDepthStencilAttachment(options?.depthStencilFormat);
|
|
94
|
+
}
|
|
95
|
+
this.framebuffer ||= new WebGPUFramebuffer(this.device, {
|
|
96
|
+
id: `${this.id}#framebuffer`,
|
|
97
|
+
colorAttachments: [currentColorAttachment],
|
|
98
|
+
depthStencilAttachment: null
|
|
99
|
+
});
|
|
100
|
+
this.framebuffer._reinitialize(currentColorAttachment.view, options?.depthStencilFormat ? this.depthStencilAttachment?.view || null : null);
|
|
101
|
+
return this.framebuffer;
|
|
102
|
+
}
|
|
103
|
+
finally {
|
|
104
|
+
if (profiler) {
|
|
105
|
+
profiler.activeDefaultFramebufferAcquireDepth =
|
|
106
|
+
(profiler.activeDefaultFramebufferAcquireDepth || 1) - 1;
|
|
107
|
+
profiler.framebufferAcquireTimeMs =
|
|
108
|
+
(profiler.framebufferAcquireTimeMs || 0) + (getTimestamp() - startTime);
|
|
109
|
+
}
|
|
69
110
|
}
|
|
70
|
-
return new WebGPUFramebuffer(this.device, {
|
|
71
|
-
colorAttachments: [currentColorAttachment],
|
|
72
|
-
depthStencilAttachment: this.depthStencilAttachment
|
|
73
|
-
});
|
|
74
111
|
}
|
|
75
112
|
// PRIMARY METHODS
|
|
76
113
|
/** Wrap the current canvas context texture in a luma.gl texture */
|
|
77
114
|
_getCurrentTexture() {
|
|
115
|
+
const profiler = getCpuHotspotProfiler(this.device);
|
|
116
|
+
const currentTextureStartTime = profiler ? getTimestamp() : 0;
|
|
78
117
|
const handle = this.handle.getCurrentTexture();
|
|
79
|
-
|
|
80
|
-
|
|
118
|
+
if (profiler) {
|
|
119
|
+
profiler.currentTextureAcquireCount = (profiler.currentTextureAcquireCount || 0) + 1;
|
|
120
|
+
profiler.currentTextureAcquireTimeMs =
|
|
121
|
+
(profiler.currentTextureAcquireTimeMs || 0) + (getTimestamp() - currentTextureStartTime);
|
|
122
|
+
}
|
|
123
|
+
if (!this.colorAttachment) {
|
|
124
|
+
this.colorAttachment = this.device.createTexture({
|
|
125
|
+
id: `${this.id}#color-texture`,
|
|
126
|
+
handle,
|
|
127
|
+
format: this.device.preferredColorFormat,
|
|
128
|
+
width: handle.width,
|
|
129
|
+
height: handle.height
|
|
130
|
+
});
|
|
131
|
+
return this.colorAttachment;
|
|
132
|
+
}
|
|
133
|
+
this.colorAttachment._reinitialize(handle, {
|
|
81
134
|
handle,
|
|
82
135
|
format: this.device.preferredColorFormat,
|
|
83
136
|
width: handle.width,
|
|
84
137
|
height: handle.height
|
|
85
138
|
});
|
|
139
|
+
return this.colorAttachment;
|
|
86
140
|
}
|
|
87
141
|
/** We build render targets on demand (i.e. not when size changes but when about to render) */
|
|
88
142
|
_createDepthStencilAttachment(depthStencilFormat) {
|
|
89
|
-
|
|
143
|
+
const needsNewDepthStencilAttachment = !this.depthStencilAttachment ||
|
|
144
|
+
this.depthStencilAttachment.width !== this.drawingBufferWidth ||
|
|
145
|
+
this.depthStencilAttachment.height !== this.drawingBufferHeight ||
|
|
146
|
+
this.depthStencilAttachment.format !== depthStencilFormat;
|
|
147
|
+
if (needsNewDepthStencilAttachment) {
|
|
148
|
+
this.depthStencilAttachment?.destroy();
|
|
90
149
|
this.depthStencilAttachment = this.device.createTexture({
|
|
91
150
|
id: `${this.id}#depth-stencil-texture`,
|
|
92
151
|
usage: Texture.RENDER_ATTACHMENT,
|