@luma.gl/webgpu 9.0.0-alpha.16 → 9.0.0-alpha.19
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 -100
- package/dist/adapter/helpers/accessor-to-format.js.map +1 -0
- package/dist/adapter/helpers/convert-texture-format.d.ts +1 -1
- package/dist/adapter/helpers/convert-texture-format.js +5 -5
- package/dist/adapter/helpers/convert-texture-format.js.map +1 -0
- package/dist/adapter/helpers/generate-mipmaps.d.ts +1 -1
- package/dist/adapter/helpers/generate-mipmaps.js +85 -88
- package/dist/adapter/helpers/generate-mipmaps.js.map +1 -0
- package/dist/adapter/helpers/get-bind-group.d.ts +1 -1
- package/dist/adapter/helpers/get-bind-group.d.ts.map +1 -1
- package/dist/adapter/helpers/get-bind-group.js +39 -54
- package/dist/adapter/helpers/get-bind-group.js.map +1 -0
- package/dist/adapter/helpers/get-vertex-buffer-layout.d.ts +1 -1
- package/dist/adapter/helpers/get-vertex-buffer-layout.js +72 -97
- package/dist/adapter/helpers/get-vertex-buffer-layout.js.map +1 -0
- package/dist/adapter/helpers/webgpu-parameters.d.ts +1 -1
- package/dist/adapter/helpers/webgpu-parameters.js +125 -182
- package/dist/adapter/helpers/webgpu-parameters.js.map +1 -0
- package/dist/adapter/resources/webgpu-buffer.d.ts +2 -2
- package/dist/adapter/resources/webgpu-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-buffer.js +63 -57
- package/dist/adapter/resources/webgpu-buffer.js.map +1 -0
- package/dist/adapter/resources/webgpu-command-encoder.d.ts +2 -2
- package/dist/adapter/resources/webgpu-command-encoder.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-command-encoder.js +46 -47
- package/dist/adapter/resources/webgpu-command-encoder.js.map +1 -0
- package/dist/adapter/resources/webgpu-compute-pass.d.ts +2 -2
- package/dist/adapter/resources/webgpu-compute-pass.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-compute-pass.js +41 -51
- package/dist/adapter/resources/webgpu-compute-pass.js.map +1 -0
- package/dist/adapter/resources/webgpu-compute-pipeline.d.ts +2 -2
- package/dist/adapter/resources/webgpu-compute-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-compute-pipeline.js +20 -22
- package/dist/adapter/resources/webgpu-compute-pipeline.js.map +1 -0
- package/dist/adapter/resources/webgpu-external-texture.d.ts +2 -2
- package/dist/adapter/resources/webgpu-external-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-external-texture.js +20 -26
- package/dist/adapter/resources/webgpu-external-texture.js.map +1 -0
- package/dist/adapter/resources/webgpu-framebuffer.d.ts +2 -2
- package/dist/adapter/resources/webgpu-framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-framebuffer.js +86 -89
- package/dist/adapter/resources/webgpu-framebuffer.js.map +1 -0
- package/dist/adapter/resources/webgpu-query.js +1 -42
- package/dist/adapter/resources/webgpu-query.js.map +1 -0
- package/dist/adapter/resources/webgpu-render-pass.d.ts +2 -2
- package/dist/adapter/resources/webgpu-render-pass.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-render-pass.js +70 -64
- package/dist/adapter/resources/webgpu-render-pass.js.map +1 -0
- package/dist/adapter/resources/webgpu-render-pipeline.d.ts +2 -2
- package/dist/adapter/resources/webgpu-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-render-pipeline.js +118 -158
- package/dist/adapter/resources/webgpu-render-pipeline.js.map +1 -0
- package/dist/adapter/resources/webgpu-sampler.d.ts +3 -3
- package/dist/adapter/resources/webgpu-sampler.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-sampler.js +16 -16
- package/dist/adapter/resources/webgpu-sampler.js.map +1 -0
- package/dist/adapter/resources/webgpu-shader.d.ts +3 -3
- package/dist/adapter/resources/webgpu-shader.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-shader.js +44 -47
- package/dist/adapter/resources/webgpu-shader.js.map +1 -0
- package/dist/adapter/resources/webgpu-texture.d.ts +3 -2
- package/dist/adapter/resources/webgpu-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-texture.js +87 -100
- package/dist/adapter/resources/webgpu-texture.js.map +1 -0
- package/dist/adapter/webgpu-canvas-context.d.ts +2 -2
- package/dist/adapter/webgpu-canvas-context.d.ts.map +1 -1
- package/dist/adapter/webgpu-canvas-context.js +68 -77
- package/dist/adapter/webgpu-canvas-context.js.map +1 -0
- package/dist/adapter/webgpu-device.d.ts +2 -2
- package/dist/adapter/webgpu-device.d.ts.map +1 -1
- package/dist/adapter/webgpu-device.js +194 -215
- package/dist/adapter/webgpu-device.js.map +1 -0
- package/dist/adapter/webgpu-types.js +2 -0
- package/dist/adapter/webgpu-types.js.map +1 -0
- package/dist/dist.dev.js +3061 -0
- package/dist/glsl/glsllang.js +6 -9
- package/dist/glsl/glsllang.js.map +1 -0
- package/dist/index.cjs +1442 -0
- package/dist/index.d.ts +1 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -10
- package/dist/index.js.map +1 -0
- package/dist.min.js +17 -0
- package/package.json +17 -8
- package/src/adapter/helpers/generate-mipmaps.ts +1 -1
- package/src/adapter/helpers/get-bind-group.ts +1 -1
- package/src/adapter/helpers/get-vertex-buffer-layout.ts +2 -2
- package/src/adapter/helpers/webgpu-parameters.ts +9 -9
- package/src/adapter/resources/webgpu-buffer.ts +1 -1
- package/src/adapter/resources/webgpu-command-encoder.ts +4 -4
- package/src/adapter/resources/webgpu-compute-pass.ts +1 -1
- package/src/adapter/resources/webgpu-compute-pipeline.ts +1 -1
- package/src/adapter/resources/webgpu-external-texture.ts +1 -1
- package/src/adapter/resources/webgpu-framebuffer.ts +6 -6
- package/src/adapter/resources/webgpu-query.ts +1 -1
- package/src/adapter/resources/webgpu-render-pass.ts +1 -1
- package/src/adapter/resources/webgpu-render-pipeline.ts +3 -3
- package/src/adapter/resources/webgpu-sampler.ts +1 -1
- package/src/adapter/resources/webgpu-shader.ts +3 -1
- package/src/adapter/resources/webgpu-texture.ts +1 -1
- package/src/adapter/webgpu-canvas-context.ts +1 -1
- package/src/adapter/webgpu-device.ts +3 -2
- package/src/index.ts +2 -5
- package/dist/bundle.d.ts +0 -2
- package/dist/bundle.d.ts.map +0 -1
- package/dist/bundle.js +0 -4
- package/dist/dist.js +0 -8051
- package/dist/dist.min.js +0 -1
- package/dist/es5/adapter/helpers/accessor-to-format.js +0 -2
- package/dist/es5/adapter/helpers/accessor-to-format.js.map +0 -1
- package/dist/es5/adapter/helpers/convert-texture-format.js +0 -13
- package/dist/es5/adapter/helpers/convert-texture-format.js.map +0 -1
- package/dist/es5/adapter/helpers/generate-mipmaps.js +0 -103
- package/dist/es5/adapter/helpers/generate-mipmaps.js.map +0 -1
- package/dist/es5/adapter/helpers/get-bind-group.js +0 -66
- package/dist/es5/adapter/helpers/get-bind-group.js.map +0 -1
- package/dist/es5/adapter/helpers/get-vertex-buffer-layout.js +0 -149
- package/dist/es5/adapter/helpers/get-vertex-buffer-layout.js.map +0 -1
- package/dist/es5/adapter/helpers/webgpu-parameters.js +0 -150
- package/dist/es5/adapter/helpers/webgpu-parameters.js.map +0 -1
- package/dist/es5/adapter/resources/webgpu-buffer.js +0 -131
- package/dist/es5/adapter/resources/webgpu-buffer.js.map +0 -1
- package/dist/es5/adapter/resources/webgpu-command-encoder.js +0 -90
- package/dist/es5/adapter/resources/webgpu-command-encoder.js.map +0 -1
- package/dist/es5/adapter/resources/webgpu-compute-pass.js +0 -85
- package/dist/es5/adapter/resources/webgpu-compute-pass.js.map +0 -1
- package/dist/es5/adapter/resources/webgpu-compute-pipeline.js +0 -48
- package/dist/es5/adapter/resources/webgpu-compute-pipeline.js.map +0 -1
- package/dist/es5/adapter/resources/webgpu-external-texture.js +0 -50
- package/dist/es5/adapter/resources/webgpu-external-texture.js.map +0 -1
- package/dist/es5/adapter/resources/webgpu-framebuffer.js +0 -126
- package/dist/es5/adapter/resources/webgpu-framebuffer.js.map +0 -1
- package/dist/es5/adapter/resources/webgpu-query.js +0 -2
- package/dist/es5/adapter/resources/webgpu-query.js.map +0 -1
- package/dist/es5/adapter/resources/webgpu-render-pass.js +0 -124
- package/dist/es5/adapter/resources/webgpu-render-pass.js.map +0 -1
- package/dist/es5/adapter/resources/webgpu-render-pipeline.js +0 -185
- package/dist/es5/adapter/resources/webgpu-render-pipeline.js.map +0 -1
- package/dist/es5/adapter/resources/webgpu-sampler.js +0 -45
- package/dist/es5/adapter/resources/webgpu-sampler.js.map +0 -1
- package/dist/es5/adapter/resources/webgpu-shader.js +0 -125
- package/dist/es5/adapter/resources/webgpu-shader.js.map +0 -1
- package/dist/es5/adapter/resources/webgpu-texture.js +0 -138
- package/dist/es5/adapter/resources/webgpu-texture.js.map +0 -1
- package/dist/es5/adapter/webgpu-canvas-context.js +0 -111
- package/dist/es5/adapter/webgpu-canvas-context.js.map +0 -1
- package/dist/es5/adapter/webgpu-device.js +0 -317
- package/dist/es5/adapter/webgpu-device.js.map +0 -1
- package/dist/es5/adapter/webgpu-types.js +0 -2
- package/dist/es5/adapter/webgpu-types.js.map +0 -1
- package/dist/es5/bundle.js +0 -6
- package/dist/es5/bundle.js.map +0 -1
- package/dist/es5/glsl/glsllang.js +0 -47
- package/dist/es5/glsl/glsllang.js.map +0 -1
- package/dist/es5/index.js +0 -44
- package/dist/es5/index.js.map +0 -1
- package/dist/es5/init.js +0 -7
- package/dist/es5/init.js.map +0 -1
- package/dist/esm/adapter/helpers/accessor-to-format.js +0 -2
- package/dist/esm/adapter/helpers/accessor-to-format.js.map +0 -1
- package/dist/esm/adapter/helpers/convert-texture-format.js +0 -7
- package/dist/esm/adapter/helpers/convert-texture-format.js.map +0 -1
- package/dist/esm/adapter/helpers/generate-mipmaps.js +0 -88
- package/dist/esm/adapter/helpers/generate-mipmaps.js.map +0 -1
- package/dist/esm/adapter/helpers/get-bind-group.js +0 -51
- package/dist/esm/adapter/helpers/get-bind-group.js.map +0 -1
- package/dist/esm/adapter/helpers/get-vertex-buffer-layout.js +0 -83
- package/dist/esm/adapter/helpers/get-vertex-buffer-layout.js.map +0 -1
- package/dist/esm/adapter/helpers/webgpu-parameters.js +0 -137
- package/dist/esm/adapter/helpers/webgpu-parameters.js.map +0 -1
- package/dist/esm/adapter/resources/webgpu-buffer.js +0 -70
- package/dist/esm/adapter/resources/webgpu-buffer.js.map +0 -1
- package/dist/esm/adapter/resources/webgpu-command-encoder.js +0 -49
- package/dist/esm/adapter/resources/webgpu-command-encoder.js.map +0 -1
- package/dist/esm/adapter/resources/webgpu-compute-pass.js +0 -44
- package/dist/esm/adapter/resources/webgpu-compute-pass.js.map +0 -1
- package/dist/esm/adapter/resources/webgpu-compute-pipeline.js +0 -23
- package/dist/esm/adapter/resources/webgpu-compute-pipeline.js.map +0 -1
- package/dist/esm/adapter/resources/webgpu-external-texture.js +0 -23
- package/dist/esm/adapter/resources/webgpu-external-texture.js.map +0 -1
- package/dist/esm/adapter/resources/webgpu-framebuffer.js +0 -93
- package/dist/esm/adapter/resources/webgpu-framebuffer.js.map +0 -1
- package/dist/esm/adapter/resources/webgpu-query.js +0 -2
- package/dist/esm/adapter/resources/webgpu-query.js.map +0 -1
- package/dist/esm/adapter/resources/webgpu-render-pass.js +0 -79
- package/dist/esm/adapter/resources/webgpu-render-pass.js.map +0 -1
- package/dist/esm/adapter/resources/webgpu-render-pipeline.js +0 -130
- package/dist/esm/adapter/resources/webgpu-render-pipeline.js.map +0 -1
- package/dist/esm/adapter/resources/webgpu-sampler.js +0 -20
- package/dist/esm/adapter/resources/webgpu-sampler.js.map +0 -1
- package/dist/esm/adapter/resources/webgpu-shader.js +0 -50
- package/dist/esm/adapter/resources/webgpu-shader.js.map +0 -1
- package/dist/esm/adapter/resources/webgpu-texture.js +0 -95
- package/dist/esm/adapter/resources/webgpu-texture.js.map +0 -1
- package/dist/esm/adapter/webgpu-canvas-context.js +0 -74
- package/dist/esm/adapter/webgpu-canvas-context.js.map +0 -1
- package/dist/esm/adapter/webgpu-device.js +0 -196
- package/dist/esm/adapter/webgpu-device.js.map +0 -1
- package/dist/esm/adapter/webgpu-types.js +0 -2
- package/dist/esm/adapter/webgpu-types.js.map +0 -1
- package/dist/esm/bundle.js +0 -4
- package/dist/esm/bundle.js.map +0 -1
- package/dist/esm/glsl/glsllang.js +0 -9
- package/dist/esm/glsl/glsllang.js.map +0 -1
- package/dist/esm/index.js +0 -8
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/init.js +0 -4
- package/dist/esm/init.js.map +0 -1
- package/dist/init.d.ts +0 -2
- package/dist/init.d.ts.map +0 -1
- package/dist/init.js +0 -3
- package/src/bundle.ts +0 -4
- package/src/init.ts +0 -4
|
@@ -1,96 +1,93 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
1
2
|
import { Framebuffer, Texture } from '@luma.gl/api';
|
|
2
|
-
|
|
3
|
-
import WEBGPUTexture from './webgpu-texture.js';
|
|
4
|
-
// const DEFAULT_DEPTH_STENCIL_FORMAT: DepthStencilTextureFormat = 'depth24plus';
|
|
5
|
-
// const MAX_COLOR_ATTACHMENTS = 8;
|
|
6
|
-
/**
|
|
7
|
-
* Create new textures with correct size for all attachments.
|
|
8
|
-
* @note resize() destroys existing textures (if size has changed).
|
|
9
|
-
*/
|
|
3
|
+
import WEBGPUTexture from "./webgpu-texture.js";
|
|
10
4
|
export default class WebGPUFramebuffer extends Framebuffer {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
if (props.colorAttachments) {
|
|
24
|
-
this.colorAttachments = props.colorAttachments.map(colorAttachment => this.createColorTexture(this.props, colorAttachment));
|
|
25
|
-
}
|
|
26
|
-
if (this.depthStencilAttachment) {
|
|
27
|
-
this.renderPassDescriptor.depthStencilAttachment = {
|
|
28
|
-
view: this.depthStencilAttachment.handle.createView(),
|
|
29
|
-
// Add default clear values
|
|
30
|
-
depthClearValue: 1.0,
|
|
31
|
-
depthStoreOp: 'store',
|
|
32
|
-
stencilClearValue: 0,
|
|
33
|
-
stencilStoreOp: 'store',
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
if (this.colorAttachments.length > 0) {
|
|
37
|
-
this.renderPassDescriptor.colorAttachments = this.colorAttachments.map(colorAttachment => ({
|
|
38
|
-
view: colorAttachment.handle.createView(),
|
|
39
|
-
loadOp: 'clear',
|
|
40
|
-
loadValue: [0.0, 0.0, 0.0, 0.0],
|
|
41
|
-
storeOp: 'store'
|
|
42
|
-
}));
|
|
43
|
-
}
|
|
5
|
+
constructor(device, props) {
|
|
6
|
+
super(device, props);
|
|
7
|
+
_defineProperty(this, "device", void 0);
|
|
8
|
+
_defineProperty(this, "colorAttachments", []);
|
|
9
|
+
_defineProperty(this, "depthStencilAttachment", null);
|
|
10
|
+
_defineProperty(this, "renderPassDescriptor", {
|
|
11
|
+
colorAttachments: []
|
|
12
|
+
});
|
|
13
|
+
this.device = device;
|
|
14
|
+
if (props.depthStencilAttachment) {
|
|
15
|
+
this.depthStencilAttachment = this.createDepthStencilTexture(props);
|
|
44
16
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
if (props.depthStencilAttachment instanceof WEBGPUTexture) {
|
|
48
|
-
return props.depthStencilAttachment;
|
|
49
|
-
}
|
|
50
|
-
if (typeof props.depthStencilAttachment === 'string') {
|
|
51
|
-
return this.device._createTexture({
|
|
52
|
-
id: 'depth-stencil-attachment',
|
|
53
|
-
format: props.depthStencilAttachment,
|
|
54
|
-
width: props.width,
|
|
55
|
-
height: props.height,
|
|
56
|
-
usage: Texture.RENDER_ATTACHMENT
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
throw new Error('type');
|
|
17
|
+
if (props.colorAttachments) {
|
|
18
|
+
this.colorAttachments = props.colorAttachments.map(colorAttachment => this.createColorTexture(this.props, colorAttachment));
|
|
60
19
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
width: props.width,
|
|
70
|
-
height: props.height,
|
|
71
|
-
usage: Texture.RENDER_ATTACHMENT
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
throw new Error('type');
|
|
20
|
+
if (this.depthStencilAttachment) {
|
|
21
|
+
this.renderPassDescriptor.depthStencilAttachment = {
|
|
22
|
+
view: this.depthStencilAttachment.handle.createView(),
|
|
23
|
+
depthClearValue: 1.0,
|
|
24
|
+
depthStoreOp: 'store',
|
|
25
|
+
stencilClearValue: 0,
|
|
26
|
+
stencilStoreOp: 'store'
|
|
27
|
+
};
|
|
75
28
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
const resizedTexture = this.device._createTexture({ ...this.colorAttachments[i].props, width, height });
|
|
84
|
-
this.colorAttachments[i].destroy();
|
|
85
|
-
this.colorAttachments[i] = resizedTexture;
|
|
86
|
-
this.renderPassDescriptor.colorAttachments[i].view = resizedTexture.handle.createView();
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
if (this.depthStencilAttachment) {
|
|
90
|
-
const resizedTexture = this.device._createTexture({ ...this.depthStencilAttachment.props, width, height });
|
|
91
|
-
this.depthStencilAttachment.destroy();
|
|
92
|
-
this.depthStencilAttachment = resizedTexture;
|
|
93
|
-
this.renderPassDescriptor.depthStencilAttachment.view = resizedTexture.handle.createView();
|
|
94
|
-
}
|
|
29
|
+
if (this.colorAttachments.length > 0) {
|
|
30
|
+
this.renderPassDescriptor.colorAttachments = this.colorAttachments.map(colorAttachment => ({
|
|
31
|
+
view: colorAttachment.handle.createView(),
|
|
32
|
+
loadOp: 'clear',
|
|
33
|
+
loadValue: [0.0, 0.0, 0.0, 0.0],
|
|
34
|
+
storeOp: 'store'
|
|
35
|
+
}));
|
|
95
36
|
}
|
|
37
|
+
}
|
|
38
|
+
createDepthStencilTexture(props) {
|
|
39
|
+
if (props.depthStencilAttachment instanceof WEBGPUTexture) {
|
|
40
|
+
return props.depthStencilAttachment;
|
|
41
|
+
}
|
|
42
|
+
if (typeof props.depthStencilAttachment === 'string') {
|
|
43
|
+
return this.device._createTexture({
|
|
44
|
+
id: 'depth-stencil-attachment',
|
|
45
|
+
format: props.depthStencilAttachment,
|
|
46
|
+
width: props.width,
|
|
47
|
+
height: props.height,
|
|
48
|
+
usage: Texture.RENDER_ATTACHMENT
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
throw new Error('type');
|
|
52
|
+
}
|
|
53
|
+
createColorTexture(props, texture) {
|
|
54
|
+
if (texture instanceof WEBGPUTexture) {
|
|
55
|
+
return texture;
|
|
56
|
+
}
|
|
57
|
+
if (typeof texture === 'string') {
|
|
58
|
+
return this.device._createTexture({
|
|
59
|
+
id: 'color-attachment',
|
|
60
|
+
format: texture,
|
|
61
|
+
width: props.width,
|
|
62
|
+
height: props.height,
|
|
63
|
+
usage: Texture.RENDER_ATTACHMENT
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
throw new Error('type');
|
|
67
|
+
}
|
|
68
|
+
_resizeAttachments(width, height) {
|
|
69
|
+
for (let i = 0; i < this.colorAttachments.length; ++i) {
|
|
70
|
+
if (this.colorAttachments[i]) {
|
|
71
|
+
const resizedTexture = this.device._createTexture({
|
|
72
|
+
...this.colorAttachments[i].props,
|
|
73
|
+
width,
|
|
74
|
+
height
|
|
75
|
+
});
|
|
76
|
+
this.colorAttachments[i].destroy();
|
|
77
|
+
this.colorAttachments[i] = resizedTexture;
|
|
78
|
+
this.renderPassDescriptor.colorAttachments[i].view = resizedTexture.handle.createView();
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
if (this.depthStencilAttachment) {
|
|
82
|
+
const resizedTexture = this.device._createTexture({
|
|
83
|
+
...this.depthStencilAttachment.props,
|
|
84
|
+
width,
|
|
85
|
+
height
|
|
86
|
+
});
|
|
87
|
+
this.depthStencilAttachment.destroy();
|
|
88
|
+
this.depthStencilAttachment = resizedTexture;
|
|
89
|
+
this.renderPassDescriptor.depthStencilAttachment.view = resizedTexture.handle.createView();
|
|
90
|
+
}
|
|
91
|
+
}
|
|
96
92
|
}
|
|
93
|
+
//# sourceMappingURL=webgpu-framebuffer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webgpu-framebuffer.js","names":["Framebuffer","Texture","WEBGPUTexture","WebGPUFramebuffer","constructor","device","props","_defineProperty","colorAttachments","depthStencilAttachment","createDepthStencilTexture","map","colorAttachment","createColorTexture","renderPassDescriptor","view","handle","createView","depthClearValue","depthStoreOp","stencilClearValue","stencilStoreOp","length","loadOp","loadValue","storeOp","_createTexture","id","format","width","height","usage","RENDER_ATTACHMENT","Error","texture","_resizeAttachments","i","resizedTexture","destroy"],"sources":["../../../src/adapter/resources/webgpu-framebuffer.ts"],"sourcesContent":["import type {FramebufferProps, ColorTextureFormat} from '@luma.gl/api';\nimport {Framebuffer, Texture} from '@luma.gl/api';\nimport {WebGPUDevice} from '../webgpu-device';\n// import WebGPUCanvasContext from '../webgpu-canvas-context';\nimport WEBGPUTexture from './webgpu-texture';\nimport WebGPUTexture from './webgpu-texture';\n\n// const DEFAULT_DEPTH_STENCIL_FORMAT: DepthStencilTextureFormat = 'depth24plus';\n\n// const MAX_COLOR_ATTACHMENTS = 8;\n\n/**\n * Create new textures with correct size for all attachments. \n * @note resize() destroys existing textures (if size has changed). \n */\nexport default class WebGPUFramebuffer extends Framebuffer {\n readonly device: WebGPUDevice;\n\n colorAttachments: WebGPUTexture[] = [];\n depthStencilAttachment: WebGPUTexture | null = null;\n\n /** Partial render pass descriptor. Used by WebGPURenderPass */\n renderPassDescriptor: {\n colorAttachments: GPURenderPassColorAttachment[];\n depthStencilAttachment?: GPURenderPassDepthStencilAttachment;\n } = {\n colorAttachments: []\n };\n\n constructor(device: WebGPUDevice, props: FramebufferProps) {\n super(device, props);\n this.device = device;\n\n if (props.depthStencilAttachment) {\n this.depthStencilAttachment = this.createDepthStencilTexture(props);\n }\n\n if (props.colorAttachments) {\n this.colorAttachments = props.colorAttachments.map(colorAttachment => this.createColorTexture(this.props, colorAttachment));\n }\n\n if (this.depthStencilAttachment) {\n this.renderPassDescriptor.depthStencilAttachment = {\n view: this.depthStencilAttachment.handle.createView(),\n // Add default clear values\n depthClearValue: 1.0,\n depthStoreOp: 'store',\n stencilClearValue: 0,\n stencilStoreOp: 'store',\n }\n }\n\n if (this.colorAttachments.length > 0) {\n this.renderPassDescriptor.colorAttachments = this.colorAttachments.map(colorAttachment => ({\n view: colorAttachment.handle.createView(),\n loadOp: 'clear',\n loadValue: [0.0, 0.0, 0.0, 0.0],\n storeOp: 'store'\n }));\n }\n }\n\n /** Create depth stencil texture */\n private createDepthStencilTexture(props: FramebufferProps): WEBGPUTexture {\n if (props.depthStencilAttachment instanceof WEBGPUTexture) {\n return props.depthStencilAttachment;\n }\n\n if (typeof props.depthStencilAttachment === 'string') {\n return this.device._createTexture({\n id: 'depth-stencil-attachment',\n format: props.depthStencilAttachment,\n width: props.width,\n height: props.height,\n usage: Texture.RENDER_ATTACHMENT\n });\n }\n\n throw new Error('type');\n }\n\n private createColorTexture(props: FramebufferProps, texture: Texture | ColorTextureFormat): WEBGPUTexture {\n if (texture instanceof WEBGPUTexture) {\n return texture;\n }\n\n if (typeof texture === 'string') {\n return this.device._createTexture({\n id: 'color-attachment',\n format: texture,\n width: props.width,\n height: props.height,\n usage: Texture.RENDER_ATTACHMENT\n });\n }\n\n throw new Error('type');\n }\n\n /**\n * Create new textures with correct size for all attachments.\n * @note destroys existing textures.\n */\n protected _resizeAttachments(width: number, height: number): void {\n for (let i = 0; i < this.colorAttachments.length; ++i) {\n if (this.colorAttachments[i]) {\n const resizedTexture = this.device._createTexture({...this.colorAttachments[i].props, width, height})\n this.colorAttachments[i].destroy();\n this.colorAttachments[i] = resizedTexture;\n this.renderPassDescriptor.colorAttachments[i].view = resizedTexture.handle.createView();\n }\n }\n\n if (this.depthStencilAttachment) {\n const resizedTexture = this.device._createTexture({...this.depthStencilAttachment.props, width, height})\n this.depthStencilAttachment.destroy();\n this.depthStencilAttachment = resizedTexture;\n this.renderPassDescriptor.depthStencilAttachment.view = resizedTexture.handle.createView();\n }\n }\n}\n"],"mappings":";AACA,SAAQA,WAAW,EAAEC,OAAO,QAAO,cAAc;AAAC,OAG3CC,aAAa;AAWpB,eAAe,MAAMC,iBAAiB,SAASH,WAAW,CAAC;EAczDI,WAAWA,CAACC,MAAoB,EAAEC,KAAuB,EAAE;IACzD,KAAK,CAACD,MAAM,EAAEC,KAAK,CAAC;IAACC,eAAA;IAAAA,eAAA,2BAZa,EAAE;IAAAA,eAAA,iCACS,IAAI;IAAAA,eAAA,+BAM/C;MACFC,gBAAgB,EAAE;IACpB,CAAC;IAIC,IAAI,CAACH,MAAM,GAAGA,MAAM;IAEpB,IAAIC,KAAK,CAACG,sBAAsB,EAAE;MAChC,IAAI,CAACA,sBAAsB,GAAG,IAAI,CAACC,yBAAyB,CAACJ,KAAK,CAAC;IACrE;IAEA,IAAIA,KAAK,CAACE,gBAAgB,EAAE;MAC1B,IAAI,CAACA,gBAAgB,GAAGF,KAAK,CAACE,gBAAgB,CAACG,GAAG,CAACC,eAAe,IAAI,IAAI,CAACC,kBAAkB,CAAC,IAAI,CAACP,KAAK,EAAEM,eAAe,CAAC,CAAC;IAC7H;IAEA,IAAI,IAAI,CAACH,sBAAsB,EAAE;MAC/B,IAAI,CAACK,oBAAoB,CAACL,sBAAsB,GAAG;QACjDM,IAAI,EAAE,IAAI,CAACN,sBAAsB,CAACO,MAAM,CAACC,UAAU,EAAE;QAErDC,eAAe,EAAE,GAAG;QACpBC,YAAY,EAAE,OAAO;QACrBC,iBAAiB,EAAE,CAAC;QACpBC,cAAc,EAAE;MAClB,CAAC;IACH;IAEA,I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ma.gl/api';
|
|
3
|
-
import WebGPUDevice from '../webgpu-device.js';
|
|
4
1
|
|
|
5
|
-
|
|
6
|
-
handle?: any;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
const DEFAULT_QUERY_PROPS: Required<WebGPUQueryProps> = {
|
|
10
|
-
id: undefined,
|
|
11
|
-
handle: undefined,
|
|
12
|
-
userData: undefined,
|
|
13
|
-
type: 'timestamp',
|
|
14
|
-
count: 1,
|
|
15
|
-
pipelineStatistics: []
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Immutable
|
|
20
|
-
*
|
|
21
|
-
class WebGPUQuery extends Resource<WebGPUQueryProps> implements Query {
|
|
22
|
-
readonly device: WebGPUDevice;
|
|
23
|
-
readonly handle: GPUQuerySet;
|
|
24
|
-
|
|
25
|
-
constructor(device: WebGPUDevice, props: WebGPUQueryProps) {
|
|
26
|
-
super(device, props, DEFAULT_QUERY_PROPS);
|
|
27
|
-
this.handle = this.props.handle as GPUQuerySet || this.createHandle();
|
|
28
|
-
this.handle.label = this.props.id;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
protected createHandle() {
|
|
32
|
-
return this.device.handle.createQuerySet({
|
|
33
|
-
type: this.props.type,
|
|
34
|
-
count: this.props.count,
|
|
35
|
-
pipelineStatistics: this.props.pipelineStatistics
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
override destroy(): void {
|
|
40
|
-
this.handle.destroy();
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
*/
|
|
2
|
+
//# sourceMappingURL=webgpu-query.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webgpu-query.js","names":[],"sources":["../../../src/adapter/resources/webgpu-query.ts"],"sourcesContent":["/*\nimport {Resource, Query, QueryProps} from '@luma.gl/api';\nimport {WebGPUDevice} from '../webgpu-device';\n\nexport type WebGPUQueryProps = QueryProps & {\n handle?: any;\n};\n\nconst DEFAULT_QUERY_PROPS: Required<WebGPUQueryProps> = {\n id: undefined,\n handle: undefined,\n userData: undefined,\n type: 'timestamp',\n count: 1,\n pipelineStatistics: []\n};\n\n/**\n * Immutable\n *\nclass WebGPUQuery extends Resource<WebGPUQueryProps> implements Query {\n readonly device: WebGPUDevice;\n readonly handle: GPUQuerySet;\n\n constructor(device: WebGPUDevice, props: WebGPUQueryProps) {\n super(device, props, DEFAULT_QUERY_PROPS);\n this.handle = this.props.handle as GPUQuerySet || this.createHandle();\n this.handle.label = this.props.id;\n }\n\n protected createHandle() {\n return this.device.handle.createQuerySet({\n type: this.props.type,\n count: this.props.count,\n pipelineStatistics: this.props.pipelineStatistics\n });\n }\n\n override destroy(): void {\n this.handle.destroy();\n }\n}\n*/"],"mappings":""}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/// <reference types="
|
|
1
|
+
/// <reference types="dist" />
|
|
2
2
|
import type { RenderPassProps, RenderPassParameters, Binding } from '@luma.gl/api';
|
|
3
3
|
import { Buffer, RenderPass, RenderPipeline } from '@luma.gl/api';
|
|
4
|
-
import WebGPUDevice from '../webgpu-device';
|
|
4
|
+
import { WebGPUDevice } from '../webgpu-device';
|
|
5
5
|
import WebGPURenderPipeline from './webgpu-render-pipeline';
|
|
6
6
|
export default class WebGPURenderPass extends RenderPass {
|
|
7
7
|
readonly device: WebGPUDevice;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgpu-render-pass.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-render-pass.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAC,eAAe,EAAE,oBAAoB,EAAE,OAAO,EAAC,MAAM,cAAc,CAAC;AACjF,OAAO,EAAC,MAAM,EAAE,UAAU,EAAE,cAAc,EAAO,MAAM,cAAc,CAAC;AACtE,OAAO,YAAY,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"webgpu-render-pass.d.ts","sourceRoot":"","sources":["../../../src/ad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AAM,CAAC;KACrB,GAAG,IAAI;IAmBR,YAAY,IAAI,IAAI;IAKpB,aAAa,CAAC,UAAU,EAAE,oBAAoB,GAAG,IAAI;IAwBrD,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAGxC,aAAa,IAAI,IAAI;IAGrB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;CAW7C"}
|
|
@@ -1,73 +1,79 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
1
2
|
import { RenderPass, cast } from '@luma.gl/api';
|
|
2
3
|
export default class WebGPURenderPass extends RenderPass {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
constructor(device) {
|
|
5
|
+
let props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
6
|
+
super(device, props);
|
|
7
|
+
_defineProperty(this, "device", void 0);
|
|
8
|
+
_defineProperty(this, "handle", void 0);
|
|
9
|
+
_defineProperty(this, "pipeline", null);
|
|
10
|
+
this.device = device;
|
|
11
|
+
const framebuffer = props.framebuffer || device.canvasContext.getCurrentFramebuffer();
|
|
12
|
+
const renderPassDescriptor = framebuffer.renderPassDescriptor;
|
|
13
|
+
this.handle = this.props.handle || device.commandEncoder.beginRenderPass(renderPassDescriptor);
|
|
14
|
+
this.handle.label = this.props.id;
|
|
15
|
+
}
|
|
16
|
+
destroy() {}
|
|
17
|
+
end() {
|
|
18
|
+
this.handle.end();
|
|
19
|
+
}
|
|
20
|
+
setPipeline(pipeline) {
|
|
21
|
+
this.pipeline = cast(pipeline);
|
|
22
|
+
this.handle.setPipeline(this.pipeline.handle);
|
|
23
|
+
}
|
|
24
|
+
setBindings(bindings) {
|
|
25
|
+
var _this$pipeline, _this$pipeline2;
|
|
26
|
+
(_this$pipeline = this.pipeline) === null || _this$pipeline === void 0 ? void 0 : _this$pipeline.setBindings(bindings);
|
|
27
|
+
const bindGroup = (_this$pipeline2 = this.pipeline) === null || _this$pipeline2 === void 0 ? void 0 : _this$pipeline2._getBindGroup();
|
|
28
|
+
if (bindGroup) {
|
|
29
|
+
this.handle.setBindGroup(0, bindGroup);
|
|
13
30
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
31
|
+
}
|
|
32
|
+
setIndexBuffer(buffer, indexFormat) {
|
|
33
|
+
let offset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
34
|
+
let size = arguments.length > 3 ? arguments[3] : undefined;
|
|
35
|
+
this.handle.setIndexBuffer(cast(buffer).handle, indexFormat, offset, size);
|
|
36
|
+
}
|
|
37
|
+
setVertexBuffer(slot, buffer) {
|
|
38
|
+
let offset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
39
|
+
this.handle.setVertexBuffer(slot, cast(buffer).handle, offset);
|
|
40
|
+
}
|
|
41
|
+
draw(options) {
|
|
42
|
+
if (options.indexCount) {
|
|
43
|
+
this.handle.drawIndexed(options.indexCount, options.instanceCount, options.firstIndex, options.baseVertex, options.firstInstance);
|
|
44
|
+
} else {
|
|
45
|
+
this.handle.draw(options.vertexCount || 0, options.instanceCount, options.firstIndex, options.firstInstance);
|
|
17
46
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
47
|
+
}
|
|
48
|
+
drawIndirect() {}
|
|
49
|
+
setParameters(parameters) {
|
|
50
|
+
const {
|
|
51
|
+
blendConstant,
|
|
52
|
+
stencilReference,
|
|
53
|
+
scissorRect,
|
|
54
|
+
viewport
|
|
55
|
+
} = parameters;
|
|
56
|
+
if (blendConstant) {
|
|
57
|
+
this.handle.setBlendConstant(blendConstant);
|
|
21
58
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
this.pipeline?.setBindings(bindings);
|
|
25
|
-
const bindGroup = this.pipeline?._getBindGroup();
|
|
26
|
-
if (bindGroup) {
|
|
27
|
-
this.handle.setBindGroup(0, bindGroup);
|
|
28
|
-
}
|
|
59
|
+
if (stencilReference) {
|
|
60
|
+
this.handle.setStencilReference(stencilReference);
|
|
29
61
|
}
|
|
30
|
-
|
|
31
|
-
|
|
62
|
+
if (scissorRect) {
|
|
63
|
+
this.handle.setScissorRect(scissorRect[0], scissorRect[1], scissorRect[2], scissorRect[3]);
|
|
32
64
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
draw(options) {
|
|
37
|
-
if (options.indexCount) {
|
|
38
|
-
this.handle.drawIndexed(options.indexCount, options.instanceCount, options.firstIndex, options.baseVertex, options.firstInstance);
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
this.handle.draw(options.vertexCount || 0, options.instanceCount, options.firstIndex, options.firstInstance);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
drawIndirect() {
|
|
45
|
-
// drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
|
|
46
|
-
// drawIndexedIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
|
|
47
|
-
}
|
|
48
|
-
setParameters(parameters) {
|
|
49
|
-
const { blendConstant, stencilReference, scissorRect, viewport } = parameters;
|
|
50
|
-
if (blendConstant) {
|
|
51
|
-
this.handle.setBlendConstant(blendConstant);
|
|
52
|
-
}
|
|
53
|
-
if (stencilReference) {
|
|
54
|
-
this.handle.setStencilReference(stencilReference);
|
|
55
|
-
}
|
|
56
|
-
if (scissorRect) {
|
|
57
|
-
this.handle.setScissorRect(scissorRect[0], scissorRect[1], scissorRect[2], scissorRect[3]);
|
|
58
|
-
}
|
|
59
|
-
// TODO - explain how 3 dimensions vs 2 in WebGL works.
|
|
60
|
-
if (viewport) {
|
|
61
|
-
this.handle.setViewport(viewport[0], viewport[1], viewport[2], viewport[3], viewport[4], viewport[5]);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
pushDebugGroup(groupLabel) {
|
|
65
|
-
this.handle.pushDebugGroup(groupLabel);
|
|
66
|
-
}
|
|
67
|
-
popDebugGroup() {
|
|
68
|
-
this.handle.popDebugGroup();
|
|
69
|
-
}
|
|
70
|
-
insertDebugMarker(markerLabel) {
|
|
71
|
-
this.handle.insertDebugMarker(markerLabel);
|
|
65
|
+
if (viewport) {
|
|
66
|
+
this.handle.setViewport(viewport[0], viewport[1], viewport[2], viewport[3], viewport[4], viewport[5]);
|
|
72
67
|
}
|
|
68
|
+
}
|
|
69
|
+
pushDebugGroup(groupLabel) {
|
|
70
|
+
this.handle.pushDebugGroup(groupLabel);
|
|
71
|
+
}
|
|
72
|
+
popDebugGroup() {
|
|
73
|
+
this.handle.popDebugGroup();
|
|
74
|
+
}
|
|
75
|
+
insertDebugMarker(markerLabel) {
|
|
76
|
+
this.handle.insertDebugMarker(markerLabel);
|
|
77
|
+
}
|
|
73
78
|
}
|
|
79
|
+
//# sourceMappingURL=webgpu-render-pass.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webgpu-render-pass.js","names":["RenderPass","cast","WebGPURenderPass","constructor","device","props","arguments","length","undefined","_defineProperty","framebuffer","canvasContext","getCurrentFramebuffer","renderPassDescriptor","handle","commandEncoder","beginRenderPass","label","id","destroy","end","setPipeline","pipeline","setBindings","bindings","_this$pipeline","_this$pipeline2","bindGroup","_getBindGroup","setBindGroup","setIndexBuffer","buffer","indexFormat","offset","size","setVertexBuffer","slot","draw","options","indexCount","drawIndexed","instanceCount","firstIndex","baseVertex","firstInstance","vertexCount","drawIndirect","setParameters","parameters","blendConstant","stencilReference","scissorRect","viewport","setBlendConstant","setStencilReference","setScissorRect","setViewport","pushDebugGroup","groupLabel","popDebugGroup","insertDebugMarker","markerLabel"],"sources":["../../../src/adapter/resources/webgpu-render-pass.ts"],"sourcesContent":["import type {RenderPassProps, RenderPassParameters, Binding} from '@luma.gl/api';\nimport {Buffer, RenderPass, RenderPipeline, cast} from '@luma.gl/api';\nimport {WebGPUDevice} from '../webgpu-device';\nimport WebGPUBuffer from './webgpu-buffer';\n// import WebGPUCommandEncoder from './webgpu-command-encoder';\nimport WebGPURenderPipeline from './webgpu-render-pipeline';\n\nexport default class WebGPURenderPass extends RenderPass {\n readonly device: WebGPUDevice;\n readonly handle: GPURenderPassEncoder;\n\n /** Active pipeline */\n pipeline: WebGPURenderPipeline | null = null;\n\n constructor(device: WebGPUDevice, props: RenderPassProps = {}) {\n super(device, props);\n this.device = device;\n const framebuffer = props.framebuffer || device.canvasContext.getCurrentFramebuffer();\n // @ts-expect-error\n const renderPassDescriptor = framebuffer.renderPassDescriptor;\n this.handle = this.props.handle || device.commandEncoder.beginRenderPass(renderPassDescriptor);\n this.handle.label = this.props.id;\n }\n\n override destroy(): void {}\n\n end(): void {\n this.handle.end();\n }\n\n setPipeline(pipeline: RenderPipeline): void {\n this.pipeline = cast<WebGPURenderPipeline>(pipeline);\n this.handle.setPipeline(this.pipeline.handle);\n }\n\n /** Sets an array of bindings (uniform buffers, samplers, textures, ...) */\n setBindings(bindings: Record<string, Binding>): void {\n this.pipeline?.setBindings(bindings);\n const bindGroup = this.pipeline?._getBindGroup();\n if (bindGroup) {\n this.handle.setBindGroup(0, bindGroup);\n }\n }\n\n setIndexBuffer(\n buffer: Buffer,\n indexFormat: GPUIndexFormat,\n offset: number = 0,\n size?: number\n ): void {\n this.handle.setIndexBuffer(cast<WebGPUBuffer>(buffer).handle, indexFormat, offset, size);\n }\n\n setVertexBuffer(slot: number, buffer: Buffer, offset: number = 0): void {\n this.handle.setVertexBuffer(slot, cast<WebGPUBuffer>(buffer).handle, offset);\n }\n\n draw(options: {\n vertexCount?: number;\n indexCount?: number;\n instanceCount?: number;\n firstVertex?: number;\n firstIndex?: number;\n firstInstance?: number;\n baseVertex?: number;\n }): void {\n if (options.indexCount) {\n this.handle.drawIndexed(\n options.indexCount,\n options.instanceCount,\n options.firstIndex,\n options.baseVertex,\n options.firstInstance\n );\n } else {\n this.handle.draw(\n options.vertexCount || 0,\n options.instanceCount,\n options.firstIndex,\n options.firstInstance\n );\n }\n }\n\n drawIndirect(): void {\n // drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;\n // drawIndexedIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;\n }\n\n setParameters(parameters: RenderPassParameters): void {\n const {blendConstant, stencilReference, scissorRect, viewport} = parameters;\n if (blendConstant) {\n this.handle.setBlendConstant(blendConstant);\n }\n if (stencilReference) {\n this.handle.setStencilReference(stencilReference);\n }\n if (scissorRect) {\n this.handle.setScissorRect(scissorRect[0], scissorRect[1], scissorRect[2], scissorRect[3]);\n }\n // TODO - explain how 3 dimensions vs 2 in WebGL works.\n if (viewport) {\n this.handle.setViewport(\n viewport[0],\n viewport[1],\n viewport[2],\n viewport[3],\n viewport[4],\n viewport[5]\n );\n }\n }\n\n pushDebugGroup(groupLabel: string): void {\n this.handle.pushDebugGroup(groupLabel);\n }\n popDebugGroup(): void {\n this.handle.popDebugGroup();\n }\n insertDebugMarker(markerLabel: string): void {\n this.handle.insertDebugMarker(markerLabel);\n }\n\n // writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;\n // beginOcclusionQuery(queryIndex: number): void;\n // endOcclusionQuery(): void;\n // beginPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;\n // endPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;\n\n // executeBundles(bundles: Iterable<GPURenderBundle>): void;\n}\n"],"mappings":";AACA,SAAgBA,UAAU,EAAkBC,IAAI,QAAO,cAAc;AAMrE,eAAe,MAAMC,gBAAgB,SAASF,UAAU,CAAC;EAOvDG,WAAWA,CAACC,MAAoB,EAA+B;IAAA,IAA7BC,KAAsB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;IAC3D,KAAK,CAACF,MAAM,EAAEC,KAAK,CAAC;IAACI,eAAA;IAAAA,eAAA;IAAAA,eAAA,mBAHiB,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IC,WAAW,EAAE;MACf,IAAI,CAACrC,MAAM,CAACyC,cAAc,CAACJ,WAAW,CAAC,CAAC,CAAC,EAAEA,WAAW,CAAC,CAAC,CAAC,EAAEA,WAAW,CAAC,CAAC,CAAC,EAAEA,WAAW,CAAC,CAAC,CAAC,CAAC;IAC5F;IAEA,IAAIC,QAAQ,EAAE;MACZ,IAAI,CAACtC,MAAM,CAAC0C,WAAW,CACrBJ,QAAQ,CAAC,CAAC,CAAC,EACXA,QAAQ,CAAC,CAAC,CAAC,EACXA,QAAQ,CAAC,CAAC,CAAC,EACXA,QAAQ,CAAC,CAAC,CAAC,EACXA,QAAQ,CAAC,CAAC,CAAC,EACXA,QAAQ,CAAC,CAAC,CAAC,CACZ;IACH;EACF;EAEAK,cAAcA,CAACC,UAAkB,EAAQ;IACvC,IAAI,CAAC5C,MAAM,CAAC2C,cAAc,CAACC,UAAU,CAAC;EACxC;EACAC,aAAaA,CAAA,EAAS;IACpB,IAAI,CAAC7C,MAAM,CAAC6C,aAAa,EAAE;EAC7B;EACAC,iBAAiBA,CAACC,WAAmB,EAAQ;IAC3C,IAAI,CAAC/C,MAAM,CAAC8C,iBAAiB,CAACC,WAAW,CAAC;EAC5C;AASF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/// <reference types="
|
|
1
|
+
/// <reference types="dist" />
|
|
2
2
|
import type { Binding, RenderPass } from '@luma.gl/api';
|
|
3
3
|
import { Buffer, RenderPipeline, RenderPipelineProps } from '@luma.gl/api';
|
|
4
|
-
import type WebGPUDevice from '../webgpu-device';
|
|
4
|
+
import type { WebGPUDevice } from '../webgpu-device';
|
|
5
5
|
import type WebGPUShader from './webgpu-shader';
|
|
6
6
|
import type WebGPURenderPass from './webgpu-render-pass';
|
|
7
7
|
/** Creates a new render pipeline when parameters change */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgpu-render-pipeline.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-render-pipeline.ts"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