@luma.gl/webgpu 9.0.0-alpha.21 → 9.0.0-alpha.23
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/resources/webgpu-command-encoder.d.ts +3 -11
- package/dist/adapter/resources/webgpu-command-encoder.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-command-encoder.js.map +1 -1
- package/dist/adapter/resources/webgpu-framebuffer.d.ts +0 -17
- package/dist/adapter/resources/webgpu-framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-framebuffer.js +2 -84
- package/dist/adapter/resources/webgpu-framebuffer.js.map +1 -1
- package/dist/adapter/resources/webgpu-render-pass.d.ts +6 -1
- package/dist/adapter/resources/webgpu-render-pass.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-render-pass.js +19 -1
- package/dist/adapter/resources/webgpu-render-pass.js.map +1 -1
- package/dist/adapter/resources/webgpu-shader.js +3 -2
- package/dist/adapter/resources/webgpu-shader.js.map +1 -1
- package/dist/adapter/resources/webgpu-texture.d.ts +10 -2
- package/dist/adapter/resources/webgpu-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-texture.js +8 -1
- package/dist/adapter/resources/webgpu-texture.js.map +1 -1
- package/dist/adapter/webgpu-canvas-context.d.ts +1 -1
- package/dist/adapter/webgpu-canvas-context.d.ts.map +1 -1
- package/dist/adapter/webgpu-canvas-context.js.map +1 -1
- package/dist/adapter/webgpu-device.d.ts +16 -2
- package/dist/adapter/webgpu-device.d.ts.map +1 -1
- package/dist/adapter/webgpu-device.js +31 -2
- package/dist/adapter/webgpu-device.js.map +1 -1
- package/dist/dist.dev.js +384 -171
- package/dist/index.cjs +80 -87
- package/dist.min.js +4 -4
- package/package.json +3 -3
- package/src/adapter/resources/webgpu-command-encoder.ts +40 -21
- package/src/adapter/resources/webgpu-framebuffer.ts +6 -107
- package/src/adapter/resources/webgpu-render-pass.ts +34 -4
- package/src/adapter/resources/webgpu-shader.ts +2 -2
- package/src/adapter/resources/webgpu-texture.ts +8 -2
- package/src/adapter/webgpu-canvas-context.ts +2 -1
- package/src/adapter/webgpu-device.ts +71 -3
- package/src/.DS_Store +0 -0
- package/src/adapter/.DS_Store +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="dist" />
|
|
2
|
-
import { CommandEncoder, CommandEncoderProps, Buffer, Texture } from '@luma.gl/api';
|
|
2
|
+
import { CommandEncoder, CommandEncoderProps, Buffer, Texture, CopyTextureToTextureOptions, CopyTextureToBufferOptions } from '@luma.gl/api';
|
|
3
3
|
import { WebGPUDevice } from '../webgpu-device';
|
|
4
4
|
export declare class WebGPUCommandEncoder extends CommandEncoder {
|
|
5
5
|
readonly device: WebGPUDevice;
|
|
@@ -27,16 +27,8 @@ export declare class WebGPUCommandEncoder extends CommandEncoder {
|
|
|
27
27
|
origin?: number[] | [number, number, number];
|
|
28
28
|
extent?: number[] | [number, number, number];
|
|
29
29
|
}): void;
|
|
30
|
-
copyTextureToBuffer(options:
|
|
31
|
-
|
|
32
|
-
destination: GPUImageCopyBuffer;
|
|
33
|
-
copySize: GPUExtent3D;
|
|
34
|
-
}): void;
|
|
35
|
-
copyTextureToTexture(options: {
|
|
36
|
-
source: GPUImageCopyTexture;
|
|
37
|
-
destination: GPUImageCopyTexture;
|
|
38
|
-
copySize: GPUExtent3D;
|
|
39
|
-
}): void;
|
|
30
|
+
copyTextureToBuffer(options: CopyTextureToBufferOptions): void;
|
|
31
|
+
copyTextureToTexture(options: CopyTextureToTextureOptions): void;
|
|
40
32
|
pushDebugGroup(groupLabel: string): void;
|
|
41
33
|
popDebugGroup(): void;
|
|
42
34
|
insertDebugMarker(markerLabel: string): void;
|
|
@@ -1 +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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AG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;KAC7C,GACE,IAAI;IAuBP,mBAAmB,CAAC,OAAO,EAAE,0BAA0B,GAAG,IAAI;IAW9D,oBAAoB,CAAC,OAAO,EAAE,2BAA2B,GAAG,IAAI;IAWvD,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAIxC,aAAa,IAAI,IAAI;IAIrB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;CAatD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgpu-command-encoder.js","names":["CommandEncoder","cast","WebGPUCommandEncoder","constructor","device","props","_defineProperty","handle","createCommandEncoder","label","id","destroy","finish","options","copyBufferToBuffer","_options$sourceOffset","_options$destinationO","_options$size","source","sourceOffset","destination","destinationOffset","size","copyBufferToTexture","_options$offset","_options$mipLevel","_options$origin","buffer","offset","bytesPerRow","rowsPerImage","texture","mipLevel","origin","width","extent","height","depthOrArrayLayers","copyTextureToBuffer","copyTextureToTexture","pushDebugGroup","groupLabel","popDebugGroup","insertDebugMarker","markerLabel"],"sources":["../../../src/adapter/resources/webgpu-command-encoder.ts"],"sourcesContent":["import {CommandEncoder, CommandEncoderProps, Buffer, Texture, cast} from '@luma.gl/api';\nimport {WebGPUDevice} from '../webgpu-device';\nimport {WebGPUBuffer} from './webgpu-buffer';\nimport {WebGPUTexture} from './webgpu-texture';\n\nexport 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 = props.handle || this.device.handle.createCommandEncoder({\n // TODO was this removed in standard?\n // measureExecutionTime: this.props.measureExecutionTime\n });\n this.handle.label = this.props.id;\n }\n\n override destroy(): void {}\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
|
|
1
|
+
{"version":3,"file":"webgpu-command-encoder.js","names":["CommandEncoder","cast","WebGPUCommandEncoder","constructor","device","props","_defineProperty","handle","createCommandEncoder","label","id","destroy","finish","options","copyBufferToBuffer","_options$sourceOffset","_options$destinationO","_options$size","source","sourceOffset","destination","destinationOffset","size","copyBufferToTexture","_options$offset","_options$mipLevel","_options$origin","buffer","offset","bytesPerRow","rowsPerImage","texture","mipLevel","origin","width","extent","height","depthOrArrayLayers","copyTextureToBuffer","copyTextureToTexture","pushDebugGroup","groupLabel","popDebugGroup","insertDebugMarker","markerLabel"],"sources":["../../../src/adapter/resources/webgpu-command-encoder.ts"],"sourcesContent":["import {CommandEncoder, CommandEncoderProps, Buffer, Texture, cast, \n CopyTextureToTextureOptions, \n CopyTextureToBufferOptions\n // CopyBufferToTextureOptions,\n // CopyBufferToBufferOptions,\n} from '@luma.gl/api';\nimport {WebGPUDevice} from '../webgpu-device';\nimport {WebGPUBuffer} from './webgpu-buffer';\nimport {WebGPUTexture} from './webgpu-texture';\n\nexport 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 = props.handle || this.device.handle.createCommandEncoder({\n // TODO was this removed in standard?\n // measureExecutionTime: this.props.measureExecutionTime\n });\n this.handle.label = this.props.id;\n }\n\n override destroy(): void {}\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: // CopyBufferToBufferOptions\n {\n source: Buffer,\n sourceOffset?: number,\n destination: Buffer,\n destinationOffset?: number,\n size?: number\n }\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: // CopyBufferToTextureOptions\n {\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 }\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 {\n // TODO exclamation mark hack\n width: options.extent[0],\n height: options.extent[1],\n depthOrArrayLayers: options.extent[2]\n }\n );\n }\n\n copyTextureToBuffer(options: CopyTextureToBufferOptions): void {\n // this.handle.copyTextureToBuffer(\n // // source\n // {},\n // // destination\n // {},\n // // copySize\n // {}\n // );\n }\n\n copyTextureToTexture(options: CopyTextureToTextureOptions): void {\n // this.handle.copyTextureToTexture(\n // // source\n // {},\n // // destination\n // {},\n // // copySize\n // {}\n // );\n }\n\n override pushDebugGroup(groupLabel: string): void {\n this.handle.pushDebugGroup(groupLabel);\n }\n\n override popDebugGroup(): void {\n this.handle.popDebugGroup();\n }\n\n override 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}"],"mappings":";AAAA,SAAQA,cAAc,EAAwCC,IAAI,QAK3D,cAAc;AAKrB,OAAO,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AO,CAACe,MAAM,cAAAJ,eAAA,cAAAA,eAAA,GAAI,CAAC;MAC3BK,WAAW,EAAEhB,OAAO,CAACgB,WAAW;MAChCC,YAAY,EAAEjB,OAAO,CAACiB;IACxB,CAAC,EACD;MACEC,OAAO,EAAE9B,IAAI,CAAgBY,OAAO,CAACO,WAAW,CAAC,CAACb,MAAM;MACxDyB,QAAQ,GAAAP,iBAAA,GAAEZ,OAAO,CAACmB,QAAQ,cAAAP,iBAAA,cAAAA,iBAAA,GAAI,CAAC;MAC/BQ,MAAM,GAAAP,eAAA,GAAEb,OAAO,CAACoB,MAAM,cAAAP,eAAA,cAAAA,eAAA,GAAI,CAAC;IAE7B,CAAC,EACD;MAEEQ,KAAK,EAAErB,OAAO,CAACsB,MAAM,CAAC,CAAC,CAAC;MACxBC,MAAM,EAAEvB,OAAO,CAACsB,MAAM,CAAC,CAAC,CAAC;MACzBE,kBAAkB,EAAExB,OAAO,CAACsB,MAAM,CAAC,CAAC;IACtC,CAAC,CACF;EACH;EAEAG,mBAAmBA,CAACzB,OAAmC,EAAQ,CAS/D;EAEA0B,oBAAoBA,CAAC1B,OAAoC,EAAQ,CASjE;EAES2B,cAAcA,CAACC,UAAkB,EAAQ;IAChD,IAAI,CAAClC,MAAM,CAACiC,cAAc,CAACC,UAAU,CAAC;EACxC;EAESC,aAAaA,CAAA,EAAS;IAC7B,IAAI,CAACnC,MAAM,CAACmC,aAAa,EAAE;EAC7B;EAESC,iBAAiBA,CAACC,WAAmB,EAAQ;IACpD,IAAI,CAACrC,MAAM,CAACoC,iBAAiB,CAACC,WAAW,CAAC;EAC5C;AAWF"}
|
|
@@ -1,29 +1,12 @@
|
|
|
1
|
-
/// <reference types="dist" />
|
|
2
1
|
import type { FramebufferProps } from '@luma.gl/api';
|
|
3
2
|
import { Framebuffer } from '@luma.gl/api';
|
|
4
3
|
import { WebGPUDevice } from '../webgpu-device';
|
|
5
|
-
import { WebGPUTexture } from './webgpu-texture';
|
|
6
4
|
/**
|
|
7
5
|
* Create new textures with correct size for all attachments.
|
|
8
6
|
* @note resize() destroys existing textures (if size has changed).
|
|
9
7
|
*/
|
|
10
8
|
export declare class WebGPUFramebuffer extends Framebuffer {
|
|
11
9
|
readonly device: WebGPUDevice;
|
|
12
|
-
colorAttachments: WebGPUTexture[];
|
|
13
|
-
depthStencilAttachment: WebGPUTexture | null;
|
|
14
|
-
/** Partial render pass descriptor. Used by WebGPURenderPass */
|
|
15
|
-
renderPassDescriptor: {
|
|
16
|
-
colorAttachments: GPURenderPassColorAttachment[];
|
|
17
|
-
depthStencilAttachment?: GPURenderPassDepthStencilAttachment;
|
|
18
|
-
};
|
|
19
10
|
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
11
|
}
|
|
29
12
|
//# sourceMappingURL=webgpu-framebuffer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgpu-framebuffer.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-framebuffer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"webgpu-framebuffer.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-framebuffer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,cAAc,CAAC;AACnD,OAAO,EAAC,WAAW,EAAC,MAAM,cAAc,CAAC;AACzC,OAAO,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAE9C;;;GAGG;AACH,qBAAa,iBAAkB,SAAQ,WAAW;IAChD,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;gBAElB,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,gBAAgB;CAO1D"}
|
|
@@ -1,93 +1,11 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
-
import { Framebuffer
|
|
3
|
-
import { WebGPUTexture } from "./webgpu-texture.js";
|
|
2
|
+
import { Framebuffer } from '@luma.gl/api';
|
|
4
3
|
export class WebGPUFramebuffer extends Framebuffer {
|
|
5
4
|
constructor(device, props) {
|
|
6
5
|
super(device, props);
|
|
7
6
|
_defineProperty(this, "device", void 0);
|
|
8
|
-
_defineProperty(this, "colorAttachments", []);
|
|
9
|
-
_defineProperty(this, "depthStencilAttachment", null);
|
|
10
|
-
_defineProperty(this, "renderPassDescriptor", {
|
|
11
|
-
colorAttachments: []
|
|
12
|
-
});
|
|
13
7
|
this.device = device;
|
|
14
|
-
|
|
15
|
-
this.depthStencilAttachment = this.createDepthStencilTexture(props);
|
|
16
|
-
}
|
|
17
|
-
if (props.colorAttachments) {
|
|
18
|
-
this.colorAttachments = props.colorAttachments.map(colorAttachment => this.createColorTexture(this.props, colorAttachment));
|
|
19
|
-
}
|
|
20
|
-
if (this.depthStencilAttachment) {
|
|
21
|
-
this.renderPassDescriptor.depthStencilAttachment = {
|
|
22
|
-
view: this.depthStencilAttachment.handle.createView(),
|
|
23
|
-
depthClearValue: 1.0,
|
|
24
|
-
depthStoreOp: 'store',
|
|
25
|
-
stencilClearValue: 0,
|
|
26
|
-
stencilStoreOp: 'store'
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
if (this.colorAttachments.length > 0) {
|
|
30
|
-
this.renderPassDescriptor.colorAttachments = this.colorAttachments.map(colorAttachment => ({
|
|
31
|
-
view: colorAttachment.handle.createView(),
|
|
32
|
-
loadOp: 'clear',
|
|
33
|
-
loadValue: [0.0, 0.0, 0.0, 0.0],
|
|
34
|
-
storeOp: 'store'
|
|
35
|
-
}));
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
createDepthStencilTexture(props) {
|
|
39
|
-
if (props.depthStencilAttachment instanceof WebGPUTexture) {
|
|
40
|
-
return props.depthStencilAttachment;
|
|
41
|
-
}
|
|
42
|
-
if (typeof props.depthStencilAttachment === 'string') {
|
|
43
|
-
return this.device._createTexture({
|
|
44
|
-
id: 'depth-stencil-attachment',
|
|
45
|
-
format: props.depthStencilAttachment,
|
|
46
|
-
width: props.width,
|
|
47
|
-
height: props.height,
|
|
48
|
-
usage: Texture.RENDER_ATTACHMENT
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
throw new Error('type');
|
|
52
|
-
}
|
|
53
|
-
createColorTexture(props, texture) {
|
|
54
|
-
if (texture instanceof WebGPUTexture) {
|
|
55
|
-
return texture;
|
|
56
|
-
}
|
|
57
|
-
if (typeof texture === 'string') {
|
|
58
|
-
return this.device._createTexture({
|
|
59
|
-
id: 'color-attachment',
|
|
60
|
-
format: texture,
|
|
61
|
-
width: props.width,
|
|
62
|
-
height: props.height,
|
|
63
|
-
usage: Texture.RENDER_ATTACHMENT
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
throw new Error('type');
|
|
67
|
-
}
|
|
68
|
-
_resizeAttachments(width, height) {
|
|
69
|
-
for (let i = 0; i < this.colorAttachments.length; ++i) {
|
|
70
|
-
if (this.colorAttachments[i]) {
|
|
71
|
-
const resizedTexture = this.device._createTexture({
|
|
72
|
-
...this.colorAttachments[i].props,
|
|
73
|
-
width,
|
|
74
|
-
height
|
|
75
|
-
});
|
|
76
|
-
this.colorAttachments[i].destroy();
|
|
77
|
-
this.colorAttachments[i] = resizedTexture;
|
|
78
|
-
this.renderPassDescriptor.colorAttachments[i].view = resizedTexture.handle.createView();
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
if (this.depthStencilAttachment) {
|
|
82
|
-
const resizedTexture = this.device._createTexture({
|
|
83
|
-
...this.depthStencilAttachment.props,
|
|
84
|
-
width,
|
|
85
|
-
height
|
|
86
|
-
});
|
|
87
|
-
this.depthStencilAttachment.destroy();
|
|
88
|
-
this.depthStencilAttachment = resizedTexture;
|
|
89
|
-
this.renderPassDescriptor.depthStencilAttachment.view = resizedTexture.handle.createView();
|
|
90
|
-
}
|
|
8
|
+
this.autoCreateAttachmentTextures();
|
|
91
9
|
}
|
|
92
10
|
}
|
|
93
11
|
//# sourceMappingURL=webgpu-framebuffer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgpu-framebuffer.js","names":["Framebuffer","
|
|
1
|
+
{"version":3,"file":"webgpu-framebuffer.js","names":["Framebuffer","WebGPUFramebuffer","constructor","device","props","_defineProperty","autoCreateAttachmentTextures"],"sources":["../../../src/adapter/resources/webgpu-framebuffer.ts"],"sourcesContent":["import type {FramebufferProps} from '@luma.gl/api';\nimport {Framebuffer} from '@luma.gl/api';\nimport {WebGPUDevice} from '../webgpu-device';\n\n/**\n * Create new textures with correct size for all attachments.\n * @note resize() destroys existing textures (if size has changed).\n */\nexport class WebGPUFramebuffer extends Framebuffer {\n readonly device: WebGPUDevice;\n\n constructor(device: WebGPUDevice, props: FramebufferProps) {\n super(device, props);\n this.device = device;\n\n // Auto create textures for attachments if needed\n this.autoCreateAttachmentTextures();\n }\n}\n"],"mappings":";AACA,SAAQA,WAAW,QAAO,cAAc;AAOxC,OAAO,MAAMC,iBAAiB,SAASD,WAAW,CAAC;EAGjDE,WAAWA,CAACC,MAAoB,EAAEC,KAAuB,EAAE;IACzD,KAAK,CAACD,MAAM,EAAEC,KAAK,CAAC;IAACC,eAAA;IACrB,IAAI,CAACF,MAAM,GAAGA,MAAM;IAGpB,IAAI,CAACG,4BAA4B,EAAE;EACrC;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="dist" />
|
|
2
|
-
import type { RenderPassProps, RenderPassParameters, Binding } from '@luma.gl/api';
|
|
2
|
+
import type { RenderPassProps, RenderPassParameters, Binding, Framebuffer } from '@luma.gl/api';
|
|
3
3
|
import { Buffer, RenderPass, RenderPipeline } from '@luma.gl/api';
|
|
4
4
|
import { WebGPUDevice } from '../webgpu-device';
|
|
5
5
|
import { WebGPURenderPipeline } from './webgpu-render-pipeline';
|
|
@@ -30,5 +30,10 @@ export declare class WebGPURenderPass extends RenderPass {
|
|
|
30
30
|
pushDebugGroup(groupLabel: string): void;
|
|
31
31
|
popDebugGroup(): void;
|
|
32
32
|
insertDebugMarker(markerLabel: string): void;
|
|
33
|
+
/**
|
|
34
|
+
* Partial render pass descriptor. Used by WebGPURenderPass.
|
|
35
|
+
* @returns attachments fields of a renderpass descriptor.
|
|
36
|
+
*/
|
|
37
|
+
protected getRenderPassDescriptor(framebuffer: Framebuffer): GPURenderPassDescriptor;
|
|
33
38
|
}
|
|
34
39
|
//# sourceMappingURL=webgpu-render-pass.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgpu-render-pass.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-render-pass.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAC,eAAe,EAAE,oBAAoB,EAAE,OAAO,EAAC,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"webgpu-render-pass.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-render-pass.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAC,eAAe,EAAE,oBAAoB,EAAE,OAAO,EAAE,WAAW,EAAC,MAAM,cAAc,CAAC;AAC9F,OAAO,EAAC,MAAM,EAAE,UAAU,EAAE,cAAc,EAAO,MAAM,cAAc,CAAC;AACtE,OAAO,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAI9C,OAAO,EAAC,oBAAoB,EAAC,MAAM,0BAA0B,CAAC;AAE9D,qBAAa,gBAAiB,SAAQ,UAAU;IAC9C,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,oBAAoB,CAAC;IAEtC,sBAAsB;IACtB,QAAQ,EAAE,oBAAoB,GAAG,IAAI,CAAQ;gBAEjC,MAAM,EAAE,YAAY,EAAE,KAAK,GAAE,eAAoB;IASpD,OAAO,IAAI,IAAI;IAExB,GAAG,IAAI,IAAI;IAIX,WAAW,CAAC,QAAQ,EAAE,cAAc,GAAG,IAAI;IAK3C,2EAA2E;IAC3E,WAAW,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAQpD,cAAc,CACZ,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,cAAc,EAC3B,MAAM,GAAE,MAAU,EAClB,IAAI,CAAC,EAAE,MAAM,GACZ,IAAI;IAIP,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAE,MAAU,GAAG,IAAI;IAIvE,IAAI,CAAC,OAAO,EAAE;QACZ,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,GAAG,IAAI;IAmBR,YAAY,IAAI,IAAI;IAKpB,aAAa,CAAC,UAAU,EAAE,oBAAoB,GAAG,IAAI;IAwBrD,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAGxC,aAAa,IAAI,IAAI;IAGrB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;IAc5C;;;OAGG;IACH,SAAS,CAAC,uBAAuB,CAAC,WAAW,EAAE,WAAW,GAAG,uBAAuB;CAuBrF"}
|
|
@@ -9,7 +9,7 @@ export class WebGPURenderPass extends RenderPass {
|
|
|
9
9
|
_defineProperty(this, "pipeline", null);
|
|
10
10
|
this.device = device;
|
|
11
11
|
const framebuffer = props.framebuffer || device.canvasContext.getCurrentFramebuffer();
|
|
12
|
-
const renderPassDescriptor = framebuffer
|
|
12
|
+
const renderPassDescriptor = this.getRenderPassDescriptor(framebuffer);
|
|
13
13
|
this.handle = this.props.handle || device.commandEncoder.beginRenderPass(renderPassDescriptor);
|
|
14
14
|
this.handle.label = this.props.id;
|
|
15
15
|
}
|
|
@@ -75,5 +75,23 @@ export class WebGPURenderPass extends RenderPass {
|
|
|
75
75
|
insertDebugMarker(markerLabel) {
|
|
76
76
|
this.handle.insertDebugMarker(markerLabel);
|
|
77
77
|
}
|
|
78
|
+
getRenderPassDescriptor(framebuffer) {
|
|
79
|
+
const renderPassDescriptor = {
|
|
80
|
+
colorAttachments: []
|
|
81
|
+
};
|
|
82
|
+
renderPassDescriptor.colorAttachments = framebuffer.colorAttachments.map(colorAttachment => ({
|
|
83
|
+
loadOp: 'clear',
|
|
84
|
+
colorClearValue: this.props.clearColor || [0, 0, 0, 0],
|
|
85
|
+
storeOp: this.props.discard ? 'discard' : 'store',
|
|
86
|
+
view: colorAttachment.handle.createView()
|
|
87
|
+
}));
|
|
88
|
+
if (framebuffer.depthStencilAttachment) {
|
|
89
|
+
renderPassDescriptor.depthStencilAttachment = {
|
|
90
|
+
...this.props,
|
|
91
|
+
view: framebuffer.depthStencilAttachment.handle.createView()
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
return renderPassDescriptor;
|
|
95
|
+
}
|
|
78
96
|
}
|
|
79
97
|
//# sourceMappingURL=webgpu-render-pass.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgpu-render-pass.js","names":["RenderPass","cast","WebGPURenderPass","constructor","device","props","arguments","length","undefined","_defineProperty","framebuffer","canvasContext","getCurrentFramebuffer","renderPassDescriptor","handle","commandEncoder","beginRenderPass","label","id","destroy","end","setPipeline","pipeline","setBindings","bindings","_this$pipeline","_this$pipeline2","bindGroup","_getBindGroup","setBindGroup","setIndexBuffer","buffer","indexFormat","offset","size","setVertexBuffer","slot","draw","options","indexCount","drawIndexed","instanceCount","firstIndex","baseVertex","firstInstance","vertexCount","drawIndirect","setParameters","parameters","blendConstant","stencilReference","scissorRect","viewport","setBlendConstant","setStencilReference","setScissorRect","setViewport","pushDebugGroup","groupLabel","popDebugGroup","insertDebugMarker","markerLabel"],"sources":["../../../src/adapter/resources/webgpu-render-pass.ts"],"sourcesContent":["import type {RenderPassProps, RenderPassParameters, Binding} from '@luma.gl/api';\nimport {Buffer, RenderPass, RenderPipeline, cast} from '@luma.gl/api';\nimport {WebGPUDevice} from '../webgpu-device';\nimport {WebGPUBuffer} from './webgpu-buffer';\n// import {WebGPUCommandEncoder} from './webgpu-command-encoder';\nimport {WebGPURenderPipeline} from './webgpu-render-pipeline';\n\nexport class WebGPURenderPass extends RenderPass {\n readonly device: WebGPUDevice;\n readonly handle: GPURenderPassEncoder;\n\n /** Active pipeline */\n pipeline: WebGPURenderPipeline | null = null;\n\n constructor(device: WebGPUDevice, props: RenderPassProps = {}) {\n super(device, props);\n this.device = device;\n const framebuffer = props.framebuffer || device.canvasContext.getCurrentFramebuffer();\n // @ts-expect-error\n const renderPassDescriptor = framebuffer.renderPassDescriptor;\n this.handle = this.props.handle || device.commandEncoder.beginRenderPass(renderPassDescriptor);\n this.handle.label = this.props.id;\n }\n\n override destroy(): void {}\n\n end(): void {\n this.handle.end();\n }\n\n setPipeline(pipeline: RenderPipeline): void {\n this.pipeline = cast<WebGPURenderPipeline>(pipeline);\n this.handle.setPipeline(this.pipeline.handle);\n }\n\n /** Sets an array of bindings (uniform buffers, samplers, textures, ...) */\n setBindings(bindings: Record<string, Binding>): void {\n this.pipeline?.setBindings(bindings);\n const bindGroup = this.pipeline?._getBindGroup();\n if (bindGroup) {\n this.handle.setBindGroup(0, bindGroup);\n }\n }\n\n setIndexBuffer(\n buffer: Buffer,\n indexFormat: GPUIndexFormat,\n offset: number = 0,\n size?: number\n ): void {\n this.handle.setIndexBuffer(cast<WebGPUBuffer>(buffer).handle, indexFormat, offset, size);\n }\n\n setVertexBuffer(slot: number, buffer: Buffer, offset: number = 0): void {\n this.handle.setVertexBuffer(slot, cast<WebGPUBuffer>(buffer).handle, offset);\n }\n\n draw(options: {\n vertexCount?: number;\n indexCount?: number;\n instanceCount?: number;\n firstVertex?: number;\n firstIndex?: number;\n firstInstance?: number;\n baseVertex?: number;\n }): void {\n if (options.indexCount) {\n this.handle.drawIndexed(\n options.indexCount,\n options.instanceCount,\n options.firstIndex,\n options.baseVertex,\n options.firstInstance\n );\n } else {\n this.handle.draw(\n options.vertexCount || 0,\n options.instanceCount,\n options.firstIndex,\n options.firstInstance\n );\n }\n }\n\n drawIndirect(): void {\n // drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;\n // drawIndexedIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;\n }\n\n setParameters(parameters: RenderPassParameters): void {\n const {blendConstant, stencilReference, scissorRect, viewport} = parameters;\n if (blendConstant) {\n this.handle.setBlendConstant(blendConstant);\n }\n if (stencilReference) {\n this.handle.setStencilReference(stencilReference);\n }\n if (scissorRect) {\n this.handle.setScissorRect(scissorRect[0], scissorRect[1], scissorRect[2], scissorRect[3]);\n }\n // TODO - explain how 3 dimensions vs 2 in WebGL works.\n if (viewport) {\n this.handle.setViewport(\n viewport[0],\n viewport[1],\n viewport[2],\n viewport[3],\n viewport[4],\n viewport[5]\n );\n }\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 // beginOcclusionQuery(queryIndex: number): void;\n // endOcclusionQuery(): void;\n // beginPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;\n // endPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;\n\n // executeBundles(bundles: Iterable<GPURenderBundle>): void;\n}\n"],"mappings":";AACA,SAAgBA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,aAAaA,CAACC,UAAgC,EAAQ;IACpD,MAAM;MAACC,aAAa;MAAEC,gBAAgB;MAAEC,WAAW;MAAEC;IAAQ,CAAC,GAAGJ,UAAU;IAC3E,IAAIC,aAAa,EAAE;MACjB,IAAI,CAACnC,MAAM,CAACuC,gBAAgB,CAACJ,aAAa,CAAC;IAC7C;IACA,IAAIC,gBAAgB,EAAE;MACpB,IAAI,CAACpC,MAAM,CAACwC,mBAAmB,CAACJ,gBAAgB,CAAC;IACnD;IACA,IAAIC,WAAW,EAAE;MACf,IAAI,CAACrC,MAAM,CAACyC,cAAc,CAACJ,WAAW,CAAC,CAAC,CAAC,EAAEA,WAAW,CAAC,CAAC,CAAC,EAAEA,WAAW,CAAC,CAAC,CAAC,EAAEA,WAAW,CAAC,CAAC,CAAC,CAAC;IAC5F;IAEA,IAAIC,QAAQ,EAAE;MACZ,IAAI,CAACtC,MAAM,CAAC0C,WAAW,CACrBJ,QAAQ,CAAC,CAAC,CAAC,EACXA,QAAQ,CAAC,CAAC,CAAC,EACXA,QAAQ,CAAC,CAAC,CAAC,EACXA,QAAQ,CAAC,CAAC,CAAC,EACXA,QAAQ,CAAC,CAAC,CAAC,EACXA,QAAQ,CAAC,CAAC,CAAC,CACZ;IACH;EACF;EAEAK,cAAcA,CAACC,UAAkB,EAAQ;IACvC,IAAI,CAAC5C,MAAM,CAAC2C,cAAc,CAACC,UAAU,CAAC;EACxC;EACAC,aAAaA,CAAA,EAAS;IACpB,IAAI,CAAC7C,MAAM,CAAC6C,aAAa,EAAE;EAC7B;EACAC,iBAAiBA,CAACC,WAAmB,EAAQ;IAC3C,IAAI,CAAC/C,MAAM,CAAC8C,iBAAiB,CAACC,WAAW,CAAC;EAC5C;AASF"}
|
|
1
|
+
{"version":3,"file":"webgpu-render-pass.js","names":["RenderPass","cast","WebGPURenderPass","constructor","device","props","arguments","length","undefined","_defineProperty","framebuffer","canvasContext","getCurrentFramebuffer","renderPassDescriptor","getRenderPassDescriptor","handle","commandEncoder","beginRenderPass","label","id","destroy","end","setPipeline","pipeline","setBindings","bindings","_this$pipeline","_this$pipeline2","bindGroup","_getBindGroup","setBindGroup","setIndexBuffer","buffer","indexFormat","offset","size","setVertexBuffer","slot","draw","options","indexCount","drawIndexed","instanceCount","firstIndex","baseVertex","firstInstance","vertexCount","drawIndirect","setParameters","parameters","blendConstant","stencilReference","scissorRect","viewport","setBlendConstant","setStencilReference","setScissorRect","setViewport","pushDebugGroup","groupLabel","popDebugGroup","insertDebugMarker","markerLabel","colorAttachments","map","colorAttachment","loadOp","colorClearValue","clearColor","storeOp","discard","view","createView","depthStencilAttachment"],"sources":["../../../src/adapter/resources/webgpu-render-pass.ts"],"sourcesContent":["import type {RenderPassProps, RenderPassParameters, Binding, Framebuffer} from '@luma.gl/api';\nimport {Buffer, RenderPass, RenderPipeline, cast} from '@luma.gl/api';\nimport {WebGPUDevice} from '../webgpu-device';\nimport {WebGPUBuffer} from './webgpu-buffer';\nimport {WebGPUTexture} from './webgpu-texture';\n// import {WebGPUCommandEncoder} from './webgpu-command-encoder';\nimport {WebGPURenderPipeline} from './webgpu-render-pipeline';\n\nexport class WebGPURenderPass extends RenderPass {\n readonly device: WebGPUDevice;\n readonly handle: GPURenderPassEncoder;\n\n /** Active pipeline */\n pipeline: WebGPURenderPipeline | null = null;\n\n constructor(device: WebGPUDevice, props: RenderPassProps = {}) {\n super(device, props);\n this.device = device;\n const framebuffer = props.framebuffer || device.canvasContext.getCurrentFramebuffer() ;\n const renderPassDescriptor = this.getRenderPassDescriptor(framebuffer);\n this.handle = this.props.handle || device.commandEncoder.beginRenderPass(renderPassDescriptor);\n this.handle.label = this.props.id;\n }\n\n override destroy(): void {}\n\n end(): void {\n this.handle.end();\n }\n\n setPipeline(pipeline: RenderPipeline): void {\n this.pipeline = cast<WebGPURenderPipeline>(pipeline);\n this.handle.setPipeline(this.pipeline.handle);\n }\n\n /** Sets an array of bindings (uniform buffers, samplers, textures, ...) */\n setBindings(bindings: Record<string, Binding>): void {\n this.pipeline?.setBindings(bindings);\n const bindGroup = this.pipeline?._getBindGroup();\n if (bindGroup) {\n this.handle.setBindGroup(0, bindGroup);\n }\n }\n\n setIndexBuffer(\n buffer: Buffer,\n indexFormat: GPUIndexFormat,\n offset: number = 0,\n size?: number\n ): void {\n this.handle.setIndexBuffer(cast<WebGPUBuffer>(buffer).handle, indexFormat, offset, size);\n }\n\n setVertexBuffer(slot: number, buffer: Buffer, offset: number = 0): void {\n this.handle.setVertexBuffer(slot, cast<WebGPUBuffer>(buffer).handle, offset);\n }\n\n draw(options: {\n vertexCount?: number;\n indexCount?: number;\n instanceCount?: number;\n firstVertex?: number;\n firstIndex?: number;\n firstInstance?: number;\n baseVertex?: number;\n }): void {\n if (options.indexCount) {\n this.handle.drawIndexed(\n options.indexCount,\n options.instanceCount,\n options.firstIndex,\n options.baseVertex,\n options.firstInstance\n );\n } else {\n this.handle.draw(\n options.vertexCount || 0,\n options.instanceCount,\n options.firstIndex,\n options.firstInstance\n );\n }\n }\n\n drawIndirect(): void {\n // drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;\n // drawIndexedIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;\n }\n\n setParameters(parameters: RenderPassParameters): void {\n const {blendConstant, stencilReference, scissorRect, viewport} = parameters;\n if (blendConstant) {\n this.handle.setBlendConstant(blendConstant);\n }\n if (stencilReference) {\n this.handle.setStencilReference(stencilReference);\n }\n if (scissorRect) {\n this.handle.setScissorRect(scissorRect[0], scissorRect[1], scissorRect[2], scissorRect[3]);\n }\n // TODO - explain how 3 dimensions vs 2 in WebGL works.\n if (viewport) {\n this.handle.setViewport(\n viewport[0],\n viewport[1],\n viewport[2],\n viewport[3],\n viewport[4],\n viewport[5]\n );\n }\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 // beginOcclusionQuery(queryIndex: number): void;\n // endOcclusionQuery(): void;\n // beginPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;\n // endPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;\n\n // executeBundles(bundles: Iterable<GPURenderBundle>): void;\n\n // INTERNAL\n\n /** \n * Partial render pass descriptor. Used by WebGPURenderPass.\n * @returns attachments fields of a renderpass descriptor. \n */\n protected getRenderPassDescriptor(framebuffer: Framebuffer): GPURenderPassDescriptor {\n const renderPassDescriptor: GPURenderPassDescriptor = {\n colorAttachments: []\n };\n\n renderPassDescriptor.colorAttachments = framebuffer.colorAttachments.map(colorAttachment => ({\n // clear values\n loadOp: 'clear',\n colorClearValue: this.props.clearColor || [0, 0, 0, 0],\n storeOp: this.props.discard? 'discard': 'store',\n // ...colorAttachment,\n view: (colorAttachment as WebGPUTexture).handle.createView()\n }));\n\n if (framebuffer.depthStencilAttachment) {\n renderPassDescriptor.depthStencilAttachment = {\n ...this.props,\n view: (framebuffer.depthStencilAttachment as WebGPUTexture).handle.createView()\n };\n }\n\n return renderPassDescriptor;\n }\n}\n"],"mappings":";AACA,SAAgBA,UAAU,EAAkBC,IAAI,QAAO,cAAc;AAOrE,OAAO,MAAMC,gBAAgB,SAASF,UAAU,CAAC;EAO/CG,WAAWA,CAACC,MAAoB,EAA+B;IAAA,IAA7BC,KAAsB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;IAC3D,KAAK,CAACF,MAAM,EAAEC,KAAK,CAAC;IAACI,eAAA;IAAAA,eAAA;IAAAA,eAAA,mBAHiB,IAAI;IAI1C,IAAI,CAACL,MAAM,GAAGA,MAAM;IACpB,MAAMM,WAAW,GAAGL,KAAK,CAACK,WAAW,IAAIN,MAAM,CAACO,aAAa,CAACC,qBAAqB,EAAE;IACrF,MAAMC,oB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AI,EAAG7D,WAAW,CAAC+D,sBAAsB,CAAmB1D,MAAM,CAACyD,UAAU;MAC/E,CAAC;IACH;IAEA,OAAO3D,oBAAoB;EAC7B;AACF"}
|
|
@@ -22,7 +22,8 @@ export class WebGPUShader extends Shader {
|
|
|
22
22
|
destroy() {}
|
|
23
23
|
createHandle() {
|
|
24
24
|
const {
|
|
25
|
-
source
|
|
25
|
+
source,
|
|
26
|
+
stage
|
|
26
27
|
} = this.props;
|
|
27
28
|
let language = this.props.language;
|
|
28
29
|
if (!language) {
|
|
@@ -36,7 +37,7 @@ export class WebGPUShader extends Shader {
|
|
|
36
37
|
case 'glsl':
|
|
37
38
|
return this.device.handle.createShaderModule({
|
|
38
39
|
code: source,
|
|
39
|
-
transform: glsl => this.device.glslang.compileGLSL(glsl,
|
|
40
|
+
transform: glsl => this.device.glslang.compileGLSL(glsl, stage)
|
|
40
41
|
});
|
|
41
42
|
default:
|
|
42
43
|
throw new Error(language);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgpu-shader.js","names":["Shader","log","WebGPUShader","constructor","device","props","_defineProperty","handle","pushErrorScope","createHandle","label","id","_checkCompilationError","popErrorScope","errorScope","error","shaderLog","compilationInfo","concat","message","Error","destroy","source","language","includes","createShaderModule","code","transform","glsl","glslang","compileGLSL","
|
|
1
|
+
{"version":3,"file":"webgpu-shader.js","names":["Shader","log","WebGPUShader","constructor","device","props","_defineProperty","handle","pushErrorScope","createHandle","label","id","_checkCompilationError","popErrorScope","errorScope","error","shaderLog","compilationInfo","concat","message","Error","destroy","source","stage","language","includes","createShaderModule","code","transform","glsl","glslang","compileGLSL","getCompilationInfo","messages"],"sources":["../../../src/adapter/resources/webgpu-shader.ts"],"sourcesContent":["// luma.gl, MIT license\n\nimport type {ShaderProps, CompilerMessage} from '@luma.gl/api';\nimport {Shader, log} from '@luma.gl/api';\nimport type {WebGPUDevice} from '../webgpu-device';\n\nexport type WebGPUShaderProps = ShaderProps & {\n handle?: GPUShaderModule;\n};\n\n/**\n * Immutable shader\n */\nexport class WebGPUShader extends Shader {\n readonly device: WebGPUDevice;\n readonly handle: GPUShaderModule;\n\n constructor(device: WebGPUDevice, props: WebGPUShaderProps) {\n super(device, props);\n this.device = device;\n\n this.device.handle.pushErrorScope('validation');\n\n this.handle = this.props.handle || this.createHandle();\n this.handle.label = this.props.id;\n\n this._checkCompilationError(this.device.handle.popErrorScope());\n }\n\n async _checkCompilationError(errorScope: Promise<GPUError | null>): Promise<void> {\n const error = await errorScope as GPUValidationError;\n if (error) {\n const shaderLog = await this.compilationInfo();\n log.error(`Shader compilation error: ${error.message}`, shaderLog)();\n // Note: Even though this error is asynchronous and thrown after the constructor completes,\n // it will result in a useful stack trace leading back to the constructor\n throw new Error(`Shader compilation error: ${error.message}`);\n }\n }\n\n override destroy(): void {\n // this.handle.destroy();\n }\n\n protected createHandle(): GPUShaderModule {\n const {source, stage} = this.props;\n\n let language = this.props.language;\n // Compile from src\n if (!language) {\n // wgsl uses C++ \"auto\" style arrow notation\n language = source.includes('->') ? 'wgsl' : 'glsl';\n }\n\n switch(language) {\n case 'wgsl':\n return this.device.handle.createShaderModule({code: source});\n case 'glsl':\n return this.device.handle.createShaderModule({\n code: source,\n // @ts-expect-error\n transform: (glsl) => this.device.glslang.compileGLSL(glsl, stage)\n });\n default:\n throw new Error(language);\n }\n }\n\n /** Returns compilation info for this shader */\n async compilationInfo(): Promise<readonly CompilerMessage[]> {\n const compilationInfo = await this.handle.getCompilationInfo();\n return compilationInfo.messages;\n }\n}\n"],"mappings":";AAGA,SAAQA,MAAM,EAAEC,GAAG,QAAO,cAAc;AAUxC,OAAO,MAAMC,YAAY,SAASF,MAAM,CAAC;EAIvCG,WAAWA,CAACC,MAAoB,EAAEC,KAAwB,EAAE;IAC1D,KAAK,CAACD,MAAM,EAAEC,KAAK,CAAC;IAACC,eAAA;IAAAA,eAAA;IACrB,IAAI,CAACF,MAAM,GAAGA,MAAM;IAEpB,IAAI,CAACA,MAAM,CA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AI,CAACzB,MAAM,CAAC0B,OAAO,CAACC,WAAW,CAACF,IAAI,EAAEN,KAAK;QAClE,CAAC,CAAC;MACJ;QACE,MAAM,IAAIH,KAAK,CAACI,QAAQ,CAAC;IAAC;EAEhC;EAGA,MAAMP,eAAeA,CAAA,EAAwC;IAC3D,MAAMA,eAAe,GAAG,MAAM,IAAI,CAACV,MAAM,CAACyB,kBAAkB,EAAE;IAC9D,OAAOf,eAAe,CAACgB,QAAQ;EACjC;AACF"}
|
|
@@ -8,6 +8,8 @@ export declare class WebGPUTexture extends Texture {
|
|
|
8
8
|
readonly handle: GPUTexture;
|
|
9
9
|
readonly view: GPUTextureView;
|
|
10
10
|
sampler: WebGPUSampler;
|
|
11
|
+
height: number;
|
|
12
|
+
width: number;
|
|
11
13
|
constructor(device: WebGPUDevice, props: TextureProps);
|
|
12
14
|
protected createHandle(): GPUTexture;
|
|
13
15
|
destroy(): void;
|
|
@@ -18,7 +20,10 @@ export declare class WebGPUTexture extends Texture {
|
|
|
18
20
|
setSampler(sampler: Sampler | SamplerProps): this;
|
|
19
21
|
setData(options: {
|
|
20
22
|
data: any;
|
|
21
|
-
}):
|
|
23
|
+
}): {
|
|
24
|
+
width: number;
|
|
25
|
+
height: number;
|
|
26
|
+
};
|
|
22
27
|
/** Set image */
|
|
23
28
|
setImage(options: {
|
|
24
29
|
source: ImageBitmap | HTMLCanvasElement | OffscreenCanvas;
|
|
@@ -34,6 +39,9 @@ export declare class WebGPUTexture extends Texture {
|
|
|
34
39
|
aspect?: 'all' | 'stencil-only' | 'depth-only';
|
|
35
40
|
colorSpace?: 'srgb';
|
|
36
41
|
premultipliedAlpha?: boolean;
|
|
37
|
-
}):
|
|
42
|
+
}): {
|
|
43
|
+
width: number;
|
|
44
|
+
height: number;
|
|
45
|
+
};
|
|
38
46
|
}
|
|
39
47
|
//# 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,EAAC,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,YAAY,EAAC,MAAM,cAAc,CAAC;AAE1E,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAC,aAAa,EAAC,MAAM,kBAAkB,CAAC;AAW/C,qBAAa,aAAc,SAAQ,OAAO;IACxC,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAC5B,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAC9B,OAAO,EAAE,aAAa,CAAC;gBASX,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,YAAY;
|
|
1
|
+
{"version":3,"file":"webgpu-texture.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-texture.ts"],"names":[],"mappings":";;AACA,OAAO,EAAC,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,YAAY,EAAC,MAAM,cAAc,CAAC;AAE1E,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAC,aAAa,EAAC,MAAM,kBAAkB,CAAC;AAW/C,qBAAa,aAAc,SAAQ,OAAO;IACxC,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAC5B,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAC9B,OAAO,EAAE,aAAa,CAAC;IAEd,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;gBASX,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,YAAY;IAkCrD,SAAS,CAAC,YAAY,IAAI,UAAU;IAyB3B,OAAO,IAAI,IAAI;IAIxB;;;OAGG;IACH,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,YAAY,GAAG,IAAI;IAKjD,OAAO,CAAC,OAAO,EAAE;QACf,IAAI,EAAE,GAAG,CAAC;KACX;;;;IAID,gBAAgB;IAChB,QAAQ,CAAC,OAAO,EAAE;QAChB,MAAM,EAAE,WAAW,GAAG,iBAAiB,GAAG,eAAe,CAAC;QAC1D,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,CAAC,CAAC,EAAE,MAAM,CAAC;QACX,CAAC,CAAC,EAAE,MAAM,CAAC;QACX,CAAC,CAAC,EAAE,MAAM,CAAC;QACX,MAAM,CAAC,EAAE,KAAK,GAAG,cAAc,GAAG,YAAY,CAAC;QAC/C,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,kBAAkB,CAAC,EAAE,OAAO,CAAC;KAC9B,GAAG;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAC;CA6HpC"}
|
|
@@ -17,6 +17,8 @@ export class WebGPUTexture extends Texture {
|
|
|
17
17
|
_defineProperty(this, "handle", void 0);
|
|
18
18
|
_defineProperty(this, "view", void 0);
|
|
19
19
|
_defineProperty(this, "sampler", void 0);
|
|
20
|
+
_defineProperty(this, "height", void 0);
|
|
21
|
+
_defineProperty(this, "width", void 0);
|
|
20
22
|
if (typeof this.props.format === 'number') {
|
|
21
23
|
throw new Error('number format');
|
|
22
24
|
}
|
|
@@ -27,6 +29,8 @@ export class WebGPUTexture extends Texture {
|
|
|
27
29
|
data: this.props.data
|
|
28
30
|
});
|
|
29
31
|
}
|
|
32
|
+
this.width = this.handle.width;
|
|
33
|
+
this.height = this.handle.height;
|
|
30
34
|
this.sampler = props.sampler instanceof WebGPUSampler ? props.sampler : new WebGPUSampler(this.device, props.sampler);
|
|
31
35
|
this.view = this.handle.createView({});
|
|
32
36
|
}
|
|
@@ -89,7 +93,10 @@ export class WebGPUTexture extends Texture {
|
|
|
89
93
|
colorSpace,
|
|
90
94
|
premultipliedAlpha
|
|
91
95
|
}, [width, height, depth]);
|
|
92
|
-
return
|
|
96
|
+
return {
|
|
97
|
+
width,
|
|
98
|
+
height
|
|
99
|
+
};
|
|
93
100
|
}
|
|
94
101
|
}
|
|
95
102
|
//# sourceMappingURL=webgpu-texture.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgpu-texture.js","names":["Texture","getWebGPUTextureFormat","WebGPUSampler","BASE_DIMENSIONS","WebGPUTexture","constructor","device","props","_defineProperty","format","Error","handle","createHandle","data","setData","sampler","view","createView","_this$props$data","_this$props$data2","width","height","createTexture","size","depthOrArrayLayers","depth","dimension","usage","mipLevelCount","mipLevels","sampleCount","samples","destroy","setSampler","options","setImage","source","sourceX","sourceY","mipLevel","x","y","z","aspect","colorSpace","premultipliedAlpha","queue","copyExternalImageToTexture","origin","texture"],"sources":["../../../src/adapter/resources/webgpu-texture.ts"],"sourcesContent":["// luma.gl, MIT license\nimport {Texture, TextureProps, Sampler, SamplerProps} from '@luma.gl/api';\nimport {getWebGPUTextureFormat} from '../helpers/convert-texture-format';\nimport type {WebGPUDevice} from '../webgpu-device';\nimport {WebGPUSampler} from './webgpu-sampler';\n\nconst BASE_DIMENSIONS: Record<string, '1d' | '2d' | '3d'> = {\n '1d': '1d',\n '2d': '2d',\n '2d-array': '2d',\n 'cube': '2d',\n 'cube-array': '2d',\n '3d': '3d'\n};\n\nexport class WebGPUTexture extends Texture {\n readonly device: WebGPUDevice;\n readonly handle: GPUTexture;\n readonly view: GPUTextureView;\n sampler: WebGPUSampler;\n\n // static async createFromImageURL(src, usage = 0) {\n // const img = document.createElement('img');\n // img.src = src;\n // await img.decode();\n // return WebGPUTexture(img, usage);\n // }\n\n constructor(device: WebGPUDevice, props: TextureProps) {\n super(device, props);\n\n if (typeof this.props.format === 'number') {\n throw new Error('number format');\n }\n\n this.device = device;\n this.handle = this.props.handle || this.createHandle();\n\n if (this.props.data) {\n this.setData({data: this.props.data} );\n }\n\n // Create a default sampler. This mimics the WebGL1 API where sampler props are stored on the texture\n // this.setSampler(props.sampler);\n this.sampler = props.sampler instanceof WebGPUSampler ? props.sampler : new WebGPUSampler(this.device, props.sampler);\n\n // TODO - To support texture arrays we need to create custom views...\n // But we are not ready to expose TextureViews to the public API.\n this.view = this.handle.createView({\n // format: this.props.format,\n // dimension: this.props.dimension,\n // aspect = \"all\";\n // baseMipLevel: 0;\n // mipLevelCount;\n // baseArrayLayer = 0;\n // arrayLayerCount;\n });\n }\n\n protected createHandle(): GPUTexture {\n if (typeof this.props.format === 'number') {\n throw new Error('number format');\n }\n\n // Deduce size from data - TODO this is a hack\n // @ts-expect-error\n const width = this.props.width || this.props.data?.width || 1;\n // @ts-expect-error\n const height = this.props.height || this.props.data?.height || 1;\n\n return this.device.handle.createTexture({\n size: {\n width,\n height,\n depthOrArrayLayers: this.props.depth\n },\n dimension: BASE_DIMENSIONS[this.props.dimension],\n format: getWebGPUTextureFormat(this.props.format),\n usage: this.props.usage,\n mipLevelCount: this.props.mipLevels,\n sampleCount: this.props.samples\n });\n }\n\n override destroy(): void {\n this.handle.destroy();\n }\n\n /**\n * Set default sampler\n * Accept a sampler instance or set of props;\n */\n setSampler(sampler: Sampler | SamplerProps): this {\n this.sampler = sampler instanceof WebGPUSampler ? sampler : new WebGPUSampler(this.device, sampler);\n return this;\n }\n\n setData(options: {\n data: any;\n }) {\n return this.setImage({source: options.data});\n }\n\n /** Set image */\n setImage(options: {\n source: ImageBitmap | HTMLCanvasElement | OffscreenCanvas;\n width?: number;\n height?: number;\n depth?: number;\n sourceX?: number;\n sourceY?: number;\n mipLevel?: number;\n x?: number;\n y?: number;\n z?: number;\n aspect?: 'all' | 'stencil-only' | 'depth-only';\n colorSpace?: 'srgb';\n premultipliedAlpha?: boolean;\n }): this {\n const {\n source,\n width = options.source.width,\n height = options.source.height,\n depth = 1,\n sourceX = 0,\n sourceY = 0,\n mipLevel = 0,\n x = 0,\n y = 0,\n z = 0,\n aspect = 'all',\n colorSpace = 'srgb',\n premultipliedAlpha = false\n } = options;\n\n // TODO - max out width\n\n this.device.handle.queue.copyExternalImageToTexture(\n // source: GPUImageCopyExternalImage\n {\n source,\n origin: [sourceX, sourceY]\n },\n // destination: GPUImageCopyTextureTagged\n {\n texture: this.handle,\n origin: [x, y, z],\n mipLevel,\n aspect,\n colorSpace,\n premultipliedAlpha\n },\n // copySize: GPUExtent3D\n [\n width,\n height,\n depth\n ]\n );\n return this;\n }\n\n /*\n async readPixels() {\n const readbackBuffer = device.createBuffer({\n usage: Buffer.COPY_DST | Buffer.MAP_READ,\n size: 4 * textureWidth * textureHeight,\n });\n\n // Copy data from the texture to the buffer.\n const encoder = device.createCommandEncoder();\n encoder.copyTextureToBuffer(\n { texture },\n { buffer, rowPitch: textureWidth * 4 },\n [textureWidth, textureHeight],\n );\n device.submit([encoder.finish()]);\n\n // Get the data on the CPU.\n await buffer.mapAsync(GPUMapMode.READ);\n saveScreenshot(buffer.getMappedRange());\n buffer.unmap();\n }\n\n setImageData(imageData, usage): this {\n let data = null;\n\n const bytesPerRow = Math.ceil((img.width * 4) / 256) * 256;\n if (bytesPerRow == img.width * 4) {\n data = imageData.data;\n } else {\n data = new Uint8Array(bytesPerRow * img.height);\n let imagePixelIndex = 0;\n for (let y = 0; y < img.height; ++y) {\n for (let x = 0; x < img.width; ++x) {\n const i = x * 4 + y * bytesPerRow;\n data[i] = imageData.data[imagePixelIndex];\n data[i + 1] = imageData.data[imagePixelIndex + 1];\n data[i + 2] = imageData.data[imagePixelIndex + 2];\n data[i + 3] = imageData.data[imagePixelIndex + 3];\n imagePixelIndex += 4;\n }\n }\n }\n return this;\n }\n\n setData(data): this {\n const textureDataBuffer = this.device.handle.createBuffer({\n size: data.byteLength,\n usage: Buffer.COPY_DST | Buffer.COPY_SRC,\n mappedAtCreation: true\n });\n new Uint8Array(textureDataBuffer.getMappedRange()).set(data);\n textureDataBuffer.unmap();\n\n this.setBuffer(textureDataBuffer);\n\n textureDataBuffer.destroy();\n return this;\n }\n\n setBuffer(textureDataBuffer, {bytesPerRow}): this {\n const commandEncoder = this.device.handle.createCommandEncoder();\n commandEncoder.copyBufferToTexture(\n {\n buffer: textureDataBuffer,\n bytesPerRow\n },\n {\n texture: this.handle\n },\n {\n width,\n height,\n depth\n }\n );\n\n this.device.handle.defaultQueue.submit([commandEncoder.finish()]);\n return this;\n }\n */\n}\n"],"mappings":";AACA,SAAQA,OAAO,QAA4C,cAAc;AAAC,SAClEC,sBAAsB;AAAA,SAEtBC,aAAa;AAErB,MAAMC,eAAmD,GAAG;EAC1D,IAAI,EAAE,IAAI;EACV,IAAI,EAAE,IAAI;EACV,UAAU,EAAE,IAAI;EAChB,MAAM,EAAE,IAAI;EACZ,YAAY,EAAE,IAAI;EAClB,IAAI,EAAE;AACR,CAAC;AAED,OAAO,MAAMC,aAAa,SAASJ,OAAO,CAAC;EAazCK,WAAWA,CAACC,MAAoB,EAAEC,KAAmB,EAAE;IACrD,KAAK,CAACD,MAAM,EAAEC,KAAK,CAAC;IAACC,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAErB,IAAI,OAAO,IAAI,CAACD,KAAK,CAACE,MAAM,KAAK,QAAQ,EAAE;MACzC,MAAM,IAAIC,KAAK,CAAC,eAAe,CAAC;IAClC;IAEA,IAAI,CAACJ,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACK,MAAM,GAAG,IAAI,CAACJ,KAAK,CAACI,MAAM,IAAI,IAAI,CAACC,YAAY,EAAE;IAEtD,IAAI,IAAI,CAACL,KAAK,CAACM,IAAI,EAAE;MACnB,IAAI,CAACC,OAAO,CAAC;QAACD,IAAI,EAAE,IAAI,CAACN,KAAK,CAACM;MAAI,CAAC,CAAG;IACzC;IAIA,IAAI,CAACE,OAAO,GAAGR,KAAK,CAACQ,OA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GPUSampler","BASE_DIMENSIONS","WebGPUTexture","constructor","device","props","_defineProperty","format","Error","handle","createHandle","data","setData","width","height","sampler","view","createView","_this$props$data","_this$props$data2","createTexture","size","depthOrArrayLayers","depth","dimension","usage","mipLevelCount","mipLevels","sampleCount","samples","destroy","setSampler","options","setImage","source","sourceX","sourceY","mipLevel","x","y","z","aspect","colorSpace","premultipliedAlpha","queue","copyExternalImageToTexture","origin","texture"],"sources":["../../../src/adapter/resources/webgpu-texture.ts"],"sourcesContent":["// luma.gl, MIT license\nimport {Texture, TextureProps, Sampler, SamplerProps} from '@luma.gl/api';\nimport {getWebGPUTextureFormat} from '../helpers/convert-texture-format';\nimport type {WebGPUDevice} from '../webgpu-device';\nimport {WebGPUSampler} from './webgpu-sampler';\n\nconst BASE_DIMENSIONS: Record<string, '1d' | '2d' | '3d'> = {\n '1d': '1d',\n '2d': '2d',\n '2d-array': '2d',\n 'cube': '2d',\n 'cube-array': '2d',\n '3d': '3d'\n};\n\nexport class WebGPUTexture extends Texture {\n readonly device: WebGPUDevice;\n readonly handle: GPUTexture;\n readonly view: GPUTextureView;\n sampler: WebGPUSampler;\n\n override height: number;\n override width: number;\n\n // static async createFromImageURL(src, usage = 0) {\n // const img = document.createElement('img');\n // img.src = src;\n // await img.decode();\n // return WebGPUTexture(img, usage);\n // }\n\n constructor(device: WebGPUDevice, props: TextureProps) {\n super(device, props);\n\n if (typeof this.props.format === 'number') {\n throw new Error('number format');\n }\n\n this.device = device;\n this.handle = this.props.handle || this.createHandle();\n\n if (this.props.data) {\n this.setData({data: this.props.data} );\n }\n\n this.width = this.handle.width;\n this.height = this.handle.height;\n\n // Create a default sampler. This mimics the WebGL1 API where sampler props are stored on the texture\n // this.setSampler(props.sampler);\n this.sampler = props.sampler instanceof WebGPUSampler ? props.sampler : new WebGPUSampler(this.device, props.sampler);\n\n // TODO - To support texture arrays we need to create custom views...\n // But we are not ready to expose TextureViews to the public API.\n this.view = this.handle.createView({\n // format: this.props.format,\n // dimension: this.props.dimension,\n // aspect = \"all\";\n // baseMipLevel: 0;\n // mipLevelCount;\n // baseArrayLayer = 0;\n // arrayLayerCount;\n });\n }\n\n protected createHandle(): GPUTexture {\n if (typeof this.props.format === 'number') {\n throw new Error('number format');\n }\n\n // Deduce size from data - TODO this is a hack\n // @ts-expect-error\n const width = this.props.width || this.props.data?.width || 1;\n // @ts-expect-error\n const height = this.props.height || this.props.data?.height || 1;\n\n return this.device.handle.createTexture({\n size: {\n width,\n height,\n depthOrArrayLayers: this.props.depth\n },\n dimension: BASE_DIMENSIONS[this.props.dimension],\n format: getWebGPUTextureFormat(this.props.format),\n usage: this.props.usage,\n mipLevelCount: this.props.mipLevels,\n sampleCount: this.props.samples\n });\n }\n\n override destroy(): void {\n this.handle.destroy();\n }\n\n /**\n * Set default sampler\n * Accept a sampler instance or set of props;\n */\n setSampler(sampler: Sampler | SamplerProps): this {\n this.sampler = sampler instanceof WebGPUSampler ? sampler : new WebGPUSampler(this.device, sampler);\n return this;\n }\n\n setData(options: {\n data: any;\n }) {\n return this.setImage({source: options.data});\n }\n\n /** Set image */\n setImage(options: {\n source: ImageBitmap | HTMLCanvasElement | OffscreenCanvas;\n width?: number;\n height?: number;\n depth?: number;\n sourceX?: number;\n sourceY?: number;\n mipLevel?: number;\n x?: number;\n y?: number;\n z?: number;\n aspect?: 'all' | 'stencil-only' | 'depth-only';\n colorSpace?: 'srgb';\n premultipliedAlpha?: boolean;\n }): {width: number, height: number} {\n const {\n source,\n width = options.source.width,\n height = options.source.height,\n depth = 1,\n sourceX = 0,\n sourceY = 0,\n mipLevel = 0,\n x = 0,\n y = 0,\n z = 0,\n aspect = 'all',\n colorSpace = 'srgb',\n premultipliedAlpha = false\n } = options;\n\n // TODO - max out width\n\n this.device.handle.queue.copyExternalImageToTexture(\n // source: GPUImageCopyExternalImage\n {\n source,\n origin: [sourceX, sourceY]\n },\n // destination: GPUImageCopyTextureTagged\n {\n texture: this.handle,\n origin: [x, y, z],\n mipLevel,\n aspect,\n colorSpace,\n premultipliedAlpha\n },\n // copySize: GPUExtent3D\n [\n width,\n height,\n depth\n ]\n );\n return {width, height};\n }\n\n /*\n async readPixels() {\n const readbackBuffer = device.createBuffer({\n usage: Buffer.COPY_DST | Buffer.MAP_READ,\n size: 4 * textureWidth * textureHeight,\n });\n\n // Copy data from the texture to the buffer.\n const encoder = device.createCommandEncoder();\n encoder.copyTextureToBuffer(\n { texture },\n { buffer, rowPitch: textureWidth * 4 },\n [textureWidth, textureHeight],\n );\n device.submit([encoder.finish()]);\n\n // Get the data on the CPU.\n await buffer.mapAsync(GPUMapMode.READ);\n saveScreenshot(buffer.getMappedRange());\n buffer.unmap();\n }\n\n setImageData(imageData, usage): this {\n let data = null;\n\n const bytesPerRow = Math.ceil((img.width * 4) / 256) * 256;\n if (bytesPerRow == img.width * 4) {\n data = imageData.data;\n } else {\n data = new Uint8Array(bytesPerRow * img.height);\n let imagePixelIndex = 0;\n for (let y = 0; y < img.height; ++y) {\n for (let x = 0; x < img.width; ++x) {\n const i = x * 4 + y * bytesPerRow;\n data[i] = imageData.data[imagePixelIndex];\n data[i + 1] = imageData.data[imagePixelIndex + 1];\n data[i + 2] = imageData.data[imagePixelIndex + 2];\n data[i + 3] = imageData.data[imagePixelIndex + 3];\n imagePixelIndex += 4;\n }\n }\n }\n return this;\n }\n\n setData(data): this {\n const textureDataBuffer = this.device.handle.createBuffer({\n size: data.byteLength,\n usage: Buffer.COPY_DST | Buffer.COPY_SRC,\n mappedAtCreation: true\n });\n new Uint8Array(textureDataBuffer.getMappedRange()).set(data);\n textureDataBuffer.unmap();\n\n this.setBuffer(textureDataBuffer);\n\n textureDataBuffer.destroy();\n return this;\n }\n\n setBuffer(textureDataBuffer, {bytesPerRow}): this {\n const commandEncoder = this.device.handle.createCommandEncoder();\n commandEncoder.copyBufferToTexture(\n {\n buffer: textureDataBuffer,\n bytesPerRow\n },\n {\n texture: this.handle\n },\n {\n width,\n height,\n depth\n }\n );\n\n this.device.handle.defaultQueue.subm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,CAAC,IAAI,CAACI,MAAM,EAAEW,OAAO,CAAC;IACnG,OAAO,IAAI;EACb;EAEAH,OAAOA,CAACoB,OAEP,EAAE;IACD,OAAO,IAAI,CAACC,QAAQ,CAAC;MAACC,MAAM,EAAEF,OAAO,CAACrB;IAAI,CAAC,CAAC;EAC9C;EAGAsB,QAAQA,CAACD,OAcR,EAAmC;IAClC,MAAM;MACJE,MAAM;MACNrB,KAAK,GAAGmB,OAAO,CAACE,MAAM,CAACrB,KAAK;MAC5BC,MAAM,GAAGkB,OAAO,CAACE,MAAM,CAACpB,MAAM;MAC9BS,KAAK,GAAG,CAAC;MACTY,OAAO,GAAG,CAAC;MACXC,OAAO,GAAG,CAAC;MACXC,QAAQ,GAAG,CAAC;MACZC,CAAC,GAAG,CAAC;MACLC,CAAC,GAAG,CAAC;MACLC,CAAC,GAAG,CAAC;MACLC,MAAM,GAAG,KAAK;MACdC,UAAU,GAAG,MAAM;MACnBC,kBAAkB,GAAG;IACvB,CAAC,GAAGX,OAAO;IAIX,IAAI,CAAC5B,MAAM,CAACK,MAAM,CAACmC,KAAK,CAACC,0BAA0B,CAEjD;MACEX,MAAM;MACNY,MAAM,EAAE,CAACX,OAAO,EAAEC,OAAO;IAC3B,CAAC,EAED;MACEW,OAAO,EAAE,IAAI,CAACtC,MAAM;MACpBqC,MAAM,EAAE,CAACR,CAAC,EAAEC,CAAC,EAAEC,CAAC,CAAC;MACjBH,QAAQ;MACRI,MAAM;MACNC,UAAU;MACVC;IACF,CAAC,EAED,CACE9B,KAAK,EACLC,MAAM,EACNS,KAAK,CACN,CACF;IACD,OAAO;MAACV,KAAK;MAAEC;IAAM,CAAC;EACxB;AAmFF"}
|
|
@@ -25,6 +25,6 @@ export declare class WebGPUCanvasContext extends CanvasContext {
|
|
|
25
25
|
useDevicePixels?: boolean | number;
|
|
26
26
|
}): void;
|
|
27
27
|
/** We build render targets on demand (i.e. not when size changes but when about to render) */
|
|
28
|
-
_createDepthStencilAttachment(): Texture
|
|
28
|
+
_createDepthStencilAttachment(): Texture<import("@luma.gl/api").TextureProps>;
|
|
29
29
|
}
|
|
30
30
|
//# sourceMappingURL=webgpu-canvas-context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgpu-canvas-context.d.ts","sourceRoot":"","sources":["../../src/adapter/webgpu-canvas-context.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAC,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAC,MAAM,cAAc,CAAC;AAC7E,OAAO,EAAC,aAAa,EAAM,MAAM,cAAc,CAAC;AAEhD,OAAO,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAC,iBAAiB,EAAC,MAAM,gCAAgC,CAAC;AAEjE;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,aAAa;IACpD,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;IAC5C,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAC/B,kBAAkB,EAAE,aAAa,CAAiB;IAClD,WAAW,EAAE,MAAM,CAAK;IAExB,OAAO,CAAC,sBAAsB,CAAwB;gBAE1C,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,kBAAkB;
|
|
1
|
+
{"version":3,"file":"webgpu-canvas-context.d.ts","sourceRoot":"","sources":["../../src/adapter/webgpu-canvas-context.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAC,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAC,MAAM,cAAc,CAAC;AAC7E,OAAO,EAAC,aAAa,EAAM,MAAM,cAAc,CAAC;AAEhD,OAAO,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAC,iBAAiB,EAAC,MAAM,gCAAgC,CAAC;AAEjE;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,aAAa;IACpD,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;IAC5C,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAC/B,kBAAkB,EAAE,aAAa,CAAiB;IAClD,WAAW,EAAE,MAAM,CAAK;IAExB,OAAO,CAAC,sBAAsB,CAAwB;gBAE1C,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,kBAAkB;IAchF,OAAO,IAAI,IAAI;IAIf,0EAA0E;IAC1E,qBAAqB,IAAI,iBAAiB;IAsB1C,sDAAsD;IACtD,MAAM;IA6BN,MAAM,CAAC,OAAO,CAAC,EAAE;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,eAAe,CAAC,EAAE,OAAO,GAAG,MAAM,CAAA;KAAC,GAAG,IAAI;IAI7F,8FAA8F;IAC9F,6BAA6B;CAY9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgpu-canvas-context.js","names":["CanvasContext","log","getWebGPUTextureFormat","WebGPUFramebuffer","WebGPUCanvasContext","constructor","device","adapter","props","_defineProperty","width","height","_setAutoCreatedCanvasId","concat","id","gpuCanvasContext","canvas","getContext","format","getPreferredFormat","destroy","unconfigure","getCurrentFramebuffer","update","currentColorAttachment","createTexture","handle","getCurrentTexture","_createDepthStencilAttachment","colorAttachments","depthStencilAttachment","getPixelSize","sizeChanged","configure","colorSpace","alphaMode","resize","options","depthStencilFormat","usage","GPUTextureUsage","RENDER_ATTACHMENT"],"sources":["../../src/adapter/webgpu-canvas-context.ts"],"sourcesContent":["import type {Texture, TextureFormat, CanvasContextProps} from '@luma.gl/api';\nimport {CanvasContext, log} from '@luma.gl/api';\nimport {getWebGPUTextureFormat} from './helpers/convert-texture-format';\nimport {WebGPUDevice} from './webgpu-device';\nimport {WebGPUFramebuffer} from './resources/webgpu-framebuffer';\n\n/** \n * Holds a WebGPU Canvas Context which handles resizing etc \n */\nexport class WebGPUCanvasContext extends CanvasContext {\n readonly device: WebGPUDevice;\n readonly gpuCanvasContext: GPUCanvasContext;\n readonly format: TextureFormat;\n depthStencilFormat: TextureFormat = 'depth24plus';\n sampleCount: number = 1;\n\n private depthStencilAttachment: Texture | null = null;\n\n constructor(device: WebGPUDevice, adapter: GPUAdapter, props: CanvasContextProps) {\n super(props);\n this.device = device;\n // TODO - hack to trigger resize?\n this.width = -1;\n this.height = -1;\n \n this._setAutoCreatedCanvasId(`${this.device.id}-canvas`);\n this.gpuCanvasContext = this.canvas.getContext('webgpu')
|
|
1
|
+
{"version":3,"file":"webgpu-canvas-context.js","names":["CanvasContext","log","getWebGPUTextureFormat","WebGPUFramebuffer","WebGPUCanvasContext","constructor","device","adapter","props","_defineProperty","width","height","_setAutoCreatedCanvasId","concat","id","gpuCanvasContext","canvas","getContext","format","getPreferredFormat","destroy","unconfigure","getCurrentFramebuffer","update","currentColorAttachment","createTexture","handle","getCurrentTexture","_createDepthStencilAttachment","colorAttachments","depthStencilAttachment","getPixelSize","sizeChanged","configure","colorSpace","alphaMode","resize","options","depthStencilFormat","usage","GPUTextureUsage","RENDER_ATTACHMENT"],"sources":["../../src/adapter/webgpu-canvas-context.ts"],"sourcesContent":["import type {Texture, TextureFormat, CanvasContextProps} from '@luma.gl/api';\nimport {CanvasContext, log} from '@luma.gl/api';\nimport {getWebGPUTextureFormat} from './helpers/convert-texture-format';\nimport {WebGPUDevice} from './webgpu-device';\nimport {WebGPUFramebuffer} from './resources/webgpu-framebuffer';\n\n/** \n * Holds a WebGPU Canvas Context which handles resizing etc \n */\nexport class WebGPUCanvasContext extends CanvasContext {\n readonly device: WebGPUDevice;\n readonly gpuCanvasContext: GPUCanvasContext;\n readonly format: TextureFormat;\n depthStencilFormat: TextureFormat = 'depth24plus';\n sampleCount: number = 1;\n\n private depthStencilAttachment: Texture | null = null;\n\n constructor(device: WebGPUDevice, adapter: GPUAdapter, props: CanvasContextProps) {\n super(props);\n this.device = device;\n // TODO - hack to trigger resize?\n this.width = -1;\n this.height = -1;\n \n this._setAutoCreatedCanvasId(`${this.device.id}-canvas`);\n // @ts-ignore TODO - we don't handle OffscreenRenderingContext.\n this.gpuCanvasContext = this.canvas.getContext('webgpu') ;\n // @ts-expect-error TODO this has been replaced\n this.format = this.gpuCanvasContext.getPreferredFormat(adapter);\n }\n\n destroy(): void {\n this.gpuCanvasContext.unconfigure();\n }\n\n /** Update framebuffer with properly resized \"swap chain\" texture views */\n getCurrentFramebuffer(): WebGPUFramebuffer {\n // Ensure the canvas context size is updated\n this.update();\n\n // Wrap the current canvas context texture in a luma.gl texture \n const currentColorAttachment = this.device.createTexture({\n id: 'default-render-target',\n handle: this.gpuCanvasContext.getCurrentTexture(),\n format: this.format,\n width: this.width,\n height: this.height\n });\n\n // Resize the depth stencil attachment\n this._createDepthStencilAttachment();\n\n return new WebGPUFramebuffer(this.device, {\n colorAttachments: [currentColorAttachment],\n depthStencilAttachment: this.depthStencilAttachment\n });\n }\n\n /** Resizes and updates render targets if necessary */\n update() {\n const [width, height] = this.getPixelSize();\n\n const sizeChanged = width !== this.width || height !== this.height;\n\n if (sizeChanged) {\n this.width = width;\n this.height = height;\n\n if (this.depthStencilAttachment) {\n this.depthStencilAttachment.destroy();\n this.depthStencilAttachment = null;\n }\n\n // Reconfigure the canvas size.\n // https://www.w3.org/TR/webgpu/#canvas-configuration\n this.gpuCanvasContext.configure({\n device: this.device.handle,\n format: getWebGPUTextureFormat(this.format),\n // size: [this.width, this.height],\n colorSpace: this.props.colorSpace,\n alphaMode: this.props.alphaMode\n });\n\n log.log(1, `Resized to ${this.width}x${this.height}px`)();\n }\n\n }\n\n resize(options?: {width?: number; height?: number; useDevicePixels?: boolean | number}): void {\n this.update();\n }\n\n /** We build render targets on demand (i.e. not when size changes but when about to render) */\n _createDepthStencilAttachment() {\n if (!this.depthStencilAttachment) {\n this.depthStencilAttachment = this.device.createTexture({\n id: 'depth-stencil-target',\n format: this.depthStencilFormat,\n width: this.width,\n height: this.height,\n usage: GPUTextureUsage.RENDER_ATTACHMENT\n });\n }\n return this.depthStencilAttachment;\n }\n}\n"],"mappings":";AACA,SAAQA,aAAa,EAAEC,GAAG,QAAO,cAAc;AAAC,SACxCC,sBAAsB;AAAA,SAEtBC,iBAAiB;AAKzB,OAAO,MAAMC,mBAAmB,SAASJ,aAAa,CAAC;EASrDK,WAAWA,CAACC,MAAoB,EAAEC,OAAmB,EAAEC,KAAyB,EAAE;IAChF,KAAK,CAACA,KAAK,CAAC;IAACC,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA,6BANqB,aAAa;IAAAA,eAAA,sBAC3B,CAAC;IAAAA,eAAA,iCAE0B,IAAI;IAInD,IAAI,CAACH,MAAM,GAAGA,MAAM;IAEpB,IAAI,CAACI,KAAK,GAAG,CAAC,CAAC;IACf,IAAI,CAACC,MAAM,GAAG,CAAC,CAAC;IAEhB,IAAI,CAACC,uBAAuB,IAAAC,MAAA,CAAI,IAAI,CAACP,MAAM,CAACQ,EAAE,aAAU;IAExD,IAAI,CAACC,gBAAgB,GAAG,IAAI,CAACC,MAAM,CAACC,UAAU,CAAC,QAAQ,CAAC;IAExD,IAAI,CAACC,MAAM,GAAG,IAAI,CAACH,gBAAgB,CAACI,kBAAkB,CAACZ,OAAO,CAAC;EACjE;EAEAa,OAAOA,CAAA,EAAS;IACd,IAAI,CAACL,gBAAgB,CAACM,WAAW,EAAE;EACrC;EAGAC,qBAAqBA,CAAA,EAAsB;IAEzC,IAAI,CAACC,MAAM,EAAE;IAGb,MAAMC,sBAAsB,GAAG,IAAI,CAAClB,MAAM,CAACmB,aAAa,CAAC;MACvDX,EAAE,EAAE,uBAAuB;MAC3BY,MAAM,EAAE,IAAI,CAACX,gBAAgB,CAACY,iBAAiB,EAAE;MACjDT,MAAM,EAAE,IAAI,CAACA,MAAM;MACnBR,KAAK,EAAE,IAAI,CAACA,KAAK;MACjBC,MAAM,EAAE,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IAAI,CAACA,sBAAsB,GAAG,IAAI,CAACxB,MAAM,CAACmB,aAAa,CAAC;QACtDX,EAAE,EAAE,sBAAsB;QAC1BI,MAAM,EAAE,IAAI,CAACoB,kBAAkB;QAC/B5B,KAAK,EAAE,IAAI,CAACA,KAAK;QACjBC,MAAM,EAAE,IAAI,CAACA,MAAM;QACnB4B,KAAK,EAAEC,eAAe,CAACC;MACzB,CAAC,CAAC;IACJ;IACA,OAAO,IAAI,CAACX,sBAAsB;EACpC;AACF"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/// <reference types="dist" />
|
|
2
|
-
|
|
2
|
+
/// <reference types="offscreencanvas" />
|
|
3
|
+
import type { DeviceProps, DeviceInfo, DeviceLimits, DeviceFeature, CanvasContextProps, BufferProps, SamplerProps, ShaderProps, Texture, TextureProps, TextureFormat, ExternalTextureProps, FramebufferProps, RenderPipelineProps, ComputePipelineProps, RenderPassProps, ComputePassProps } from '@luma.gl/api';
|
|
3
4
|
import { Device } from '@luma.gl/api';
|
|
4
5
|
import { WebGPUBuffer } from './resources/webgpu-buffer';
|
|
5
6
|
import { WebGPUTexture } from './resources/webgpu-texture';
|
|
@@ -40,7 +41,7 @@ export declare class WebGPUDevice extends Device {
|
|
|
40
41
|
/** @todo implement proper check? */
|
|
41
42
|
isTextureFormatRenderable(format: TextureFormat): boolean;
|
|
42
43
|
get isLost(): boolean;
|
|
43
|
-
|
|
44
|
+
createBuffer(props: BufferProps | ArrayBuffer | ArrayBufferView): WebGPUBuffer;
|
|
44
45
|
_createTexture(props: TextureProps): WebGPUTexture;
|
|
45
46
|
createExternalTexture(props: ExternalTextureProps): WebGPUExternalTexture;
|
|
46
47
|
createShader(props: ShaderProps): WebGPUShader;
|
|
@@ -63,5 +64,18 @@ export declare class WebGPUDevice extends Device {
|
|
|
63
64
|
getDefaultRenderPass(): WebGPURenderPass;
|
|
64
65
|
submit(): void;
|
|
65
66
|
_getFeatures(): Set<DeviceFeature>;
|
|
67
|
+
copyExternalImageToTexture(options: {
|
|
68
|
+
texture: Texture;
|
|
69
|
+
mipLevel?: number;
|
|
70
|
+
aspect?: 'all' | 'stencil-only' | 'depth-only';
|
|
71
|
+
colorSpace?: 'display-p3' | 'srgb';
|
|
72
|
+
premultipliedAlpha?: boolean;
|
|
73
|
+
source: ImageBitmap | HTMLVideoElement | HTMLCanvasElement | OffscreenCanvas;
|
|
74
|
+
sourceX?: number;
|
|
75
|
+
sourceY?: number;
|
|
76
|
+
width?: number;
|
|
77
|
+
height?: number;
|
|
78
|
+
depth?: number;
|
|
79
|
+
}): void;
|
|
66
80
|
}
|
|
67
81
|
//# sourceMappingURL=webgpu-device.d.ts.map
|