@luma.gl/webgpu 9.1.0-alpha.9 → 9.1.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapter/helpers/accessor-to-format.js +1 -0
- package/dist/adapter/helpers/accessor-to-format.js.map +1 -0
- package/dist/adapter/helpers/convert-texture-format.js +1 -0
- package/dist/adapter/helpers/convert-texture-format.js.map +1 -0
- package/dist/adapter/helpers/get-bind-group.d.ts +3 -1
- package/dist/adapter/helpers/get-bind-group.d.ts.map +1 -1
- package/dist/adapter/helpers/get-bind-group.js +18 -4
- package/dist/adapter/helpers/get-bind-group.js.map +1 -0
- package/dist/adapter/helpers/get-vertex-buffer-layout.js +4 -3
- package/dist/adapter/helpers/get-vertex-buffer-layout.js.map +1 -0
- package/dist/adapter/helpers/webgpu-parameters.js +1 -0
- package/dist/adapter/helpers/webgpu-parameters.js.map +1 -0
- package/dist/adapter/resources/webgpu-buffer.js +1 -0
- package/dist/adapter/resources/webgpu-buffer.js.map +1 -0
- package/dist/adapter/resources/webgpu-command-encoder.d.ts +4 -4
- package/dist/adapter/resources/webgpu-command-encoder.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-command-encoder.js +22 -4
- package/dist/adapter/resources/webgpu-command-encoder.js.map +1 -0
- package/dist/adapter/resources/webgpu-compute-pass.js +1 -0
- package/dist/adapter/resources/webgpu-compute-pass.js.map +1 -0
- package/dist/adapter/resources/webgpu-compute-pipeline.js +1 -0
- package/dist/adapter/resources/webgpu-compute-pipeline.js.map +1 -0
- package/dist/adapter/resources/webgpu-external-texture.js +1 -0
- package/dist/adapter/resources/webgpu-external-texture.js.map +1 -0
- package/dist/adapter/resources/webgpu-framebuffer.d.ts +1 -0
- package/dist/adapter/resources/webgpu-framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-framebuffer.js +4 -0
- package/dist/adapter/resources/webgpu-framebuffer.js.map +1 -0
- package/dist/adapter/resources/webgpu-query-set.js +1 -0
- package/dist/adapter/resources/webgpu-query-set.js.map +1 -0
- package/dist/adapter/resources/webgpu-render-pass.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-render-pass.js +19 -6
- package/dist/adapter/resources/webgpu-render-pass.js.map +1 -0
- package/dist/adapter/resources/webgpu-render-pipeline.d.ts +1 -0
- package/dist/adapter/resources/webgpu-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-render-pipeline.js +42 -6
- package/dist/adapter/resources/webgpu-render-pipeline.js.map +1 -0
- package/dist/adapter/resources/webgpu-sampler.d.ts +1 -1
- package/dist/adapter/resources/webgpu-sampler.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-sampler.js +15 -6
- package/dist/adapter/resources/webgpu-sampler.js.map +1 -0
- package/dist/adapter/resources/webgpu-shader.d.ts +2 -2
- package/dist/adapter/resources/webgpu-shader.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-shader.js +23 -19
- package/dist/adapter/resources/webgpu-shader.js.map +1 -0
- package/dist/adapter/resources/webgpu-texture-view.js +1 -0
- package/dist/adapter/resources/webgpu-texture-view.js.map +1 -0
- package/dist/adapter/resources/webgpu-texture.d.ts +2 -5
- package/dist/adapter/resources/webgpu-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-texture.js +17 -38
- package/dist/adapter/resources/webgpu-texture.js.map +1 -0
- package/dist/adapter/resources/webgpu-vertex-array.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-vertex-array.js +3 -2
- package/dist/adapter/resources/webgpu-vertex-array.js.map +1 -0
- package/dist/adapter/webgpu-adapter.d.ts.map +1 -1
- package/dist/adapter/webgpu-adapter.js +3 -6
- package/dist/adapter/webgpu-adapter.js.map +1 -0
- package/dist/adapter/webgpu-canvas-context.d.ts +8 -9
- package/dist/adapter/webgpu-canvas-context.d.ts.map +1 -1
- package/dist/adapter/webgpu-canvas-context.js +56 -60
- package/dist/adapter/webgpu-canvas-context.js.map +1 -0
- package/dist/adapter/webgpu-device.d.ts +10 -12
- package/dist/adapter/webgpu-device.d.ts.map +1 -1
- package/dist/adapter/webgpu-device.js +41 -36
- package/dist/adapter/webgpu-device.js.map +1 -0
- package/dist/dist.dev.js +242 -179
- package/dist/dist.min.js +5 -1
- package/dist/index.cjs +222 -166
- package/dist/index.cjs.map +4 -4
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -0
- package/package.json +3 -3
- package/src/adapter/helpers/get-bind-group.ts +23 -4
- package/src/adapter/helpers/get-vertex-buffer-layout.ts +3 -3
- package/src/adapter/resources/webgpu-command-encoder.ts +26 -8
- package/src/adapter/resources/webgpu-framebuffer.ts +4 -0
- package/src/adapter/resources/webgpu-render-pass.ts +29 -14
- package/src/adapter/resources/webgpu-render-pipeline.ts +45 -6
- package/src/adapter/resources/webgpu-sampler.ts +16 -6
- package/src/adapter/resources/webgpu-shader.ts +23 -23
- package/src/adapter/resources/webgpu-texture.ts +31 -59
- package/src/adapter/resources/webgpu-vertex-array.ts +7 -2
- package/src/adapter/webgpu-adapter.ts +2 -7
- package/src/adapter/webgpu-canvas-context.ts +67 -69
- package/src/adapter/webgpu-device.ts +51 -44
|
@@ -8,10 +8,10 @@ export declare class WebGPUShader extends Shader {
|
|
|
8
8
|
readonly device: WebGPUDevice;
|
|
9
9
|
readonly handle: GPUShaderModule;
|
|
10
10
|
constructor(device: WebGPUDevice, props: ShaderProps);
|
|
11
|
-
|
|
11
|
+
get asyncCompilationStatus(): Promise<any>;
|
|
12
|
+
_checkCompilationError(): Promise<void>;
|
|
12
13
|
destroy(): void;
|
|
13
14
|
/** Returns compilation info for this shader */
|
|
14
15
|
getCompilationInfo(): Promise<readonly CompilerMessage[]>;
|
|
15
|
-
protected createHandle(): GPUShaderModule;
|
|
16
16
|
}
|
|
17
17
|
//# sourceMappingURL=webgpu-shader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgpu-shader.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-shader.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,WAAW,EAAE,eAAe,EAAC,MAAM,eAAe,CAAC;AAChE,OAAO,EAAC,MAAM,EAAM,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,EAAC,YAAY,EAAC,4BAAyB;AAEnD;;GAEG;AACH,qBAAa,YAAa,SAAQ,MAAM;IACtC,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAC;gBAErB,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,WAAW;
|
|
1
|
+
{"version":3,"file":"webgpu-shader.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-shader.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,WAAW,EAAE,eAAe,EAAC,MAAM,eAAe,CAAC;AAChE,OAAO,EAAC,MAAM,EAAM,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,EAAC,YAAY,EAAC,4BAAyB;AAEnD;;GAEG;AACH,qBAAa,YAAa,SAAQ,MAAM;IACtC,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAC;gBAErB,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,WAAW;IAqBpD,IAAI,sBAAsB,IAAI,OAAO,CAAC,GAAG,CAAC,CAEzC;IAEK,sBAAsB,IAAI,OAAO,CAAC,IAAI,CAAC;IAcpC,OAAO,IAAI,IAAI;IAOxB,+CAA+C;IACzC,kBAAkB,IAAI,OAAO,CAAC,SAAS,eAAe,EAAE,CAAC;CAIhE"}
|
|
@@ -11,21 +11,33 @@ export class WebGPUShader extends Shader {
|
|
|
11
11
|
constructor(device, props) {
|
|
12
12
|
super(device, props);
|
|
13
13
|
this.device = device;
|
|
14
|
+
const isGLSL = props.source.includes('#version');
|
|
15
|
+
if (this.props.language === 'glsl' || isGLSL) {
|
|
16
|
+
throw new Error('GLSL shaders are not supported in WebGPU');
|
|
17
|
+
}
|
|
14
18
|
this.device.handle.pushErrorScope('validation');
|
|
15
|
-
this.handle = this.props.handle || this.
|
|
19
|
+
this.handle = this.props.handle || this.device.handle.createShaderModule({ code: props.source });
|
|
20
|
+
this.device.handle.popErrorScope().then((error) => {
|
|
21
|
+
if (error) {
|
|
22
|
+
log.error(`${this} creation failed:\n"${error.message}"`, this, this.props.source)();
|
|
23
|
+
}
|
|
24
|
+
});
|
|
16
25
|
this.handle.label = this.props.id;
|
|
17
|
-
this._checkCompilationError(
|
|
26
|
+
this._checkCompilationError();
|
|
27
|
+
}
|
|
28
|
+
get asyncCompilationStatus() {
|
|
29
|
+
return this.getCompilationInfo().then(() => this.compilationStatus);
|
|
18
30
|
}
|
|
19
|
-
async _checkCompilationError(
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
log.error(`Shader compilation error
|
|
31
|
+
async _checkCompilationError() {
|
|
32
|
+
const shaderLog = await this.getCompilationInfo();
|
|
33
|
+
const hasErrors = Boolean(shaderLog.find(msg => msg.type === 'error'));
|
|
34
|
+
this.compilationStatus = hasErrors ? 'error' : 'success';
|
|
35
|
+
this.debugShader();
|
|
36
|
+
if (this.compilationStatus === 'error') {
|
|
37
|
+
log.error(`Shader compilation error`, shaderLog)();
|
|
26
38
|
// Note: Even though this error is asynchronous and thrown after the constructor completes,
|
|
27
39
|
// it will result in a useful stack trace leading back to the constructor
|
|
28
|
-
throw new Error(`Shader compilation error
|
|
40
|
+
// throw new Error(`Shader compilation error`);
|
|
29
41
|
}
|
|
30
42
|
}
|
|
31
43
|
destroy() {
|
|
@@ -39,13 +51,5 @@ export class WebGPUShader extends Shader {
|
|
|
39
51
|
const compilationInfo = await this.handle.getCompilationInfo();
|
|
40
52
|
return compilationInfo.messages;
|
|
41
53
|
}
|
|
42
|
-
// PRIVATE METHODS
|
|
43
|
-
createHandle() {
|
|
44
|
-
const { source } = this.props;
|
|
45
|
-
const isGLSL = source.includes('#version');
|
|
46
|
-
if (this.props.language === 'glsl' || isGLSL) {
|
|
47
|
-
throw new Error('GLSL shaders are not supported in WebGPU');
|
|
48
|
-
}
|
|
49
|
-
return this.device.handle.createShaderModule({ code: source });
|
|
50
|
-
}
|
|
51
54
|
}
|
|
55
|
+
//# sourceMappingURL=webgpu-shader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webgpu-shader.js","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-shader.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAGpC,OAAO,EAAC,MAAM,EAAE,GAAG,EAAC,MAAM,eAAe,CAAC;AAG1C;;GAEG;AACH,MAAM,OAAO,YAAa,SAAQ,MAAM;IAC7B,MAAM,CAAe;IACrB,MAAM,CAAkB;IAEjC,YAAY,MAAoB,EAAE,KAAkB;QAClD,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAErB,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;QACjD,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,KAAK,MAAM,IAAI,MAAM,EAAE,CAAC;YAC7C,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;QAC9D,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC;QAChD,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,kBAAkB,CAAC,EAAC,IAAI,EAAE,KAAK,CAAC,MAAM,EAAC,CAAC,CAAC;QAC/F,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC,IAAI,CAAC,CAAC,KAAsB,EAAE,EAAE;YACjE,IAAI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I,CAAC,MAAM,GAAG,IAAI,CAAC;IACrB,CAAC;CACF"}
|
|
@@ -6,8 +6,6 @@ import { WebGPUTextureView } from "./webgpu-texture-view.js";
|
|
|
6
6
|
export declare class WebGPUTexture extends Texture {
|
|
7
7
|
readonly device: WebGPUDevice;
|
|
8
8
|
readonly handle: GPUTexture;
|
|
9
|
-
height: number;
|
|
10
|
-
width: number;
|
|
11
9
|
sampler: WebGPUSampler;
|
|
12
10
|
view: WebGPUTextureView;
|
|
13
11
|
constructor(device: WebGPUDevice, props: TextureProps);
|
|
@@ -34,9 +32,8 @@ export declare class WebGPUTexture extends Texture {
|
|
|
34
32
|
width: number;
|
|
35
33
|
height: number;
|
|
36
34
|
};
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
source: ExternalImage;
|
|
35
|
+
copyExternalImage(options: {
|
|
36
|
+
image: ExternalImage;
|
|
40
37
|
width?: number;
|
|
41
38
|
height?: number;
|
|
42
39
|
depth?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgpu-texture.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-texture.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,YAAY,EACZ,gBAAgB,EAChB,OAAO,EACP,YAAY,EAKZ,aAAa,EACb,aAAa,EACb,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,oBAAoB,EACpB,aAAa,EACd,MAAM,eAAe,CAAC;AACvB,OAAO,EAAC,OAAO,EAAC,MAAM,eAAe,CAAC;AAGtC,OAAO,KAAK,EAAC,YAAY,EAAC,4BAAyB;AACnD,OAAO,EAAC,aAAa,EAAC,4BAAyB;AAC/C,OAAO,EAAC,iBAAiB,EAAC,iCAA8B;AAWxD,qBAAa,aAAc,SAAQ,OAAO;IACxC,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"webgpu-texture.d.ts","sourceR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AI,EAAE,eAAe,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI;IAI/D,mBAAmB,CAAC,IAAI,EAAE,gBAAgB,GAAG,IAAI;IAIjD,uBAAuB,CAAC,IAAI,EAAE,oBAAoB,GAAG,IAAI;IAIzD,OAAO,CAAC,OAAO,EAAE;QAAC,IAAI,EAAE,GAAG,CAAA;KAAC,GAAG;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAC;IAW9D,iBAAiB,CAAC,OAAO,EAAE;QACzB,KAAK,EAAE,aAAa,CAAC;QACrB,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;CAgHpC"}
|
|
@@ -13,28 +13,17 @@ const BASE_DIMENSIONS = {
|
|
|
13
13
|
export class WebGPUTexture extends Texture {
|
|
14
14
|
device;
|
|
15
15
|
handle;
|
|
16
|
-
height = 1;
|
|
17
|
-
width = 1;
|
|
18
16
|
sampler;
|
|
19
17
|
view;
|
|
20
|
-
// static async createFromImageURL(src, usage = 0) {
|
|
21
|
-
// const img = document.createElement('img');
|
|
22
|
-
// img.src = src;
|
|
23
|
-
// await img.decode();
|
|
24
|
-
// return WebGPUTexture(img, usage);
|
|
25
|
-
// }
|
|
26
18
|
constructor(device, props) {
|
|
27
19
|
super(device, props);
|
|
28
20
|
this.device = device;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
this.initialize(this.props);
|
|
34
|
-
});
|
|
35
|
-
return;
|
|
21
|
+
// Texture base class strips out the data prop, so we need to add it back in
|
|
22
|
+
const propsWithData = { ...this.props };
|
|
23
|
+
if (props.data) {
|
|
24
|
+
propsWithData.data = props.data;
|
|
36
25
|
}
|
|
37
|
-
this.initialize(
|
|
26
|
+
this.initialize(propsWithData);
|
|
38
27
|
}
|
|
39
28
|
destroy() {
|
|
40
29
|
this.handle?.destroy();
|
|
@@ -50,7 +39,7 @@ export class WebGPUTexture extends Texture {
|
|
|
50
39
|
this.handle.label ||= this.id;
|
|
51
40
|
if (this.props.data) {
|
|
52
41
|
if (Texture.isExternalImage(this.props.data)) {
|
|
53
|
-
this.
|
|
42
|
+
this.copyExternalImage({ image: this.props.data });
|
|
54
43
|
}
|
|
55
44
|
else {
|
|
56
45
|
this.setData({ data: this.props.data });
|
|
@@ -135,36 +124,25 @@ export class WebGPUTexture extends Texture {
|
|
|
135
124
|
throw new Error('not implemented');
|
|
136
125
|
}
|
|
137
126
|
setData(options) {
|
|
138
|
-
let source = options.data;
|
|
139
127
|
if (ArrayBuffer.isView(options.data)) {
|
|
140
128
|
const clampedArray = new Uint8ClampedArray(options.data.buffer);
|
|
141
129
|
// TODO - pass through src data color space as ImageData Options?
|
|
142
|
-
|
|
130
|
+
const image = new ImageData(clampedArray, this.width, this.height);
|
|
131
|
+
return this.copyExternalImage({ image });
|
|
143
132
|
}
|
|
144
|
-
|
|
133
|
+
throw new Error('Texture.setData: Use CommandEncoder to upload data to texture in WebGPU');
|
|
145
134
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
// mappedAtCreation: true
|
|
151
|
-
// });
|
|
152
|
-
// new Uint8Array(textureDataBuffer.getMappedRange()).set(data);
|
|
153
|
-
// textureDataBuffer.unmap();
|
|
154
|
-
// this.setBuffer(textureDataBuffer);
|
|
155
|
-
// textureDataBuffer.destroy();
|
|
156
|
-
// return this;
|
|
157
|
-
// }
|
|
158
|
-
/** Set image */
|
|
159
|
-
setImage(options) {
|
|
160
|
-
const size = Texture.getExternalImageSize(options.source);
|
|
161
|
-
const { source, width = size.width, height = size.height, depth = 1, sourceX = 0, sourceY = 0, mipLevel = 0, x = 0, y = 0, z = 0, aspect = 'all', colorSpace = 'srgb', premultipliedAlpha = false } = options;
|
|
135
|
+
copyExternalImage(options) {
|
|
136
|
+
const size = Texture.getExternalImageSize(options.image);
|
|
137
|
+
const opts = { ...Texture.defaultCopyExternalImageOptions, ...size, ...options };
|
|
138
|
+
const { image, sourceX, sourceY, width, height, depth, mipLevel, x, y, z, aspect, colorSpace, premultipliedAlpha, flipY } = opts;
|
|
162
139
|
// TODO - max out width
|
|
163
140
|
this.device.handle.queue.copyExternalImageToTexture(
|
|
164
141
|
// source: GPUImageCopyExternalImage
|
|
165
142
|
{
|
|
166
|
-
source,
|
|
167
|
-
origin: [sourceX, sourceY]
|
|
143
|
+
source: image,
|
|
144
|
+
origin: [sourceX, sourceY],
|
|
145
|
+
flipY
|
|
168
146
|
},
|
|
169
147
|
// destination: GPUImageCopyTextureTagged
|
|
170
148
|
{
|
|
@@ -180,3 +158,4 @@ export class WebGPUTexture extends Texture {
|
|
|
180
158
|
return { width, height };
|
|
181
159
|
}
|
|
182
160
|
}
|
|
161
|
+
//# sourceMappingURL=webgpu-texture.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webgpu-texture.js","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-texture.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,OAAO,EAAC,MAAM,eAAe,CAAC;AAEtC,OAAO,EAAC,sBAAsB,EAAC,6CAA0C;AAEzE,OAAO,EAAC,aAAa,EAAC,4BAAyB;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kB,EAClB,KAAK,EACN,GAAG,IAAI,CAAC;QAET,uBAAuB;QAEvB,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,0BAA0B;QACjD,oCAAoC;QACpC;YACE,MAAM,EAAE,KAAK;YACb,MAAM,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC;YAC1B,KAAK;SACN;QACD,yCAAyC;QACzC;YACE,OAAO,EAAE,IAAI,CAAC,MAAM;YACpB,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;YACjB,QAAQ;YACR,MAAM;YACN,UAAU;YACV,kBAAkB;SACnB;QACD,wBAAwB;QACxB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,CACvB,CAAC;QACF,OAAO,EAAC,KAAK,EAAE,MAAM,EAAC,CAAC;IACzB,CAAC;CAsEF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgpu-vertex-array.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-vertex-array.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,UAAU,EAAC,MAAM,eAAe,CAAC;AAChF,OAAO,EAAC,WAAW,EAAM,MAAM,eAAe,CAAC;AAG/C,OAAO,EAAC,YAAY,EAAC,4BAAyB;AAK9C,gCAAgC;AAChC,qBAAa,iBAAkB,SAAQ,WAAW;IAChD,IAAa,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,MAAM,CAE1C;IAED,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,kDAAkD;IAClD,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC;gBAGX,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,gBAAgB;IAKhD,OAAO,IAAI,IAAI;IAExB;;;OAGG;IACH,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAK3C,oGAAoG;IACpG,SAAS,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IAS1C,gBAAgB,CACvB,UAAU,EAAE,UAAU,EACtB,UAAU,CAAC,EAAE,MAAM,EACnB,UAAU,CAAC,EAAE,MAAM,GAClB,IAAI;
|
|
1
|
+
{"version":3,"file":"webgpu-vertex-array.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-vertex-array.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,UAAU,EAAC,MAAM,eAAe,CAAC;AAChF,OAAO,EAAC,WAAW,EAAM,MAAM,eAAe,CAAC;AAG/C,OAAO,EAAC,YAAY,EAAC,4BAAyB;AAK9C,gCAAgC;AAChC,qBAAa,iBAAkB,SAAQ,WAAW;IAChD,IAAa,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,MAAM,CAE1C;IAED,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,kDAAkD;IAClD,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC;gBAGX,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,gBAAgB;IAKhD,OAAO,IAAI,IAAI;IAExB;;;OAGG;IACH,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAK3C,oGAAoG;IACpG,SAAS,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IAS1C,gBAAgB,CACvB,UAAU,EAAE,UAAU,EACtB,UAAU,CAAC,EAAE,MAAM,EACnB,UAAU,CAAC,EAAE,MAAM,GAClB,IAAI;IA2BE,iBAAiB,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI;IAQxD;;;OAGG;IACH,MAAM,CAAC,gCAAgC,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;CAGjE"}
|
|
@@ -38,7 +38,7 @@ export class WebGPUVertexArray extends VertexArray {
|
|
|
38
38
|
const webgpuIndexBuffer = this.indexBuffer;
|
|
39
39
|
if (webgpuIndexBuffer?.handle) {
|
|
40
40
|
// Note we can't unset an index buffer
|
|
41
|
-
log.
|
|
41
|
+
log.info(3, 'setting index buffer', webgpuIndexBuffer?.handle, webgpuIndexBuffer?.indexType)();
|
|
42
42
|
webgpuRenderPass.handle.setIndexBuffer(webgpuIndexBuffer?.handle,
|
|
43
43
|
// @ts-expect-error TODO - we must enforce type
|
|
44
44
|
webgpuIndexBuffer?.indexType);
|
|
@@ -46,7 +46,7 @@ export class WebGPUVertexArray extends VertexArray {
|
|
|
46
46
|
for (let location = 0; location < this.maxVertexAttributes; location++) {
|
|
47
47
|
const webgpuBuffer = this.attributes[location];
|
|
48
48
|
if (webgpuBuffer?.handle) {
|
|
49
|
-
log.
|
|
49
|
+
log.info(3, `setting vertex buffer ${location}`, webgpuBuffer?.handle)();
|
|
50
50
|
webgpuRenderPass.handle.setVertexBuffer(location, webgpuBuffer?.handle);
|
|
51
51
|
}
|
|
52
52
|
}
|
|
@@ -66,3 +66,4 @@ export class WebGPUVertexArray extends VertexArray {
|
|
|
66
66
|
return getBrowser() === 'Chrome';
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
|
+
//# sourceMappingURL=webgpu-vertex-array.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webgpu-vertex-array.js","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-vertex-array.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAGpC,OAAO,EAAC,WAAW,EAAE,GAAG,EAAC,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;AAOzC,gCAAgC;AAChC,MAAM,OAAO,iBAAkB,SAAQ,WAAW;IAChD,IAAa,CAAC,MAAM,CAAC,WAAW,CAAC;QAC/B,OAAO,mBAAmB,CAAC;IAC7B,CAAC;IAEQ,MAAM,CAAe;IAC9B,kDAAkD;IACzC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E,YAAY,EAAE,MAAM,CAAC,EAAE,CAAC;gBACzE,gBAAgB,CAAC,MAAM,CAAC,eAAe,CAAC,QAAQ,EAAE,YAAY,EAAE,MAAM,CAAC,CAAC;YAC1E,CAAC;QACH,CAAC;QACD,oFAAoF;IACtF,CAAC;IAEQ,iBAAiB,CAAC,UAAsB;QAC/C,qCAAqC;QACrC,mFAAmF;QACnF,4EAA4E;IAC9E,CAAC;IAED,qBAAqB;IAErB;;;OAGG;IACH,MAAM,CAAC,gCAAgC,CAAC,MAAc;QACpD,OAAO,UAAU,EAAE,KAAK,QAAQ,CAAC;IACnC,CAAC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgpu-adapter.d.ts","sourceRoot":"","sources":["../../src/adapter/webgpu-adapter.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,OAAO,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"webgpu-adapter.d.ts","sourceRoot":"","sources":["../../src/adapter/webgpu-adapter.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,OAAO,EAAE,WAAW,EAAM,MAAM,eAAe,CAAC;AACxD,OAAO,EAAC,YAAY,EAAC,2BAAwB;AAI7C,qBAAa,aAAc,SAAQ,OAAO;IACxC,+CAA+C;IAC/C,QAAQ,CAAC,IAAI,YAAkC;;IAQ/C,mCAAmC;IACnC,WAAW,IAAI,OAAO;IAIhB,MAAM,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC;IA0DjD,MAAM,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,YAAY,CAAC;CAGvD;AAED,eAAO,MAAM,aAAa,eAAsB,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// luma.gl
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
|
-
import { Adapter,
|
|
4
|
+
import { Adapter, log } from '@luma.gl/core';
|
|
5
5
|
import { WebGPUDevice } from "./webgpu-device.js";
|
|
6
6
|
// / <reference types="@webgpu/types" />
|
|
7
7
|
export class WebGPUAdapter extends Adapter {
|
|
@@ -32,7 +32,7 @@ export class WebGPUAdapter extends Adapter {
|
|
|
32
32
|
log.probe(2, 'Adapter available', adapterInfo)();
|
|
33
33
|
const requiredFeatures = [];
|
|
34
34
|
const requiredLimits = {};
|
|
35
|
-
if (props.
|
|
35
|
+
if (props._requestMaxLimits) {
|
|
36
36
|
// Require all features
|
|
37
37
|
requiredFeatures.push(...Array.from(adapter.features));
|
|
38
38
|
// Require all limits
|
|
@@ -51,10 +51,6 @@ export class WebGPUAdapter extends Adapter {
|
|
|
51
51
|
requiredLimits
|
|
52
52
|
});
|
|
53
53
|
log.probe(1, 'GPUDevice available')();
|
|
54
|
-
if (typeof props.canvas === 'string') {
|
|
55
|
-
await CanvasContext.pageLoaded;
|
|
56
|
-
log.probe(1, 'DOM is loaded')();
|
|
57
|
-
}
|
|
58
54
|
const device = new WebGPUDevice(props, gpuDevice, adapter, adapterInfo);
|
|
59
55
|
log.probe(1, 'Device created. For more info, set chrome://flags/#enable-webgpu-developer-features')();
|
|
60
56
|
log.table(1, device.info)();
|
|
@@ -66,3 +62,4 @@ export class WebGPUAdapter extends Adapter {
|
|
|
66
62
|
}
|
|
67
63
|
}
|
|
68
64
|
export const webgpuAdapter = new WebGPUAdapter();
|
|
65
|
+
//# sourceMappingURL=webgpu-adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webgpu-adapter.js","sourceRoot":"","sources":["../../src/adapter/webgpu-adapter.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAEpC,OAAO,EAAC,OAAO,EAAe,GAAG,EAAC,MAAM,eAAe,CAAC;AACxD,OAAO,EAAC,YAAY,EAAC,2BAAwB;AAE7C,wCAAwC;AAExC,MAAM,OAAO,aAAc,SAAQ,OAAO;IACxC,+CAA+C;IACtC,IAAI,GAA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AAiB,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAC7D,CAAC;YACF,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;gBACzB,MAAM,KAAK,GAAG,GAA+B,CAAC;gBAC9C,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBACpC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;oBAC9B,cAAc,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC;gBAChC,CAAC;YACH,CAAC;QACH,CAAC;QAED,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,aAAa,CAAC;YAC5C,gBAAgB;YAChB,cAAc;SACf,CAAC,CAAC;QAEH,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,qBAAqB,CAAC,EAAE,CAAC;QAEtC,MAAM,MAAM,GAAG,IAAI,YAAY,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC;QAExE,GAAG,CAAC,KAAK,CACP,CAAC,EACD,qFAAqF,CACtF,EAAE,CAAC;QACJ,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;QAC5B,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;QAClB,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,MAAiB;QAC5B,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;IAC5D,CAAC;CACF;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,aAAa,EAAE,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { DepthStencilTextureFormat, CanvasContextProps } from '@luma.gl/core';
|
|
2
2
|
import { CanvasContext } from '@luma.gl/core';
|
|
3
3
|
import { WebGPUDevice } from "./webgpu-device.js";
|
|
4
4
|
import { WebGPUFramebuffer } from "./resources/webgpu-framebuffer.js";
|
|
@@ -10,19 +10,18 @@ import { WebGPUTexture } from "./resources/webgpu-texture.js";
|
|
|
10
10
|
*/
|
|
11
11
|
export declare class WebGPUCanvasContext extends CanvasContext {
|
|
12
12
|
readonly device: WebGPUDevice;
|
|
13
|
-
readonly
|
|
14
|
-
/** Format of returned textures: "bgra8unorm", "rgba8unorm", "rgba16float". */
|
|
15
|
-
readonly format: TextureFormat;
|
|
16
|
-
/** Default stencil format for depth textures */
|
|
17
|
-
readonly depthStencilFormat: TextureFormat;
|
|
13
|
+
readonly handle: GPUCanvasContext;
|
|
18
14
|
private depthStencilAttachment;
|
|
15
|
+
get [Symbol.toStringTag](): string;
|
|
19
16
|
constructor(device: WebGPUDevice, adapter: GPUAdapter, props: CanvasContextProps);
|
|
20
17
|
/** Destroy any textures produced while configured and remove the context configuration. */
|
|
21
18
|
destroy(): void;
|
|
22
19
|
/** Update framebuffer with properly resized "swap chain" texture views */
|
|
23
|
-
getCurrentFramebuffer(
|
|
20
|
+
getCurrentFramebuffer(options?: {
|
|
21
|
+
depthStencilFormat?: DepthStencilTextureFormat | false;
|
|
22
|
+
}): WebGPUFramebuffer;
|
|
24
23
|
/** Resizes and updates render targets if necessary */
|
|
25
|
-
|
|
24
|
+
updateSize(size: [newWidth: number, newHeight: number]): void;
|
|
26
25
|
resize(options?: {
|
|
27
26
|
width?: number;
|
|
28
27
|
height?: number;
|
|
@@ -31,6 +30,6 @@ export declare class WebGPUCanvasContext extends CanvasContext {
|
|
|
31
30
|
/** Wrap the current canvas context texture in a luma.gl texture */
|
|
32
31
|
getCurrentTexture(): WebGPUTexture;
|
|
33
32
|
/** We build render targets on demand (i.e. not when size changes but when about to render) */
|
|
34
|
-
_createDepthStencilAttachment():
|
|
33
|
+
_createDepthStencilAttachment(depthStencilFormat: DepthStencilTextureFormat): WebGPUTexture;
|
|
35
34
|
}
|
|
36
35
|
//# 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":"AAMA,OAAO,KAAK,EAAC,
|
|
1
|
+
{"version":3,"file":"webgpu-canvas-context.d.ts","sourceRoot":"","sources":["../../src/adapter/webgpu-canvas-context.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAC,yBAAyB,EAAE,kBAAkB,EAAC,MAAM,eAAe,CAAC;AACjF,OAAO,EAAC,aAAa,EAAe,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAC,YAAY,EAAC,2BAAwB;AAC7C,OAAO,EAAC,iBAAiB,EAAC,0CAAuC;AACjE,OAAO,EAAC,aAAa,EAAC,sCAAmC;AAEzD;;;;GAIG;AACH,qBAAa,mBAAoB,SAAQ,aAAa;IACpD,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC;IAElC,OAAO,CAAC,sBAAsB,CAA8B;IAE5D,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,MAAM,CAEjC;gBAEW,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,kBAAkB;IAShF,2FAA2F;IAC3F,OAAO,IAAI,IAAI;IAIf,0EAA0E;IAC1E,qBAAqB,CACnB,OAAO,GAAE;QAAC,kBAAkB,CAAC,EAAE,yBAAyB,GAAG,KAAK,CAAA;KAE/D,GACA,iBAAiB;IA4BpB,sDAAsD;IACtD,UAAU,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,GAAG,IAAI;IAkB7D,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;IAe7F,mEAAmE;IACnE,iBAAiB,IAAI,aAAa;IAQlC,8FAA8F;IAC9F,6BAA6B,CAAC,kBAAkB,EAAE,yBAAyB,GAAG,aAAa;CAY5F"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
// luma.gl
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
|
-
import { CanvasContext, log } from '@luma.gl/core';
|
|
5
|
-
import { getWebGPUTextureFormat } from "./helpers/convert-texture-format.js";
|
|
4
|
+
import { CanvasContext, Texture, log } from '@luma.gl/core';
|
|
6
5
|
import { WebGPUFramebuffer } from "./resources/webgpu-framebuffer.js";
|
|
7
6
|
/**
|
|
8
7
|
* Holds a WebGPU Canvas Context
|
|
@@ -11,98 +10,95 @@ import { WebGPUFramebuffer } from "./resources/webgpu-framebuffer.js";
|
|
|
11
10
|
*/
|
|
12
11
|
export class WebGPUCanvasContext extends CanvasContext {
|
|
13
12
|
device;
|
|
14
|
-
|
|
15
|
-
/** Format of returned textures: "bgra8unorm", "rgba8unorm", "rgba16float". */
|
|
16
|
-
format = navigator.gpu.getPreferredCanvasFormat();
|
|
17
|
-
/** Default stencil format for depth textures */
|
|
18
|
-
depthStencilFormat = 'depth24plus';
|
|
13
|
+
handle;
|
|
19
14
|
depthStencilAttachment = null;
|
|
15
|
+
get [Symbol.toStringTag]() {
|
|
16
|
+
return 'WebGPUCanvasContext';
|
|
17
|
+
}
|
|
20
18
|
constructor(device, adapter, props) {
|
|
21
19
|
super(props);
|
|
22
20
|
this.device = device;
|
|
23
|
-
//
|
|
24
|
-
this.width = -1;
|
|
25
|
-
this.height = -1;
|
|
21
|
+
// Base class constructor cannot access derived methods/fields, so we need to call these functions in the subclass constructor
|
|
26
22
|
this._setAutoCreatedCanvasId(`${this.device.id}-canvas`);
|
|
27
|
-
|
|
28
|
-
this.gpuCanvasContext = this.canvas.getContext('webgpu');
|
|
29
|
-
// TODO this has been replaced
|
|
30
|
-
// this.format = this.gpuCanvasContext.getPreferredFormat(adapter);
|
|
31
|
-
this.format = 'bgra8unorm';
|
|
23
|
+
this.updateSize([this.drawingBufferWidth, this.drawingBufferHeight]);
|
|
32
24
|
}
|
|
33
25
|
/** Destroy any textures produced while configured and remove the context configuration. */
|
|
34
26
|
destroy() {
|
|
35
|
-
this.
|
|
27
|
+
this.handle.unconfigure();
|
|
36
28
|
}
|
|
37
29
|
/** Update framebuffer with properly resized "swap chain" texture views */
|
|
38
|
-
getCurrentFramebuffer(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
// Wrap the current canvas context texture in a luma.gl texture
|
|
42
|
-
// const currentColorAttachment = this.device.createTexture({
|
|
43
|
-
// id: 'default-render-target',
|
|
44
|
-
// handle: this.gpuCanvasContext.getCurrentTexture(),
|
|
45
|
-
// format: this.format,
|
|
46
|
-
// width: this.width,
|
|
47
|
-
// height: this.height
|
|
48
|
-
// });
|
|
30
|
+
getCurrentFramebuffer(options = {
|
|
31
|
+
depthStencilFormat: 'depth24plus'
|
|
32
|
+
}) {
|
|
49
33
|
// Wrap the current canvas context texture in a luma.gl texture
|
|
50
34
|
const currentColorAttachment = this.getCurrentTexture();
|
|
51
|
-
|
|
52
|
-
|
|
35
|
+
// TODO - temporary debug code
|
|
36
|
+
if (currentColorAttachment.width !== this.drawingBufferWidth ||
|
|
37
|
+
currentColorAttachment.height !== this.drawingBufferHeight) {
|
|
38
|
+
const [oldWidth, oldHeight] = this.getDrawingBufferSize();
|
|
39
|
+
this.drawingBufferWidth = currentColorAttachment.width;
|
|
40
|
+
this.drawingBufferHeight = currentColorAttachment.height;
|
|
41
|
+
log.log(1, `${this}: Resized to compensate for initial canvas size mismatch ${oldWidth}x${oldHeight} => ${this.drawingBufferWidth}x${this.drawingBufferHeight}px`)();
|
|
42
|
+
}
|
|
53
43
|
// Resize the depth stencil attachment
|
|
54
|
-
|
|
44
|
+
if (options?.depthStencilFormat) {
|
|
45
|
+
this._createDepthStencilAttachment(options?.depthStencilFormat);
|
|
46
|
+
}
|
|
55
47
|
return new WebGPUFramebuffer(this.device, {
|
|
56
48
|
colorAttachments: [currentColorAttachment],
|
|
57
49
|
depthStencilAttachment: this.depthStencilAttachment
|
|
58
50
|
});
|
|
59
51
|
}
|
|
60
52
|
/** Resizes and updates render targets if necessary */
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
this.width = width;
|
|
66
|
-
this.height = height;
|
|
67
|
-
if (this.depthStencilAttachment) {
|
|
68
|
-
this.depthStencilAttachment.destroy();
|
|
69
|
-
this.depthStencilAttachment = null;
|
|
70
|
-
}
|
|
71
|
-
// Reconfigure the canvas size.
|
|
72
|
-
// https://www.w3.org/TR/webgpu/#canvas-configuration
|
|
73
|
-
this.gpuCanvasContext.configure({
|
|
74
|
-
device: this.device.handle,
|
|
75
|
-
format: getWebGPUTextureFormat(this.format),
|
|
76
|
-
// Can be used to define e.g. -srgb views
|
|
77
|
-
// viewFormats: [...]
|
|
78
|
-
colorSpace: this.props.colorSpace,
|
|
79
|
-
alphaMode: this.props.alphaMode
|
|
80
|
-
});
|
|
81
|
-
log.log(1, `Resized to ${this.width}x${this.height}px`)();
|
|
53
|
+
updateSize(size) {
|
|
54
|
+
if (this.depthStencilAttachment) {
|
|
55
|
+
this.depthStencilAttachment.destroy();
|
|
56
|
+
this.depthStencilAttachment = null;
|
|
82
57
|
}
|
|
58
|
+
// Reconfigure the canvas size.
|
|
59
|
+
// https://www.w3.org/TR/webgpu/#canvas-configuration
|
|
60
|
+
this.handle.configure({
|
|
61
|
+
device: this.device.handle,
|
|
62
|
+
format: this.device.preferredColorFormat,
|
|
63
|
+
// Can be used to define e.g. -srgb views
|
|
64
|
+
// viewFormats: [...]
|
|
65
|
+
colorSpace: this.props.colorSpace,
|
|
66
|
+
alphaMode: this.props.alphaMode
|
|
67
|
+
});
|
|
83
68
|
}
|
|
84
69
|
resize(options) {
|
|
85
|
-
this.
|
|
70
|
+
if (!this.device.handle)
|
|
71
|
+
return;
|
|
72
|
+
if (this.props.autoResize) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
// Resize browser context .
|
|
76
|
+
if (this.canvas) {
|
|
77
|
+
const devicePixelRatio = this.getDevicePixelRatio(options?.useDevicePixels);
|
|
78
|
+
this._setDevicePixelRatio(devicePixelRatio, options);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
86
81
|
}
|
|
87
82
|
/** Wrap the current canvas context texture in a luma.gl texture */
|
|
88
83
|
getCurrentTexture() {
|
|
89
|
-
return this.device.
|
|
84
|
+
return this.device.createTexture({
|
|
90
85
|
id: `${this.id}#color-texture`,
|
|
91
|
-
handle: this.
|
|
92
|
-
format: this.
|
|
86
|
+
handle: this.handle.getCurrentTexture(),
|
|
87
|
+
format: this.device.preferredColorFormat
|
|
93
88
|
});
|
|
94
89
|
}
|
|
95
90
|
/** We build render targets on demand (i.e. not when size changes but when about to render) */
|
|
96
|
-
_createDepthStencilAttachment() {
|
|
91
|
+
_createDepthStencilAttachment(depthStencilFormat) {
|
|
97
92
|
if (!this.depthStencilAttachment) {
|
|
98
93
|
this.depthStencilAttachment = this.device.createTexture({
|
|
99
94
|
id: `${this.id}#depth-stencil-texture`,
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
95
|
+
usage: Texture.RENDER_ATTACHMENT,
|
|
96
|
+
format: depthStencilFormat,
|
|
97
|
+
width: this.drawingBufferWidth,
|
|
98
|
+
height: this.drawingBufferHeight
|
|
104
99
|
});
|
|
105
100
|
}
|
|
106
101
|
return this.depthStencilAttachment;
|
|
107
102
|
}
|
|
108
103
|
}
|
|
104
|
+
//# sourceMappingURL=webgpu-canvas-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webgpu-canvas-context.js","sourceRoot":"","sources":["../../src/adapter/webgpu-canvas-context.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAKpC,OAAO,EAAC,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mBAAmB,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;YAC5E,IAAI,CAAC,oBAAoB,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;YACrD,OAAO;QACT,CAAC;IACH,CAAC;IAED,mEAAmE;IACnE,iBAAiB;QACf,OAAO,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC;YAC/B,EAAE,EAAE,GAAG,IAAI,CAAC,EAAE,gBAAgB;YAC9B,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,iBAAiB,EAAE;YACvC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,oBAAoB;SACzC,CAAC,CAAC;IACL,CAAC;IAED,8FAA8F;IAC9F,6BAA6B,CAAC,kBAA6C;QACzE,IAAI,CAAC,IAAI,CAAC,sBAAsB,EAAE,CAAC;YACjC,IAAI,CAAC,sBAAsB,GAAG,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC;gBACtD,EAAE,EAAE,GAAG,IAAI,CAAC,EAAE,wBAAwB;gBACtC,KAAK,EAAE,OAAO,CAAC,iBAAiB;gBAChC,MAAM,EAAE,kBAAkB;gBAC1B,KAAK,EAAE,IAAI,CAAC,kBAAkB;gBAC9B,MAAM,EAAE,IAAI,CAAC,mBAAmB;aACjC,CAAC,CAAC;QACL,CAAC;QACD,OAAO,IAAI,CAAC,sBAAsB,CAAC;IACrC,CAAC;CACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { DeviceInfo, DeviceLimits, DeviceTextureFormatCapabilities, CanvasContextProps, BufferProps, SamplerProps, ShaderProps, Texture, TextureProps, ExternalTextureProps, FramebufferProps, RenderPipelineProps, ComputePipelineProps, RenderPassProps, ComputePassProps, VertexArrayProps, TransformFeedback, TransformFeedbackProps, QuerySet, QuerySetProps, DeviceProps } from '@luma.gl/core';
|
|
2
2
|
import { Device, DeviceFeatures } from '@luma.gl/core';
|
|
3
3
|
import { WebGPUBuffer } from "./resources/webgpu-buffer.js";
|
|
4
4
|
import { WebGPUTexture } from "./resources/webgpu-texture.js";
|
|
@@ -14,12 +14,12 @@ import { WebGPUVertexArray } from "./resources/webgpu-vertex-array.js";
|
|
|
14
14
|
import { WebGPUCanvasContext } from "./webgpu-canvas-context.js";
|
|
15
15
|
/** WebGPU Device implementation */
|
|
16
16
|
export declare class WebGPUDevice extends Device {
|
|
17
|
-
/** type of this device */
|
|
18
|
-
readonly type = "webgpu";
|
|
19
17
|
/** The underlying WebGPU device */
|
|
20
18
|
readonly handle: GPUDevice;
|
|
21
|
-
|
|
22
|
-
readonly
|
|
19
|
+
/** type of this device */
|
|
20
|
+
readonly type = "webgpu";
|
|
21
|
+
readonly preferredColorFormat: "rgba8unorm" | "bgra8unorm";
|
|
22
|
+
readonly preferredDepthFormat = "depth24plus";
|
|
23
23
|
readonly features: DeviceFeatures;
|
|
24
24
|
readonly info: DeviceInfo;
|
|
25
25
|
readonly limits: DeviceLimits;
|
|
@@ -27,20 +27,17 @@ export declare class WebGPUDevice extends Device {
|
|
|
27
27
|
reason: 'destroyed';
|
|
28
28
|
message: string;
|
|
29
29
|
}>;
|
|
30
|
+
renderPass: WebGPURenderPass | null;
|
|
30
31
|
canvasContext: WebGPUCanvasContext | null;
|
|
31
32
|
private _isLost;
|
|
32
33
|
commandEncoder: GPUCommandEncoder | null;
|
|
33
|
-
|
|
34
|
+
readonly adapter: GPUAdapter;
|
|
35
|
+
readonly adapterInfo: GPUAdapterInfo;
|
|
34
36
|
constructor(props: DeviceProps, device: GPUDevice, adapter: GPUAdapter, adapterInfo: GPUAdapterInfo);
|
|
35
37
|
destroy(): void;
|
|
36
|
-
isTextureFormatSupported(format: TextureFormat): boolean;
|
|
37
|
-
/** @todo implement proper check? */
|
|
38
|
-
isTextureFormatFilterable(format: TextureFormat): boolean;
|
|
39
|
-
/** @todo implement proper check? */
|
|
40
|
-
isTextureFormatRenderable(format: TextureFormat): boolean;
|
|
41
38
|
get isLost(): boolean;
|
|
42
39
|
createBuffer(props: BufferProps | ArrayBuffer | ArrayBufferView): WebGPUBuffer;
|
|
43
|
-
|
|
40
|
+
createTexture(props: TextureProps): WebGPUTexture;
|
|
44
41
|
createExternalTexture(props: ExternalTextureProps): WebGPUExternalTexture;
|
|
45
42
|
createShader(props: ShaderProps): WebGPUShader;
|
|
46
43
|
createSampler(props: SamplerProps): WebGPUSampler;
|
|
@@ -60,6 +57,7 @@ export declare class WebGPUDevice extends Device {
|
|
|
60
57
|
submit(): void;
|
|
61
58
|
protected _getInfo(): DeviceInfo;
|
|
62
59
|
protected _getFeatures(): DeviceFeatures;
|
|
60
|
+
_getDeviceSpecificTextureFormatCapabilities(capabilities: DeviceTextureFormatCapabilities): DeviceTextureFormatCapabilities;
|
|
63
61
|
copyExternalImageToTexture(options: {
|
|
64
62
|
texture: Texture;
|
|
65
63
|
mipLevel?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgpu-device.d.ts","sourceRoot":"","sources":["../../src/adapter/webgpu-device.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,
|
|
1
|
+
{"version":3,"file":"webgpu-device.d.ts","sourceRoot":"","sources":["../../src/adapter/webgpu-device.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,UAAU,EACV,YAAY,EAEZ,+BAA+B,EAC/B,kBAAkB,EAClB,WAAW,EACX,YAAY,EACZ,WAAW,EACX,OAAO,EACP,YAAY,EACZ,oBAAoB,EACpB,gBAAgB,EAChB,mBAAmB,EACnB,oBAAoB,EACpB,eAAe,EACf,gBAAgB,EAEhB,gBAAgB,EAChB,iBAAiB,EACjB,sBAAsB,EACtB,QAAQ,EACR,aAAa,EACb,WAAW,EACZ,MAAM,eAAe,CAAC;AACvB,OAAO,EAAC,MAAM,EAAE,cAAc,EAAC,MAAM,eAAe,CAAC;AACrD,OAAO,EAAC,YAAY,EAAC,qCAAkC;AACvD,OAAO,EAAC,aAAa,EAAC,sCAAmC;AACzD,OAAO,EAAC,qBAAqB,EAAC,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