@luma.gl/webgpu 9.1.1 → 9.1.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/get-vertex-buffer-layout.d.ts.map +1 -1
- package/dist/adapter/helpers/get-vertex-buffer-layout.js +3 -2
- package/dist/adapter/helpers/get-vertex-buffer-layout.js.map +1 -1
- package/dist/adapter/helpers/webgpu-parameters.d.ts.map +1 -1
- package/dist/adapter/helpers/webgpu-parameters.js +7 -3
- package/dist/adapter/helpers/webgpu-parameters.js.map +1 -1
- package/dist/adapter/resources/webgpu-render-pass.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-render-pass.js +4 -1
- package/dist/adapter/resources/webgpu-render-pass.js.map +1 -1
- package/dist/adapter/resources/webgpu-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-render-pipeline.js +7 -0
- package/dist/adapter/resources/webgpu-render-pipeline.js.map +1 -1
- package/dist/adapter/webgpu-device.d.ts.map +1 -1
- package/dist/adapter/webgpu-device.js +2 -2
- package/dist/adapter/webgpu-device.js.map +1 -1
- package/dist/dist.dev.js +71 -56
- package/dist/dist.min.js +4 -4
- package/dist/index.cjs +69 -56
- package/dist/index.cjs.map +3 -3
- package/package.json +2 -2
- package/src/adapter/helpers/get-vertex-buffer-layout.ts +3 -2
- package/src/adapter/helpers/webgpu-parameters.ts +7 -4
- package/src/adapter/resources/webgpu-render-pass.ts +8 -2
- package/src/adapter/resources/webgpu-render-pipeline.ts +8 -0
- package/src/adapter/webgpu-device.ts +2 -3
|
@@ -37,7 +37,7 @@ export function getVertexBufferLayout(
|
|
|
37
37
|
let stepMode: 'vertex' | 'instance' = 'vertex';
|
|
38
38
|
let byteStride = 0;
|
|
39
39
|
// @ts-ignore
|
|
40
|
-
|
|
40
|
+
let format: VertexFormat = mapping.format;
|
|
41
41
|
|
|
42
42
|
// interleaved mapping {..., attributes: [{...}, ...]}
|
|
43
43
|
if (mapping.attributes) {
|
|
@@ -48,12 +48,13 @@ export function getVertexBufferLayout(
|
|
|
48
48
|
|
|
49
49
|
// @ts-ignore
|
|
50
50
|
const location: number = attributeLayout?.location;
|
|
51
|
+
format = attributeMapping.format || mapping.format;
|
|
51
52
|
|
|
52
53
|
stepMode =
|
|
53
54
|
attributeLayout?.stepMode ||
|
|
54
55
|
(attributeLayout?.name.startsWith('instance') ? 'instance' : 'vertex');
|
|
55
56
|
vertexAttributes.push({
|
|
56
|
-
format: getWebGPUVertexFormat(
|
|
57
|
+
format: getWebGPUVertexFormat(format),
|
|
57
58
|
offset: attributeMapping.byteOffset,
|
|
58
59
|
shaderLocation: location
|
|
59
60
|
});
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import {Parameters} from '@luma.gl/core';
|
|
5
|
+
import {Parameters, log} from '@luma.gl/core';
|
|
6
6
|
|
|
7
7
|
function addDepthStencil(descriptor: GPURenderPipelineDescriptor): GPUDepthStencilState {
|
|
8
8
|
descriptor.depthStencil = descriptor.depthStencil || {
|
|
@@ -297,19 +297,22 @@ function setParameters(
|
|
|
297
297
|
for (const [key, value] of Object.entries(parameters)) {
|
|
298
298
|
const setterFunction = PARAMETER_TABLE[key as keyof Parameters];
|
|
299
299
|
if (!setterFunction) {
|
|
300
|
-
|
|
300
|
+
log.warn(`Illegal parameter ${key}`)();
|
|
301
|
+
continue;
|
|
301
302
|
}
|
|
302
303
|
setterFunction(key, value, pipelineDescriptor);
|
|
303
304
|
}
|
|
304
305
|
}
|
|
305
306
|
|
|
306
307
|
function addColorState(descriptor: GPURenderPipelineDescriptor): GPUColorTargetState[] {
|
|
307
|
-
// @ts-ignore
|
|
308
|
+
// @ts-ignore GPU types as iterator
|
|
308
309
|
descriptor.fragment.targets = descriptor.fragment?.targets || [];
|
|
309
310
|
if (!Array.isArray(descriptor.fragment?.targets)) {
|
|
310
|
-
|
|
311
|
+
log.warn('parameters: no targets array')();
|
|
311
312
|
}
|
|
313
|
+
// @ts-expect-error GPU types as iterator
|
|
312
314
|
if (descriptor.fragment?.targets?.length === 0) {
|
|
315
|
+
// @ts-expect-error GPU types as iterator
|
|
313
316
|
descriptor.fragment.targets?.push({});
|
|
314
317
|
}
|
|
315
318
|
return descriptor.fragment?.targets as GPUColorTargetState[];
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
+
import type {TypedArray, NumberArray4} from '@math.gl/types';
|
|
5
6
|
import type {RenderPassProps, RenderPassParameters, Binding} from '@luma.gl/core';
|
|
6
7
|
import {Buffer, RenderPass, RenderPipeline, log} from '@luma.gl/core';
|
|
7
8
|
import {WebGPUDevice} from '../webgpu-device';
|
|
@@ -182,8 +183,9 @@ export class WebGPURenderPass extends RenderPass {
|
|
|
182
183
|
(colorAttachment, index) => ({
|
|
183
184
|
// clear values
|
|
184
185
|
loadOp: this.props.clearColor !== false ? 'clear' : 'load',
|
|
185
|
-
|
|
186
|
-
this.props.clearColors?.[index] || this.props.clearColor || RenderPass.defaultClearColor
|
|
186
|
+
clearValue: convertColor(
|
|
187
|
+
this.props.clearColors?.[index] || this.props.clearColor || RenderPass.defaultClearColor
|
|
188
|
+
),
|
|
187
189
|
storeOp: this.props.discard ? 'discard' : 'store',
|
|
188
190
|
// ...colorAttachment,
|
|
189
191
|
view: colorAttachment.handle
|
|
@@ -226,3 +228,7 @@ export class WebGPURenderPass extends RenderPass {
|
|
|
226
228
|
return renderPassDescriptor;
|
|
227
229
|
}
|
|
228
230
|
}
|
|
231
|
+
|
|
232
|
+
function convertColor(color: TypedArray | NumberArray4): GPUColor {
|
|
233
|
+
return {r: color[0], g: color[1], b: color[2], a: color[3]};
|
|
234
|
+
}
|
|
@@ -178,6 +178,14 @@ export class WebGPURenderPipeline extends RenderPipeline {
|
|
|
178
178
|
layout: 'auto'
|
|
179
179
|
};
|
|
180
180
|
|
|
181
|
+
if (this.props.parameters.depthWriteEnabled && this.props.parameters.depthCompare) {
|
|
182
|
+
descriptor.depthStencil = {
|
|
183
|
+
format: 'depth24plus',
|
|
184
|
+
depthWriteEnabled: this.props.parameters.depthWriteEnabled,
|
|
185
|
+
depthCompare: this.props.parameters.depthCompare
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
|
|
181
189
|
// Set parameters on the descriptor
|
|
182
190
|
applyParametersToRenderPipelineDescriptor(descriptor, this.props.parameters);
|
|
183
191
|
|
|
@@ -106,9 +106,8 @@ export class WebGPUDevice extends Device {
|
|
|
106
106
|
});
|
|
107
107
|
|
|
108
108
|
// Note: WebGPU devices can be created without a canvas, for compute shader purposes
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
props.createCanvasContext === true ? {} : props.createCanvasContext;
|
|
109
|
+
const canvasContextProps = Device._getCanvasContextProps(props);
|
|
110
|
+
if (canvasContextProps) {
|
|
112
111
|
this.canvasContext = new WebGPUCanvasContext(this, this.adapter, canvasContextProps);
|
|
113
112
|
}
|
|
114
113
|
}
|