@luma.gl/webgpu 9.0.0-alpha.51 → 9.0.0-alpha.53
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 +2 -1
- package/dist/adapter/resources/webgpu-command-encoder.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-command-encoder.js +8 -4
- package/dist/adapter/resources/webgpu-command-encoder.js.map +1 -1
- package/dist/adapter/resources/webgpu-compute-pass.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-compute-pass.js +4 -3
- package/dist/adapter/resources/webgpu-compute-pass.js.map +1 -1
- package/dist/adapter/resources/webgpu-compute-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-compute-pipeline.js +3 -3
- package/dist/adapter/resources/webgpu-compute-pipeline.js.map +1 -1
- package/dist/adapter/webgpu-device.d.ts +1 -1
- package/dist/adapter/webgpu-device.d.ts.map +1 -1
- package/dist/adapter/webgpu-device.js +20 -11
- package/dist/adapter/webgpu-device.js.map +1 -1
- package/dist/dist.dev.js +35 -22
- package/dist/index.cjs +25 -16
- package/dist.min.js +18 -17
- package/package.json +3 -3
- package/src/adapter/resources/webgpu-command-encoder.ts +36 -36
- package/src/adapter/resources/webgpu-compute-pass.ts +4 -3
- package/src/adapter/resources/webgpu-compute-pipeline.ts +3 -3
- package/src/adapter/webgpu-device.ts +25 -11
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/// <reference types="dist" />
|
|
2
|
-
import { CommandEncoder, CommandEncoderProps, Buffer, Texture
|
|
2
|
+
import { CommandEncoder, CommandEncoderProps, Buffer, Texture } from '@luma.gl/core';
|
|
3
|
+
import type { CopyTextureToTextureOptions, CopyTextureToBufferOptions } from '@luma.gl/core';
|
|
3
4
|
import { WebGPUDevice } from '../webgpu-device';
|
|
4
5
|
export declare class WebGPUCommandEncoder extends CommandEncoder {
|
|
5
6
|
readonly device: WebGPUDevice;
|
|
@@ -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,EAAE,MAAM,EAAE,OAAO,
|
|
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,EAAE,MAAM,EAAE,OAAO,EAAC,MAAM,eAAe,CAAC;AACnF,OAAO,KAAK,EAAC,2BAA2B,EAAE,0BAA0B,EAAC,MAAM,eAAe,CAAC;AAC3F,OAAO,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAI9C,qBAAa,oBAAqB,SAAQ,cAAc;IACtD,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAC;gBAEvB,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,mBAAmB;IAYnD,OAAO,IAAI,IAAI;IAExB,MAAM,CAAC,OAAO,CAAC,EAAE;QAAC,EAAE,CAAC,EAAE,MAAM,CAAA;KAAC,GAAG,gBAAgB;IAOjD,kBAAkB,CAAC,OAAO,EAC1B;QACE,MAAM,EAAE,MAAM,CAAC;QACf,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,WAAW,EAAE,MAAM,CAAC;QACpB,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,GAAG,IAAI;IAYR,mBAAmB,CAAC,OAAO,EAC3B;QACE,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,WAAW,EAAE,MAAM,CAAC;QACpB,YAAY,EAAE,MAAM,CAAC;QAErB,WAAW,EAAE,OAAO,CAAC;QACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,MAAM,CAAC,EAAE,KAAK,GAAG,cAAc,GAAG,YAAY,CAAC;QAE/C,MAAM,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;QAC7C,MAAM,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;KAC9C,GAAG,IAAI;IAyBR,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,4 +1,4 @@
|
|
|
1
|
-
import { CommandEncoder
|
|
1
|
+
import { CommandEncoder } from '@luma.gl/core';
|
|
2
2
|
export class WebGPUCommandEncoder extends CommandEncoder {
|
|
3
3
|
constructor(device, props) {
|
|
4
4
|
super(device, props);
|
|
@@ -14,17 +14,21 @@ export class WebGPUCommandEncoder extends CommandEncoder {
|
|
|
14
14
|
}
|
|
15
15
|
copyBufferToBuffer(options) {
|
|
16
16
|
var _options$sourceOffset, _options$destinationO, _options$size;
|
|
17
|
-
|
|
17
|
+
const webgpuSourceBuffer = options.source;
|
|
18
|
+
const WebGPUDestinationBuffer = options.destination;
|
|
19
|
+
this.handle.copyBufferToBuffer(webgpuSourceBuffer.handle, (_options$sourceOffset = options.sourceOffset) !== null && _options$sourceOffset !== void 0 ? _options$sourceOffset : 0, WebGPUDestinationBuffer.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);
|
|
18
20
|
}
|
|
19
21
|
copyBufferToTexture(options) {
|
|
20
22
|
var _options$offset, _options$mipLevel, _options$origin;
|
|
23
|
+
const webgpuSourceBuffer = options.source;
|
|
24
|
+
const WebGPUDestinationTexture = options.destination;
|
|
21
25
|
this.handle.copyBufferToTexture({
|
|
22
|
-
buffer:
|
|
26
|
+
buffer: webgpuSourceBuffer.handle,
|
|
23
27
|
offset: (_options$offset = options.offset) !== null && _options$offset !== void 0 ? _options$offset : 0,
|
|
24
28
|
bytesPerRow: options.bytesPerRow,
|
|
25
29
|
rowsPerImage: options.rowsPerImage
|
|
26
30
|
}, {
|
|
27
|
-
texture:
|
|
31
|
+
texture: WebGPUDestinationTexture.handle,
|
|
28
32
|
mipLevel: (_options$mipLevel = options.mipLevel) !== null && _options$mipLevel !== void 0 ? _options$mipLevel : 0,
|
|
29
33
|
origin: (_options$origin = options.origin) !== null && _options$origin !== void 0 ? _options$origin : {}
|
|
30
34
|
}, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgpu-command-encoder.js","names":["CommandEncoder","
|
|
1
|
+
{"version":3,"file":"webgpu-command-encoder.js","names":["CommandEncoder","WebGPUCommandEncoder","constructor","device","props","handle","createCommandEncoder","label","id","destroy","finish","options","copyBufferToBuffer","_options$sourceOffset","_options$destinationO","_options$size","webgpuSourceBuffer","source","WebGPUDestinationBuffer","destination","sourceOffset","destinationOffset","size","copyBufferToTexture","_options$offset","_options$mipLevel","_options$origin","WebGPUDestinationTexture","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} from '@luma.gl/core';\nimport type {CopyTextureToTextureOptions, CopyTextureToBufferOptions} from '@luma.gl/core';\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(device, props);\n this.device = device;\n this.handle =\n props.handle ||\n 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 }): void {\n const webgpuSourceBuffer = options.source as WebGPUBuffer;\n const WebGPUDestinationBuffer = options.destination as WebGPUBuffer;\n this.handle.copyBufferToBuffer(\n webgpuSourceBuffer.handle,\n options.sourceOffset ?? 0,\n WebGPUDestinationBuffer.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 }): void {\n const webgpuSourceBuffer = options.source as WebGPUBuffer;\n const WebGPUDestinationTexture = options.destination as WebGPUTexture;\n this.handle.copyBufferToTexture(\n {\n buffer: webgpuSourceBuffer.handle,\n offset: options.offset ?? 0,\n bytesPerRow: options.bytesPerRow,\n rowsPerImage: options.rowsPerImage\n },\n {\n texture: WebGPUDestinationTexture.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}\n"],"mappings":"AAAA,SAAQA,cAAc,QAA6C,eAAe;AAMlF,OAAO,MAAMC,oBAAoB,SAASD,cAAc,CAAC;EAIvDE,WAAWA,CAACC,MAAoB,EAAEC,KAA0B,EAAE;IAC5D,KAAK,CAACD,MAAM,EAAEC,KAAK,CAAC;IAAC,KAJdD,MAAM;IAAA,KACNE,MAAM;IAIb,IAAI,CAACF,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACE,MAAM,GACTD,KAAK,CAACC,MAAM,IACZ,IAAI,CAACF,MAAM,CAACE,MAAM,CAACC,oBAAoB,CAAC,CAGxC,CAAC,CAAC;IACJ,IAAI,CAACD,MAAM,CAACE,KAAK,GAAG,IAAI,CAACH,KAAK,CAACI,EAAE;EACnC;EAESC,OAAOA,CAAA,EAAS,CAAC;EAE1BC,MAAMA,CAACC,OAAuB,EAAoB;IAChD,OAAO,IAAI,CAACD,MAAM,CAACC,OAAO,CAAC;EAC7B;EAKAC,kBAAkBA,CAACD,OAOlB,EAAQ;IAAA,IAAAE,qBAAA,EAAAC,qBAAA,EAAAC,aAAA;IACP,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O,CAACyB,MAAM,CAAC,CAAC,CAAC;MACzBE,kBAAkB,EAAE3B,OAAO,CAACyB,MAAM,CAAC,CAAC;IACtC,CACF,CAAC;EACH;EAEAG,mBAAmBA,CAAC5B,OAAmC,EAAQ,CAS/D;EAEA6B,oBAAoBA,CAAC7B,OAAoC,EAAQ,CASjE;EAES8B,cAAcA,CAACC,UAAkB,EAAQ;IAChD,IAAI,CAACrC,MAAM,CAACoC,cAAc,CAACC,UAAU,CAAC;EACxC;EAESC,aAAaA,CAAA,EAAS;IAC7B,IAAI,CAACtC,MAAM,CAACsC,aAAa,CAAC,CAAC;EAC7B;EAESC,iBAAiBA,CAACC,WAAmB,EAAQ;IACpD,IAAI,CAACxC,MAAM,CAACuC,iBAAiB,CAACC,WAAW,CAAC;EAC5C;AAWF"}
|
|
@@ -1 +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,
|
|
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,EAAC,MAAM,eAAe,CAAC;AAC9F,OAAO,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAK9C,qBAAa,iBAAkB,SAAQ,WAAW;IAChD,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,qBAAqB,CAAC;IACvC,gBAAgB,EAAE,kBAAkB,GAAG,IAAI,CAAQ;gBAEvC,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,gBAAgB;IAUzD,8CAA8C;IACrC,OAAO,IAAI,IAAI;IAExB,GAAG,IAAI,IAAI;IAIX,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;IAK1E,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAGxC,aAAa,IAAI,IAAI;IAGrB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;CAO7C"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ComputePass
|
|
1
|
+
import { ComputePass } from '@luma.gl/core';
|
|
2
2
|
export class WebGPUComputePass extends ComputePass {
|
|
3
3
|
constructor(device, props) {
|
|
4
4
|
var _device$commandEncode;
|
|
@@ -16,7 +16,7 @@ export class WebGPUComputePass extends ComputePass {
|
|
|
16
16
|
this.handle.end();
|
|
17
17
|
}
|
|
18
18
|
setPipeline(pipeline) {
|
|
19
|
-
const wgpuPipeline =
|
|
19
|
+
const wgpuPipeline = pipeline;
|
|
20
20
|
this.handle.setPipeline(wgpuPipeline.handle);
|
|
21
21
|
this._bindGroupLayout = wgpuPipeline._getBindGroupLayout();
|
|
22
22
|
}
|
|
@@ -28,7 +28,8 @@ export class WebGPUComputePass extends ComputePass {
|
|
|
28
28
|
}
|
|
29
29
|
dispatchIndirect(indirectBuffer) {
|
|
30
30
|
let indirectOffset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
31
|
-
|
|
31
|
+
const webgpuBuffer = indirectBuffer;
|
|
32
|
+
this.handle.dispatchWorkgroupsIndirect(webgpuBuffer.handle, indirectOffset);
|
|
32
33
|
}
|
|
33
34
|
pushDebugGroup(groupLabel) {
|
|
34
35
|
this.handle.pushDebugGroup(groupLabel);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgpu-compute-pass.js","names":["ComputePass","
|
|
1
|
+
{"version":3,"file":"webgpu-compute-pass.js","names":["ComputePass","WebGPUComputePass","constructor","device","props","_device$commandEncode","handle","_bindGroupLayout","commandEncoder","beginComputePass","label","id","destroy","end","setPipeline","pipeline","wgpuPipeline","_getBindGroupLayout","setBindings","bindings","Error","dispatch","x","y","z","dispatchWorkgroups","dispatchIndirect","indirectBuffer","indirectOffset","arguments","length","undefined","webgpuBuffer","dispatchWorkgroupsIndirect","pushDebugGroup","groupLabel","popDebugGroup","insertDebugMarker","markerLabel"],"sources":["../../../src/adapter/resources/webgpu-compute-pass.ts"],"sourcesContent":["import {ComputePass, ComputePassProps, ComputePipeline, Buffer, Binding} from '@luma.gl/core';\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 class WebGPUComputePass extends ComputePass {\n readonly device: WebGPUDevice;\n readonly handle: GPUComputePassEncoder;\n _bindGroupLayout: GPUBindGroupLayout | null = null;\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 override destroy(): void {}\n\n end(): void {\n this.handle.end();\n }\n\n setPipeline(pipeline: ComputePipeline): void {\n const wgpuPipeline = pipeline as WebGPUComputePipeline;\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.dispatchWorkgroups(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 const webgpuBuffer = indirectBuffer as WebGPUBuffer;\n this.handle.dispatchWorkgroupsIndirect(webgpuBuffer.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"],"mappings":"AAAA,SAAQA,WAAW,QAA2D,eAAe;AAM7F,OAAO,MAAMC,iBAAiB,SAASD,WAAW,CAAC;EAKjDE,WAAWA,CAACC,MAAoB,EAAEC,KAAuB,EAAE;IAAA,IAAAC,qBAAA;IACzD,KAAK,CAACF,MAAM,EAAEC,KAAK,CAAC;IAAC,KALdD,MAAM;IAAA,KACNG,MAAM;IAAA,KACfC,gBAAgB,GAA8B,IAAI;IAIhD,IAAI,CAACJ,MAAM,GAAGA,MAAM;IAEpB,IAAI,CAACG,MAAM,GAAG,IAAI,CAACF,KAAK,CAACE,MAAM,MAAAD,qBAAA,GAAIF,MAAM,CAAC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AAW,CAAC;EAC5C;AAKF"}
|
|
@@ -1 +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,
|
|
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,EAAC,MAAM,eAAe,CAAC;AAEpE,OAAO,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAK9C,4DAA4D;AAC5D,qBAAa,qBAAsB,SAAQ,eAAe;IACxD,MAAM,EAAE,YAAY,CAAC;IACrB,MAAM,EAAE,kBAAkB,CAAC;gBAEf,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,oBAAoB;IAgB7D,wCAAwC;IACxC,mBAAmB;CAIpB"}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { ComputePipeline
|
|
1
|
+
import { ComputePipeline } from '@luma.gl/core';
|
|
2
2
|
export class WebGPUComputePipeline extends ComputePipeline {
|
|
3
3
|
constructor(device, props) {
|
|
4
4
|
super(device, props);
|
|
5
5
|
this.device = void 0;
|
|
6
6
|
this.handle = void 0;
|
|
7
7
|
this.device = device;
|
|
8
|
-
const
|
|
8
|
+
const webgpuShader = this.props.cs;
|
|
9
9
|
this.handle = this.props.handle || this.device.handle.createComputePipeline({
|
|
10
10
|
label: this.props.id,
|
|
11
11
|
compute: {
|
|
12
|
-
module,
|
|
12
|
+
module: webgpuShader.handle,
|
|
13
13
|
entryPoint: this.props.csEntryPoint
|
|
14
14
|
},
|
|
15
15
|
layout: 'auto'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgpu-compute-pipeline.js","names":["ComputePipeline","
|
|
1
|
+
{"version":3,"file":"webgpu-compute-pipeline.js","names":["ComputePipeline","WebGPUComputePipeline","constructor","device","props","handle","webgpuShader","cs","createComputePipeline","label","id","compute","module","entryPoint","csEntryPoint","layout","_getBindGroupLayout","getBindGroupLayout"],"sources":["../../../src/adapter/resources/webgpu-compute-pipeline.ts"],"sourcesContent":["// prettier-ignore\nimport {ComputePipeline, ComputePipelineProps} from '@luma.gl/core';\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 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 webgpuShader = this.props.cs as WebGPUShader;\n this.handle = this.props.handle || this.device.handle.createComputePipeline({\n label: this.props.id,\n compute: {\n module: webgpuShader.handle,\n entryPoint: this.props.csEntryPoint,\n // constants: this.props.csConstants\n },\n layout: 'auto'\n });\n }\n\n /** For internal use in render passes */\n _getBindGroupLayout() {\n // TODO: Cache?\n return this.handle.getBindGroupLayout(0);\n }\n}\n"],"mappings":"AACA,SAAQA,eAAe,QAA6B,eAAe;AAQnE,OAAO,MAAMC,qBAAqB,SAASD,eAAe,CAAC;EAIzDE,WAAWA,CAACC,MAAoB,EAAEC,KAA2B,EAAE;IAC7D,KAAK,CAACD,MAAM,EAAEC,KAAK,CAAC;IAAC,KAJvBD,MAAM;IAAA,KACNE,MAAM;IAIJ,IAAI,CAACF,MAAM,GAAGA,MAAM;IAEpB,MAAMG,YAAY,GAAG,IAAI,CAACF,KAAK,CAACG,EAAkB;IAClD,IAAI,CAACF,MAAM,GAAG,IAAI,CAACD,KAAK,CAACC,MAAM,IAAI,IAAI,CAACF,MAAM,CAACE,MAAM,CAACG,qBAAqB,CAAC;MAC1EC,KAAK,EAAE,IAAI,CAACL,KAAK,CAACM,EAAE;MACpBC,OAAO,EAAE;QACPC,MAAM,EAAEN,YAAY,CAACD,MAAM;QAC3BQ,UAAU,EAAE,IAAI,CAACT,KAAK,CAACU;MAEzB,CAAC;MACDC,MAAM,EAAE;IACV,CAAC,CAAC;EACJ;EAGAC,mBAAmBA,CAAA,EAAG;IAEpB,OAAO,IAAI,CAACX,MAAM,CAACY,kBAAkB,CAAC,CAAC,CAAC;EAC1C;AACF"}
|
|
@@ -30,7 +30,7 @@ export declare class WebGPUDevice extends Device {
|
|
|
30
30
|
/** Check if WebGPU is available */
|
|
31
31
|
static isSupported(): boolean;
|
|
32
32
|
static create(props: DeviceProps): Promise<WebGPUDevice>;
|
|
33
|
-
constructor(device: GPUDevice, adapter: GPUAdapter, props: DeviceProps);
|
|
33
|
+
constructor(device: GPUDevice, adapter: GPUAdapter, adapterInfo: GPUAdapterInfo, props: DeviceProps);
|
|
34
34
|
destroy(): void;
|
|
35
35
|
get info(): DeviceInfo;
|
|
36
36
|
features: Set<DeviceFeature>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgpu-device.d.ts","sourceRoot":"","sources":["../../src/adapter/webgpu-device.ts"],"names":[],"mappings":";AAGA,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,WAAW,EACX,YAAY,EACZ,WAAW,EACX,OAAO,EACP,YAAY,EACZ,aAAa,EACb,oBAAoB,EACpB,gBAAgB,EAChB,mBAAmB,EACnB,oBAAoB,EACpB,eAAe,EACf,gBAAgB,EAEhB,gBAAgB,EAChB,iBAAiB,EACjB,sBAAsB,EACvB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAC,MAAM,EAA0B,MAAM,eAAe,CAAC;AAC9D,OAAO,EAAC,YAAY,EAAC,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAC,aAAa,EAAC,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAC,qBAAqB,EAAC,MAAM,qCAAqC,CAAC;AAC1E,OAAO,EAAC,aAAa,EAAC,MAAM,4BAA4B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,GAAG,iBAAiB;IAM7D;;;OAGG;IACH,eAAe,CAAC,KAAK,EAAE,eAAe,GAAG,gBAAgB;IAKzD,gBAAgB,CAAC,KAAK,EAAE,gBAAgB,GAAG,iBAAiB;IAS5D,uBAAuB,CAAC,KAAK,EAAE,sBAAsB,GAAG,iBAAiB;IAIzE,mBAAmB,CAAC,KAAK,EAAE,kBAAkB,GAAG,mBAAmB;IAInE;;;;;OAKG;IACH,oBAAoB,IAAI,gBAAgB;IAUxC,MAAM,IAAI,IAAI;IAUd,YAAY;IAuDZ,0BAA0B,CAAC,OAAO,EAAE;QAClC,OAAO,EAAE,OAAO,CAAC;QACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,MAAM,CAAC,EAAE,KAAK,GAAG,cAAc,GAAG,YAAY,CAAC;QAC/C,UAAU,CAAC,EAAE,YAAY,GAAG,MAAM,CAAC;QACnC,kBAAkB,CAAC,EAAE,OAAO,CAAC;QAE7B,MAAM,EAAE,WAAW,GAAG,gBAAgB,GAAG,iBAAiB,GAAG,eAAe,CAAC;QAC7E,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,OAAO,CAAC,EAAE,MAAM,CAAC;QAEjB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,GAAG,IAAI;CAyCT"}
|
|
@@ -26,7 +26,7 @@ export class WebGPUDevice extends Device {
|
|
|
26
26
|
throw new Error('Failed to request WebGPU adapter');
|
|
27
27
|
}
|
|
28
28
|
const adapterInfo = await adapter.requestAdapterInfo();
|
|
29
|
-
log.probe(
|
|
29
|
+
log.probe(2, 'Adapter available', adapterInfo)();
|
|
30
30
|
const gpuDevice = await adapter.requestDevice({
|
|
31
31
|
requiredFeatures: adapter.features
|
|
32
32
|
});
|
|
@@ -35,13 +35,13 @@ export class WebGPUDevice extends Device {
|
|
|
35
35
|
await CanvasContext.pageLoaded;
|
|
36
36
|
log.probe(1, 'DOM is loaded')();
|
|
37
37
|
}
|
|
38
|
-
const device = new WebGPUDevice(gpuDevice, adapter, props);
|
|
39
|
-
log.probe(1, 'Device created
|
|
38
|
+
const device = new WebGPUDevice(gpuDevice, adapter, adapterInfo, props);
|
|
39
|
+
log.probe(1, 'Device created. For more info, set chrome://flags/#enable-webgpu-developer-features')();
|
|
40
40
|
log.table(1, device.info)();
|
|
41
41
|
log.groupEnd(1)();
|
|
42
42
|
return device;
|
|
43
43
|
}
|
|
44
|
-
constructor(device, adapter, props) {
|
|
44
|
+
constructor(device, adapter, adapterInfo, props) {
|
|
45
45
|
super({
|
|
46
46
|
...props,
|
|
47
47
|
id: props.id || uid('webgpu-device')
|
|
@@ -57,16 +57,25 @@ export class WebGPUDevice extends Device {
|
|
|
57
57
|
this.features = void 0;
|
|
58
58
|
this.handle = device;
|
|
59
59
|
this.adapter = adapter;
|
|
60
|
+
const [driver, driverVersion] = (adapterInfo.driver || '').split(' Version ');
|
|
61
|
+
const vendor = adapterInfo.vendor || this.adapter.__brand || 'unknown';
|
|
62
|
+
const renderer = driver || '';
|
|
63
|
+
const version = driverVersion || '';
|
|
64
|
+
const gpu = vendor === 'apple' ? 'apple' : 'unknown';
|
|
65
|
+
const gpuArchitecture = adapterInfo.architecture || 'unknown';
|
|
66
|
+
const gpuBackend = adapterInfo.backend || 'unknown';
|
|
67
|
+
const gpuType = (adapterInfo.type || '').split(' ')[0].toLowerCase() || 'unknown';
|
|
60
68
|
this._info = {
|
|
61
69
|
type: 'webgpu',
|
|
62
|
-
vendor
|
|
63
|
-
renderer
|
|
64
|
-
version
|
|
65
|
-
gpu
|
|
70
|
+
vendor,
|
|
71
|
+
renderer,
|
|
72
|
+
version,
|
|
73
|
+
gpu,
|
|
74
|
+
gpuType,
|
|
75
|
+
gpuBackend,
|
|
76
|
+
gpuArchitecture,
|
|
66
77
|
shadingLanguage: 'wgsl',
|
|
67
|
-
shadingLanguageVersion: 100
|
|
68
|
-
vendorMasked: '',
|
|
69
|
-
rendererMasked: ''
|
|
78
|
+
shadingLanguageVersion: 100
|
|
70
79
|
};
|
|
71
80
|
this.lost = new Promise(async resolve => {
|
|
72
81
|
const lostInfo = await this.handle.lost;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgpu-device.js","names":["Device","CanvasContext","log","uid","WebGPUBuffer","WebGPUTexture","WebGPUExternalTexture","WebGPUSampler","WebGPUShader","WebGPURenderPipeline","WebGPUComputePipeline","WebGPURenderPass","WebGPUComputePass","WebGPUVertexArray","WebGPUCanvasContext","WebGPUDevice","isSupported","Boolean","navigator","gpu","create","props","Error","groupCollapsed","adapter","requestAdapter","powerPreference","adapterInfo","requestAdapterInfo","probe","gpuDevice","requestDevice","requiredFeatures","features","canvas","pageLoaded","device","info","table","groupEnd","constructor","id","handle","lost","canvasContext","commandEncoder","renderPass","_info","_isLost","type","vendor","__brand","renderer","version","shadingLanguage","shadingLanguageVersion","vendorMasked","rendererMasked","Promise","resolve","lostInfo","reason","message","height","width","container","_getFeatures","destroy","limits","isTextureFormatSupported","format","includes","isTextureFormatFilterable","isTextureFormatRenderable","isLost","createBuffer","newProps","_getBufferProps","_createTexture","createExternalTexture","createShader","createSampler","createRenderPipeline","createFramebuffer","createComputePipeline","createVertexArray","beginRenderPass","createCommandEncoder","beginComputePass","createTransformFeedback","createCanvasContext","getDefaultRenderPass","submit","_this$commandEncoder","commandBuffer","finish","queue","Set","has","delete","add","copyExternalImageToTexture","options","_this$handle","source","sourceX","sourceY","texture","mipLevel","aspect","colorSpace","premultipliedAlpha","depth","webGpuTexture","origin"],"sources":["../../src/adapter/webgpu-device.ts"],"sourcesContent":["// prettier-ignore\n// / <reference types=\"@webgpu/types\" />\n\nimport type {\n DeviceProps,\n DeviceInfo,\n DeviceLimits,\n DeviceFeature,\n CanvasContextProps,\n BufferProps,\n SamplerProps,\n ShaderProps,\n Texture,\n TextureProps,\n TextureFormat,\n ExternalTextureProps,\n FramebufferProps,\n RenderPipelineProps,\n ComputePipelineProps,\n RenderPassProps,\n ComputePassProps,\n // CommandEncoderProps,\n VertexArrayProps,\n TransformFeedback,\n TransformFeedbackProps\n} from '@luma.gl/core';\nimport {Device, CanvasContext, log, uid} from '@luma.gl/core';\nimport {WebGPUBuffer} from './resources/webgpu-buffer';\nimport {WebGPUTexture} from './resources/webgpu-texture';\nimport {WebGPUExternalTexture} from './resources/webgpu-external-texture';\nimport {WebGPUSampler} from './resources/webgpu-sampler';\nimport {WebGPUShader} from './resources/webgpu-shader';\nimport {WebGPURenderPipeline} from './resources/webgpu-render-pipeline';\nimport {WebGPUFramebuffer} from './resources/webgpu-framebuffer';\nimport {WebGPUComputePipeline} from './resources/webgpu-compute-pipeline';\nimport {WebGPURenderPass} from './resources/webgpu-render-pass';\nimport {WebGPUComputePass} from './resources/webgpu-compute-pass';\n// import {WebGPUCommandEncoder} from './resources/webgpu-command-encoder';\nimport {WebGPUVertexArray} from './resources/webgpu-vertex-array';\n\nimport {WebGPUCanvasContext} from './webgpu-canvas-context';\n// import {loadGlslangModule} from '../glsl/glslang';\n\n/** WebGPU Device implementation */\nexport class WebGPUDevice extends Device {\n readonly handle: GPUDevice;\n readonly adapter: GPUAdapter;\n readonly lost: Promise<{reason: 'destroyed'; message: string}>;\n canvasContext: WebGPUCanvasContext | null = null;\n\n commandEncoder: GPUCommandEncoder | null = null;\n renderPass: WebGPURenderPass | null = null;\n\n private _info: DeviceInfo;\n private _isLost: boolean = false;\n\n static type: string = 'webgpu';\n\n /** Check if WebGPU is available */\n static isSupported(): boolean {\n return Boolean(typeof navigator !== 'undefined' && navigator.gpu);\n }\n\n static async create(props: DeviceProps): Promise<WebGPUDevice> {\n if (!navigator.gpu) {\n throw new Error(\n 'WebGPU not available. Open in Chrome Canary and turn on chrome://flags/#enable-unsafe-webgpu'\n );\n }\n log.groupCollapsed(1, 'WebGPUDevice created')();\n const adapter = await navigator.gpu.requestAdapter({\n powerPreference: 'high-performance'\n // forceSoftware: false\n });\n if (!adapter) {\n throw new Error('Failed to request WebGPU adapter');\n }\n\n const adapterInfo = await adapter.requestAdapterInfo();\n log.probe(1, 'Adapter available', adapterInfo)();\n\n const gpuDevice = await adapter.requestDevice({\n requiredFeatures: adapter.features as ReadonlySet<GPUFeatureName>\n // TODO ensure we obtain best limits\n // requiredLimits: adapter.limits\n });\n log.probe(1, 'GPUDevice available')();\n\n if (typeof props.canvas === 'string') {\n await CanvasContext.pageLoaded;\n log.probe(1, 'DOM is loaded')();\n }\n\n const device = new WebGPUDevice(gpuDevice, adapter, props);\n log.probe(1, 'Device created', device.info)();\n log.table(1, device.info)();\n log.groupEnd(1)();\n return device;\n }\n\n constructor(device: GPUDevice, adapter: GPUAdapter, props: DeviceProps) {\n super({...props, id: props.id || uid('webgpu-device')});\n this.handle = device;\n this.adapter = adapter;\n\n this._info = {\n type: 'webgpu',\n vendor: this.adapter.__brand,\n renderer: '',\n version: '',\n gpu: 'unknown', // 'nvidia' | 'amd' | 'intel' | 'apple' | 'unknown',\n shadingLanguage: 'wgsl',\n shadingLanguageVersion: 100,\n vendorMasked: '',\n rendererMasked: ''\n };\n\n // \"Context\" loss handling\n this.lost = new Promise<{reason: 'destroyed'; message: string}>(async resolve => {\n const lostInfo = await this.handle.lost;\n this._isLost = true;\n resolve({reason: 'destroyed', message: lostInfo.message});\n });\n\n // Note: WebGPU devices can be created without a canvas, for compute shader purposes\n // if (props.canvas) {\n this.canvasContext = new WebGPUCanvasContext(this, this.adapter, {\n canvas: props.canvas,\n height: props.height,\n width: props.width,\n container: props.container\n });\n // }\n\n this.features = this._getFeatures();\n }\n\n // TODO\n // Load the glslang module now so that it is available synchronously when compiling shaders\n // const {glsl = true} = props;\n // this.glslang = glsl && await loadGlslangModule();\n\n destroy(): void {\n this.handle.destroy();\n }\n\n get info(): DeviceInfo {\n return this._info;\n }\n\n features: Set<DeviceFeature>;\n\n get limits(): DeviceLimits {\n return this.handle.limits;\n }\n\n isTextureFormatSupported(format: TextureFormat): boolean {\n return !format.includes('webgl');\n }\n\n /** @todo implement proper check? */\n isTextureFormatFilterable(format: TextureFormat): boolean {\n return this.isTextureFormatSupported(format);\n }\n\n /** @todo implement proper check? */\n isTextureFormatRenderable(format: TextureFormat): boolean {\n return this.isTextureFormatSupported(format);\n }\n\n get isLost(): boolean {\n return this._isLost;\n }\n\n createBuffer(props: BufferProps | ArrayBuffer | ArrayBufferView): WebGPUBuffer {\n const newProps = this._getBufferProps(props);\n return new WebGPUBuffer(this, newProps);\n }\n\n _createTexture(props: TextureProps): WebGPUTexture {\n return new WebGPUTexture(this, props);\n }\n\n createExternalTexture(props: ExternalTextureProps): WebGPUExternalTexture {\n return new WebGPUExternalTexture(this, props);\n }\n\n createShader(props: ShaderProps): WebGPUShader {\n return new WebGPUShader(this, props);\n }\n\n createSampler(props: SamplerProps): WebGPUSampler {\n return new WebGPUSampler(this, props);\n }\n\n createRenderPipeline(props: RenderPipelineProps): WebGPURenderPipeline {\n return new WebGPURenderPipeline(this, props);\n }\n\n createFramebuffer(props: FramebufferProps): WebGPUFramebuffer {\n throw new Error('Not implemented');\n }\n\n createComputePipeline(props: ComputePipelineProps): WebGPUComputePipeline {\n return new WebGPUComputePipeline(this, props);\n }\n\n createVertexArray(props: VertexArrayProps): WebGPUVertexArray {\n return new WebGPUVertexArray(this, props);\n }\n\n // WebGPU specifics\n\n /**\n * Allows a render pass to begin against a canvas context\n * @todo need to support a \"Framebuffer\" equivalent (aka preconfigured RenderPassDescriptors?).\n */\n beginRenderPass(props: RenderPassProps): WebGPURenderPass {\n this.commandEncoder = this.commandEncoder || this.handle.createCommandEncoder();\n return new WebGPURenderPass(this, props);\n }\n\n beginComputePass(props: ComputePassProps): WebGPUComputePass {\n this.commandEncoder = this.commandEncoder || this.handle.createCommandEncoder();\n return new WebGPUComputePass(this, props);\n }\n\n // createCommandEncoder(props: CommandEncoderProps): WebGPUCommandEncoder {\n // return new WebGPUCommandEncoder(this, props);\n // }\n\n createTransformFeedback(props: TransformFeedbackProps): TransformFeedback {\n throw new Error('Transform feedback not supported in WebGPU');\n }\n\n createCanvasContext(props: CanvasContextProps): WebGPUCanvasContext {\n return new WebGPUCanvasContext(this, this.adapter, props);\n }\n\n /**\n * Gets default renderpass encoder.\n * Creates a new encoder against default canvasContext if not already created\n * @note Called internally by Model.\n * @deprecated Create explicit pass with device.beginRenderPass\n */\n getDefaultRenderPass(): WebGPURenderPass {\n // this.renderPass =\n // this.renderPass ||\n // this.beginRenderPass({\n // framebuffer: this.canvasContext?.getCurrentFramebuffer()\n // });\n // return this.renderPass;\n throw new Error('a');\n }\n\n submit(): void {\n // this.renderPass?.end();\n const commandBuffer = this.commandEncoder?.finish();\n if (commandBuffer) {\n this.handle.queue.submit([commandBuffer]);\n }\n this.commandEncoder = null;\n // this.renderPass = null;\n }\n\n _getFeatures() {\n // WebGPU Features\n const features = new Set<DeviceFeature>(this.handle.features as Set<DeviceFeature>);\n\n // Fixups for pre-standard names: https://github.com/webgpu-native/webgpu-headers/issues/133\n // @ts-expect-error Chrome Canary v99\n if (features.has('depth-clamping')) {\n // @ts-expect-error Chrome Canary v99\n features.delete('depth-clamping');\n features.add('depth-clip-control');\n }\n\n // Add subsets\n if (features.has('texture-compression-bc')) {\n features.add('texture-compression-bc5-webgl');\n }\n\n features.add('webgpu');\n\n features.add('timer-query-webgl');\n\n // WEBGL1 SUPPORT\n features.add('vertex-array-object-webgl1');\n features.add('instanced-rendering-webgl1');\n features.add('multiple-render-targets-webgl1');\n features.add('index-uint32-webgl1');\n features.add('blend-minmax-webgl1');\n features.add('texture-blend-float-webgl1');\n\n // TEXTURES, RENDERBUFFERS\n features.add('texture-formats-srgb-webgl1');\n\n // TEXTURES\n features.add('texture-formats-depth-webgl1');\n features.add('texture-formats-float32-webgl1');\n features.add('texture-formats-float16-webgl1');\n\n features.add('texture-filter-linear-float32-webgl');\n features.add('texture-filter-linear-float16-webgl');\n features.add('texture-filter-anisotropic-webgl');\n\n // FRAMEBUFFERS, TEXTURES AND RENDERBUFFERS\n features.add('texture-renderable-rgba32float-webgl');\n features.add('texture-renderable-float32-webgl');\n features.add('texture-renderable-float16-webgl');\n\n // GLSL extensions\n features.add('glsl-frag-data');\n features.add('glsl-frag-depth');\n features.add('glsl-derivatives');\n features.add('glsl-texture-lod');\n\n return features;\n }\n\n copyExternalImageToTexture(options: {\n texture: Texture;\n mipLevel?: number;\n aspect?: 'all' | 'stencil-only' | 'depth-only';\n colorSpace?: 'display-p3' | 'srgb';\n premultipliedAlpha?: boolean;\n\n source: ImageBitmap | HTMLVideoElement | HTMLCanvasElement | OffscreenCanvas;\n sourceX?: number;\n sourceY?: number;\n\n width?: number;\n height?: number;\n depth?: number;\n }): void {\n const {\n source,\n sourceX = 0,\n sourceY = 0,\n\n texture,\n mipLevel = 0,\n aspect = 'all',\n colorSpace = 'display-p3',\n premultipliedAlpha = false,\n // destinationX,\n // destinationY,\n // desitnationZ,\n\n width = texture.width,\n height = texture.height,\n depth = 1\n } = options;\n\n const webGpuTexture = texture as WebGPUTexture;\n\n this.handle?.queue.copyExternalImageToTexture(\n // source: GPUImageCopyExternalImage\n {\n source,\n origin: [sourceX, sourceY]\n },\n // destination: GPUImageCopyTextureTagged\n {\n texture: webGpuTexture.handle,\n origin: [0, 0, 0], // [x, y, z],\n mipLevel,\n aspect,\n colorSpace,\n premultipliedAlpha\n },\n // copySize: GPUExtent3D\n [width, height, depth]\n );\n }\n}\n"],"mappings":"AA0BA,SAAQA,MAAM,EAAEC,aAAa,EAAEC,GAAG,EAAEC,GAAG,QAAO,eAAe;AAAC,SACtDC,YAAY;AAAA,SACZC,aAAa;AAAA,SACbC,qBAAqB;AAAA,SACrBC,aAAa;AAAA,SACbC,YAAY;AAAA,SACZC,oBAAoB;AAAA,SAEpBC,qBAAqB;AAAA,SACrBC,gBAAgB;AAAA,SAChBC,iBAAiB;AAAA,SAEjBC,iBAAiB;AAAA,SAEjBC,mBAAmB;AAI3B,OAAO,MAAMC,YAAY,SAASf,MAAM,CAAC;EAevC,OAAOgB,WA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AA6D,YAAA,uBAAXA,YAAA,CAAaP,KAAK,CAACK,0BAA0B,CAE3C;MACEG,MAAM;MACNU,MAAM,EAAE,CAACT,OAAO,EAAEC,OAAO;IAC3B,CAAC,EAED;MACEC,OAAO,EAAEM,aAAa,CAACvE,MAAM;MAC7BwE,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;MACjBN,QAAQ;MACRC,MAAM;MACNC,UAAU;MACVC;IACF,CAAC,EAED,CAAC/C,KAAK,EAAED,MAAM,EAAEiD,KAAK,CACvB,CAAC;EACH;AACF;AA3UajG,YAAY,CAYhBkC,IAAI,GAAW,QAAQ"}
|
|
1
|
+
{"version":3,"file":"webgpu-device.js","names":["Device","CanvasContext","log","uid","WebGPUBuffer","WebGPUTexture","WebGPUExternalTexture","WebGPUSampler","WebGPUShader","WebGPURenderPipeline","WebGPUComputePipeline","WebGPURenderPass","WebGPUComputePass","WebGPUVertexArray","WebGPUCanvasContext","WebGPUDevice","isSupported","Boolean","navigator","gpu","create","props","Error","groupCollapsed","adapter","requestAdapter","powerPreference","adapterInfo","requestAdapterInfo","probe","gpuDevice","requestDevice","requiredFeatures","features","canvas","pageLoaded","device","table","info","groupEnd","constructor","id","handle","lost","canvasContext","commandEncoder","renderPass","_info","_isLost","driver","driverVersion","split","vendor","__brand","renderer","version","gpuArchitecture","architecture","gpuBackend","backend","gpuType","type","toLowerCase","shadingLanguage","shadingLanguageVersion","Promise","resolve","lostInfo","reason","message","height","width","container","_getFeatures","destroy","limits","isTextureFormatSupported","format","includes","isTextureFormatFilterable","isTextureFormatRenderable","isLost","createBuffer","newProps","_getBufferProps","_createTexture","createExternalTexture","createShader","createSampler","createRenderPipeline","createFramebuffer","createComputePipeline","createVertexArray","beginRenderPass","createCommandEncoder","beginComputePass","createTransformFeedback","createCanvasContext","getDefaultRenderPass","submit","_this$commandEncoder","commandBuffer","finish","queue","Set","has","delete","add","copyExternalImageToTexture","options","_this$handle","source","sourceX","sourceY","texture","mipLevel","aspect","colorSpace","premultipliedAlpha","depth","webGpuTexture","origin"],"sources":["../../src/adapter/webgpu-device.ts"],"sourcesContent":["// prettier-ignore\n// / <reference types=\"@webgpu/types\" />\n\nimport type {\n DeviceProps,\n DeviceInfo,\n DeviceLimits,\n DeviceFeature,\n CanvasContextProps,\n BufferProps,\n SamplerProps,\n ShaderProps,\n Texture,\n TextureProps,\n TextureFormat,\n ExternalTextureProps,\n FramebufferProps,\n RenderPipelineProps,\n ComputePipelineProps,\n RenderPassProps,\n ComputePassProps,\n // CommandEncoderProps,\n VertexArrayProps,\n TransformFeedback,\n TransformFeedbackProps\n} from '@luma.gl/core';\nimport {Device, CanvasContext, log, uid} from '@luma.gl/core';\nimport {WebGPUBuffer} from './resources/webgpu-buffer';\nimport {WebGPUTexture} from './resources/webgpu-texture';\nimport {WebGPUExternalTexture} from './resources/webgpu-external-texture';\nimport {WebGPUSampler} from './resources/webgpu-sampler';\nimport {WebGPUShader} from './resources/webgpu-shader';\nimport {WebGPURenderPipeline} from './resources/webgpu-render-pipeline';\nimport {WebGPUFramebuffer} from './resources/webgpu-framebuffer';\nimport {WebGPUComputePipeline} from './resources/webgpu-compute-pipeline';\nimport {WebGPURenderPass} from './resources/webgpu-render-pass';\nimport {WebGPUComputePass} from './resources/webgpu-compute-pass';\n// import {WebGPUCommandEncoder} from './resources/webgpu-command-encoder';\nimport {WebGPUVertexArray} from './resources/webgpu-vertex-array';\n\nimport {WebGPUCanvasContext} from './webgpu-canvas-context';\n// import {loadGlslangModule} from '../glsl/glslang';\n\n/** WebGPU Device implementation */\nexport class WebGPUDevice extends Device {\n readonly handle: GPUDevice;\n readonly adapter: GPUAdapter;\n readonly lost: Promise<{reason: 'destroyed'; message: string}>;\n canvasContext: WebGPUCanvasContext | null = null;\n\n commandEncoder: GPUCommandEncoder | null = null;\n renderPass: WebGPURenderPass | null = null;\n\n private _info: DeviceInfo;\n private _isLost: boolean = false;\n\n static type: string = 'webgpu';\n\n /** Check if WebGPU is available */\n static isSupported(): boolean {\n return Boolean(typeof navigator !== 'undefined' && navigator.gpu);\n }\n\n static async create(props: DeviceProps): Promise<WebGPUDevice> {\n if (!navigator.gpu) {\n throw new Error(\n 'WebGPU not available. Open in Chrome Canary and turn on chrome://flags/#enable-unsafe-webgpu'\n );\n }\n log.groupCollapsed(1, 'WebGPUDevice created')();\n const adapter = await navigator.gpu.requestAdapter({\n powerPreference: 'high-performance'\n // forceSoftware: false\n });\n if (!adapter) {\n throw new Error('Failed to request WebGPU adapter');\n }\n\n const adapterInfo = await adapter.requestAdapterInfo();\n log.probe(2, 'Adapter available', adapterInfo)();\n\n const gpuDevice = await adapter.requestDevice({\n requiredFeatures: adapter.features as ReadonlySet<GPUFeatureName>\n // TODO ensure we obtain best limits\n // requiredLimits: adapter.limits\n });\n log.probe(1, 'GPUDevice available')();\n\n if (typeof props.canvas === 'string') {\n await CanvasContext.pageLoaded;\n log.probe(1, 'DOM is loaded')();\n }\n\n const device = new WebGPUDevice(gpuDevice, adapter, adapterInfo, props);\n\n log.probe(1, 'Device created. For more info, set chrome://flags/#enable-webgpu-developer-features')();\n log.table(1, device.info)();\n log.groupEnd(1)();\n return device;\n }\n\n constructor(device: GPUDevice, adapter: GPUAdapter, adapterInfo: GPUAdapterInfo, props: DeviceProps) {\n super({...props, id: props.id || uid('webgpu-device')});\n this.handle = device;\n this.adapter = adapter;\n\n const [driver, driverVersion] = ((adapterInfo as any).driver || '').split(' Version ');\n\n // See https://developer.chrome.com/blog/new-in-webgpu-120#adapter_information_updates\n const vendor = adapterInfo.vendor || this.adapter.__brand || 'unknown';\n const renderer = driver || '';\n const version = driverVersion || '';\n\n const gpu = vendor === 'apple' ? 'apple' : 'unknown'; // 'nvidia' | 'amd' | 'intel' | 'apple' | 'unknown',\n const gpuArchitecture = adapterInfo.architecture || 'unknown';\n const gpuBackend = (adapterInfo as any).backend || 'unknown';\n const gpuType = ((adapterInfo as any).type || '').split(' ')[0].toLowerCase() || 'unknown'\n\n this._info = {\n type: 'webgpu',\n vendor,\n renderer,\n version,\n gpu, \n gpuType,\n gpuBackend,\n gpuArchitecture,\n shadingLanguage: 'wgsl',\n shadingLanguageVersion: 100\n };\n\n // \"Context\" loss handling\n this.lost = new Promise<{reason: 'destroyed'; message: string}>(async resolve => {\n const lostInfo = await this.handle.lost;\n this._isLost = true;\n resolve({reason: 'destroyed', message: lostInfo.message});\n });\n\n // Note: WebGPU devices can be created without a canvas, for compute shader purposes\n // if (props.canvas) {\n this.canvasContext = new WebGPUCanvasContext(this, this.adapter, {\n canvas: props.canvas,\n height: props.height,\n width: props.width,\n container: props.container\n });\n // }\n\n this.features = this._getFeatures();\n }\n\n // TODO\n // Load the glslang module now so that it is available synchronously when compiling shaders\n // const {glsl = true} = props;\n // this.glslang = glsl && await loadGlslangModule();\n\n destroy(): void {\n this.handle.destroy();\n }\n\n get info(): DeviceInfo {\n return this._info;\n }\n\n features: Set<DeviceFeature>;\n\n get limits(): DeviceLimits {\n return this.handle.limits;\n }\n\n isTextureFormatSupported(format: TextureFormat): boolean {\n return !format.includes('webgl');\n }\n\n /** @todo implement proper check? */\n isTextureFormatFilterable(format: TextureFormat): boolean {\n return this.isTextureFormatSupported(format);\n }\n\n /** @todo implement proper check? */\n isTextureFormatRenderable(format: TextureFormat): boolean {\n return this.isTextureFormatSupported(format);\n }\n\n get isLost(): boolean {\n return this._isLost;\n }\n\n createBuffer(props: BufferProps | ArrayBuffer | ArrayBufferView): WebGPUBuffer {\n const newProps = this._getBufferProps(props);\n return new WebGPUBuffer(this, newProps);\n }\n\n _createTexture(props: TextureProps): WebGPUTexture {\n return new WebGPUTexture(this, props);\n }\n\n createExternalTexture(props: ExternalTextureProps): WebGPUExternalTexture {\n return new WebGPUExternalTexture(this, props);\n }\n\n createShader(props: ShaderProps): WebGPUShader {\n return new WebGPUShader(this, props);\n }\n\n createSampler(props: SamplerProps): WebGPUSampler {\n return new WebGPUSampler(this, props);\n }\n\n createRenderPipeline(props: RenderPipelineProps): WebGPURenderPipeline {\n return new WebGPURenderPipeline(this, props);\n }\n\n createFramebuffer(props: FramebufferProps): WebGPUFramebuffer {\n throw new Error('Not implemented');\n }\n\n createComputePipeline(props: ComputePipelineProps): WebGPUComputePipeline {\n return new WebGPUComputePipeline(this, props);\n }\n\n createVertexArray(props: VertexArrayProps): WebGPUVertexArray {\n return new WebGPUVertexArray(this, props);\n }\n\n // WebGPU specifics\n\n /**\n * Allows a render pass to begin against a canvas context\n * @todo need to support a \"Framebuffer\" equivalent (aka preconfigured RenderPassDescriptors?).\n */\n beginRenderPass(props: RenderPassProps): WebGPURenderPass {\n this.commandEncoder = this.commandEncoder || this.handle.createCommandEncoder();\n return new WebGPURenderPass(this, props);\n }\n\n beginComputePass(props: ComputePassProps): WebGPUComputePass {\n this.commandEncoder = this.commandEncoder || this.handle.createCommandEncoder();\n return new WebGPUComputePass(this, props);\n }\n\n // createCommandEncoder(props: CommandEncoderProps): WebGPUCommandEncoder {\n // return new WebGPUCommandEncoder(this, props);\n // }\n\n createTransformFeedback(props: TransformFeedbackProps): TransformFeedback {\n throw new Error('Transform feedback not supported in WebGPU');\n }\n\n createCanvasContext(props: CanvasContextProps): WebGPUCanvasContext {\n return new WebGPUCanvasContext(this, this.adapter, props);\n }\n\n /**\n * Gets default renderpass encoder.\n * Creates a new encoder against default canvasContext if not already created\n * @note Called internally by Model.\n * @deprecated Create explicit pass with device.beginRenderPass\n */\n getDefaultRenderPass(): WebGPURenderPass {\n // this.renderPass =\n // this.renderPass ||\n // this.beginRenderPass({\n // framebuffer: this.canvasContext?.getCurrentFramebuffer()\n // });\n // return this.renderPass;\n throw new Error('a');\n }\n\n submit(): void {\n // this.renderPass?.end();\n const commandBuffer = this.commandEncoder?.finish();\n if (commandBuffer) {\n this.handle.queue.submit([commandBuffer]);\n }\n this.commandEncoder = null;\n // this.renderPass = null;\n }\n\n _getFeatures() {\n // WebGPU Features\n const features = new Set<DeviceFeature>(this.handle.features as Set<DeviceFeature>);\n\n // Fixups for pre-standard names: https://github.com/webgpu-native/webgpu-headers/issues/133\n // @ts-expect-error Chrome Canary v99\n if (features.has('depth-clamping')) {\n // @ts-expect-error Chrome Canary v99\n features.delete('depth-clamping');\n features.add('depth-clip-control');\n }\n\n // Add subsets\n if (features.has('texture-compression-bc')) {\n features.add('texture-compression-bc5-webgl');\n }\n\n features.add('webgpu');\n\n features.add('timer-query-webgl');\n\n // WEBGL1 SUPPORT\n features.add('vertex-array-object-webgl1');\n features.add('instanced-rendering-webgl1');\n features.add('multiple-render-targets-webgl1');\n features.add('index-uint32-webgl1');\n features.add('blend-minmax-webgl1');\n features.add('texture-blend-float-webgl1');\n\n // TEXTURES, RENDERBUFFERS\n features.add('texture-formats-srgb-webgl1');\n\n // TEXTURES\n features.add('texture-formats-depth-webgl1');\n features.add('texture-formats-float32-webgl1');\n features.add('texture-formats-float16-webgl1');\n\n features.add('texture-filter-linear-float32-webgl');\n features.add('texture-filter-linear-float16-webgl');\n features.add('texture-filter-anisotropic-webgl');\n\n // FRAMEBUFFERS, TEXTURES AND RENDERBUFFERS\n features.add('texture-renderable-rgba32float-webgl');\n features.add('texture-renderable-float32-webgl');\n features.add('texture-renderable-float16-webgl');\n\n // GLSL extensions\n features.add('glsl-frag-data');\n features.add('glsl-frag-depth');\n features.add('glsl-derivatives');\n features.add('glsl-texture-lod');\n\n return features;\n }\n\n copyExternalImageToTexture(options: {\n texture: Texture;\n mipLevel?: number;\n aspect?: 'all' | 'stencil-only' | 'depth-only';\n colorSpace?: 'display-p3' | 'srgb';\n premultipliedAlpha?: boolean;\n\n source: ImageBitmap | HTMLVideoElement | HTMLCanvasElement | OffscreenCanvas;\n sourceX?: number;\n sourceY?: number;\n\n width?: number;\n height?: number;\n depth?: number;\n }): void {\n const {\n source,\n sourceX = 0,\n sourceY = 0,\n\n texture,\n mipLevel = 0,\n aspect = 'all',\n colorSpace = 'display-p3',\n premultipliedAlpha = false,\n // destinationX,\n // destinationY,\n // desitnationZ,\n\n width = texture.width,\n height = texture.height,\n depth = 1\n } = options;\n\n const webGpuTexture = texture as WebGPUTexture;\n\n this.handle?.queue.copyExternalImageToTexture(\n // source: GPUImageCopyExternalImage\n {\n source,\n origin: [sourceX, sourceY]\n },\n // destination: GPUImageCopyTextureTagged\n {\n texture: webGpuTexture.handle,\n origin: [0, 0, 0], // [x, y, z],\n mipLevel,\n aspect,\n colorSpace,\n premultipliedAlpha\n },\n // copySize: GPUExtent3D\n [width, height, depth]\n );\n }\n}\n"],"mappings":"AA0BA,SAAQA,MAAM,EAAEC,aAAa,EAAEC,GAAG,EAAEC,GAAG,QAAO,eAAe;AAAC,SACtDC,YAAY;AAAA,SACZC,aAAa;AAAA,SACbC,qBAAqB;AAAA,SACrBC,aAAa;AAAA,SACbC,YAAY;AAAA,SACZC,oBAAoB;AAAA,SAEpBC,qBAAqB;AAAA,SACrBC,gBAAgB;AAAA,SAChBC,iBAAiB;AAAA,SAEjBC,iBAAiB;AAAA,SAEjBC,mBAAmB;AAI3B,OAAO,MAAMC,YAAY,SAASf,MAAM,CAAC;EAevC,OAAOgB,WAAWA,CAAA,EAAY;IAC5B,OAAOC,OAAO,CAAC,OAAOC,SAAS,KAAK,WAAW,IAAIA,SAAS,CAACC,GAAG,CAAC;EACnE;EAEA,aAAaC,MAAMA,CAACC,KAAkB,EAAyB;IAC7D,IAAI,CAACH,SAAS,CAACC,GAAG,EAAE;MAClB,MAAM,IAAIG,KAAK,CACb,8FACF,CAAC;IACH;IACApB,GAAG,CAACqB,cAAc,CAAC,CAAC,EAAE,sBAAsB,CAAC,CAAC,CAAC;IAC/C,MAAMC,OAAO,GAAG,MAAMN,SAAS,CAACC,GAAG,CAACM,cAAc,CAAC;MACjDC,eAAe,EAAE;IAEnB,CAAC,CAAC;IACF,IAAI,CAACF,OAAO,EAAE;MACZ,MAAM,IAAIF,KAAK,CAAC,kCAAkC,CAAC;IACrD;IAEA,MAAMK,WAAW,GAAG,MAAMH,OAAO,CAACI,kBAAkB,CAAC,CAAC;IACtD1B,GAAG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AACpE,MAAM,cAAAoE,YAAA,uBAAXA,YAAA,CAAaP,KAAK,CAACK,0BAA0B,CAE3C;MACEG,MAAM;MACNU,MAAM,EAAE,CAACT,OAAO,EAAEC,OAAO;IAC3B,CAAC,EAED;MACEC,OAAO,EAAEM,aAAa,CAAC9E,MAAM;MAC7B+E,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;MACjBN,QAAQ;MACRC,MAAM;MACNC,UAAU;MACVC;IACF,CAAC,EAED,CAAC/C,KAAK,EAAED,MAAM,EAAEiD,KAAK,CACvB,CAAC;EACH;AACF;AAzVaxG,YAAY,CAYhB8C,IAAI,GAAW,QAAQ"}
|
package/dist/dist.dev.js
CHANGED
|
@@ -596,7 +596,7 @@ var __exports__ = (() => {
|
|
|
596
596
|
id: "@probe.gl/log"
|
|
597
597
|
});
|
|
598
598
|
|
|
599
|
-
// ../core/src/
|
|
599
|
+
// ../core/src/utils/log.ts
|
|
600
600
|
var log = new Log({
|
|
601
601
|
id: "luma.gl"
|
|
602
602
|
});
|
|
@@ -792,7 +792,7 @@ var __exports__ = (() => {
|
|
|
792
792
|
}
|
|
793
793
|
};
|
|
794
794
|
|
|
795
|
-
// ../core/src/
|
|
795
|
+
// ../core/src/utils/stats-manager.ts
|
|
796
796
|
var StatsManager = class {
|
|
797
797
|
stats = /* @__PURE__ */ new Map();
|
|
798
798
|
getStats(name2) {
|
|
@@ -811,14 +811,14 @@ var __exports__ = (() => {
|
|
|
811
811
|
|
|
812
812
|
// ../core/src/init.ts
|
|
813
813
|
function initializeLuma() {
|
|
814
|
-
const VERSION3 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "
|
|
814
|
+
const VERSION3 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "running from source";
|
|
815
815
|
const STARTUP_MESSAGE = "set luma.log.level=1 (or higher) to trace rendering";
|
|
816
816
|
if (globalThis.luma && globalThis.luma.VERSION !== VERSION3) {
|
|
817
817
|
throw new Error(`luma.gl - multiple VERSIONs detected: ${globalThis.luma.VERSION} vs ${VERSION3}`);
|
|
818
818
|
}
|
|
819
819
|
if (!globalThis.luma) {
|
|
820
820
|
if (isBrowser()) {
|
|
821
|
-
log.log(1,
|
|
821
|
+
log.log(1, `${VERSION3} - ${STARTUP_MESSAGE}`)();
|
|
822
822
|
}
|
|
823
823
|
globalThis.luma = globalThis.luma || {
|
|
824
824
|
VERSION: VERSION3,
|
|
@@ -831,7 +831,7 @@ var __exports__ = (() => {
|
|
|
831
831
|
}
|
|
832
832
|
var VERSION2 = initializeLuma();
|
|
833
833
|
|
|
834
|
-
// ../core/src/
|
|
834
|
+
// ../core/src/utils/utils.ts
|
|
835
835
|
var uidCounters = {};
|
|
836
836
|
function uid(id = "id") {
|
|
837
837
|
uidCounters[id] = uidCounters[id] || 1;
|
|
@@ -1506,7 +1506,10 @@ ${htmlLog}
|
|
|
1506
1506
|
button.style.width = "100%";
|
|
1507
1507
|
button.style.textAlign = "left";
|
|
1508
1508
|
document.body.appendChild(button);
|
|
1509
|
-
document.getElementsByClassName("luma-compiler-log-error")
|
|
1509
|
+
const errors = document.getElementsByClassName("luma-compiler-log-error");
|
|
1510
|
+
if (errors[0]?.scrollIntoView) {
|
|
1511
|
+
errors[0].scrollIntoView();
|
|
1512
|
+
}
|
|
1510
1513
|
button.onclick = () => {
|
|
1511
1514
|
const dataURI = `data:text/plain,${encodeURIComponent(this.source)}`;
|
|
1512
1515
|
navigator.clipboard.writeText(dataURI);
|
|
@@ -1990,7 +1993,7 @@ ${htmlLog}
|
|
|
1990
1993
|
renderPipeline: null
|
|
1991
1994
|
});
|
|
1992
1995
|
|
|
1993
|
-
// ../core/src/
|
|
1996
|
+
// ../core/src/utils/cast.ts
|
|
1994
1997
|
function cast(value) {
|
|
1995
1998
|
return value;
|
|
1996
1999
|
}
|
|
@@ -2642,11 +2645,11 @@ ${htmlLog}
|
|
|
2642
2645
|
constructor(device, props) {
|
|
2643
2646
|
super(device, props);
|
|
2644
2647
|
this.device = device;
|
|
2645
|
-
const
|
|
2648
|
+
const webgpuShader = this.props.cs;
|
|
2646
2649
|
this.handle = this.props.handle || this.device.handle.createComputePipeline({
|
|
2647
2650
|
label: this.props.id,
|
|
2648
2651
|
compute: {
|
|
2649
|
-
module,
|
|
2652
|
+
module: webgpuShader.handle,
|
|
2650
2653
|
entryPoint: this.props.csEntryPoint
|
|
2651
2654
|
},
|
|
2652
2655
|
layout: "auto"
|
|
@@ -2783,7 +2786,7 @@ ${htmlLog}
|
|
|
2783
2786
|
this.handle.end();
|
|
2784
2787
|
}
|
|
2785
2788
|
setPipeline(pipeline) {
|
|
2786
|
-
const wgpuPipeline =
|
|
2789
|
+
const wgpuPipeline = pipeline;
|
|
2787
2790
|
this.handle.setPipeline(wgpuPipeline.handle);
|
|
2788
2791
|
this._bindGroupLayout = wgpuPipeline._getBindGroupLayout();
|
|
2789
2792
|
}
|
|
@@ -2794,7 +2797,8 @@ ${htmlLog}
|
|
|
2794
2797
|
this.handle.dispatchWorkgroups(x, y, z);
|
|
2795
2798
|
}
|
|
2796
2799
|
dispatchIndirect(indirectBuffer, indirectOffset = 0) {
|
|
2797
|
-
|
|
2800
|
+
const webgpuBuffer = indirectBuffer;
|
|
2801
|
+
this.handle.dispatchWorkgroupsIndirect(webgpuBuffer.handle, indirectOffset);
|
|
2798
2802
|
}
|
|
2799
2803
|
pushDebugGroup(groupLabel) {
|
|
2800
2804
|
this.handle.pushDebugGroup(groupLabel);
|
|
@@ -2943,7 +2947,7 @@ ${htmlLog}
|
|
|
2943
2947
|
throw new Error("Failed to request WebGPU adapter");
|
|
2944
2948
|
}
|
|
2945
2949
|
const adapterInfo = await adapter.requestAdapterInfo();
|
|
2946
|
-
log.probe(
|
|
2950
|
+
log.probe(2, "Adapter available", adapterInfo)();
|
|
2947
2951
|
const gpuDevice = await adapter.requestDevice({
|
|
2948
2952
|
requiredFeatures: adapter.features
|
|
2949
2953
|
});
|
|
@@ -2952,29 +2956,38 @@ ${htmlLog}
|
|
|
2952
2956
|
await CanvasContext.pageLoaded;
|
|
2953
2957
|
log.probe(1, "DOM is loaded")();
|
|
2954
2958
|
}
|
|
2955
|
-
const device = new _WebGPUDevice(gpuDevice, adapter, props);
|
|
2956
|
-
log.probe(1, "Device created
|
|
2959
|
+
const device = new _WebGPUDevice(gpuDevice, adapter, adapterInfo, props);
|
|
2960
|
+
log.probe(1, "Device created. For more info, set chrome://flags/#enable-webgpu-developer-features")();
|
|
2957
2961
|
log.table(1, device.info)();
|
|
2958
2962
|
log.groupEnd(1)();
|
|
2959
2963
|
return device;
|
|
2960
2964
|
}
|
|
2961
|
-
constructor(device, adapter, props) {
|
|
2965
|
+
constructor(device, adapter, adapterInfo, props) {
|
|
2962
2966
|
super({
|
|
2963
2967
|
...props,
|
|
2964
2968
|
id: props.id || uid("webgpu-device")
|
|
2965
2969
|
});
|
|
2966
2970
|
this.handle = device;
|
|
2967
2971
|
this.adapter = adapter;
|
|
2972
|
+
const [driver, driverVersion] = (adapterInfo.driver || "").split(" Version ");
|
|
2973
|
+
const vendor = adapterInfo.vendor || this.adapter.__brand || "unknown";
|
|
2974
|
+
const renderer = driver || "";
|
|
2975
|
+
const version = driverVersion || "";
|
|
2976
|
+
const gpu = vendor === "apple" ? "apple" : "unknown";
|
|
2977
|
+
const gpuArchitecture = adapterInfo.architecture || "unknown";
|
|
2978
|
+
const gpuBackend = adapterInfo.backend || "unknown";
|
|
2979
|
+
const gpuType = (adapterInfo.type || "").split(" ")[0].toLowerCase() || "unknown";
|
|
2968
2980
|
this._info = {
|
|
2969
2981
|
type: "webgpu",
|
|
2970
|
-
vendor
|
|
2971
|
-
renderer
|
|
2972
|
-
version
|
|
2973
|
-
gpu
|
|
2982
|
+
vendor,
|
|
2983
|
+
renderer,
|
|
2984
|
+
version,
|
|
2985
|
+
gpu,
|
|
2986
|
+
gpuType,
|
|
2987
|
+
gpuBackend,
|
|
2988
|
+
gpuArchitecture,
|
|
2974
2989
|
shadingLanguage: "wgsl",
|
|
2975
|
-
shadingLanguageVersion: 100
|
|
2976
|
-
vendorMasked: "",
|
|
2977
|
-
rendererMasked: ""
|
|
2990
|
+
shadingLanguageVersion: 100
|
|
2978
2991
|
};
|
|
2979
2992
|
this.lost = new Promise(async (resolve) => {
|
|
2980
2993
|
const lostInfo = await this.handle.lost;
|