holostaff-widget 3.0.2 → 3.0.4
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/{CanvasRenderer-BL1L0Zug.js → CanvasRenderer-DtJMGjQ-.js} +50 -50
- package/dist/{CanvasRenderer-BL1L0Zug.js.map → CanvasRenderer-DtJMGjQ-.js.map} +1 -1
- package/dist/Filter-BZ0p_cLc.js +670 -0
- package/dist/Filter-BZ0p_cLc.js.map +1 -0
- package/dist/GpuStencilModesToPixi-BhdxrQzF.js +222 -0
- package/dist/GpuStencilModesToPixi-BhdxrQzF.js.map +1 -0
- package/dist/{RenderTargetSystem-CahYKOD4.js → RenderTargetSystem-Cbru8Ci0.js} +327 -391
- package/dist/RenderTargetSystem-Cbru8Ci0.js.map +1 -0
- package/dist/WebGLRenderer--845IaSu.js +2237 -0
- package/dist/WebGLRenderer--845IaSu.js.map +1 -0
- package/dist/{WebGPURenderer-SF1OSYpo.js → WebGPURenderer-DBDzoMAw.js} +281 -374
- package/dist/WebGPURenderer-DBDzoMAw.js.map +1 -0
- package/dist/{browserAll-B97ymwYI.js → browserAll-CIOBMh08.js} +3 -3
- package/dist/{browserAll-B97ymwYI.js.map → browserAll-CIOBMh08.js.map} +1 -1
- package/dist/{getTextureBatchBindGroup-BPB_9pp9.js → getTextureBatchBindGroup-DCKtteRk.js} +3 -3
- package/dist/{getTextureBatchBindGroup-BPB_9pp9.js.map → getTextureBatchBindGroup-DCKtteRk.js.map} +1 -1
- package/dist/hs-widget.es.js +2 -2
- package/dist/hs-widget.umd.js +360 -346
- package/dist/hs-widget.umd.js.map +1 -1
- package/dist/{index-qJyFW51-.js → index-BbQvHSpa.js} +11198 -9102
- package/dist/index-BbQvHSpa.js.map +1 -0
- package/dist/{webworkerAll-DYG_wBG4.js → webworkerAll-EB5JX-2r.js} +12 -12
- package/dist/{webworkerAll-DYG_wBG4.js.map → webworkerAll-EB5JX-2r.js.map} +1 -1
- package/package.json +1 -1
- package/dist/BufferResource-6mO-PO_c.js +0 -537
- package/dist/BufferResource-6mO-PO_c.js.map +0 -1
- package/dist/Geometry-B-K9I6MO.js +0 -1017
- package/dist/Geometry-B-K9I6MO.js.map +0 -1
- package/dist/RenderTargetSystem-CahYKOD4.js.map +0 -1
- package/dist/WebGLRenderer-Ci14rIHw.js +0 -2939
- package/dist/WebGLRenderer-Ci14rIHw.js.map +0 -1
- package/dist/WebGPURenderer-SF1OSYpo.js.map +0 -1
- package/dist/index-qJyFW51-.js.map +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { D as x, n as
|
|
2
|
-
import { g as D } from "./getTextureBatchBindGroup-
|
|
3
|
-
import { G as k, f as
|
|
4
|
-
import {
|
|
5
|
-
import { S as
|
|
6
|
-
class
|
|
1
|
+
import { D as x, n as w, G as ue, E as l, u as ce, B as S, f as de, h as he, c as M, w as v, i as y, j as pe, k as le, d as L, M as A, T as R, A as fe, e as B, l as ge } from "./index-BbQvHSpa.js";
|
|
2
|
+
import { g as D } from "./getTextureBatchBindGroup-DCKtteRk.js";
|
|
3
|
+
import { G as k, f as me, S as T, R as _e, c as F, a as be, r as O, g as ye, b as xe, d as Ge } from "./RenderTargetSystem-Cbru8Ci0.js";
|
|
4
|
+
import { G as Pe, e as Be, l as Se, a as Te, t as Ce } from "./GpuStencilModesToPixi-BhdxrQzF.js";
|
|
5
|
+
import { S as I, B as H, a as W, R as ve } from "./Filter-BZ0p_cLc.js";
|
|
6
|
+
class Ue {
|
|
7
7
|
constructor(e) {
|
|
8
8
|
this._canvasPool = /* @__PURE__ */ Object.create(null), this.canvasOptions = e || {}, this.enableFullScreen = !1;
|
|
9
9
|
}
|
|
@@ -26,40 +26,40 @@ class Ee {
|
|
|
26
26
|
* @returns The new render texture.
|
|
27
27
|
*/
|
|
28
28
|
getOptimalCanvasAndContext(e, t, r = 1) {
|
|
29
|
-
e = Math.ceil(e * r - 1e-6), t = Math.ceil(t * r - 1e-6), e =
|
|
29
|
+
e = Math.ceil(e * r - 1e-6), t = Math.ceil(t * r - 1e-6), e = w(e), t = w(t);
|
|
30
30
|
const s = (e << 17) + (t << 1);
|
|
31
31
|
this._canvasPool[s] || (this._canvasPool[s] = []);
|
|
32
|
-
let
|
|
33
|
-
return
|
|
32
|
+
let n = this._canvasPool[s].pop();
|
|
33
|
+
return n || (n = this._createCanvasAndContext(e, t)), n;
|
|
34
34
|
}
|
|
35
35
|
/**
|
|
36
36
|
* Place a render texture back into the pool.
|
|
37
37
|
* @param canvasAndContext
|
|
38
38
|
*/
|
|
39
39
|
returnCanvasAndContext(e) {
|
|
40
|
-
const t = e.canvas, { width: r, height: s } = t,
|
|
41
|
-
e.context.resetTransform(), e.context.clearRect(0, 0, r, s), this._canvasPool[
|
|
40
|
+
const t = e.canvas, { width: r, height: s } = t, n = (r << 17) + (s << 1);
|
|
41
|
+
e.context.resetTransform(), e.context.clearRect(0, 0, r, s), this._canvasPool[n].push(e);
|
|
42
42
|
}
|
|
43
43
|
clear() {
|
|
44
44
|
this._canvasPool = {};
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
const C = new
|
|
48
|
-
|
|
49
|
-
const P =
|
|
47
|
+
const C = new Ue();
|
|
48
|
+
ue.register(C);
|
|
49
|
+
const P = I.for2d();
|
|
50
50
|
class V {
|
|
51
51
|
start(e, t, r) {
|
|
52
|
-
const s = e.renderer,
|
|
53
|
-
this._shader = r, this._geometry = t,
|
|
52
|
+
const s = e.renderer, n = s.encoder, i = r.gpuProgram;
|
|
53
|
+
this._shader = r, this._geometry = t, n.setGeometry(t, i), P.blendMode = "normal", s.pipeline.getPipeline(
|
|
54
54
|
t,
|
|
55
|
-
|
|
55
|
+
i,
|
|
56
56
|
P
|
|
57
57
|
);
|
|
58
58
|
const o = s.globalUniforms.bindGroup;
|
|
59
|
-
|
|
59
|
+
n.resetBindGroup(1), n.setBindGroup(0, o, i);
|
|
60
60
|
}
|
|
61
61
|
execute(e, t) {
|
|
62
|
-
const r = this._shader.gpuProgram, s = e.renderer,
|
|
62
|
+
const r = this._shader.gpuProgram, s = e.renderer, n = s.encoder;
|
|
63
63
|
if (!t.bindGroup) {
|
|
64
64
|
const u = t.textures;
|
|
65
65
|
t.bindGroup = D(
|
|
@@ -69,7 +69,7 @@ class V {
|
|
|
69
69
|
);
|
|
70
70
|
}
|
|
71
71
|
P.blendMode = t.blendMode;
|
|
72
|
-
const
|
|
72
|
+
const i = s.bindGroup.getBindGroup(
|
|
73
73
|
t.bindGroup,
|
|
74
74
|
r,
|
|
75
75
|
1
|
|
@@ -79,12 +79,12 @@ class V {
|
|
|
79
79
|
P,
|
|
80
80
|
t.topology
|
|
81
81
|
);
|
|
82
|
-
t.bindGroup._touch(s.gc.now, s.tick),
|
|
82
|
+
t.bindGroup._touch(s.gc.now, s.tick), n.setPipeline(o), n.renderPassEncoder.setBindGroup(1, i), n.renderPassEncoder.drawIndexed(t.size, 1, t.start);
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
V.extension = {
|
|
86
86
|
type: [
|
|
87
|
-
|
|
87
|
+
l.WebGPUPipesAdaptor
|
|
88
88
|
],
|
|
89
89
|
name: "batch"
|
|
90
90
|
};
|
|
@@ -99,48 +99,48 @@ class N {
|
|
|
99
99
|
return e._updateKey(), this._hash[e._key] || this._createBindGroup(e, t, r);
|
|
100
100
|
}
|
|
101
101
|
_createBindGroup(e, t, r) {
|
|
102
|
-
const s = this._gpu.device,
|
|
103
|
-
for (const f in
|
|
104
|
-
const h = e.resources[f] ?? e.resources[
|
|
105
|
-
let
|
|
102
|
+
const s = this._gpu.device, n = t.layout[r], i = [], o = this._renderer;
|
|
103
|
+
for (const f in n) {
|
|
104
|
+
const h = e.resources[f] ?? e.resources[n[f]];
|
|
105
|
+
let p;
|
|
106
106
|
if (h._resourceType === "uniformGroup") {
|
|
107
107
|
const d = h;
|
|
108
108
|
o.ubo.updateUniformGroup(d);
|
|
109
109
|
const g = d.buffer;
|
|
110
|
-
|
|
110
|
+
p = {
|
|
111
111
|
buffer: o.buffer.getGPUBuffer(g),
|
|
112
112
|
offset: 0,
|
|
113
113
|
size: g.descriptor.size
|
|
114
114
|
};
|
|
115
115
|
} else if (h._resourceType === "buffer") {
|
|
116
116
|
const d = h;
|
|
117
|
-
|
|
117
|
+
p = {
|
|
118
118
|
buffer: o.buffer.getGPUBuffer(d),
|
|
119
119
|
offset: 0,
|
|
120
120
|
size: d.descriptor.size
|
|
121
121
|
};
|
|
122
122
|
} else if (h._resourceType === "bufferResource") {
|
|
123
123
|
const d = h;
|
|
124
|
-
|
|
124
|
+
p = {
|
|
125
125
|
buffer: o.buffer.getGPUBuffer(d.buffer),
|
|
126
126
|
offset: d.offset,
|
|
127
127
|
size: d.size
|
|
128
128
|
};
|
|
129
129
|
} else if (h._resourceType === "textureSampler") {
|
|
130
130
|
const d = h;
|
|
131
|
-
|
|
131
|
+
p = o.texture.getGpuSampler(d);
|
|
132
132
|
} else if (h._resourceType === "textureSource") {
|
|
133
133
|
const d = h;
|
|
134
|
-
|
|
134
|
+
p = o.texture.getTextureView(d);
|
|
135
135
|
}
|
|
136
|
-
|
|
137
|
-
binding:
|
|
138
|
-
resource:
|
|
136
|
+
i.push({
|
|
137
|
+
binding: n[f],
|
|
138
|
+
resource: p
|
|
139
139
|
});
|
|
140
140
|
}
|
|
141
141
|
const u = o.shader.getProgramData(t).bindGroups[r], c = s.createBindGroup({
|
|
142
142
|
layout: u,
|
|
143
|
-
entries:
|
|
143
|
+
entries: i
|
|
144
144
|
});
|
|
145
145
|
return this._hash[e._key] = c, c;
|
|
146
146
|
}
|
|
@@ -150,11 +150,11 @@ class N {
|
|
|
150
150
|
}
|
|
151
151
|
N.extension = {
|
|
152
152
|
type: [
|
|
153
|
-
|
|
153
|
+
l.WebGPUSystem
|
|
154
154
|
],
|
|
155
155
|
name: "bindGroup"
|
|
156
156
|
};
|
|
157
|
-
class
|
|
157
|
+
class we {
|
|
158
158
|
constructor(e) {
|
|
159
159
|
this.gpuBuffer = e;
|
|
160
160
|
}
|
|
@@ -162,7 +162,7 @@ class Le {
|
|
|
162
162
|
this.gpuBuffer.destroy(), this.gpuBuffer = null;
|
|
163
163
|
}
|
|
164
164
|
}
|
|
165
|
-
class
|
|
165
|
+
class z {
|
|
166
166
|
constructor(e) {
|
|
167
167
|
this._renderer = e, this._managedBuffers = new k({
|
|
168
168
|
renderer: e,
|
|
@@ -198,12 +198,12 @@ class j {
|
|
|
198
198
|
}
|
|
199
199
|
createGPUBuffer(e) {
|
|
200
200
|
const t = this._gpu.device.createBuffer(e.descriptor);
|
|
201
|
-
return e._updateID = 0, e._resourceId =
|
|
201
|
+
return e._updateID = 0, e._resourceId = ce("resource"), e.data && (me(
|
|
202
202
|
e.data.buffer,
|
|
203
203
|
t.getMappedRange(),
|
|
204
204
|
e.data.byteOffset,
|
|
205
205
|
e.data.byteLength
|
|
206
|
-
), t.unmap()), e._gpuData[this._renderer.uid] = new
|
|
206
|
+
), t.unmap()), e._gpuData[this._renderer.uid] = new we(t), this._managedBuffers.add(e) && (e.on("update", this.updateBuffer, this), e.on("change", this.onBufferChange, this)), t;
|
|
207
207
|
}
|
|
208
208
|
onBufferChange(e) {
|
|
209
209
|
this._managedBuffers.remove(e), e._updateID = 0, this.createGPUBuffer(e);
|
|
@@ -212,13 +212,13 @@ class j {
|
|
|
212
212
|
this._managedBuffers.destroy(), this._renderer = null, this._gpu = null;
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
|
-
|
|
215
|
+
z.extension = {
|
|
216
216
|
type: [
|
|
217
|
-
|
|
217
|
+
l.WebGPUSystem
|
|
218
218
|
],
|
|
219
219
|
name: "buffer"
|
|
220
220
|
};
|
|
221
|
-
class
|
|
221
|
+
class Me {
|
|
222
222
|
constructor({ minUniformOffsetAlignment: e }) {
|
|
223
223
|
this._minUniformOffsetAlignment = 256, this.byteIndex = 0, this._minUniformOffsetAlignment = e, this.data = new Float32Array(65535);
|
|
224
224
|
}
|
|
@@ -244,7 +244,7 @@ class Ae {
|
|
|
244
244
|
this.data = null;
|
|
245
245
|
}
|
|
246
246
|
}
|
|
247
|
-
class
|
|
247
|
+
class j {
|
|
248
248
|
constructor(e) {
|
|
249
249
|
this._colorMaskCache = 15, this._renderer = e;
|
|
250
250
|
}
|
|
@@ -255,13 +255,13 @@ class K {
|
|
|
255
255
|
this._renderer = null, this._colorMaskCache = null;
|
|
256
256
|
}
|
|
257
257
|
}
|
|
258
|
-
|
|
258
|
+
j.extension = {
|
|
259
259
|
type: [
|
|
260
|
-
|
|
260
|
+
l.WebGPUSystem
|
|
261
261
|
],
|
|
262
262
|
name: "colorMask"
|
|
263
263
|
};
|
|
264
|
-
class
|
|
264
|
+
class U {
|
|
265
265
|
/**
|
|
266
266
|
* @param {WebGPURenderer} renderer - The renderer this System works for.
|
|
267
267
|
*/
|
|
@@ -295,7 +295,7 @@ class w {
|
|
|
295
295
|
"texture-compression-bc",
|
|
296
296
|
"texture-compression-astc",
|
|
297
297
|
"texture-compression-etc2"
|
|
298
|
-
].filter((
|
|
298
|
+
].filter((n) => t.features.has(n)), s = await t.requestDevice({
|
|
299
299
|
requiredFeatures: r
|
|
300
300
|
});
|
|
301
301
|
return { adapter: t, device: s };
|
|
@@ -304,13 +304,13 @@ class w {
|
|
|
304
304
|
this.gpu = null, this._renderer = null;
|
|
305
305
|
}
|
|
306
306
|
}
|
|
307
|
-
|
|
307
|
+
U.extension = {
|
|
308
308
|
type: [
|
|
309
|
-
|
|
309
|
+
l.WebGPUSystem
|
|
310
310
|
],
|
|
311
311
|
name: "device"
|
|
312
312
|
};
|
|
313
|
-
|
|
313
|
+
U.defaultOptions = {
|
|
314
314
|
/**
|
|
315
315
|
* {@link WebGPUOptions.powerPreference}
|
|
316
316
|
* @default default
|
|
@@ -322,7 +322,7 @@ w.defaultOptions = {
|
|
|
322
322
|
*/
|
|
323
323
|
forceFallbackAdapter: !1
|
|
324
324
|
};
|
|
325
|
-
class
|
|
325
|
+
class K {
|
|
326
326
|
constructor(e) {
|
|
327
327
|
this._boundBindGroup = /* @__PURE__ */ Object.create(null), this._boundVertexBuffer = /* @__PURE__ */ Object.create(null), this._renderer = e;
|
|
328
328
|
}
|
|
@@ -341,8 +341,8 @@ class q {
|
|
|
341
341
|
this.renderPassEncoder.setViewport(e.x, e.y, e.width, e.height, 0, 1);
|
|
342
342
|
}
|
|
343
343
|
setPipelineFromGeometryProgramAndState(e, t, r, s) {
|
|
344
|
-
const
|
|
345
|
-
this.setPipeline(
|
|
344
|
+
const n = this._renderer.pipeline.getPipeline(e, t, r, s);
|
|
345
|
+
this.setPipeline(n);
|
|
346
346
|
}
|
|
347
347
|
setPipeline(e) {
|
|
348
348
|
this._boundPipeline !== e && (this._boundPipeline = e, this.renderPassEncoder.setPipeline(e));
|
|
@@ -384,12 +384,12 @@ class q {
|
|
|
384
384
|
}
|
|
385
385
|
}
|
|
386
386
|
draw(e) {
|
|
387
|
-
const { geometry: t, shader: r, state: s, topology:
|
|
388
|
-
this.setPipelineFromGeometryProgramAndState(t, r.gpuProgram, s,
|
|
389
|
-
|
|
387
|
+
const { geometry: t, shader: r, state: s, topology: n, size: i, start: o, instanceCount: u, skipSync: c } = e;
|
|
388
|
+
this.setPipelineFromGeometryProgramAndState(t, r.gpuProgram, s, n), this.setGeometry(t, r.gpuProgram), this._setShaderBindGroups(r, c), t.indexBuffer ? this.renderPassEncoder.drawIndexed(
|
|
389
|
+
i || t.indexBuffer.data.length,
|
|
390
390
|
u ?? t.instanceCount,
|
|
391
391
|
o || 0
|
|
392
|
-
) : this.renderPassEncoder.draw(
|
|
392
|
+
) : this.renderPassEncoder.draw(i || t.getSize(), u ?? t.instanceCount, o || 0);
|
|
393
393
|
}
|
|
394
394
|
finishRenderPass() {
|
|
395
395
|
this.renderPassEncoder && (this.renderPassEncoder.end(), this.renderPassEncoder = null);
|
|
@@ -409,14 +409,14 @@ class q {
|
|
|
409
409
|
this._renderer.renderTarget.layer
|
|
410
410
|
);
|
|
411
411
|
this.renderPassEncoder = this.commandEncoder.beginRenderPass(e);
|
|
412
|
-
const t = this._boundPipeline, r = { ...this._boundVertexBuffer }, s = this._boundIndexBuffer,
|
|
412
|
+
const t = this._boundPipeline, r = { ...this._boundVertexBuffer }, s = this._boundIndexBuffer, n = { ...this._boundBindGroup };
|
|
413
413
|
this._clearCache();
|
|
414
|
-
const
|
|
415
|
-
this.renderPassEncoder.setViewport(
|
|
414
|
+
const i = this._renderer.renderTarget.viewport;
|
|
415
|
+
this.renderPassEncoder.setViewport(i.x, i.y, i.width, i.height, 0, 1), this.setPipeline(t);
|
|
416
416
|
for (const o in r)
|
|
417
417
|
this._setVertexBuffer(o, r[o]);
|
|
418
|
-
for (const o in
|
|
419
|
-
this.setBindGroup(o,
|
|
418
|
+
for (const o in n)
|
|
419
|
+
this.setBindGroup(o, n[o], null);
|
|
420
420
|
this._setIndexBuffer(s);
|
|
421
421
|
}
|
|
422
422
|
_clearCache() {
|
|
@@ -431,12 +431,12 @@ class q {
|
|
|
431
431
|
this._gpu = e;
|
|
432
432
|
}
|
|
433
433
|
}
|
|
434
|
-
|
|
435
|
-
type: [
|
|
434
|
+
K.extension = {
|
|
435
|
+
type: [l.WebGPUSystem],
|
|
436
436
|
name: "encoder",
|
|
437
437
|
priority: 1
|
|
438
438
|
};
|
|
439
|
-
class
|
|
439
|
+
class q {
|
|
440
440
|
constructor(e) {
|
|
441
441
|
this._renderer = e;
|
|
442
442
|
}
|
|
@@ -446,20 +446,20 @@ class Y {
|
|
|
446
446
|
destroy() {
|
|
447
447
|
}
|
|
448
448
|
}
|
|
449
|
-
|
|
449
|
+
q.extension = {
|
|
450
450
|
type: [
|
|
451
|
-
|
|
451
|
+
l.WebGPUSystem
|
|
452
452
|
],
|
|
453
453
|
name: "limits"
|
|
454
454
|
};
|
|
455
|
-
class
|
|
455
|
+
class Y {
|
|
456
456
|
constructor(e) {
|
|
457
457
|
this._renderTargetStencilState = /* @__PURE__ */ Object.create(null), this._renderer = e, e.renderTarget.onRenderTargetChange.add(this);
|
|
458
458
|
}
|
|
459
459
|
onRenderTargetChange(e) {
|
|
460
460
|
let t = this._renderTargetStencilState[e.uid];
|
|
461
461
|
t || (t = this._renderTargetStencilState[e.uid] = {
|
|
462
|
-
stencilMode:
|
|
462
|
+
stencilMode: T.DISABLED,
|
|
463
463
|
stencilReference: 0
|
|
464
464
|
}), this._activeRenderTarget = e, this.setStencilMode(t.stencilMode, t.stencilReference);
|
|
465
465
|
}
|
|
@@ -473,113 +473,20 @@ class $ {
|
|
|
473
473
|
this._renderer.renderTarget.onRenderTargetChange.remove(this), this._renderer = null, this._activeRenderTarget = null, this._renderTargetStencilState = null;
|
|
474
474
|
}
|
|
475
475
|
}
|
|
476
|
-
|
|
476
|
+
Y.extension = {
|
|
477
477
|
type: [
|
|
478
|
-
|
|
478
|
+
l.WebGPUSystem
|
|
479
479
|
],
|
|
480
480
|
name: "stencil"
|
|
481
481
|
};
|
|
482
|
-
const B = {
|
|
483
|
-
i32: { align: 4, size: 4 },
|
|
484
|
-
u32: { align: 4, size: 4 },
|
|
485
|
-
f32: { align: 4, size: 4 },
|
|
486
|
-
f16: { align: 2, size: 2 },
|
|
487
|
-
"vec2<i32>": { align: 8, size: 8 },
|
|
488
|
-
"vec2<u32>": { align: 8, size: 8 },
|
|
489
|
-
"vec2<f32>": { align: 8, size: 8 },
|
|
490
|
-
"vec2<f16>": { align: 4, size: 4 },
|
|
491
|
-
"vec3<i32>": { align: 16, size: 12 },
|
|
492
|
-
"vec3<u32>": { align: 16, size: 12 },
|
|
493
|
-
"vec3<f32>": { align: 16, size: 12 },
|
|
494
|
-
"vec3<f16>": { align: 8, size: 6 },
|
|
495
|
-
"vec4<i32>": { align: 16, size: 16 },
|
|
496
|
-
"vec4<u32>": { align: 16, size: 16 },
|
|
497
|
-
"vec4<f32>": { align: 16, size: 16 },
|
|
498
|
-
"vec4<f16>": { align: 8, size: 8 },
|
|
499
|
-
"mat2x2<f32>": { align: 8, size: 16 },
|
|
500
|
-
"mat2x2<f16>": { align: 4, size: 8 },
|
|
501
|
-
"mat3x2<f32>": { align: 8, size: 24 },
|
|
502
|
-
"mat3x2<f16>": { align: 4, size: 12 },
|
|
503
|
-
"mat4x2<f32>": { align: 8, size: 32 },
|
|
504
|
-
"mat4x2<f16>": { align: 4, size: 16 },
|
|
505
|
-
"mat2x3<f32>": { align: 16, size: 32 },
|
|
506
|
-
"mat2x3<f16>": { align: 8, size: 16 },
|
|
507
|
-
"mat3x3<f32>": { align: 16, size: 48 },
|
|
508
|
-
"mat3x3<f16>": { align: 8, size: 24 },
|
|
509
|
-
"mat4x3<f32>": { align: 16, size: 64 },
|
|
510
|
-
"mat4x3<f16>": { align: 8, size: 32 },
|
|
511
|
-
"mat2x4<f32>": { align: 16, size: 32 },
|
|
512
|
-
"mat2x4<f16>": { align: 8, size: 16 },
|
|
513
|
-
"mat3x4<f32>": { align: 16, size: 48 },
|
|
514
|
-
"mat3x4<f16>": { align: 8, size: 24 },
|
|
515
|
-
"mat4x4<f32>": { align: 16, size: 64 },
|
|
516
|
-
"mat4x4<f16>": { align: 8, size: 32 }
|
|
517
|
-
};
|
|
518
|
-
function De(a) {
|
|
519
|
-
const e = a.map((r) => ({
|
|
520
|
-
data: r,
|
|
521
|
-
offset: 0,
|
|
522
|
-
size: 0
|
|
523
|
-
}));
|
|
524
|
-
let t = 0;
|
|
525
|
-
for (let r = 0; r < e.length; r++) {
|
|
526
|
-
const s = e[r];
|
|
527
|
-
let i = B[s.data.type].size;
|
|
528
|
-
const n = B[s.data.type].align;
|
|
529
|
-
if (!B[s.data.type])
|
|
530
|
-
throw new Error(`[Pixi.js] WebGPU UniformBuffer: Unknown type ${s.data.type}`);
|
|
531
|
-
s.data.size > 1 && (i = Math.max(i, n) * s.data.size), t = Math.ceil(t / n) * n, s.size = i, s.offset = t, t += i;
|
|
532
|
-
}
|
|
533
|
-
return t = Math.ceil(t / 16) * 16, { uboElements: e, size: t };
|
|
534
|
-
}
|
|
535
|
-
function ke(a, e) {
|
|
536
|
-
const { size: t, align: r } = B[a.data.type], s = (r - t) / 4, i = a.data.type.indexOf("i32") >= 0 ? "dataInt32" : "data";
|
|
537
|
-
return `
|
|
538
|
-
v = uv.${a.data.name};
|
|
539
|
-
${e !== 0 ? `offset += ${e};` : ""}
|
|
540
|
-
|
|
541
|
-
arrayOffset = offset;
|
|
542
|
-
|
|
543
|
-
t = 0;
|
|
544
|
-
|
|
545
|
-
for(var i=0; i < ${a.data.size * (t / 4)}; i++)
|
|
546
|
-
{
|
|
547
|
-
for(var j = 0; j < ${t / 4}; j++)
|
|
548
|
-
{
|
|
549
|
-
${i}[arrayOffset++] = v[t++];
|
|
550
|
-
}
|
|
551
|
-
${s !== 0 ? `arrayOffset += ${s};` : ""}
|
|
552
|
-
}
|
|
553
|
-
`;
|
|
554
|
-
}
|
|
555
|
-
function ze(a) {
|
|
556
|
-
return Ge(
|
|
557
|
-
a,
|
|
558
|
-
"uboWgsl",
|
|
559
|
-
ke,
|
|
560
|
-
Pe
|
|
561
|
-
);
|
|
562
|
-
}
|
|
563
|
-
class X extends Be {
|
|
564
|
-
constructor() {
|
|
565
|
-
super({
|
|
566
|
-
createUboElements: De,
|
|
567
|
-
generateUboSync: ze
|
|
568
|
-
});
|
|
569
|
-
}
|
|
570
|
-
}
|
|
571
|
-
X.extension = {
|
|
572
|
-
type: [p.WebGPUSystem],
|
|
573
|
-
name: "ubo"
|
|
574
|
-
};
|
|
575
482
|
const b = 128;
|
|
576
|
-
class
|
|
483
|
+
class X {
|
|
577
484
|
constructor(e) {
|
|
578
|
-
this._bindGroupHash = /* @__PURE__ */ Object.create(null), this._buffers = [], this._bindGroups = [], this._bufferResources = [], this._renderer = e, this._batchBuffer = new
|
|
485
|
+
this._bindGroupHash = /* @__PURE__ */ Object.create(null), this._buffers = [], this._bindGroups = [], this._bufferResources = [], this._renderer = e, this._batchBuffer = new Me({ minUniformOffsetAlignment: b });
|
|
579
486
|
const t = 256 / b;
|
|
580
487
|
for (let r = 0; r < t; r++) {
|
|
581
|
-
let s =
|
|
582
|
-
r === 0 && (s |=
|
|
488
|
+
let s = S.UNIFORM | S.COPY_DST;
|
|
489
|
+
r === 0 && (s |= S.COPY_SRC), this._buffers.push(new de({
|
|
583
490
|
data: this._batchBuffer.data,
|
|
584
491
|
usage: s
|
|
585
492
|
}));
|
|
@@ -615,7 +522,7 @@ class Z {
|
|
|
615
522
|
_getBufferResource(e) {
|
|
616
523
|
if (!this._bufferResources[e]) {
|
|
617
524
|
const t = this._buffers[e % 2];
|
|
618
|
-
this._bufferResources[e] = new
|
|
525
|
+
this._bufferResources[e] = new he({
|
|
619
526
|
buffer: t,
|
|
620
527
|
offset: (e / 2 | 0) * 256,
|
|
621
528
|
size: b
|
|
@@ -625,7 +532,7 @@ class Z {
|
|
|
625
532
|
}
|
|
626
533
|
_getBindGroup(e) {
|
|
627
534
|
if (!this._bindGroups[e]) {
|
|
628
|
-
const t = new
|
|
535
|
+
const t = new H({
|
|
629
536
|
0: this._getBufferResource(e)
|
|
630
537
|
});
|
|
631
538
|
this._bindGroups[e] = t;
|
|
@@ -637,11 +544,11 @@ class Z {
|
|
|
637
544
|
t.update(this._batchBuffer.byteIndex), e.updateBuffer(t);
|
|
638
545
|
const r = this._renderer.gpu.device.createCommandEncoder();
|
|
639
546
|
for (let s = 1; s < this._buffers.length; s++) {
|
|
640
|
-
const
|
|
547
|
+
const n = this._buffers[s];
|
|
641
548
|
r.copyBufferToBuffer(
|
|
642
549
|
e.getGPUBuffer(t),
|
|
643
550
|
b,
|
|
644
|
-
e.getGPUBuffer(
|
|
551
|
+
e.getGPUBuffer(n),
|
|
645
552
|
0,
|
|
646
553
|
this._batchBuffer.byteIndex
|
|
647
554
|
);
|
|
@@ -661,31 +568,31 @@ class Z {
|
|
|
661
568
|
this._bufferResources = null, this._batchBuffer.destroy(), this._renderer = null;
|
|
662
569
|
}
|
|
663
570
|
}
|
|
664
|
-
|
|
571
|
+
X.extension = {
|
|
665
572
|
type: [
|
|
666
|
-
|
|
573
|
+
l.WebGPUPipes
|
|
667
574
|
],
|
|
668
575
|
name: "uniformBatch"
|
|
669
576
|
};
|
|
670
|
-
const
|
|
577
|
+
const Re = {
|
|
671
578
|
"point-list": 0,
|
|
672
579
|
"line-list": 1,
|
|
673
580
|
"line-strip": 2,
|
|
674
581
|
"triangle-list": 3,
|
|
675
582
|
"triangle-strip": 4
|
|
676
583
|
};
|
|
677
|
-
function
|
|
584
|
+
function Ee(a, e, t, r, s) {
|
|
678
585
|
return a << 24 | e << 16 | t << 10 | r << 5 | s;
|
|
679
586
|
}
|
|
680
|
-
function
|
|
587
|
+
function Le(a, e, t, r, s) {
|
|
681
588
|
return t << 8 | a << 5 | r << 3 | s << 1 | e;
|
|
682
589
|
}
|
|
683
|
-
class
|
|
590
|
+
class $ {
|
|
684
591
|
constructor(e) {
|
|
685
592
|
this._moduleCache = /* @__PURE__ */ Object.create(null), this._bufferLayoutsCache = /* @__PURE__ */ Object.create(null), this._bindingNamesCache = /* @__PURE__ */ Object.create(null), this._pipeCache = /* @__PURE__ */ Object.create(null), this._pipeStateCaches = /* @__PURE__ */ Object.create(null), this._colorMask = 15, this._multisampleCount = 1, this._colorTargetCount = 1, this._renderer = e;
|
|
686
593
|
}
|
|
687
594
|
contextChange(e) {
|
|
688
|
-
this._gpu = e, this.setStencilMode(
|
|
595
|
+
this._gpu = e, this.setStencilMode(T.DISABLED), this._updatePipeHash();
|
|
689
596
|
}
|
|
690
597
|
setMultisampleCount(e) {
|
|
691
598
|
this._multisampleCount !== e && (this._multisampleCount = e, this._updatePipeHash());
|
|
@@ -697,27 +604,27 @@ class J {
|
|
|
697
604
|
this._colorMask !== e && (this._colorMask = e, this._updatePipeHash());
|
|
698
605
|
}
|
|
699
606
|
setStencilMode(e) {
|
|
700
|
-
this._stencilMode !== e && (this._stencilMode = e, this._stencilState =
|
|
607
|
+
this._stencilMode !== e && (this._stencilMode = e, this._stencilState = Pe[e], this._updatePipeHash());
|
|
701
608
|
}
|
|
702
609
|
setPipeline(e, t, r, s) {
|
|
703
|
-
const
|
|
704
|
-
s.setPipeline(
|
|
610
|
+
const n = this.getPipeline(e, t, r);
|
|
611
|
+
s.setPipeline(n);
|
|
705
612
|
}
|
|
706
613
|
getPipeline(e, t, r, s) {
|
|
707
|
-
e._layoutKey || (
|
|
708
|
-
const
|
|
614
|
+
e._layoutKey || (Be(e, t.attributeData), this._generateBufferKey(e)), s || (s = e.topology);
|
|
615
|
+
const n = Ee(
|
|
709
616
|
e._layoutKey,
|
|
710
617
|
t._layoutKey,
|
|
711
618
|
r.data,
|
|
712
619
|
r._blendModeId,
|
|
713
|
-
|
|
620
|
+
Re[s]
|
|
714
621
|
);
|
|
715
|
-
return this._pipeCache[
|
|
622
|
+
return this._pipeCache[n] ? this._pipeCache[n] : (this._pipeCache[n] = this._createPipeline(e, t, r, s), this._pipeCache[n]);
|
|
716
623
|
}
|
|
717
624
|
_createPipeline(e, t, r, s) {
|
|
718
|
-
const
|
|
719
|
-
for (let
|
|
720
|
-
o[
|
|
625
|
+
const n = this._gpu.device, i = this._createVertexBufferLayouts(e, t), o = this._renderer.state.getColorTargets(r, this._colorTargetCount), u = this._stencilMode === T.RENDERING_MASK_ADD ? 0 : this._colorMask;
|
|
626
|
+
for (let p = 0; p < o.length; p++)
|
|
627
|
+
o[p].writeMask = u;
|
|
721
628
|
const c = this._renderer.shader.getProgramData(t).pipeline, f = {
|
|
722
629
|
// TODO later check if its helpful to create..
|
|
723
630
|
// layout,
|
|
@@ -725,7 +632,7 @@ class J {
|
|
|
725
632
|
module: this._getModule(t.vertex.source),
|
|
726
633
|
entryPoint: t.vertex.entryPoint,
|
|
727
634
|
// geometry..
|
|
728
|
-
buffers:
|
|
635
|
+
buffers: i
|
|
729
636
|
},
|
|
730
637
|
fragment: {
|
|
731
638
|
module: this._getModule(t.fragment.source),
|
|
@@ -748,7 +655,7 @@ class J {
|
|
|
748
655
|
format: "depth24plus-stencil8",
|
|
749
656
|
depthWriteEnabled: r.depthTest,
|
|
750
657
|
depthCompare: r.depthTest ? "less" : "always"
|
|
751
|
-
}),
|
|
658
|
+
}), n.createRenderPipeline(f);
|
|
752
659
|
}
|
|
753
660
|
_getModule(e) {
|
|
754
661
|
return this._moduleCache[e] || this._createModule(e);
|
|
@@ -763,23 +670,23 @@ class J {
|
|
|
763
670
|
const t = [];
|
|
764
671
|
let r = 0;
|
|
765
672
|
const s = Object.keys(e.attributes).sort();
|
|
766
|
-
for (let
|
|
767
|
-
const o = e.attributes[s[
|
|
673
|
+
for (let i = 0; i < s.length; i++) {
|
|
674
|
+
const o = e.attributes[s[i]];
|
|
768
675
|
t[r++] = o.offset, t[r++] = o.format, t[r++] = o.stride, t[r++] = o.instance;
|
|
769
676
|
}
|
|
770
|
-
const
|
|
771
|
-
return e._layoutKey =
|
|
677
|
+
const n = t.join("|");
|
|
678
|
+
return e._layoutKey = M(n, "geometry"), e._layoutKey;
|
|
772
679
|
}
|
|
773
680
|
_generateAttributeLocationsKey(e) {
|
|
774
681
|
const t = [];
|
|
775
682
|
let r = 0;
|
|
776
683
|
const s = Object.keys(e.attributeData).sort();
|
|
777
|
-
for (let
|
|
778
|
-
const o = e.attributeData[s[
|
|
684
|
+
for (let i = 0; i < s.length; i++) {
|
|
685
|
+
const o = e.attributeData[s[i]];
|
|
779
686
|
t[r++] = o.location;
|
|
780
687
|
}
|
|
781
|
-
const
|
|
782
|
-
return e._attributeLocationsKey =
|
|
688
|
+
const n = t.join("|");
|
|
689
|
+
return e._attributeLocationsKey = M(n, "programAttributes"), e._attributeLocationsKey;
|
|
783
690
|
}
|
|
784
691
|
/**
|
|
785
692
|
* Returns a hash of buffer names mapped to bind locations.
|
|
@@ -791,16 +698,16 @@ class J {
|
|
|
791
698
|
getBufferNamesToBind(e, t) {
|
|
792
699
|
const r = e._layoutKey << 16 | t._attributeLocationsKey;
|
|
793
700
|
if (this._bindingNamesCache[r]) return this._bindingNamesCache[r];
|
|
794
|
-
const s = this._createVertexBufferLayouts(e, t),
|
|
701
|
+
const s = this._createVertexBufferLayouts(e, t), n = /* @__PURE__ */ Object.create(null), i = t.attributeData;
|
|
795
702
|
for (let o = 0; o < s.length; o++) {
|
|
796
703
|
const c = Object.values(s[o].attributes)[0].shaderLocation;
|
|
797
|
-
for (const f in
|
|
798
|
-
if (
|
|
799
|
-
|
|
704
|
+
for (const f in i)
|
|
705
|
+
if (i[f].location === c) {
|
|
706
|
+
n[o] = f;
|
|
800
707
|
break;
|
|
801
708
|
}
|
|
802
709
|
}
|
|
803
|
-
return this._bindingNamesCache[r] =
|
|
710
|
+
return this._bindingNamesCache[r] = n, n;
|
|
804
711
|
}
|
|
805
712
|
_createVertexBufferLayouts(e, t) {
|
|
806
713
|
t._attributeLocationsKey || this._generateAttributeLocationsKey(t);
|
|
@@ -808,25 +715,25 @@ class J {
|
|
|
808
715
|
if (this._bufferLayoutsCache[r])
|
|
809
716
|
return this._bufferLayoutsCache[r];
|
|
810
717
|
const s = [];
|
|
811
|
-
return e.buffers.forEach((
|
|
812
|
-
const
|
|
718
|
+
return e.buffers.forEach((n) => {
|
|
719
|
+
const i = {
|
|
813
720
|
arrayStride: 0,
|
|
814
721
|
stepMode: "vertex",
|
|
815
722
|
attributes: []
|
|
816
|
-
}, o =
|
|
723
|
+
}, o = i.attributes;
|
|
817
724
|
for (const u in t.attributeData) {
|
|
818
725
|
const c = e.attributes[u];
|
|
819
|
-
(c.divisor ?? 1) !== 1 &&
|
|
726
|
+
(c.divisor ?? 1) !== 1 && v(`Attribute ${u} has an invalid divisor value of '${c.divisor}'. WebGPU only supports a divisor value of 1`), c.buffer === n && (i.arrayStride = c.stride, i.stepMode = c.instance ? "instance" : "vertex", o.push({
|
|
820
727
|
shaderLocation: t.attributeData[u].location,
|
|
821
728
|
offset: c.offset,
|
|
822
729
|
format: c.format
|
|
823
730
|
}));
|
|
824
731
|
}
|
|
825
|
-
o.length && s.push(
|
|
732
|
+
o.length && s.push(i);
|
|
826
733
|
}), this._bufferLayoutsCache[r] = s, s;
|
|
827
734
|
}
|
|
828
735
|
_updatePipeHash() {
|
|
829
|
-
const e =
|
|
736
|
+
const e = Le(
|
|
830
737
|
this._stencilMode,
|
|
831
738
|
this._multisampleCount,
|
|
832
739
|
this._colorMask,
|
|
@@ -839,45 +746,45 @@ class J {
|
|
|
839
746
|
this._renderer = null, this._bufferLayoutsCache = null;
|
|
840
747
|
}
|
|
841
748
|
}
|
|
842
|
-
|
|
843
|
-
type: [
|
|
749
|
+
$.extension = {
|
|
750
|
+
type: [l.WebGPUSystem],
|
|
844
751
|
name: "pipeline"
|
|
845
752
|
};
|
|
846
|
-
class
|
|
753
|
+
class Ae {
|
|
847
754
|
constructor() {
|
|
848
755
|
this.contexts = [], this.msaaTextures = [], this.msaaSamples = 1;
|
|
849
756
|
}
|
|
850
757
|
}
|
|
851
|
-
class
|
|
758
|
+
class De {
|
|
852
759
|
init(e, t) {
|
|
853
760
|
this._renderer = e, this._renderTargetSystem = t;
|
|
854
761
|
}
|
|
855
|
-
copyToTexture(e, t, r, s,
|
|
856
|
-
const
|
|
762
|
+
copyToTexture(e, t, r, s, n) {
|
|
763
|
+
const i = this._renderer, o = this._getGpuColorTexture(
|
|
857
764
|
e
|
|
858
|
-
), u =
|
|
765
|
+
), u = i.texture.getGpuSource(
|
|
859
766
|
t.source
|
|
860
767
|
);
|
|
861
|
-
return
|
|
768
|
+
return i.encoder.commandEncoder.copyTextureToTexture(
|
|
862
769
|
{
|
|
863
770
|
texture: o,
|
|
864
771
|
origin: r
|
|
865
772
|
},
|
|
866
773
|
{
|
|
867
774
|
texture: u,
|
|
868
|
-
origin:
|
|
775
|
+
origin: n
|
|
869
776
|
},
|
|
870
777
|
s
|
|
871
778
|
), t;
|
|
872
779
|
}
|
|
873
|
-
startRenderPass(e, t = !0, r, s,
|
|
780
|
+
startRenderPass(e, t = !0, r, s, n = 0, i = 0) {
|
|
874
781
|
var f, h;
|
|
875
782
|
const u = this._renderTargetSystem.getGpuRenderTarget(e);
|
|
876
|
-
if (
|
|
783
|
+
if (i !== 0 && ((f = u.msaaTextures) != null && f.length))
|
|
877
784
|
throw new Error("[RenderTargetSystem] Rendering to array layers is not supported with MSAA render targets.");
|
|
878
|
-
if (
|
|
785
|
+
if (n > 0 && ((h = u.msaaTextures) != null && h.length))
|
|
879
786
|
throw new Error("[RenderTargetSystem] Rendering to mip levels is not supported with MSAA render targets.");
|
|
880
|
-
const c = this.getDescriptor(e, t, r,
|
|
787
|
+
const c = this.getDescriptor(e, t, r, n, i);
|
|
881
788
|
u.descriptor = c, this._renderer.pipeline.setRenderTarget(u), this._renderer.encoder.beginRenderPass(u), this._renderer.encoder.setViewport(s);
|
|
882
789
|
}
|
|
883
790
|
finishRenderPass() {
|
|
@@ -895,14 +802,14 @@ class He {
|
|
|
895
802
|
e.colorTextures[0].source
|
|
896
803
|
);
|
|
897
804
|
}
|
|
898
|
-
getDescriptor(e, t, r, s = 0,
|
|
805
|
+
getDescriptor(e, t, r, s = 0, n = 0) {
|
|
899
806
|
typeof t == "boolean" && (t = t ? y.ALL : y.NONE);
|
|
900
|
-
const
|
|
901
|
-
(h,
|
|
902
|
-
const d = o.contexts[
|
|
807
|
+
const i = this._renderTargetSystem, o = i.getGpuRenderTarget(e), u = e.colorTextures.map(
|
|
808
|
+
(h, p) => {
|
|
809
|
+
const d = o.contexts[p];
|
|
903
810
|
let g, m;
|
|
904
811
|
if (d) {
|
|
905
|
-
if (
|
|
812
|
+
if (n !== 0)
|
|
906
813
|
throw new Error("[RenderTargetSystem] Rendering to array layers is not supported for canvas targets.");
|
|
907
814
|
g = d.getCurrentTexture().createView();
|
|
908
815
|
} else
|
|
@@ -911,14 +818,14 @@ class He {
|
|
|
911
818
|
dimension: "2d",
|
|
912
819
|
baseMipLevel: s,
|
|
913
820
|
mipLevelCount: 1,
|
|
914
|
-
baseArrayLayer:
|
|
821
|
+
baseArrayLayer: n,
|
|
915
822
|
arrayLayerCount: 1
|
|
916
823
|
});
|
|
917
|
-
o.msaaTextures[
|
|
918
|
-
o.msaaTextures[
|
|
824
|
+
o.msaaTextures[p] && (m = g, g = this._renderer.texture.getTextureView(
|
|
825
|
+
o.msaaTextures[p]
|
|
919
826
|
));
|
|
920
827
|
const G = t & y.COLOR ? "clear" : "load";
|
|
921
|
-
return r ?? (r =
|
|
828
|
+
return r ?? (r = i.defaultClearColor), {
|
|
922
829
|
view: g,
|
|
923
830
|
resolveTarget: m,
|
|
924
831
|
clearValue: r,
|
|
@@ -929,19 +836,19 @@ class He {
|
|
|
929
836
|
);
|
|
930
837
|
let c;
|
|
931
838
|
if ((e.stencil || e.depth) && !e.depthStencilTexture && (e.ensureDepthStencilTexture(), e.depthStencilTexture.source.sampleCount = o.msaa ? 4 : 1), e.depthStencilTexture) {
|
|
932
|
-
const h = t & y.STENCIL ? "clear" : "load",
|
|
839
|
+
const h = t & y.STENCIL ? "clear" : "load", p = t & y.DEPTH ? "clear" : "load";
|
|
933
840
|
c = {
|
|
934
841
|
view: this._renderer.texture.getGpuSource(e.depthStencilTexture.source).createView({
|
|
935
842
|
dimension: "2d",
|
|
936
843
|
baseMipLevel: s,
|
|
937
844
|
mipLevelCount: 1,
|
|
938
|
-
baseArrayLayer:
|
|
845
|
+
baseArrayLayer: n,
|
|
939
846
|
arrayLayerCount: 1
|
|
940
847
|
}),
|
|
941
848
|
stencilStoreOp: "store",
|
|
942
849
|
stencilLoadOp: h,
|
|
943
850
|
depthClearValue: 1,
|
|
944
|
-
depthLoadOp:
|
|
851
|
+
depthLoadOp: p,
|
|
945
852
|
depthStoreOp: "store"
|
|
946
853
|
};
|
|
947
854
|
}
|
|
@@ -950,45 +857,45 @@ class He {
|
|
|
950
857
|
depthStencilAttachment: c
|
|
951
858
|
};
|
|
952
859
|
}
|
|
953
|
-
clear(e, t = !0, r, s,
|
|
860
|
+
clear(e, t = !0, r, s, n = 0, i = 0) {
|
|
954
861
|
if (!t) return;
|
|
955
862
|
const { gpu: o, encoder: u } = this._renderer, c = o.device;
|
|
956
863
|
if (u.commandEncoder === null) {
|
|
957
|
-
const h = c.createCommandEncoder(),
|
|
864
|
+
const h = c.createCommandEncoder(), p = this.getDescriptor(e, t, r, n, i), d = h.beginRenderPass(p);
|
|
958
865
|
d.setViewport(s.x, s.y, s.width, s.height, 0, 1), d.end();
|
|
959
866
|
const g = h.finish();
|
|
960
867
|
c.queue.submit([g]);
|
|
961
868
|
} else
|
|
962
|
-
this.startRenderPass(e, t, r, s,
|
|
869
|
+
this.startRenderPass(e, t, r, s, n, i);
|
|
963
870
|
}
|
|
964
871
|
initGpuRenderTarget(e) {
|
|
965
872
|
e.isRoot = !0;
|
|
966
|
-
const t = new
|
|
873
|
+
const t = new Ae();
|
|
967
874
|
return t.colorTargetCount = e.colorTextures.length, e.colorTextures.forEach((r, s) => {
|
|
968
|
-
if (r instanceof
|
|
969
|
-
const
|
|
875
|
+
if (r instanceof pe) {
|
|
876
|
+
const n = r.resource.getContext(
|
|
970
877
|
"webgpu"
|
|
971
|
-
),
|
|
878
|
+
), i = r.transparent ? "premultiplied" : "opaque";
|
|
972
879
|
try {
|
|
973
|
-
|
|
880
|
+
n.configure({
|
|
974
881
|
device: this._renderer.gpu.device,
|
|
975
882
|
usage: GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST | GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.COPY_SRC,
|
|
976
883
|
format: "bgra8unorm",
|
|
977
|
-
alphaMode:
|
|
884
|
+
alphaMode: i
|
|
978
885
|
});
|
|
979
886
|
} catch (o) {
|
|
980
887
|
console.error(o);
|
|
981
888
|
}
|
|
982
|
-
t.contexts[s] =
|
|
889
|
+
t.contexts[s] = n;
|
|
983
890
|
}
|
|
984
891
|
if (t.msaa = r.source.antialias, r.source.antialias) {
|
|
985
|
-
const
|
|
892
|
+
const n = new le({
|
|
986
893
|
width: 0,
|
|
987
894
|
height: 0,
|
|
988
895
|
sampleCount: 4,
|
|
989
896
|
arrayLayerCount: r.source.arrayLayerCount
|
|
990
897
|
});
|
|
991
|
-
t.msaaTextures[s] =
|
|
898
|
+
t.msaaTextures[s] = n;
|
|
992
899
|
}
|
|
993
900
|
}), t.msaa && (t.msaaSamples = 4, e.depthStencilTexture && (e.depthStencilTexture.source.sampleCount = 4)), t;
|
|
994
901
|
}
|
|
@@ -1006,8 +913,8 @@ class He {
|
|
|
1006
913
|
resizeGpuRenderTarget(e) {
|
|
1007
914
|
const t = this._renderTargetSystem.getGpuRenderTarget(e);
|
|
1008
915
|
t.width = e.width, t.height = e.height, t.msaa && e.colorTextures.forEach((r, s) => {
|
|
1009
|
-
const
|
|
1010
|
-
|
|
916
|
+
const n = t.msaaTextures[s];
|
|
917
|
+
n == null || n.resize(
|
|
1011
918
|
r.source.width,
|
|
1012
919
|
r.source.height,
|
|
1013
920
|
r.source._resolution
|
|
@@ -1015,16 +922,16 @@ class He {
|
|
|
1015
922
|
});
|
|
1016
923
|
}
|
|
1017
924
|
}
|
|
1018
|
-
class
|
|
925
|
+
class J extends _e {
|
|
1019
926
|
constructor(e) {
|
|
1020
|
-
super(e), this.adaptor = new
|
|
927
|
+
super(e), this.adaptor = new De(), this.adaptor.init(e, this);
|
|
1021
928
|
}
|
|
1022
929
|
}
|
|
1023
|
-
|
|
1024
|
-
type: [
|
|
930
|
+
J.extension = {
|
|
931
|
+
type: [l.WebGPUSystem],
|
|
1025
932
|
name: "renderTarget"
|
|
1026
933
|
};
|
|
1027
|
-
class
|
|
934
|
+
class Q {
|
|
1028
935
|
constructor() {
|
|
1029
936
|
this._gpuProgramData = /* @__PURE__ */ Object.create(null);
|
|
1030
937
|
}
|
|
@@ -1035,7 +942,7 @@ class ee {
|
|
|
1035
942
|
return this._gpuProgramData[e._layoutKey] || this._createGPUProgramData(e);
|
|
1036
943
|
}
|
|
1037
944
|
_createGPUProgramData(e) {
|
|
1038
|
-
const t = this._gpu.device, r = e.gpuLayout.map((
|
|
945
|
+
const t = this._gpu.device, r = e.gpuLayout.map((n) => t.createBindGroupLayout({ entries: n })), s = { bindGroupLayouts: r };
|
|
1039
946
|
return this._gpuProgramData[e._layoutKey] = {
|
|
1040
947
|
bindGroups: r,
|
|
1041
948
|
pipeline: t.createPipelineLayout(s)
|
|
@@ -1045,9 +952,9 @@ class ee {
|
|
|
1045
952
|
this._gpu = null, this._gpuProgramData = null;
|
|
1046
953
|
}
|
|
1047
954
|
}
|
|
1048
|
-
|
|
955
|
+
Q.extension = {
|
|
1049
956
|
type: [
|
|
1050
|
-
|
|
957
|
+
l.WebGPUSystem
|
|
1051
958
|
],
|
|
1052
959
|
name: "shader"
|
|
1053
960
|
};
|
|
@@ -1196,9 +1103,9 @@ _.max = {
|
|
|
1196
1103
|
operation: "max"
|
|
1197
1104
|
}
|
|
1198
1105
|
};
|
|
1199
|
-
class
|
|
1106
|
+
class Z {
|
|
1200
1107
|
constructor() {
|
|
1201
|
-
this.defaultState = new
|
|
1108
|
+
this.defaultState = new I(), this.defaultState.blend = !0;
|
|
1202
1109
|
}
|
|
1203
1110
|
contextChange(e) {
|
|
1204
1111
|
this.gpu = e;
|
|
@@ -1209,36 +1116,36 @@ class te {
|
|
|
1209
1116
|
* @param count - The number of color targets to create
|
|
1210
1117
|
*/
|
|
1211
1118
|
getColorTargets(e, t) {
|
|
1212
|
-
const r = _[e.blendMode] || _.normal, s = [],
|
|
1119
|
+
const r = _[e.blendMode] || _.normal, s = [], n = {
|
|
1213
1120
|
format: "bgra8unorm",
|
|
1214
1121
|
writeMask: 0,
|
|
1215
1122
|
blend: r
|
|
1216
1123
|
};
|
|
1217
|
-
for (let
|
|
1218
|
-
s[
|
|
1124
|
+
for (let i = 0; i < t; i++)
|
|
1125
|
+
s[i] = n;
|
|
1219
1126
|
return s;
|
|
1220
1127
|
}
|
|
1221
1128
|
destroy() {
|
|
1222
1129
|
this.gpu = null;
|
|
1223
1130
|
}
|
|
1224
1131
|
}
|
|
1225
|
-
|
|
1132
|
+
Z.extension = {
|
|
1226
1133
|
type: [
|
|
1227
|
-
|
|
1134
|
+
l.WebGPUSystem
|
|
1228
1135
|
],
|
|
1229
1136
|
name: "state"
|
|
1230
1137
|
};
|
|
1231
|
-
const
|
|
1138
|
+
const ke = {
|
|
1232
1139
|
type: "image",
|
|
1233
1140
|
upload(a, e, t, r = 0) {
|
|
1234
|
-
const s = a.resource,
|
|
1141
|
+
const s = a.resource, n = (a.pixelWidth | 0) * (a.pixelHeight | 0), i = s.byteLength / n;
|
|
1235
1142
|
t.device.queue.writeTexture(
|
|
1236
1143
|
{ texture: e, origin: { x: 0, y: 0, z: r } },
|
|
1237
1144
|
s,
|
|
1238
1145
|
{
|
|
1239
1146
|
offset: 0,
|
|
1240
1147
|
rowsPerImage: a.pixelHeight,
|
|
1241
|
-
bytesPerRow: a.pixelWidth *
|
|
1148
|
+
bytesPerRow: a.pixelWidth * i
|
|
1242
1149
|
},
|
|
1243
1150
|
{
|
|
1244
1151
|
width: a.pixelWidth,
|
|
@@ -1247,7 +1154,7 @@ const Ve = {
|
|
|
1247
1154
|
}
|
|
1248
1155
|
);
|
|
1249
1156
|
}
|
|
1250
|
-
},
|
|
1157
|
+
}, ee = {
|
|
1251
1158
|
"bc1-rgba-unorm": { blockBytes: 8, blockWidth: 4, blockHeight: 4 },
|
|
1252
1159
|
"bc2-rgba-unorm": { blockBytes: 16, blockWidth: 4, blockHeight: 4 },
|
|
1253
1160
|
"bc3-rgba-unorm": { blockBytes: 16, blockWidth: 4, blockHeight: 4 },
|
|
@@ -1255,13 +1162,13 @@ const Ve = {
|
|
|
1255
1162
|
"etc1-rgb-unorm": { blockBytes: 8, blockWidth: 4, blockHeight: 4 },
|
|
1256
1163
|
"etc2-rgba8unorm": { blockBytes: 16, blockWidth: 4, blockHeight: 4 },
|
|
1257
1164
|
"astc-4x4-unorm": { blockBytes: 16, blockWidth: 4, blockHeight: 4 }
|
|
1258
|
-
},
|
|
1165
|
+
}, Fe = { blockBytes: 4, blockWidth: 1, blockHeight: 1 }, Oe = {
|
|
1259
1166
|
type: "compressed",
|
|
1260
1167
|
upload(a, e, t, r = 0) {
|
|
1261
|
-
let s = a.pixelWidth,
|
|
1262
|
-
const
|
|
1168
|
+
let s = a.pixelWidth, n = a.pixelHeight;
|
|
1169
|
+
const i = ee[a.format] || Fe;
|
|
1263
1170
|
for (let o = 0; o < a.resource.length; o++) {
|
|
1264
|
-
const u = a.resource[o], c = Math.ceil(s /
|
|
1171
|
+
const u = a.resource[o], c = Math.ceil(s / i.blockWidth) * i.blockBytes;
|
|
1265
1172
|
t.device.queue.writeTexture(
|
|
1266
1173
|
{
|
|
1267
1174
|
texture: e,
|
|
@@ -1274,52 +1181,52 @@ const Ve = {
|
|
|
1274
1181
|
bytesPerRow: c
|
|
1275
1182
|
},
|
|
1276
1183
|
{
|
|
1277
|
-
width: Math.ceil(s /
|
|
1278
|
-
height: Math.ceil(
|
|
1184
|
+
width: Math.ceil(s / i.blockWidth) * i.blockWidth,
|
|
1185
|
+
height: Math.ceil(n / i.blockHeight) * i.blockHeight,
|
|
1279
1186
|
depthOrArrayLayers: 1
|
|
1280
1187
|
}
|
|
1281
|
-
), s = Math.max(s >> 1, 1),
|
|
1188
|
+
), s = Math.max(s >> 1, 1), n = Math.max(n >> 1, 1);
|
|
1282
1189
|
}
|
|
1283
1190
|
}
|
|
1284
|
-
},
|
|
1285
|
-
function
|
|
1191
|
+
}, E = ["right", "left", "top", "bottom", "front", "back"];
|
|
1192
|
+
function Ie(a) {
|
|
1286
1193
|
return {
|
|
1287
1194
|
type: "cube",
|
|
1288
1195
|
upload(e, t, r) {
|
|
1289
1196
|
const s = e.faces;
|
|
1290
|
-
for (let
|
|
1291
|
-
const
|
|
1292
|
-
(a[o.uploadMethodId] || a.image).upload(o, t, r,
|
|
1197
|
+
for (let n = 0; n < E.length; n++) {
|
|
1198
|
+
const i = E[n], o = s[i];
|
|
1199
|
+
(a[o.uploadMethodId] || a.image).upload(o, t, r, n);
|
|
1293
1200
|
}
|
|
1294
1201
|
}
|
|
1295
1202
|
};
|
|
1296
1203
|
}
|
|
1297
|
-
const
|
|
1204
|
+
const te = {
|
|
1298
1205
|
type: "image",
|
|
1299
1206
|
upload(a, e, t, r = 0) {
|
|
1300
1207
|
const s = a.resource;
|
|
1301
1208
|
if (!s) return;
|
|
1302
1209
|
if (globalThis.HTMLImageElement && s instanceof HTMLImageElement) {
|
|
1303
1210
|
const u = x.get().createCanvas(s.width, s.height);
|
|
1304
|
-
u.getContext("2d").drawImage(s, 0, 0, s.width, s.height), a.resource = u,
|
|
1211
|
+
u.getContext("2d").drawImage(s, 0, 0, s.width, s.height), a.resource = u, v("ImageSource: Image element passed, converting to canvas and replacing resource.");
|
|
1305
1212
|
}
|
|
1306
|
-
const
|
|
1213
|
+
const n = Math.min(e.width, a.resourceWidth || a.pixelWidth), i = Math.min(e.height, a.resourceHeight || a.pixelHeight), o = a.alphaMode === "premultiply-alpha-on-upload";
|
|
1307
1214
|
t.device.queue.copyExternalImageToTexture(
|
|
1308
1215
|
{ source: s },
|
|
1309
1216
|
{ texture: e, origin: { x: 0, y: 0, z: r }, premultipliedAlpha: o },
|
|
1310
1217
|
{
|
|
1311
|
-
width:
|
|
1312
|
-
height:
|
|
1218
|
+
width: n,
|
|
1219
|
+
height: i
|
|
1313
1220
|
}
|
|
1314
1221
|
);
|
|
1315
1222
|
}
|
|
1316
|
-
},
|
|
1223
|
+
}, He = {
|
|
1317
1224
|
type: "video",
|
|
1318
1225
|
upload(a, e, t, r) {
|
|
1319
|
-
|
|
1226
|
+
te.upload(a, e, t, r);
|
|
1320
1227
|
}
|
|
1321
1228
|
};
|
|
1322
|
-
class
|
|
1229
|
+
class We {
|
|
1323
1230
|
constructor(e) {
|
|
1324
1231
|
this.device = e, this.sampler = e.createSampler({ minFilter: "linear" }), this.pipelines = {};
|
|
1325
1232
|
}
|
|
@@ -1377,8 +1284,8 @@ class Ye {
|
|
|
1377
1284
|
if (e.dimension === "3d" || e.dimension === "1d")
|
|
1378
1285
|
throw new Error("Generating mipmaps for non-2d textures is currently unsupported!");
|
|
1379
1286
|
let r = e;
|
|
1380
|
-
const s = e.depthOrArrayLayers || 1,
|
|
1381
|
-
if (!
|
|
1287
|
+
const s = e.depthOrArrayLayers || 1, n = e.usage & GPUTextureUsage.RENDER_ATTACHMENT;
|
|
1288
|
+
if (!n) {
|
|
1382
1289
|
const u = {
|
|
1383
1290
|
size: {
|
|
1384
1291
|
width: Math.ceil(e.width / 2),
|
|
@@ -1391,7 +1298,7 @@ class Ye {
|
|
|
1391
1298
|
};
|
|
1392
1299
|
r = this.device.createTexture(u);
|
|
1393
1300
|
}
|
|
1394
|
-
const
|
|
1301
|
+
const i = this.device.createCommandEncoder({}), o = t.getBindGroupLayout(0);
|
|
1395
1302
|
for (let u = 0; u < s; ++u) {
|
|
1396
1303
|
let c = e.createView({
|
|
1397
1304
|
baseMipLevel: 0,
|
|
@@ -1399,17 +1306,17 @@ class Ye {
|
|
|
1399
1306
|
dimension: "2d",
|
|
1400
1307
|
baseArrayLayer: u,
|
|
1401
1308
|
arrayLayerCount: 1
|
|
1402
|
-
}), f =
|
|
1309
|
+
}), f = n ? 1 : 0;
|
|
1403
1310
|
for (let h = 1; h < e.mipLevelCount; ++h) {
|
|
1404
|
-
const
|
|
1311
|
+
const p = r.createView({
|
|
1405
1312
|
baseMipLevel: f++,
|
|
1406
1313
|
mipLevelCount: 1,
|
|
1407
1314
|
dimension: "2d",
|
|
1408
1315
|
baseArrayLayer: u,
|
|
1409
1316
|
arrayLayerCount: 1
|
|
1410
|
-
}), d =
|
|
1317
|
+
}), d = i.beginRenderPass({
|
|
1411
1318
|
colorAttachments: [{
|
|
1412
|
-
view:
|
|
1319
|
+
view: p,
|
|
1413
1320
|
storeOp: "store",
|
|
1414
1321
|
loadOp: "clear",
|
|
1415
1322
|
clearValue: { r: 0, g: 0, b: 0, a: 0 }
|
|
@@ -1424,17 +1331,17 @@ class Ye {
|
|
|
1424
1331
|
resource: c
|
|
1425
1332
|
}]
|
|
1426
1333
|
});
|
|
1427
|
-
d.setPipeline(t), d.setBindGroup(0, g), d.draw(3, 1, 0, 0), d.end(), c =
|
|
1334
|
+
d.setPipeline(t), d.setBindGroup(0, g), d.draw(3, 1, 0, 0), d.end(), c = p;
|
|
1428
1335
|
}
|
|
1429
1336
|
}
|
|
1430
|
-
if (!
|
|
1337
|
+
if (!n) {
|
|
1431
1338
|
const u = {
|
|
1432
1339
|
width: Math.ceil(e.width / 2),
|
|
1433
1340
|
height: Math.ceil(e.height / 2),
|
|
1434
1341
|
depthOrArrayLayers: s
|
|
1435
1342
|
};
|
|
1436
1343
|
for (let c = 1; c < e.mipLevelCount; ++c)
|
|
1437
|
-
|
|
1344
|
+
i.copyTextureToTexture({
|
|
1438
1345
|
texture: r,
|
|
1439
1346
|
mipLevel: c - 1
|
|
1440
1347
|
}, {
|
|
@@ -1442,10 +1349,10 @@ class Ye {
|
|
|
1442
1349
|
mipLevel: c
|
|
1443
1350
|
}, u), u.width = Math.ceil(u.width / 2), u.height = Math.ceil(u.height / 2);
|
|
1444
1351
|
}
|
|
1445
|
-
return this.device.queue.submit([
|
|
1352
|
+
return this.device.queue.submit([i.finish()]), n || r.destroy(), e;
|
|
1446
1353
|
}
|
|
1447
1354
|
}
|
|
1448
|
-
class
|
|
1355
|
+
class Ve {
|
|
1449
1356
|
constructor(e) {
|
|
1450
1357
|
this.textureView = null, this.gpuTexture = e;
|
|
1451
1358
|
}
|
|
@@ -1454,7 +1361,7 @@ class $e {
|
|
|
1454
1361
|
this.gpuTexture.destroy(), this.textureView = null, this.gpuTexture = null;
|
|
1455
1362
|
}
|
|
1456
1363
|
}
|
|
1457
|
-
class
|
|
1364
|
+
class re {
|
|
1458
1365
|
constructor(e) {
|
|
1459
1366
|
this._gpuSamplers = /* @__PURE__ */ Object.create(null), this._bindGroupHash = /* @__PURE__ */ Object.create(null), this._renderer = e, e.gc.addCollection(this, "_bindGroupHash", "hash"), this._managedTextures = new k({
|
|
1460
1367
|
renderer: e,
|
|
@@ -1463,14 +1370,14 @@ class ie {
|
|
|
1463
1370
|
name: "gpuTextureSource"
|
|
1464
1371
|
});
|
|
1465
1372
|
const t = {
|
|
1466
|
-
image:
|
|
1467
|
-
buffer:
|
|
1468
|
-
video:
|
|
1469
|
-
compressed:
|
|
1373
|
+
image: te,
|
|
1374
|
+
buffer: ke,
|
|
1375
|
+
video: He,
|
|
1376
|
+
compressed: Oe
|
|
1470
1377
|
};
|
|
1471
1378
|
this._uploads = {
|
|
1472
1379
|
...t,
|
|
1473
|
-
cube:
|
|
1380
|
+
cube: Ie(t)
|
|
1474
1381
|
};
|
|
1475
1382
|
}
|
|
1476
1383
|
/**
|
|
@@ -1498,23 +1405,23 @@ class ie {
|
|
|
1498
1405
|
}
|
|
1499
1406
|
let t = GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST;
|
|
1500
1407
|
e.uploadMethodId !== "compressed" && (t |= GPUTextureUsage.RENDER_ATTACHMENT, t |= GPUTextureUsage.COPY_SRC);
|
|
1501
|
-
const r =
|
|
1408
|
+
const r = ee[e.format] || { blockWidth: 1, blockHeight: 1 }, s = Math.ceil(e.pixelWidth / r.blockWidth) * r.blockWidth, n = Math.ceil(e.pixelHeight / r.blockHeight) * r.blockHeight, i = {
|
|
1502
1409
|
label: e.label,
|
|
1503
|
-
size: { width: s, height:
|
|
1410
|
+
size: { width: s, height: n, depthOrArrayLayers: e.arrayLayerCount },
|
|
1504
1411
|
format: e.format,
|
|
1505
1412
|
sampleCount: e.sampleCount,
|
|
1506
1413
|
mipLevelCount: e.mipLevelCount,
|
|
1507
1414
|
dimension: e.dimension,
|
|
1508
1415
|
usage: t
|
|
1509
|
-
}, o = this._gpu.device.createTexture(
|
|
1510
|
-
return e._gpuData[this._renderer.uid] = new
|
|
1416
|
+
}, o = this._gpu.device.createTexture(i);
|
|
1417
|
+
return e._gpuData[this._renderer.uid] = new Ve(o), this._managedTextures.add(e) && (e.on("update", this.onSourceUpdate, this), e.on("resize", this.onSourceResize, this), e.on("updateMipmaps", this.onUpdateMipmaps, this)), this.onSourceUpdate(e), o;
|
|
1511
1418
|
}
|
|
1512
1419
|
onSourceUpdate(e) {
|
|
1513
1420
|
const t = this.getGpuSource(e);
|
|
1514
1421
|
t && (this._uploads[e.uploadMethodId] && this._uploads[e.uploadMethodId].upload(e, t, this._gpu), e.autoGenerateMipmaps && e.mipLevelCount > 1 && this.onUpdateMipmaps(e));
|
|
1515
1422
|
}
|
|
1516
1423
|
onUpdateMipmaps(e) {
|
|
1517
|
-
this._mipmapGenerator || (this._mipmapGenerator = new
|
|
1424
|
+
this._mipmapGenerator || (this._mipmapGenerator = new We(this._gpu.device));
|
|
1518
1425
|
const t = this.getGpuSource(e);
|
|
1519
1426
|
this._mipmapGenerator.generateMipmap(t);
|
|
1520
1427
|
}
|
|
@@ -1550,10 +1457,10 @@ class ie {
|
|
|
1550
1457
|
}
|
|
1551
1458
|
_createTextureBindGroup(e) {
|
|
1552
1459
|
const t = e.source;
|
|
1553
|
-
return this._bindGroupHash[e.uid] = new
|
|
1460
|
+
return this._bindGroupHash[e.uid] = new H({
|
|
1554
1461
|
0: t,
|
|
1555
1462
|
1: t.style,
|
|
1556
|
-
2: new
|
|
1463
|
+
2: new L({
|
|
1557
1464
|
uTextureMatrix: { type: "mat3x3<f32>", value: e.textureMatrix.mapCoord }
|
|
1558
1465
|
})
|
|
1559
1466
|
}), this._bindGroupHash[e.uid];
|
|
@@ -1567,8 +1474,8 @@ class ie {
|
|
|
1567
1474
|
generateCanvas(e) {
|
|
1568
1475
|
const t = this._renderer, r = t.gpu.device.createCommandEncoder(), s = x.get().createCanvas();
|
|
1569
1476
|
s.width = e.source.pixelWidth, s.height = e.source.pixelHeight;
|
|
1570
|
-
const
|
|
1571
|
-
return
|
|
1477
|
+
const n = s.getContext("webgpu");
|
|
1478
|
+
return n.configure({
|
|
1572
1479
|
device: t.gpu.device,
|
|
1573
1480
|
usage: GPUTextureUsage.COPY_DST | GPUTextureUsage.COPY_SRC,
|
|
1574
1481
|
format: x.get().getNavigator().gpu.getPreferredCanvasFormat(),
|
|
@@ -1580,7 +1487,7 @@ class ie {
|
|
|
1580
1487
|
y: 0
|
|
1581
1488
|
}
|
|
1582
1489
|
}, {
|
|
1583
|
-
texture:
|
|
1490
|
+
texture: n.getCurrentTexture()
|
|
1584
1491
|
}, {
|
|
1585
1492
|
width: s.width,
|
|
1586
1493
|
height: s.height
|
|
@@ -1589,8 +1496,8 @@ class ie {
|
|
|
1589
1496
|
getPixels(e) {
|
|
1590
1497
|
const t = this.generateCanvas(e), r = C.getOptimalCanvasAndContext(t.width, t.height), s = r.context;
|
|
1591
1498
|
s.drawImage(t, 0, 0);
|
|
1592
|
-
const { width:
|
|
1593
|
-
return C.returnCanvasAndContext(r), { pixels: u, width:
|
|
1499
|
+
const { width: n, height: i } = t, o = s.getImageData(0, 0, n, i), u = new Uint8ClampedArray(o.data.buffer);
|
|
1500
|
+
return C.returnCanvasAndContext(r), { pixels: u, width: n, height: i };
|
|
1594
1501
|
}
|
|
1595
1502
|
destroy() {
|
|
1596
1503
|
this._managedTextures.destroy();
|
|
@@ -1601,33 +1508,33 @@ class ie {
|
|
|
1601
1508
|
this._renderer = null, this._gpu = null, this._mipmapGenerator = null, this._gpuSamplers = null, this._bindGroupHash = null;
|
|
1602
1509
|
}
|
|
1603
1510
|
}
|
|
1604
|
-
|
|
1511
|
+
re.extension = {
|
|
1605
1512
|
type: [
|
|
1606
|
-
|
|
1513
|
+
l.WebGPUSystem
|
|
1607
1514
|
],
|
|
1608
1515
|
name: "texture"
|
|
1609
1516
|
};
|
|
1610
|
-
class
|
|
1517
|
+
class se {
|
|
1611
1518
|
constructor() {
|
|
1612
1519
|
this._maxTextures = 0;
|
|
1613
1520
|
}
|
|
1614
1521
|
contextChange(e) {
|
|
1615
|
-
const t = new
|
|
1522
|
+
const t = new L({
|
|
1616
1523
|
uTransformMatrix: { value: new A(), type: "mat3x3<f32>" },
|
|
1617
1524
|
uColor: { value: new Float32Array([1, 1, 1, 1]), type: "vec4<f32>" },
|
|
1618
1525
|
uRound: { value: 0, type: "f32" }
|
|
1619
1526
|
});
|
|
1620
1527
|
this._maxTextures = e.limits.maxBatchableTextures;
|
|
1621
|
-
const r =
|
|
1528
|
+
const r = F({
|
|
1622
1529
|
name: "graphics",
|
|
1623
1530
|
bits: [
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1531
|
+
be,
|
|
1532
|
+
ye(this._maxTextures),
|
|
1533
|
+
Se,
|
|
1534
|
+
O
|
|
1628
1535
|
]
|
|
1629
1536
|
});
|
|
1630
|
-
this.shader = new
|
|
1537
|
+
this.shader = new W({
|
|
1631
1538
|
gpuProgram: r,
|
|
1632
1539
|
resources: {
|
|
1633
1540
|
// added on the fly!
|
|
@@ -1636,19 +1543,19 @@ class ne {
|
|
|
1636
1543
|
});
|
|
1637
1544
|
}
|
|
1638
1545
|
execute(e, t) {
|
|
1639
|
-
const r = t.context, s = r.customShader || this.shader,
|
|
1546
|
+
const r = t.context, s = r.customShader || this.shader, n = e.renderer, i = n.graphicsContext, {
|
|
1640
1547
|
batcher: o,
|
|
1641
1548
|
instructions: u
|
|
1642
|
-
} =
|
|
1549
|
+
} = i.getContextRenderData(r), c = n.encoder;
|
|
1643
1550
|
c.setGeometry(o.geometry, s.gpuProgram);
|
|
1644
|
-
const f =
|
|
1551
|
+
const f = n.globalUniforms.bindGroup;
|
|
1645
1552
|
c.setBindGroup(0, f, s.gpuProgram);
|
|
1646
|
-
const h =
|
|
1553
|
+
const h = n.renderPipes.uniformBatch.getUniformBindGroup(s.resources.localUniforms, !0);
|
|
1647
1554
|
c.setBindGroup(2, h, s.gpuProgram);
|
|
1648
|
-
const
|
|
1555
|
+
const p = u.instructions;
|
|
1649
1556
|
let d = null;
|
|
1650
1557
|
for (let g = 0; g < u.instructionSize; g++) {
|
|
1651
|
-
const m =
|
|
1558
|
+
const m = p[g];
|
|
1652
1559
|
if (m.topology !== d && (d = m.topology, c.setPipelineFromGeometryProgramAndState(
|
|
1653
1560
|
o.geometry,
|
|
1654
1561
|
s.gpuProgram,
|
|
@@ -1660,7 +1567,7 @@ class ne {
|
|
|
1660
1567
|
G.textures,
|
|
1661
1568
|
G.count,
|
|
1662
1569
|
this._maxTextures
|
|
1663
|
-
), m.gpuBindGroup =
|
|
1570
|
+
), m.gpuBindGroup = n.bindGroup.getBindGroup(
|
|
1664
1571
|
m.bindGroup,
|
|
1665
1572
|
s.gpuProgram,
|
|
1666
1573
|
1
|
|
@@ -1673,23 +1580,23 @@ class ne {
|
|
|
1673
1580
|
this.shader.destroy(!0), this.shader = null;
|
|
1674
1581
|
}
|
|
1675
1582
|
}
|
|
1676
|
-
|
|
1583
|
+
se.extension = {
|
|
1677
1584
|
type: [
|
|
1678
|
-
|
|
1585
|
+
l.WebGPUPipesAdaptor
|
|
1679
1586
|
],
|
|
1680
1587
|
name: "graphics"
|
|
1681
1588
|
};
|
|
1682
|
-
class
|
|
1589
|
+
class ne {
|
|
1683
1590
|
init() {
|
|
1684
|
-
const e =
|
|
1591
|
+
const e = F({
|
|
1685
1592
|
name: "mesh",
|
|
1686
1593
|
bits: [
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1594
|
+
Te,
|
|
1595
|
+
Ce,
|
|
1596
|
+
O
|
|
1690
1597
|
]
|
|
1691
1598
|
});
|
|
1692
|
-
this._shader = new
|
|
1599
|
+
this._shader = new W({
|
|
1693
1600
|
gpuProgram: e,
|
|
1694
1601
|
resources: {
|
|
1695
1602
|
uTexture: R.EMPTY._source,
|
|
@@ -1706,13 +1613,13 @@ class oe {
|
|
|
1706
1613
|
if (!s)
|
|
1707
1614
|
s = this._shader, s.groups[2] = r.texture.getTextureBindGroup(t.texture);
|
|
1708
1615
|
else if (!s.gpuProgram) {
|
|
1709
|
-
|
|
1616
|
+
v("Mesh shader has no gpuProgram", t.shader);
|
|
1710
1617
|
return;
|
|
1711
1618
|
}
|
|
1712
|
-
const
|
|
1713
|
-
if (
|
|
1714
|
-
const
|
|
1715
|
-
s.groups[1] = r.renderPipes.uniformBatch.getUniformBindGroup(
|
|
1619
|
+
const n = s.gpuProgram;
|
|
1620
|
+
if (n.autoAssignGlobalUniforms && (s.groups[0] = r.globalUniforms.bindGroup), n.autoAssignLocalUniforms) {
|
|
1621
|
+
const i = e.localUniforms;
|
|
1622
|
+
s.groups[1] = r.renderPipes.uniformBatch.getUniformBindGroup(i, !0);
|
|
1716
1623
|
}
|
|
1717
1624
|
r.encoder.draw({
|
|
1718
1625
|
geometry: t._geometry,
|
|
@@ -1724,45 +1631,45 @@ class oe {
|
|
|
1724
1631
|
this._shader.destroy(!0), this._shader = null;
|
|
1725
1632
|
}
|
|
1726
1633
|
}
|
|
1727
|
-
|
|
1634
|
+
ne.extension = {
|
|
1728
1635
|
type: [
|
|
1729
|
-
|
|
1636
|
+
l.WebGPUPipesAdaptor
|
|
1730
1637
|
],
|
|
1731
1638
|
name: "mesh"
|
|
1732
1639
|
};
|
|
1733
|
-
const
|
|
1734
|
-
...
|
|
1735
|
-
|
|
1640
|
+
const Ne = [
|
|
1641
|
+
...xe,
|
|
1642
|
+
ge,
|
|
1643
|
+
K,
|
|
1644
|
+
U,
|
|
1736
1645
|
q,
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
j,
|
|
1740
|
-
ie,
|
|
1741
|
-
Q,
|
|
1742
|
-
ee,
|
|
1743
|
-
te,
|
|
1646
|
+
z,
|
|
1647
|
+
re,
|
|
1744
1648
|
J,
|
|
1745
|
-
|
|
1649
|
+
Q,
|
|
1650
|
+
Z,
|
|
1746
1651
|
$,
|
|
1652
|
+
j,
|
|
1653
|
+
Y,
|
|
1747
1654
|
N
|
|
1748
|
-
],
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
class
|
|
1655
|
+
], ze = [...Ge, X], je = [V, ne, se], ie = [], oe = [], ae = [];
|
|
1656
|
+
B.handleByNamedList(l.WebGPUSystem, ie);
|
|
1657
|
+
B.handleByNamedList(l.WebGPUPipes, oe);
|
|
1658
|
+
B.handleByNamedList(l.WebGPUPipesAdaptor, ae);
|
|
1659
|
+
B.add(...Ne, ...ze, ...je);
|
|
1660
|
+
class Ze extends fe {
|
|
1754
1661
|
constructor() {
|
|
1755
1662
|
const e = {
|
|
1756
1663
|
name: "webgpu",
|
|
1757
|
-
type:
|
|
1758
|
-
systems:
|
|
1759
|
-
renderPipes:
|
|
1760
|
-
renderPipeAdaptors:
|
|
1664
|
+
type: ve.WEBGPU,
|
|
1665
|
+
systems: ie,
|
|
1666
|
+
renderPipes: oe,
|
|
1667
|
+
renderPipeAdaptors: ae
|
|
1761
1668
|
};
|
|
1762
1669
|
super(e);
|
|
1763
1670
|
}
|
|
1764
1671
|
}
|
|
1765
1672
|
export {
|
|
1766
|
-
|
|
1673
|
+
Ze as WebGPURenderer
|
|
1767
1674
|
};
|
|
1768
|
-
//# sourceMappingURL=WebGPURenderer-
|
|
1675
|
+
//# sourceMappingURL=WebGPURenderer-DBDzoMAw.js.map
|