@luma.gl/webgpu 9.0.0-alpha.2
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/README.md +1 -0
- package/dist/adapter/helpers/accessor-to-format.d.ts +1 -0
- package/dist/adapter/helpers/accessor-to-format.d.ts.map +1 -0
- package/dist/adapter/helpers/accessor-to-format.js +2 -0
- package/dist/adapter/helpers/accessor-to-format.js.map +1 -0
- package/dist/adapter/helpers/convert-texture-format.d.ts +5 -0
- package/dist/adapter/helpers/convert-texture-format.d.ts.map +1 -0
- package/dist/adapter/helpers/convert-texture-format.js +8 -0
- package/dist/adapter/helpers/convert-texture-format.js.map +1 -0
- package/dist/adapter/helpers/generate-mipmaps.d.ts +10 -0
- package/dist/adapter/helpers/generate-mipmaps.d.ts.map +1 -0
- package/dist/adapter/helpers/generate-mipmaps.js +95 -0
- package/dist/adapter/helpers/generate-mipmaps.js.map +1 -0
- package/dist/adapter/helpers/get-bind-group.d.ts +13 -0
- package/dist/adapter/helpers/get-bind-group.d.ts.map +1 -0
- package/dist/adapter/helpers/get-bind-group.js +60 -0
- package/dist/adapter/helpers/get-bind-group.js.map +1 -0
- package/dist/adapter/helpers/get-vertex-buffer-layout.d.ts +12 -0
- package/dist/adapter/helpers/get-vertex-buffer-layout.d.ts.map +1 -0
- package/dist/adapter/helpers/get-vertex-buffer-layout.js +98 -0
- package/dist/adapter/helpers/get-vertex-buffer-layout.js.map +1 -0
- package/dist/adapter/helpers/webgpu-parameters.d.ts +9 -0
- package/dist/adapter/helpers/webgpu-parameters.d.ts.map +1 -0
- package/dist/adapter/helpers/webgpu-parameters.js +134 -0
- package/dist/adapter/helpers/webgpu-parameters.js.map +1 -0
- package/dist/adapter/resources/webgpu-buffer.d.ts +18 -0
- package/dist/adapter/resources/webgpu-buffer.d.ts.map +1 -0
- package/dist/adapter/resources/webgpu-buffer.js +84 -0
- package/dist/adapter/resources/webgpu-buffer.js.map +1 -0
- package/dist/adapter/resources/webgpu-command-encoder.d.ts +45 -0
- package/dist/adapter/resources/webgpu-command-encoder.d.ts.map +1 -0
- package/dist/adapter/resources/webgpu-command-encoder.js +66 -0
- package/dist/adapter/resources/webgpu-command-encoder.js.map +1 -0
- package/dist/adapter/resources/webgpu-compute-pass.d.ts +32 -0
- package/dist/adapter/resources/webgpu-compute-pass.d.ts.map +1 -0
- package/dist/adapter/resources/webgpu-compute-pass.js +56 -0
- package/dist/adapter/resources/webgpu-compute-pass.js.map +1 -0
- package/dist/adapter/resources/webgpu-compute-pipeline.d.ts +12 -0
- package/dist/adapter/resources/webgpu-compute-pipeline.d.ts.map +1 -0
- package/dist/adapter/resources/webgpu-compute-pipeline.js +27 -0
- package/dist/adapter/resources/webgpu-compute-pipeline.js.map +1 -0
- package/dist/adapter/resources/webgpu-external-texture.d.ts +18 -0
- package/dist/adapter/resources/webgpu-external-texture.d.ts.map +1 -0
- package/dist/adapter/resources/webgpu-external-texture.js +30 -0
- package/dist/adapter/resources/webgpu-external-texture.js.map +1 -0
- package/dist/adapter/resources/webgpu-framebuffer.d.ts +29 -0
- package/dist/adapter/resources/webgpu-framebuffer.d.ts.map +1 -0
- package/dist/adapter/resources/webgpu-framebuffer.js +111 -0
- package/dist/adapter/resources/webgpu-framebuffer.js.map +1 -0
- package/dist/adapter/resources/webgpu-query.d.ts +1 -0
- package/dist/adapter/resources/webgpu-query.d.ts.map +1 -0
- package/dist/adapter/resources/webgpu-query.js +2 -0
- package/dist/adapter/resources/webgpu-query.js.map +1 -0
- package/dist/adapter/resources/webgpu-render-pass.d.ts +34 -0
- package/dist/adapter/resources/webgpu-render-pass.d.ts.map +1 -0
- package/dist/adapter/resources/webgpu-render-pass.js +92 -0
- package/dist/adapter/resources/webgpu-render-pass.js.map +1 -0
- package/dist/adapter/resources/webgpu-render-pipeline.d.ts +41 -0
- package/dist/adapter/resources/webgpu-render-pipeline.d.ts.map +1 -0
- package/dist/adapter/resources/webgpu-render-pipeline.js +148 -0
- package/dist/adapter/resources/webgpu-render-pipeline.js.map +1 -0
- package/dist/adapter/resources/webgpu-sampler.d.ts +16 -0
- package/dist/adapter/resources/webgpu-sampler.d.ts.map +1 -0
- package/dist/adapter/resources/webgpu-sampler.js +19 -0
- package/dist/adapter/resources/webgpu-sampler.js.map +1 -0
- package/dist/adapter/resources/webgpu-shader.d.ts +21 -0
- package/dist/adapter/resources/webgpu-shader.d.ts.map +1 -0
- package/dist/adapter/resources/webgpu-shader.js +64 -0
- package/dist/adapter/resources/webgpu-shader.js.map +1 -0
- package/dist/adapter/resources/webgpu-texture.d.ts +39 -0
- package/dist/adapter/resources/webgpu-texture.d.ts.map +1 -0
- package/dist/adapter/resources/webgpu-texture.js +111 -0
- package/dist/adapter/resources/webgpu-texture.js.map +1 -0
- package/dist/adapter/webgpu-canvas-context.d.ts +32 -0
- package/dist/adapter/webgpu-canvas-context.d.ts.map +1 -0
- package/dist/adapter/webgpu-canvas-context.js +95 -0
- package/dist/adapter/webgpu-canvas-context.js.map +1 -0
- package/dist/adapter/webgpu-device.d.ts +67 -0
- package/dist/adapter/webgpu-device.d.ts.map +1 -0
- package/dist/adapter/webgpu-device.js +225 -0
- package/dist/adapter/webgpu-device.js.map +1 -0
- package/dist/adapter/webgpu-types.d.ts +1 -0
- package/dist/adapter/webgpu-types.d.ts.map +1 -0
- package/dist/adapter/webgpu-types.js +2 -0
- package/dist/adapter/webgpu-types.js.map +1 -0
- package/dist/bundle.d.ts +2 -0
- package/dist/bundle.d.ts.map +1 -0
- package/dist/bundle.js +5 -0
- package/dist/bundle.js.map +1 -0
- package/dist/glsl/glsllang.d.ts +3 -0
- package/dist/glsl/glsllang.d.ts.map +1 -0
- package/dist/glsl/glsllang.js +10 -0
- package/dist/glsl/glsllang.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/init.d.ts +2 -0
- package/dist/init.d.ts.map +1 -0
- package/dist/init.js +4 -0
- package/dist/init.js.map +1 -0
- package/package.json +36 -0
- package/src/adapter/helpers/accessor-to-format.ts +101 -0
- package/src/adapter/helpers/convert-texture-format.ts +10 -0
- package/src/adapter/helpers/generate-mipmaps.ts +107 -0
- package/src/adapter/helpers/get-bind-group.ts +82 -0
- package/src/adapter/helpers/get-vertex-buffer-layout.ts +123 -0
- package/src/adapter/helpers/webgpu-parameters.ts +226 -0
- package/src/adapter/resources/webgpu-buffer.ts +96 -0
- package/src/adapter/resources/webgpu-command-encoder.ts +111 -0
- package/src/adapter/resources/webgpu-compute-pass.ts +74 -0
- package/src/adapter/resources/webgpu-compute-pipeline.ts +34 -0
- package/src/adapter/resources/webgpu-external-texture.ts +37 -0
- package/src/adapter/resources/webgpu-framebuffer.ts +120 -0
- package/src/adapter/resources/webgpu-query.ts +43 -0
- package/src/adapter/resources/webgpu-render-pass.ts +128 -0
- package/src/adapter/resources/webgpu-render-pipeline.ts +231 -0
- package/src/adapter/resources/webgpu-sampler.ts +25 -0
- package/src/adapter/resources/webgpu-shader.ts +72 -0
- package/src/adapter/resources/webgpu-texture.ts +243 -0
- package/src/adapter/webgpu-canvas-context.ts +102 -0
- package/src/adapter/webgpu-device.ts +282 -0
- package/src/adapter/webgpu-types.ts +0 -0
- package/src/bundle.ts +4 -0
- package/src/glsl/glsllang.ts +14 -0
- package/src/index.ts +13 -0
- package/src/init.ts +4 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
import { Buffer } from '@luma.gl/api';
|
|
3
|
+
|
|
4
|
+
function getByteLength(props) {
|
|
5
|
+
var _props$data;
|
|
6
|
+
|
|
7
|
+
return props.byteLength || ((_props$data = props.data) === null || _props$data === void 0 ? void 0 : _props$data.byteLength) || 0;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export default class WebGPUBuffer extends Buffer {
|
|
11
|
+
constructor(device, props) {
|
|
12
|
+
super(device, props);
|
|
13
|
+
|
|
14
|
+
_defineProperty(this, "device", void 0);
|
|
15
|
+
|
|
16
|
+
_defineProperty(this, "handle", void 0);
|
|
17
|
+
|
|
18
|
+
_defineProperty(this, "byteLength", void 0);
|
|
19
|
+
|
|
20
|
+
this.device = device;
|
|
21
|
+
this.byteLength = getByteLength(props);
|
|
22
|
+
const mapBuffer = Boolean(props.data);
|
|
23
|
+
this.handle = this.props.handle || this.device.handle.createBuffer({
|
|
24
|
+
size: this.byteLength,
|
|
25
|
+
usage: this.props.usage || GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST,
|
|
26
|
+
mappedAtCreation: this.props.mappedAtCreation || mapBuffer,
|
|
27
|
+
label: this.props.id
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
if (props.data) {
|
|
31
|
+
this._writeMapped(props.data);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (mapBuffer && !props.mappedAtCreation) {
|
|
35
|
+
this.handle.unmap();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
createHandle(mapBuffer) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
destroy() {
|
|
44
|
+
this.handle.destroy();
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
write(data, byteOffset = 0) {
|
|
48
|
+
this.device.handle.queue.writeBuffer(this.handle, byteOffset, data.buffer, data.byteOffset, data.byteLength);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async readAsync(byteOffset = 0, byteLength = this.byteLength) {
|
|
52
|
+
const tempBuffer = new WebGPUBuffer(this.device, {
|
|
53
|
+
usage: Buffer.MAP_READ | Buffer.COPY_DST,
|
|
54
|
+
byteLength
|
|
55
|
+
});
|
|
56
|
+
const commandEncoder = this.device.handle.createCommandEncoder();
|
|
57
|
+
commandEncoder.copyBufferToBuffer(this.handle, byteOffset, tempBuffer.handle, 0, byteLength);
|
|
58
|
+
this.device.handle.queue.submit([commandEncoder.finish()]);
|
|
59
|
+
await tempBuffer.handle.mapAsync(GPUMapMode.READ, byteOffset, byteLength);
|
|
60
|
+
const arrayBuffer = tempBuffer.handle.getMappedRange().slice(0);
|
|
61
|
+
tempBuffer.handle.unmap();
|
|
62
|
+
tempBuffer.destroy();
|
|
63
|
+
return arrayBuffer;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
_writeMapped(typedArray) {
|
|
67
|
+
const arrayBuffer = this.handle.getMappedRange();
|
|
68
|
+
new typedArray.constructor(arrayBuffer).set(typedArray);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
mapAsync(mode, offset = 0, size) {
|
|
72
|
+
return this.handle.mapAsync(mode, offset, size);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
getMappedRange(offset = 0, size) {
|
|
76
|
+
return this.handle.getMappedRange(offset, size);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
unmap() {
|
|
80
|
+
this.handle.unmap();
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=webgpu-buffer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/adapter/resources/webgpu-buffer.ts"],"names":["Buffer","getByteLength","props","byteLength","data","WebGPUBuffer","constructor","device","mapBuffer","Boolean","handle","createBuffer","size","usage","GPUBufferUsage","VERTEX","COPY_DST","mappedAtCreation","label","id","_writeMapped","unmap","createHandle","destroy","write","byteOffset","queue","writeBuffer","buffer","readAsync","tempBuffer","MAP_READ","commandEncoder","createCommandEncoder","copyBufferToBuffer","submit","finish","mapAsync","GPUMapMode","READ","arrayBuffer","getMappedRange","slice","typedArray","set","mode","offset"],"mappings":";AACA,SAAQA,MAAR,QAA0C,cAA1C;;AAGA,SAASC,aAAT,CAAuBC,KAAvB,EAAmD;AAAA;;AACjD,SAAOA,KAAK,CAACC,UAAN,oBAAoBD,KAAK,CAACE,IAA1B,gDAAoB,YAAYD,UAAhC,KAA8C,CAArD;AACD;;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,EAAiE;AACvE,WAAO,KAAKF,MAAL,CAAY2B,QAAZ,CAAqBQ,IAArB,EAA2BC,MAA3B,EAAmClC,IAAnC,CAAP;AACD;;AAED6B,EAAAA,cAAc,CAACK,MAAc,GAAG,CAAlB,EAAqBlC,IAArB,EAAiD;AAC7D,WAAO,KAAKF,MAAL,CAAY+B,cAAZ,CAA2BK,MAA3B,EAAmClC,IAAnC,CAAP;AACD;;AAEDS,EAAAA,KAAK,GAAS;AACZ,SAAKX,MAAL,CAAYW,KAAZ;AACD;;AAtF8C","sourcesContent":["// WEBGPU Buffer implementation\nimport {Buffer, BufferProps, assert} from '@luma.gl/api';\nimport type WebGPUDevice from '../webgpu-device';\n\nfunction getByteLength(props: BufferProps): number {\n return props.byteLength || props.data?.byteLength || 0;\n}\n\nexport default class WebGPUBuffer extends Buffer {\n readonly device: WebGPUDevice;\n readonly handle: GPUBuffer;\n readonly byteLength: number;\n\n constructor(device: WebGPUDevice, props: BufferProps) {\n super(device, props);\n this.device = device;\n\n this.byteLength = getByteLength(props);\n const mapBuffer = Boolean(props.data);\n\n this.handle = this.props.handle || this.device.handle.createBuffer({\n size: this.byteLength,\n // usage defaults to vertex\n usage: this.props.usage || (GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST),\n mappedAtCreation: this.props.mappedAtCreation || mapBuffer,\n label: this.props.id\n });\n\n if (props.data) {\n this._writeMapped(props.data);\n // this.handle.writeAsync({data: props.data, map: false, unmap: false});\n }\n\n if (mapBuffer && !props.mappedAtCreation) {\n this.handle.unmap();\n }\n }\n\n protected createHandle(mapBuffer: boolean): GPUBuffer {\n return\n }\n\n destroy(): void {\n this.handle.destroy();\n }\n\n // WebGPU provides multiple ways to write a buffer...\n write(data: ArrayBufferView, byteOffset = 0) {\n this.device.handle.queue.writeBuffer(\n this.handle,\n byteOffset,\n data.buffer,\n data.byteOffset,\n data.byteLength\n );\n }\n\n async readAsync(byteOffset: number = 0, byteLength: number = this.byteLength): Promise<ArrayBuffer> {\n // We need MAP_READ flag, but only COPY_DST buffers can have MAP_READ flag, so we need to create a temp buffer\n const tempBuffer = new WebGPUBuffer(this.device, {usage: Buffer.MAP_READ | Buffer.COPY_DST, byteLength});\n\n // Now do a GPU-side copy into the temp buffer we can actually read.\n // TODO - we are spinning up an independent command queue here, what does this mean\n const commandEncoder = this.device.handle.createCommandEncoder();\n commandEncoder.copyBufferToBuffer(this.handle, byteOffset, tempBuffer.handle, 0, byteLength);\n this.device.handle.queue.submit([commandEncoder.finish()]);\n\n // Map the temp buffer and read the data.\n await tempBuffer.handle.mapAsync(GPUMapMode.READ, byteOffset, byteLength);\n const arrayBuffer = tempBuffer.handle.getMappedRange().slice(0);\n tempBuffer.handle.unmap();\n tempBuffer.destroy();\n\n return arrayBuffer;\n }\n\n _writeMapped<TypedArray>(typedArray: TypedArray): void {\n const arrayBuffer = this.handle.getMappedRange();\n // @ts-expect-error\n new typedArray.constructor(arrayBuffer).set(typedArray);\n }\n\n // WEBGPU API\n\n mapAsync(mode: number, offset: number = 0, size?: number): Promise<void> {\n return this.handle.mapAsync(mode, offset, size);\n }\n\n getMappedRange(offset: number = 0, size?: number): ArrayBuffer {\n return this.handle.getMappedRange(offset, size);\n }\n\n unmap(): void {\n this.handle.unmap();\n }\n}\n"],"file":"webgpu-buffer.js"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/// <reference types="@webgpu/types" />
|
|
2
|
+
import { CommandEncoder, CommandEncoderProps, Buffer, Texture } from '@luma.gl/api';
|
|
3
|
+
import WebGPUDevice from '../webgpu-device';
|
|
4
|
+
export default class WebGPUCommandEncoder extends CommandEncoder {
|
|
5
|
+
readonly device: WebGPUDevice;
|
|
6
|
+
readonly handle: GPUCommandEncoder;
|
|
7
|
+
constructor(device: WebGPUDevice, props: CommandEncoderProps);
|
|
8
|
+
protected createHandle(): GPUCommandEncoder;
|
|
9
|
+
destroy(): void;
|
|
10
|
+
finish(options?: {
|
|
11
|
+
id?: string;
|
|
12
|
+
}): GPUCommandBuffer;
|
|
13
|
+
copyBufferToBuffer(options: {
|
|
14
|
+
source: Buffer;
|
|
15
|
+
sourceOffset?: number;
|
|
16
|
+
destination: Buffer;
|
|
17
|
+
destinationOffset?: number;
|
|
18
|
+
size?: number;
|
|
19
|
+
}): void;
|
|
20
|
+
copyBufferToTexture(options: {
|
|
21
|
+
source: Buffer;
|
|
22
|
+
offset?: number;
|
|
23
|
+
bytesPerRow: number;
|
|
24
|
+
rowsPerImage: number;
|
|
25
|
+
destination: Texture;
|
|
26
|
+
mipLevel?: number;
|
|
27
|
+
aspect?: 'all' | 'stencil-only' | 'depth-only';
|
|
28
|
+
origin?: number[] | [number, number, number];
|
|
29
|
+
extent?: number[] | [number, number, number];
|
|
30
|
+
}): void;
|
|
31
|
+
copyTextureToBuffer(options: {
|
|
32
|
+
source: GPUImageCopyTexture;
|
|
33
|
+
destination: GPUImageCopyBuffer;
|
|
34
|
+
copySize: GPUExtent3D;
|
|
35
|
+
}): void;
|
|
36
|
+
copyTextureToTexture(options: {
|
|
37
|
+
source: GPUImageCopyTexture;
|
|
38
|
+
destination: GPUImageCopyTexture;
|
|
39
|
+
copySize: GPUExtent3D;
|
|
40
|
+
}): void;
|
|
41
|
+
pushDebugGroup(groupLabel: string): void;
|
|
42
|
+
popDebugGroup(): void;
|
|
43
|
+
insertDebugMarker(markerLabel: string): void;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=webgpu-command-encoder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webgpu-command-encoder.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-command-encoder.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,cAAc,EAAE,mBAAmB,EAAkB,MAAM,EAAE,OAAO,EAAO,MAAM,cAAc,CAAC;AACxG,OAAO,YAAY,MAAM,kBAAkB,CAAC;AAI5C,MAAM,CAAC,OAAO,OAAO,oBAAqB,SAAQ,cAAc;IAC9D,QAAQ,CAAC,MAA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QAAQ,EAAE,WAAW,CAAA;KACtB,GAAG,IAAI;IAER,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAIxC,aAAa,IAAI,IAAI;IAIrB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;CAa7C"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
import { CommandEncoder, cast } from '@luma.gl/api';
|
|
3
|
+
export default class WebGPUCommandEncoder extends CommandEncoder {
|
|
4
|
+
constructor(device, props) {
|
|
5
|
+
super(props);
|
|
6
|
+
|
|
7
|
+
_defineProperty(this, "device", void 0);
|
|
8
|
+
|
|
9
|
+
_defineProperty(this, "handle", void 0);
|
|
10
|
+
|
|
11
|
+
this.device = device;
|
|
12
|
+
this.handle = this.handle || this.createHandle();
|
|
13
|
+
this.handle.label = this.props.id;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
createHandle() {
|
|
17
|
+
return this.device.handle.createCommandEncoder({
|
|
18
|
+
measureExecutionTime: this.props.measureExecutionTime
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
destroy() {}
|
|
23
|
+
|
|
24
|
+
finish(options) {
|
|
25
|
+
return this.finish(options);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
copyBufferToBuffer(options) {
|
|
29
|
+
var _options$sourceOffset, _options$destinationO, _options$size;
|
|
30
|
+
|
|
31
|
+
this.handle.copyBufferToBuffer(cast(options.source).handle, (_options$sourceOffset = options.sourceOffset) !== null && _options$sourceOffset !== void 0 ? _options$sourceOffset : 0, cast(options.destination).handle, (_options$destinationO = options.destinationOffset) !== null && _options$destinationO !== void 0 ? _options$destinationO : 0, (_options$size = options.size) !== null && _options$size !== void 0 ? _options$size : 0);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
copyBufferToTexture(options) {
|
|
35
|
+
var _options$offset, _options$mipLevel, _options$origin;
|
|
36
|
+
|
|
37
|
+
this.handle.copyBufferToTexture({
|
|
38
|
+
buffer: cast(options.source).handle,
|
|
39
|
+
offset: (_options$offset = options.offset) !== null && _options$offset !== void 0 ? _options$offset : 0,
|
|
40
|
+
bytesPerRow: options.bytesPerRow,
|
|
41
|
+
rowsPerImage: options.rowsPerImage
|
|
42
|
+
}, {
|
|
43
|
+
texture: cast(options.destination).handle,
|
|
44
|
+
mipLevel: (_options$mipLevel = options.mipLevel) !== null && _options$mipLevel !== void 0 ? _options$mipLevel : 0,
|
|
45
|
+
origin: (_options$origin = options.origin) !== null && _options$origin !== void 0 ? _options$origin : {}
|
|
46
|
+
}, options.extent);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
copyTextureToBuffer(options) {}
|
|
50
|
+
|
|
51
|
+
copyTextureToTexture(options) {}
|
|
52
|
+
|
|
53
|
+
pushDebugGroup(groupLabel) {
|
|
54
|
+
this.handle.pushDebugGroup(groupLabel);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
popDebugGroup() {
|
|
58
|
+
this.handle.popDebugGroup();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
insertDebugMarker(markerLabel) {
|
|
62
|
+
this.handle.insertDebugMarker(markerLabel);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=webgpu-command-encoder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/adapter/resources/webgpu-command-encoder.ts"],"names":["CommandEncoder","cast","WebGPUCommandEncoder","constructor","device","props","handle","createHandle","label","id","createCommandEncoder","measureExecutionTime","destroy","finish","options","copyBufferToBuffer","source","sourceOffset","destination","destinationOffset","size","copyBufferToTexture","buffer","offset","bytesPerRow","rowsPerImage","texture","mipLevel","origin","extent","copyTextureToBuffer","copyTextureToTexture","pushDebugGroup","groupLabel","popDebugGroup","insertDebugMarker","markerLabel"],"mappings":";AAAA,SAAQA,cAAR,EAA8EC,IAA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U,WAHvB;AAIEC,MAAAA,YAAY,EAAEX,OAAO,CAACW;AAJxB,KADF,EAOE;AACEC,MAAAA,OAAO,EAAEzB,IAAI,CAAgBa,OAAO,CAACI,WAAxB,CAAJ,CAAyCZ,MADpD;AAEEqB,MAAAA,QAAQ,uBAAEb,OAAO,CAACa,QAAV,iEAAsB,CAFhC;AAGEC,MAAAA,MAAM,qBAAEd,OAAO,CAACc,MAAV,6DAAoB;AAH5B,KAPF,EAaEd,OAAO,CAACe,MAbV;AAeD;;AAEDC,EAAAA,mBAAmB,CAAChB,OAAD,EAIV,CAAE;;AAEXiB,EAAAA,oBAAoB,CAACjB,OAAD,EAIX,CAAE;;AAEXkB,EAAAA,cAAc,CAACC,UAAD,EAA2B;AACvC,SAAK3B,MAAL,CAAY0B,cAAZ,CAA2BC,UAA3B;AACD;;AAEDC,EAAAA,aAAa,GAAS;AACpB,SAAK5B,MAAL,CAAY4B,aAAZ;AACD;;AAEDC,EAAAA,iBAAiB,CAACC,WAAD,EAA4B;AAC3C,SAAK9B,MAAL,CAAY6B,iBAAZ,CAA8BC,WAA9B;AACD;;AA9F8D","sourcesContent":["import {CommandEncoder, CommandEncoderProps, RenderPipeline, Buffer, Texture, cast} from '@luma.gl/api';\nimport WebGPUDevice from '../webgpu-device';\nimport WEBGPUBuffer from './webgpu-buffer';\nimport WebGPUTexture from './webgpu-texture';\n\nexport default class WebGPUCommandEncoder extends CommandEncoder {\n readonly device: WebGPUDevice;\n readonly handle: GPUCommandEncoder;\n\n constructor(device: WebGPUDevice, props: CommandEncoderProps) {\n super(props);\n this.device = device;\n this.handle = this.handle || this.createHandle();\n this.handle.label = this.props.id;\n }\n\n protected createHandle(): GPUCommandEncoder {\n return this.device.handle.createCommandEncoder({\n measureExecutionTime: this.props.measureExecutionTime\n });\n }\n\n destroy() {}\n\n finish(options?: {id?: string}): GPUCommandBuffer {\n return this.finish(options);\n }\n\n // beginRenderPass(GPURenderPassDescriptor descriptor): GPURenderPassEncoder;\n // beginComputePass(optional GPUComputePassDescriptor descriptor = {}): GPUComputePassEncoder;\n\n copyBufferToBuffer(options: {\n source: Buffer,\n sourceOffset?: number,\n destination: Buffer,\n destinationOffset?: number,\n size?: number\n }): void {\n this.handle.copyBufferToBuffer(\n cast<WEBGPUBuffer>(options.source).handle,\n options.sourceOffset ?? 0,\n cast<WEBGPUBuffer>(options.destination).handle,\n options.destinationOffset ?? 0,\n options.size ?? 0\n );\n }\n\n copyBufferToTexture(options: {\n source: Buffer,\n offset?: number,\n bytesPerRow: number,\n rowsPerImage: number,\n\n destination: Texture,\n mipLevel?: number;\n aspect?: 'all' | 'stencil-only' | 'depth-only',\n\n origin?: number[] | [number, number, number],\n extent?: number[] | [number, number, number]\n }): void {\n this.handle.copyBufferToTexture(\n {\n buffer: cast<WEBGPUBuffer>(options.source).handle,\n offset: options.offset ?? 0,\n bytesPerRow: options.bytesPerRow,\n rowsPerImage: options.rowsPerImage,\n },\n {\n texture: cast<WebGPUTexture>(options.destination).handle,\n mipLevel: options.mipLevel ?? 0,\n origin: options.origin ?? {},\n // aspect: options.aspect\n },\n options.extent // default depth?\n );\n }\n\n copyTextureToBuffer(options: {\n source: GPUImageCopyTexture,\n destination: GPUImageCopyBuffer,\n copySize: GPUExtent3D\n }): void {}\n\n copyTextureToTexture(options: {\n source: GPUImageCopyTexture ,\n destination: GPUImageCopyTexture,\n copySize: GPUExtent3D\n }): void {}\n\n pushDebugGroup(groupLabel: string): void {\n this.handle.pushDebugGroup(groupLabel);\n }\n\n popDebugGroup(): void {\n this.handle.popDebugGroup();\n }\n\n insertDebugMarker(markerLabel: string): void {\n this.handle.insertDebugMarker(markerLabel);\n }\n\n // writeTimestamp(querySet: Query, queryIndex: number): void {}\n\n // resolveQuerySet(options: {\n // querySet: GPUQuerySet,\n // firstQuery: number,\n // queryCount: number,\n // destination: Buffer,\n // destinationOffset?: number;\n // }): void;\n}"],"file":"webgpu-command-encoder.js"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/// <reference types="@webgpu/types" />
|
|
2
|
+
import { ComputePass, ComputePassProps, ComputePipeline, Buffer, Binding } from '@luma.gl/api';
|
|
3
|
+
import WebGPUDevice from '../webgpu-device';
|
|
4
|
+
export default class WebGPUComputePass extends ComputePass {
|
|
5
|
+
readonly device: WebGPUDevice;
|
|
6
|
+
readonly handle: GPUComputePassEncoder;
|
|
7
|
+
_bindGroupLayout: GPUBindGroupLayout;
|
|
8
|
+
constructor(device: WebGPUDevice, props: ComputePassProps);
|
|
9
|
+
/** @note no WebGPU destroy method, just gc */
|
|
10
|
+
destroy(): void;
|
|
11
|
+
endPass(): void;
|
|
12
|
+
setPipeline(pipeline: ComputePipeline): void;
|
|
13
|
+
/** Sets an array of bindings (uniform buffers, samplers, textures, ...) */
|
|
14
|
+
setBindings(bindings: Binding[]): void;
|
|
15
|
+
/**
|
|
16
|
+
* Dispatch work to be performed with the current ComputePipeline.
|
|
17
|
+
* @param x X dimension of the grid of workgroups to dispatch.
|
|
18
|
+
* @param y Y dimension of the grid of workgroups to dispatch.
|
|
19
|
+
* @param z Z dimension of the grid of workgroups to dispatch.
|
|
20
|
+
*/
|
|
21
|
+
dispatch(x: number, y?: number, z?: number): void;
|
|
22
|
+
/**
|
|
23
|
+
* Dispatch work to be performed with the current ComputePipeline.
|
|
24
|
+
* @param indirectBuffer buffer must be a tightly packed block of three 32-bit unsigned integer values (12 bytes total), given in the same order as the arguments for dispatch()
|
|
25
|
+
* @param indirectOffset
|
|
26
|
+
*/
|
|
27
|
+
dispatchIndirect(indirectBuffer: Buffer, indirectOffset?: number): void;
|
|
28
|
+
pushDebugGroup(groupLabel: string): void;
|
|
29
|
+
popDebugGroup(): void;
|
|
30
|
+
insertDebugMarker(markerLabel: string): void;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=webgpu-compute-pass.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webgpu-compute-pass.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-compute-pass.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,WAAW,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,EAAE,OAAO,EAAO,MAAM,cAAc,CAAC;AACnG,OAAO,YAAY,MAAM,kBAAkB,CAAC;AAK5C,MAAM,CAAC,OAAO,OAAO,iBAAkB,SAAQ,WAAW;IACxD,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,qBAAqB,CAAC;IACvC,gBAAgB,EAAE,kBAAkB,CAAC;gBAEzB,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,gBAAgB;IAUzD,8CAA8C;IAC9C,OAAO;IAEP,OAAO,IAAI,IAAI;IAIf,WAAW,CAAC,QAAQ,EAAE,eAAe,GAAG,IAAI;IAM5C,2EAA2E;IAC3E,WAAW,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,IAAI;IAMtC;;;;;OAKG;IACH,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI;IAIjD;;;;OAIG;IACH,gBAAgB,CAAC,cAAc,EAAE,MAAM,EAAE,cAAc,GAAE,MAAU,GAAG,IAAI;IAI1E,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAGxC,aAAa,IAAI,IAAI;IAGrB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;CAO7C"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
import { ComputePass, cast } from '@luma.gl/api';
|
|
3
|
+
export default class WebGPUComputePass extends ComputePass {
|
|
4
|
+
constructor(device, props) {
|
|
5
|
+
super(device, props);
|
|
6
|
+
|
|
7
|
+
_defineProperty(this, "device", void 0);
|
|
8
|
+
|
|
9
|
+
_defineProperty(this, "handle", void 0);
|
|
10
|
+
|
|
11
|
+
_defineProperty(this, "_bindGroupLayout", void 0);
|
|
12
|
+
|
|
13
|
+
this.device = device;
|
|
14
|
+
this.handle = this.props.handle || device.commandEncoder.beginComputePass({
|
|
15
|
+
label: this.props.id
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
destroy() {}
|
|
20
|
+
|
|
21
|
+
endPass() {
|
|
22
|
+
this.handle.endPass();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
setPipeline(pipeline) {
|
|
26
|
+
const wgpuPipeline = cast(pipeline);
|
|
27
|
+
this.handle.setPipeline(wgpuPipeline.handle);
|
|
28
|
+
this._bindGroupLayout = wgpuPipeline._getBindGroupLayout();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
setBindings(bindings) {
|
|
32
|
+
throw new Error('fix me');
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
dispatch(x, y, z) {
|
|
36
|
+
this.handle.dispatch(x, y, z);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
dispatchIndirect(indirectBuffer, indirectOffset = 0) {
|
|
40
|
+
this.handle.dispatchIndirect(cast(indirectBuffer).handle, indirectOffset);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
pushDebugGroup(groupLabel) {
|
|
44
|
+
this.handle.pushDebugGroup(groupLabel);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
popDebugGroup() {
|
|
48
|
+
this.handle.popDebugGroup();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
insertDebugMarker(markerLabel) {
|
|
52
|
+
this.handle.insertDebugMarker(markerLabel);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=webgpu-compute-pass.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/adapter/resources/webgpu-compute-pass.ts"],"names":["ComputePass","cast","WebGPUComputePass","constructor","device","props","handle","commandEncoder","beginComputePass","label","id","destroy","endPass","setPipeline","pipeline","wgpuPipeline","_bindGroupLayout","_getBindGroupLayout","setBindings","bindings","Error","dispatch","x","y","z","dispatchIndirect","indirectBuffer","indirectOffset","pushDebugGroup","groupLabel","popDebugGroup","insertDebugMarker","markerLabel"],"mappings":";AAAA,SAAQA,WAAR,EAAyEC,IAAzE,QAAoF,cAApF;AAMA,eAAe,MAAMC,iBAAN,SAAgCF,WAAhC,CAA4C;AAKzDG,EAAAA,WAAW,CAACC,MAAD,EAAuBC,KAAvB,EAAgD;AACzD,UAAMD,MAAN,EAAcC,KAAd;;AADyD;;AAAA;;AAAA;;AAEzD,SAAKD,MAAL,GAAcA,MAAd;AAEA,SAAKE,MAAL,GAAc,KAAKD,KAAL,CAAWC,MAAX,IAAqBF,MAAM,CAACG,cAAP,CAAsBC,gBAAtB,CAAuC;AACxEC,MAAAA,KAAK,EAAE,KAAKJ,KAAL,CAAWK;AADsD,KAAvC,CAAnC;AAID;;AAGDC,EAAAA,OAAO,GAAG,CAAE;;AAEZC,EAAAA,OAAO,GAAS;AACd,SAAKN,MAAL,CAAYM,OAAZ;AACD;;AAEDC,EAAAA,WAAW,CAACC,QAAD,EAAkC;AAC3C,UAAMC,YAAY,GAAGd,IAAI,CAAwBa,QAAxB,CAAzB;AACA,SAAKR,MAAL,CAAYO,WAAZ,CAAwBE,YAAY,CAACT,MAArC;AACA,SAAKU,gBAAL,GAAwBD,YAAY,CAACE,mBAAb,EAAxB;AACD;;AAGDC,EAAAA,WAAW,CAACC,QAAD,EAA4B;AACrC,UAAM,IAAIC,KAAJ,CAAU,QAAV,CAAN;AAGD;;AAQDC,EAAAA,QAAQ,CAACC,CAAD,EAAYC,CAAZ,EAAwBC,CAAxB,EAA0C;AAChD,SAAKlB,MAAL,CAAYe,QAAZ,CAAqBC,CAArB,EAAwBC,CAAxB,EAA2BC,CAA3B;AACD;;AAODC,EAAAA,gBAAgB,CAACC,cAAD,EAAyBC,cAAsB,GAAG,CAAlD,EAA2D;AACzE,SAAKrB,MAAL,CAAYmB,gBAAZ,CAA6BxB,IAAI,CAAeyB,cAAf,CAAJ,CAAmCpB,MAAhE,EAAwEqB,cAAxE;AACD;;AAEDC,EAAAA,cAAc,CAACC,UAAD,EAA2B;AACvC,SAAKvB,MAAL,CAAYsB,cAAZ,CAA2BC,UAA3B;AACD;;AACDC,EAAAA,aAAa,GAAS;AACpB,SAAKxB,MAAL,CAAYwB,aAAZ;AACD;;AACDC,EAAAA,iBAAiB,CAACC,WAAD,EAA4B;AAC3C,SAAK1B,MAAL,CAAYyB,iBAAZ,CAA8BC,WAA9B;AACD;;AA9DwD","sourcesContent":["import {ComputePass, ComputePassProps, ComputePipeline, Buffer, Binding, cast} from '@luma.gl/api';\nimport WebGPUDevice from '../webgpu-device';\nimport WebGPUBuffer from './webgpu-buffer';\n// import WebGPUCommandEncoder from './webgpu-command-encoder';\nimport WebGPUComputePipeline from './webgpu-compute-pipeline';\n\nexport default class WebGPUComputePass extends ComputePass {\n readonly device: WebGPUDevice;\n readonly handle: GPUComputePassEncoder;\n _bindGroupLayout: GPUBindGroupLayout;\n\n constructor(device: WebGPUDevice, props: ComputePassProps) {\n super(device, props);\n this.device = device;\n\n this.handle = this.props.handle || device.commandEncoder.beginComputePass({\n label: this.props.id,\n // timestampWrites?: GPUComputePassTimestampWrites;\n });\n }\n\n /** @note no WebGPU destroy method, just gc */\n destroy() {}\n\n endPass(): void {\n this.handle.endPass();\n }\n\n setPipeline(pipeline: ComputePipeline): void {\n const wgpuPipeline = cast<WebGPUComputePipeline>(pipeline);\n this.handle.setPipeline(wgpuPipeline.handle);\n this._bindGroupLayout = wgpuPipeline._getBindGroupLayout();\n }\n\n /** Sets an array of bindings (uniform buffers, samplers, textures, ...) */\n setBindings(bindings: Binding[]): void {\n throw new Error('fix me');\n // const bindGroup = getBindGroup(this.device.handle, this._bindGroupLayout, this.props.bindings);\n // this.handle.setBindGroup(0, bindGroup);\n }\n\n /**\n * Dispatch work to be performed with the current ComputePipeline.\n * @param x X dimension of the grid of workgroups to dispatch.\n * @param y Y dimension of the grid of workgroups to dispatch.\n * @param z Z dimension of the grid of workgroups to dispatch.\n */\n dispatch(x: number, y?: number, z?: number): void {\n this.handle.dispatch(x, y, z);\n }\n\n /**\n * Dispatch work to be performed with the current ComputePipeline.\n * @param indirectBuffer buffer must be a tightly packed block of three 32-bit unsigned integer values (12 bytes total), given in the same order as the arguments for dispatch()\n * @param indirectOffset\n */\n dispatchIndirect(indirectBuffer: Buffer, indirectOffset: number = 0): void {\n this.handle.dispatchIndirect(cast<WebGPUBuffer>(indirectBuffer).handle, indirectOffset);\n }\n\n pushDebugGroup(groupLabel: string): void {\n this.handle.pushDebugGroup(groupLabel);\n }\n popDebugGroup(): void {\n this.handle.popDebugGroup();\n }\n insertDebugMarker(markerLabel: string): void {\n this.handle.insertDebugMarker(markerLabel);\n }\n\n // writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;\n // beginPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;\n // endPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;\n}\n"],"file":"webgpu-compute-pass.js"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="@webgpu/types" />
|
|
2
|
+
import { ComputePipeline, ComputePipelineProps } from '@luma.gl/api';
|
|
3
|
+
import WebGPUDevice from '../webgpu-device';
|
|
4
|
+
/** Creates a new compute pipeline when parameters change */
|
|
5
|
+
export default class WebGPUComputePipeline extends ComputePipeline {
|
|
6
|
+
device: WebGPUDevice;
|
|
7
|
+
handle: GPUComputePipeline;
|
|
8
|
+
constructor(device: WebGPUDevice, props: ComputePipelineProps);
|
|
9
|
+
/** For internal use in render passes */
|
|
10
|
+
_getBindGroupLayout(): GPUBindGroupLayout;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=webgpu-compute-pipeline.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webgpu-compute-pipeline.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-compute-pipeline.ts"],"names":[],"mappings":";AACA,OAAO,EAAC,eAAe,EAAE,oBAAoB,EAAO,MAAM,cAAc,CAAC;AAEzE,OAAO,YAAY,MAAM,kBAAkB,CAAC;AAK5C,4DAA4D;AAC5D,MAAM,CAAC,OAAO,OAAO,qBAAsB,SAAQ,eAAe;IAChE,MAAM,EAAE,YAAY,CAAC;IACrB,MAAM,EAAE,kBAAkB,CAAC;gBAEf,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,oBAAoB;IAe7D,wCAAwC;IACxC,mBAAmB;CAIpB"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
import { ComputePipeline, cast } from '@luma.gl/api';
|
|
3
|
+
export default class WebGPUComputePipeline extends ComputePipeline {
|
|
4
|
+
constructor(device, props) {
|
|
5
|
+
super(device, props);
|
|
6
|
+
|
|
7
|
+
_defineProperty(this, "device", void 0);
|
|
8
|
+
|
|
9
|
+
_defineProperty(this, "handle", void 0);
|
|
10
|
+
|
|
11
|
+
this.device = device;
|
|
12
|
+
const module = cast(this.props.cs).handle;
|
|
13
|
+
this.handle = this.props.handle || this.device.handle.createComputePipeline({
|
|
14
|
+
label: this.props.id,
|
|
15
|
+
compute: {
|
|
16
|
+
module,
|
|
17
|
+
entryPoint: this.props.csEntryPoint
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
_getBindGroupLayout() {
|
|
23
|
+
return this.handle.getBindGroupLayout(0);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=webgpu-compute-pipeline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/adapter/resources/webgpu-compute-pipeline.ts"],"names":["ComputePipeline","cast","WebGPUComputePipeline","constructor","device","props","module","cs","handle","createComputePipeline","label","id","compute","entryPoint","csEntryPoint","_getBindGroupLayout","getBindGroupLayout"],"mappings":";AACA,SAAQA,eAAR,EAA+CC,IAA/C,QAA0D,cAA1D;AAQA,eAAe,MAAMC,qBAAN,SAAoCF,eAApC,CAAoD;AAIjEG,EAAAA,WAAW,CAACC,MAAD,EAAuBC,KAAvB,EAAoD;AAC7D,UAAMD,MAAN,EAAcC,KAAd;;AAD6D;;AAAA;;AAE7D,SAAKD,MAAL,GAAcA,MAAd;AAEA,UAAME,MAAM,GAAGL,IAAI,CAAe,KAAKI,KAAL,CAAWE,EAA1B,CAAJ,CAAkCC,MAAjD;AACA,SAAKA,MAAL,GAAc,KAAKH,KAAL,CAAWG,MAAX,IAAqB,KAAKJ,MAAL,CAAYI,MAAZ,CAAmBC,qBAAnB,CAAyC;AAC1EC,MAAAA,KAAK,EAAE,KAAKL,KAAL,CAAWM,EADwD;AAE1EC,MAAAA,OAAO,EAAE;AACPN,QAAAA,MADO;AAEPO,QAAAA,UAAU,EAAE,KAAKR,KAAL,CAAWS;AAFhB;AAFiE,KAAzC,CAAnC;AAQD;;AAGDC,EAAAA,mBAAmB,GAAG;AAEpB,WAAO,KAAKP,MAAL,CAAYQ,kBAAZ,CAA+B,CAA/B,CAAP;AACD;;AAvBgE","sourcesContent":["// prettier-ignore\nimport {ComputePipeline, ComputePipelineProps, cast} from '@luma.gl/api';\n\nimport WebGPUDevice from '../webgpu-device';\nimport WebGPUShader from './webgpu-shader';\n\n// COMPUTE PIPELINE\n\n/** Creates a new compute pipeline when parameters change */\nexport default class WebGPUComputePipeline extends ComputePipeline {\n device: WebGPUDevice;\n handle: GPUComputePipeline;\n\n constructor(device: WebGPUDevice, props: ComputePipelineProps) {\n super(device, props);\n this.device = device;\n\n const module = cast<WebGPUShader>(this.props.cs).handle;\n this.handle = this.props.handle || this.device.handle.createComputePipeline({\n label: this.props.id,\n compute: {\n module,\n entryPoint: this.props.csEntryPoint,\n // constants: this.props.csConstants\n }\n });\n }\n\n /** For internal use in render passes */\n _getBindGroupLayout() {\n // TODO: Cache?\n return this.handle.getBindGroupLayout(0);\n }\n}\n"],"file":"webgpu-compute-pipeline.js"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/// <reference types="@webgpu/types" />
|
|
2
|
+
import { ExternalTexture, ExternalTextureProps, Sampler, SamplerProps } from '@luma.gl/api';
|
|
3
|
+
import type WebGPUDevice from '../webgpu-device';
|
|
4
|
+
import WebGPUSampler from './webgpu-sampler';
|
|
5
|
+
/**
|
|
6
|
+
* Cheap, temporary texture view for videos
|
|
7
|
+
* Only valid within same callback, destroyed automatically as a microtask.
|
|
8
|
+
*/
|
|
9
|
+
export default class WebGPUExternalTexture extends ExternalTexture {
|
|
10
|
+
readonly device: WebGPUDevice;
|
|
11
|
+
readonly handle: GPUExternalTexture;
|
|
12
|
+
sampler: WebGPUSampler;
|
|
13
|
+
constructor(device: WebGPUDevice, props: ExternalTextureProps);
|
|
14
|
+
destroy(): void;
|
|
15
|
+
/** Set default sampler */
|
|
16
|
+
setSampler(sampler: Sampler | SamplerProps): this;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=webgpu-external-texture.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webgpu-external-texture.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-external-texture.ts"],"names":[],"mappings":";AACA,OAAO,EAAC,eAAe,EAAE,oBAAoB,EAAE,OAAO,EAAE,YAAY,EAAC,MAAM,cAAc,CAAC;AAC1F,OAAO,KAAK,YAAY,MAAM,kBAAkB,CAAC;AACjD,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAE7C;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,qBAAsB,SAAQ,eAAe;IAChE,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,kBAAkB,CAAC;IACpC,OAAO,EAAE,aAAa,CAAC;gBAEX,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,oBAAoB;IAU7D,OAAO,IAAI,IAAI;IAMf,0BAA0B;IAC1B,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,YAAY,GAAG,IAAI;CAKlD"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
import { ExternalTexture } from '@luma.gl/api';
|
|
3
|
+
import WebGPUSampler from './webgpu-sampler';
|
|
4
|
+
export default class WebGPUExternalTexture extends ExternalTexture {
|
|
5
|
+
constructor(device, props) {
|
|
6
|
+
super(device, props);
|
|
7
|
+
|
|
8
|
+
_defineProperty(this, "device", void 0);
|
|
9
|
+
|
|
10
|
+
_defineProperty(this, "handle", void 0);
|
|
11
|
+
|
|
12
|
+
_defineProperty(this, "sampler", void 0);
|
|
13
|
+
|
|
14
|
+
this.device = device;
|
|
15
|
+
this.handle = this.props.handle || this.device.handle.importExternalTexture({
|
|
16
|
+
source: props.source,
|
|
17
|
+
colorSpace: props.colorSpace
|
|
18
|
+
});
|
|
19
|
+
this.sampler = null;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
destroy() {}
|
|
23
|
+
|
|
24
|
+
setSampler(sampler) {
|
|
25
|
+
this.sampler = sampler instanceof WebGPUSampler ? sampler : new WebGPUSampler(this.device, sampler);
|
|
26
|
+
return this;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=webgpu-external-texture.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/adapter/resources/webgpu-external-texture.ts"],"names":["ExternalTexture","WebGPUSampler","WebGPUExternalTexture","constructor","device","props","handle","importExternalTexture","source","colorSpace","sampler","destroy","setSampler"],"mappings":";AACA,SAAQA,eAAR,QAA2E,cAA3E;AAEA,OAAOC,aAAP,MAA0B,kBAA1B;AAMA,eAAe,MAAMC,qBAAN,SAAoCF,eAApC,CAAoD;AAKjEG,EAAAA,WAAW,CAACC,MAAD,EAAuBC,KAAvB,EAAoD;AAC7D,UAAMD,MAAN,EAAcC,KAAd;;AAD6D;;AAAA;;AAAA;;AAE7D,SAAKD,MAAL,GAAcA,MAAd;AACA,SAAKE,MAAL,GAAc,KAAKD,KAAL,CAAWC,MAAX,IAAqB,KAAKF,MAAL,CAAYE,MAAZ,CAAmBC,qBAAnB,CAAyC;AAC1EC,MAAAA,MAAM,EAAEH,KAAK,CAACG,MAD4D;AAE1EC,MAAAA,UAAU,EAAEJ,KAAK,CAACI;AAFwD,KAAzC,CAAnC;AAIA,SAAKC,OAAL,GAAe,IAAf;AACD;;AAEDC,EAAAA,OAAO,GAAS,CAIf;;AAGDC,EAAAA,UAAU,CAACF,OAAD,EAAwC;AAEhD,SAAKA,OAAL,GAAeA,OAAO,YAAYT,aAAnB,GAAmCS,OAAnC,GAA6C,IAAIT,aAAJ,CAAkB,KAAKG,MAAvB,EAA+BM,OAA/B,CAA5D;AACA,WAAO,IAAP;AACD;;AA1BgE","sourcesContent":["// luma.gl, MIT license\nimport {ExternalTexture, ExternalTextureProps, Sampler, SamplerProps} from '@luma.gl/api';\nimport type WebGPUDevice from '../webgpu-device';\nimport WebGPUSampler from './webgpu-sampler';\n\n/**\n * Cheap, temporary texture view for videos\n * Only valid within same callback, destroyed automatically as a microtask.\n */\nexport default class WebGPUExternalTexture extends ExternalTexture {\n readonly device: WebGPUDevice;\n readonly handle: GPUExternalTexture;\n sampler: WebGPUSampler;\n\n constructor(device: WebGPUDevice, props: ExternalTextureProps) {\n super(device, props);\n this.device = device;\n this.handle = this.props.handle || this.device.handle.importExternalTexture({\n source: props.source,\n colorSpace: props.colorSpace\n });\n this.sampler = null;\n }\n\n destroy(): void {\n // External textures are destroyed automatically,\n // as a microtask, instead of manually or upon garbage collection like other resources.\n // this.handle.destroy();\n }\n\n /** Set default sampler */\n setSampler(sampler: Sampler | SamplerProps): this {\n // We can accept a sampler instance or set of props;\n this.sampler = sampler instanceof WebGPUSampler ? sampler : new WebGPUSampler(this.device, sampler);\n return this;\n }\n}\n"],"file":"webgpu-external-texture.js"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/// <reference types="@webgpu/types" />
|
|
2
|
+
import type { FramebufferProps } from '@luma.gl/api';
|
|
3
|
+
import { Framebuffer } from '@luma.gl/api';
|
|
4
|
+
import WebGPUDevice from '../webgpu-device';
|
|
5
|
+
import WebGPUTexture from './webgpu-texture';
|
|
6
|
+
/**
|
|
7
|
+
* Create new textures with correct size for all attachments.
|
|
8
|
+
* @note resize() destroys existing textures (if size has changed).
|
|
9
|
+
*/
|
|
10
|
+
export default class WebGPUFramebuffer extends Framebuffer {
|
|
11
|
+
readonly device: WebGPUDevice;
|
|
12
|
+
colorAttachments: WebGPUTexture[];
|
|
13
|
+
depthStencilAttachment: WebGPUTexture;
|
|
14
|
+
/** Partial render pass descriptor. Used by WebGPURenderPass */
|
|
15
|
+
renderPassDescriptor: {
|
|
16
|
+
colorAttachments: GPURenderPassColorAttachment[];
|
|
17
|
+
depthStencilAttachment?: GPURenderPassDepthStencilAttachment;
|
|
18
|
+
};
|
|
19
|
+
constructor(device: WebGPUDevice, props: FramebufferProps);
|
|
20
|
+
/** Create depth stencil texture */
|
|
21
|
+
private createDepthStencilTexture;
|
|
22
|
+
private createColorTexture;
|
|
23
|
+
/**
|
|
24
|
+
* Create new textures with correct size for all attachments.
|
|
25
|
+
* @note destroys existing textures.
|
|
26
|
+
*/
|
|
27
|
+
protected _resizeAttachments(width: number, height: number): void;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=webgpu-framebuffer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webgpu-framebuffer.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-framebuffer.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAC,gBAAgB,EAAqB,MAAM,cAAc,CAAC;AACvE,OAAO,EAAC,WAAW,EAAU,MAAM,cAAc,CAAC;AAClD,OAAO,YAAY,MAAM,kBAAkB,CAAC;AAG5C,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAM7C;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,iBAAkB,SAAQ,WAAW;IACxD,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAE9B,gBAAgB,EAAE,aAAa,EAAE,CAAM;IACvC,sBAAsB,EAAE,aAAa,CAAC;IAEtC,+DAA+D;IAC/D,oBAAoB,EAAE;QACpB,gBAAgB,EAAE,4BAA4B,EAAE,CAAC;QACjD,sBAAsB,CAAC,EAAE,mCAAmC,CAAC;KAC9D,CAEC;gBAEU,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,gBAAgB;IAgCzD,mCAAmC;IACnC,OAAO,CAAC,yBAAyB;IAkBjC,OAAO,CAAC,kBAAkB;IAkB1B;;;OAGG;IACF,SAAS,CAAC,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;CAiBnE"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
import { Framebuffer, Texture } from '@luma.gl/api';
|
|
3
|
+
import WEBGPUTexture from './webgpu-texture';
|
|
4
|
+
const MAX_COLOR_ATTACHMENTS = 8;
|
|
5
|
+
export default class WebGPUFramebuffer extends Framebuffer {
|
|
6
|
+
constructor(device, props) {
|
|
7
|
+
super(device, props);
|
|
8
|
+
|
|
9
|
+
_defineProperty(this, "device", void 0);
|
|
10
|
+
|
|
11
|
+
_defineProperty(this, "colorAttachments", []);
|
|
12
|
+
|
|
13
|
+
_defineProperty(this, "depthStencilAttachment", void 0);
|
|
14
|
+
|
|
15
|
+
_defineProperty(this, "renderPassDescriptor", {
|
|
16
|
+
colorAttachments: []
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
this.device = device;
|
|
20
|
+
|
|
21
|
+
if (props.depthStencilAttachment) {
|
|
22
|
+
this.depthStencilAttachment = this.createDepthStencilTexture(props);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (props.colorAttachments) {
|
|
26
|
+
this.colorAttachments = props.colorAttachments.map(colorAttachment => this.createColorTexture(this.props, colorAttachment));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (this.depthStencilAttachment) {
|
|
30
|
+
this.renderPassDescriptor.depthStencilAttachment = {
|
|
31
|
+
view: this.depthStencilAttachment.handle.createView(),
|
|
32
|
+
depthLoadValue: 1.0,
|
|
33
|
+
depthStoreOp: 'store',
|
|
34
|
+
stencilLoadValue: 0,
|
|
35
|
+
stencilStoreOp: 'store'
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (this.colorAttachments.length > 0) {
|
|
40
|
+
this.renderPassDescriptor.colorAttachments = this.colorAttachments.map(colorAttachment => ({
|
|
41
|
+
view: colorAttachment.handle.createView(),
|
|
42
|
+
loadValue: [0.0, 0.0, 0.0, 0.0],
|
|
43
|
+
storeOp: 'store'
|
|
44
|
+
}));
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
createDepthStencilTexture(props) {
|
|
49
|
+
if (props.depthStencilAttachment instanceof WEBGPUTexture) {
|
|
50
|
+
return props.depthStencilAttachment;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (typeof props.depthStencilAttachment === 'string') {
|
|
54
|
+
return this.device._createTexture({
|
|
55
|
+
id: 'depth-stencil-attachment',
|
|
56
|
+
format: props.depthStencilAttachment,
|
|
57
|
+
width: props.width,
|
|
58
|
+
height: props.height,
|
|
59
|
+
usage: Texture.RENDER_ATTACHMENT
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
throw new Error('type');
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
createColorTexture(props, texture) {
|
|
67
|
+
if (texture instanceof WEBGPUTexture) {
|
|
68
|
+
return texture;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (typeof texture === 'string') {
|
|
72
|
+
return this.device._createTexture({
|
|
73
|
+
id: 'color-attachment',
|
|
74
|
+
format: texture,
|
|
75
|
+
width: props.width,
|
|
76
|
+
height: props.height,
|
|
77
|
+
usage: Texture.RENDER_ATTACHMENT
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
throw new Error('type');
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
_resizeAttachments(width, height) {
|
|
85
|
+
for (let i = 0; i < this.colorAttachments.length; ++i) {
|
|
86
|
+
if (this.colorAttachments[i]) {
|
|
87
|
+
const resizedTexture = this.device._createTexture({ ...this.colorAttachments[i].props,
|
|
88
|
+
width,
|
|
89
|
+
height
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
this.colorAttachments[i].destroy();
|
|
93
|
+
this.colorAttachments[i] = resizedTexture;
|
|
94
|
+
this.renderPassDescriptor.colorAttachments[i].view = resizedTexture.handle.createView();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (this.depthStencilAttachment) {
|
|
99
|
+
const resizedTexture = this.device._createTexture({ ...this.depthStencilAttachment.props,
|
|
100
|
+
width,
|
|
101
|
+
height
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
this.depthStencilAttachment.destroy();
|
|
105
|
+
this.depthStencilAttachment = resizedTexture;
|
|
106
|
+
this.renderPassDescriptor.depthStencilAttachment.view = resizedTexture.handle.createView();
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=webgpu-framebuffer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/adapter/resources/webgpu-framebuffer.ts"],"names":["Framebuffer","Texture","WEBGPUTexture","MAX_COLOR_ATTACHMENTS","WebGPUFramebuffer","constructor","device","props","colorAttachments","depthStencilAttachment","createDepthStencilTexture","map","colorAttachment","createColorTexture","renderPassDescriptor","view","handle","createView","depthLoadValue","depthStoreOp","stencilLoadValue","stencilStoreOp","length","loadValue","storeOp","_createTexture","id","format","width","height","usage","RENDER_ATTACHMENT","Error","texture","_resizeAttachments","i","resizedTexture","destroy"],"mappings":";AACA,SAAQA,WAAR,EAAqBC,OAArB,QAAmC,cAAnC;AAGA,OAAOC,aAAP,MAA0B,kBAA1B;AAKA,MAAMC,qBAAqB,GAAG,CAA9B;AAMA,eAAe,MAAMC,iBAAN,SAAgCJ,WAAhC,CAA4C;AAczDK,EAAAA,WAAW,CAACC,MAAD,EAAuBC,KAAvB,EAAgD;AACzD,UAAMD,MAAN,EAAcC,KAAd;;AADyD;;AAAA,8CAXvB,EAWuB;;AAAA;;AAAA,kDAJvD;AACFC,MAAAA,gBAAgB,EAAE;AADhB,KAIuD;;AAEzD,SAAKF,MAAL,GAAcA,MAAd;;AAEA,QAAIC,KAAK,CAACE,sBAAV,EAAkC;AAChC,WAAKA,sBAAL,GAA8B,KAAKC,yBAAL,CAA+BH,KAA/B,CAA9B;AACD;;AAED,QAAIA,KAAK,CAACC,gBAAV,EAA4B;AAC1B,WAAKA,gBAAL,GAAwBD,KAAK,CAACC,gBAAN,CAAuBG,GAAvB,CAA2BC,eAAe,IAAI,KAAKC,kBAAL,CAAwB,KAAKN,KAA7B,EAAoCK,eAApC,CAA9C,CAAxB;AACD;;AAED,QAAI,KAAKH,sBAAT,EAAiC;AAC/B,WAAKK,oBAAL,CAA0BL,sBAA1B,GAAmD;AACjDM,QAAAA,IAAI,EAAE,KAAKN,sBAAL,CAA4BO,MAA5B,CAAmCC,UAAnC,EAD2C;AAGjDC,QAAAA,cAAc,EAAE,GAHiC;AAIjDC,QAAAA,YAAY,EAAE,OAJmC;AAKjDC,QAAAA,gBAAgB,EAAE,CAL+B;AAMjDC,QAAAA,cAAc,EAAE;AANiC,OAAnD;AAQD;;AAED,QAAI,KAAKb,gBAAL,CAAsBc,MAAtB,GAA+B,CAAnC,EAAsC;AACpC,WAA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ormat} from '@luma.gl/api';\nimport {Framebuffer, Texture} from '@luma.gl/api';\nimport WebGPUDevice from '../webgpu-device';\n// import WebGPUCanvasContext from '../webgpu-canvas-context';\nimport WEBGPUTexture from './webgpu-texture';\nimport WebGPUTexture from './webgpu-texture';\n\n// const DEFAULT_DEPTH_STENCIL_FORMAT: DepthStencilTextureFormat = 'depth24plus';\n\nconst MAX_COLOR_ATTACHMENTS = 8;\n\n/**\n * Create new textures with correct size for all attachments. \n * @note resize() destroys existing textures (if size has changed). \n */\nexport default class WebGPUFramebuffer extends Framebuffer {\n readonly device: WebGPUDevice;\n\n colorAttachments: WebGPUTexture[] = [];\n depthStencilAttachment: WebGPUTexture;\n\n /** Partial render pass descriptor. Used by WebGPURenderPass */\n renderPassDescriptor: {\n colorAttachments: GPURenderPassColorAttachment[];\n depthStencilAttachment?: GPURenderPassDepthStencilAttachment;\n } = {\n colorAttachments: []\n };\n\n constructor(device: WebGPUDevice, props: FramebufferProps) {\n super(device, props);\n this.device = device;\n\n if (props.depthStencilAttachment) {\n this.depthStencilAttachment = this.createDepthStencilTexture(props);\n }\n\n if (props.colorAttachments) {\n this.colorAttachments = props.colorAttachments.map(colorAttachment => this.createColorTexture(this.props, colorAttachment));\n }\n\n if (this.depthStencilAttachment) {\n this.renderPassDescriptor.depthStencilAttachment = {\n view: this.depthStencilAttachment.handle.createView(),\n // Add default clear values\n depthLoadValue: 1.0,\n depthStoreOp: 'store',\n stencilLoadValue: 0,\n stencilStoreOp: 'store',\n }\n }\n\n if (this.colorAttachments.length > 0) {\n this.renderPassDescriptor.colorAttachments = this.colorAttachments.map(colorAttachment => ({\n view: colorAttachment.handle.createView(),\n loadValue: [0.0, 0.0, 0.0, 0.0],\n storeOp: 'store'\n }));\n }\n }\n\n /** Create depth stencil texture */\n private createDepthStencilTexture(props: FramebufferProps): WEBGPUTexture {\n if (props.depthStencilAttachment instanceof WEBGPUTexture) {\n return props.depthStencilAttachment;\n }\n\n if (typeof props.depthStencilAttachment === 'string') {\n return this.device._createTexture({\n id: 'depth-stencil-attachment',\n format: props.depthStencilAttachment,\n width: props.width,\n height: props.height,\n usage: Texture.RENDER_ATTACHMENT\n });\n }\n\n throw new Error('type');\n }\n\n private createColorTexture(props: FramebufferProps, texture: Texture | ColorTextureFormat): WEBGPUTexture {\n if (texture instanceof WEBGPUTexture) {\n return texture;\n }\n\n if (typeof texture === 'string') {\n return this.device._createTexture({\n id: 'color-attachment',\n format: texture,\n width: props.width,\n height: props.height,\n usage: Texture.RENDER_ATTACHMENT\n });\n }\n\n throw new Error('type');\n }\n\n /**\n * Create new textures with correct size for all attachments.\n * @note destroys existing textures.\n */\n protected _resizeAttachments(width: number, height: number): void {\n for (let i = 0; i < this.colorAttachments.length; ++i) {\n if (this.colorAttachments[i]) {\n const resizedTexture = this.device._createTexture({...this.colorAttachments[i].props, width, height})\n this.colorAttachments[i].destroy();\n this.colorAttachments[i] = resizedTexture;\n this.renderPassDescriptor.colorAttachments[i].view = resizedTexture.handle.createView();\n }\n }\n\n if (this.depthStencilAttachment) {\n const resizedTexture = this.device._createTexture({...this.depthStencilAttachment.props, width, height})\n this.depthStencilAttachment.destroy();\n this.depthStencilAttachment = resizedTexture;\n this.renderPassDescriptor.depthStencilAttachment.view = resizedTexture.handle.createView();\n }\n }\n}\n"],"file":"webgpu-framebuffer.js"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=webgpu-query.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webgpu-query.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-query.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[],"file":"webgpu-query.js"}
|