holostaff-widget 3.0.0-alpha.9 → 3.0.0
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/{BufferResource-B55p1jpv.js → BufferResource-DeLlYxf8.js} +58 -56
- package/dist/{BufferResource-B55p1jpv.js.map → BufferResource-DeLlYxf8.js.map} +1 -1
- package/dist/CanvasRenderer-BgLtSh22.js +5933 -0
- package/dist/CanvasRenderer-BgLtSh22.js.map +1 -0
- package/dist/Geometry-Bdq2tsB3.js +1017 -0
- package/dist/Geometry-Bdq2tsB3.js.map +1 -0
- package/dist/{RenderTargetSystem-CgD3OnwB.js → RenderTargetSystem-BCBByEgg.js} +1543 -501
- package/dist/RenderTargetSystem-BCBByEgg.js.map +1 -0
- package/dist/{WebGLRenderer-BuYJ2PeA.js → WebGLRenderer-3x7mgYt9.js} +55 -54
- package/dist/{WebGLRenderer-BuYJ2PeA.js.map → WebGLRenderer-3x7mgYt9.js.map} +1 -1
- package/dist/{WebGPURenderer-Cggaw1fN.js → WebGPURenderer-CdbjQMqs.js} +242 -197
- package/dist/WebGPURenderer-CdbjQMqs.js.map +1 -0
- package/dist/{browserAll-Q-GPHxQW.js → browserAll-DejMU3y7.js} +3 -3
- package/dist/{browserAll-Q-GPHxQW.js.map → browserAll-DejMU3y7.js.map} +1 -1
- package/dist/getTextureBatchBindGroup-CHJWR-eE.js +23 -0
- package/dist/getTextureBatchBindGroup-CHJWR-eE.js.map +1 -0
- package/dist/hs-widget.es.js +2 -2
- package/dist/hs-widget.umd.js +210 -122
- package/dist/hs-widget.umd.js.map +1 -1
- package/dist/index-C1ZbqCjI.js +17937 -0
- package/dist/index-C1ZbqCjI.js.map +1 -0
- package/dist/{webworkerAll-B8GxyCwb.js → webworkerAll-D5g5Ds7S.js} +12 -12
- package/dist/{webworkerAll-B8GxyCwb.js.map → webworkerAll-D5g5Ds7S.js.map} +1 -1
- package/package.json +2 -1
- package/dist/CanvasRenderer-B-tXhUVj.js +0 -976
- package/dist/CanvasRenderer-B-tXhUVj.js.map +0 -1
- package/dist/Filter-CgpxtqZ1.js +0 -57
- package/dist/Filter-CgpxtqZ1.js.map +0 -1
- package/dist/RenderTargetSystem-CgD3OnwB.js.map +0 -1
- package/dist/WebGPURenderer-Cggaw1fN.js.map +0 -1
- package/dist/index-IH6ECrLJ.js +0 -25726
- package/dist/index-IH6ECrLJ.js.map +0 -1
|
@@ -1,14 +1,59 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { D as x, n as M, G as de, c as p, a as he, w as U, d as y, f as le, g as pe, M as A, T as R, A as fe, e as S } from "./index-C1ZbqCjI.js";
|
|
2
|
+
import { g as D } from "./getTextureBatchBindGroup-CHJWR-eE.js";
|
|
3
|
+
import { G as k, f as ge, S as v, R as me, c as z, a as _e, r as F, g as be, b as ye, d as xe } from "./RenderTargetSystem-BCBByEgg.js";
|
|
4
|
+
import { c as Ge, u as Pe, U as Be, B as Se, G as Te, e as ve, l as Ce, a as Ue, t as we } from "./BufferResource-DeLlYxf8.js";
|
|
5
|
+
import { S as O, b as T, a as Me, B as I, c as E, U as W, d as H, R as Re } from "./Geometry-Bdq2tsB3.js";
|
|
6
|
+
class Ee {
|
|
7
|
+
constructor(e) {
|
|
8
|
+
this._canvasPool = /* @__PURE__ */ Object.create(null), this.canvasOptions = e || {}, this.enableFullScreen = !1;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Creates texture with params that were specified in pool constructor.
|
|
12
|
+
* @param pixelWidth - Width of texture in pixels.
|
|
13
|
+
* @param pixelHeight - Height of texture in pixels.
|
|
14
|
+
*/
|
|
15
|
+
_createCanvasAndContext(e, t) {
|
|
16
|
+
const r = x.get().createCanvas();
|
|
17
|
+
r.width = e, r.height = t;
|
|
18
|
+
const s = r.getContext("2d");
|
|
19
|
+
return { canvas: r, context: s };
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Gets a Power-of-Two render texture or fullScreen texture
|
|
23
|
+
* @param minWidth - The minimum width of the render texture.
|
|
24
|
+
* @param minHeight - The minimum height of the render texture.
|
|
25
|
+
* @param resolution - The resolution of the render texture.
|
|
26
|
+
* @returns The new render texture.
|
|
27
|
+
*/
|
|
28
|
+
getOptimalCanvasAndContext(e, t, r = 1) {
|
|
29
|
+
e = Math.ceil(e * r - 1e-6), t = Math.ceil(t * r - 1e-6), e = M(e), t = M(t);
|
|
30
|
+
const s = (e << 17) + (t << 1);
|
|
31
|
+
this._canvasPool[s] || (this._canvasPool[s] = []);
|
|
32
|
+
let i = this._canvasPool[s].pop();
|
|
33
|
+
return i || (i = this._createCanvasAndContext(e, t)), i;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Place a render texture back into the pool.
|
|
37
|
+
* @param canvasAndContext
|
|
38
|
+
*/
|
|
39
|
+
returnCanvasAndContext(e) {
|
|
40
|
+
const t = e.canvas, { width: r, height: s } = t, i = (r << 17) + (s << 1);
|
|
41
|
+
e.context.resetTransform(), e.context.clearRect(0, 0, r, s), this._canvasPool[i].push(e);
|
|
42
|
+
}
|
|
43
|
+
clear() {
|
|
44
|
+
this._canvasPool = {};
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
const C = new Ee();
|
|
48
|
+
de.register(C);
|
|
49
|
+
const P = O.for2d();
|
|
50
|
+
class V {
|
|
6
51
|
start(e, t, r) {
|
|
7
52
|
const s = e.renderer, i = s.encoder, n = r.gpuProgram;
|
|
8
|
-
this._shader = r, this._geometry = t, i.setGeometry(t, n),
|
|
53
|
+
this._shader = r, this._geometry = t, i.setGeometry(t, n), P.blendMode = "normal", s.pipeline.getPipeline(
|
|
9
54
|
t,
|
|
10
55
|
n,
|
|
11
|
-
|
|
56
|
+
P
|
|
12
57
|
);
|
|
13
58
|
const o = s.globalUniforms.bindGroup;
|
|
14
59
|
i.resetBindGroup(1), i.setBindGroup(0, o, n);
|
|
@@ -17,13 +62,13 @@ class H {
|
|
|
17
62
|
const r = this._shader.gpuProgram, s = e.renderer, i = s.encoder;
|
|
18
63
|
if (!t.bindGroup) {
|
|
19
64
|
const u = t.textures;
|
|
20
|
-
t.bindGroup =
|
|
65
|
+
t.bindGroup = D(
|
|
21
66
|
u.textures,
|
|
22
67
|
u.count,
|
|
23
68
|
s.limits.maxBatchableTextures
|
|
24
69
|
);
|
|
25
70
|
}
|
|
26
|
-
|
|
71
|
+
P.blendMode = t.blendMode;
|
|
27
72
|
const n = s.bindGroup.getBindGroup(
|
|
28
73
|
t.bindGroup,
|
|
29
74
|
r,
|
|
@@ -31,19 +76,19 @@ class H {
|
|
|
31
76
|
), o = s.pipeline.getPipeline(
|
|
32
77
|
this._geometry,
|
|
33
78
|
r,
|
|
34
|
-
|
|
79
|
+
P,
|
|
35
80
|
t.topology
|
|
36
81
|
);
|
|
37
82
|
t.bindGroup._touch(s.gc.now, s.tick), i.setPipeline(o), i.renderPassEncoder.setBindGroup(1, n), i.renderPassEncoder.drawIndexed(t.size, 1, t.start);
|
|
38
83
|
}
|
|
39
84
|
}
|
|
40
|
-
|
|
85
|
+
V.extension = {
|
|
41
86
|
type: [
|
|
42
|
-
|
|
87
|
+
p.WebGPUPipesAdaptor
|
|
43
88
|
],
|
|
44
89
|
name: "batch"
|
|
45
90
|
};
|
|
46
|
-
class
|
|
91
|
+
class N {
|
|
47
92
|
constructor(e) {
|
|
48
93
|
this._hash = /* @__PURE__ */ Object.create(null), this._renderer = e;
|
|
49
94
|
}
|
|
@@ -57,40 +102,40 @@ class V {
|
|
|
57
102
|
const s = this._gpu.device, i = t.layout[r], n = [], o = this._renderer;
|
|
58
103
|
for (const f in i) {
|
|
59
104
|
const h = e.resources[f] ?? e.resources[i[f]];
|
|
60
|
-
let
|
|
105
|
+
let l;
|
|
61
106
|
if (h._resourceType === "uniformGroup") {
|
|
62
107
|
const d = h;
|
|
63
108
|
o.ubo.updateUniformGroup(d);
|
|
64
109
|
const g = d.buffer;
|
|
65
|
-
|
|
110
|
+
l = {
|
|
66
111
|
buffer: o.buffer.getGPUBuffer(g),
|
|
67
112
|
offset: 0,
|
|
68
113
|
size: g.descriptor.size
|
|
69
114
|
};
|
|
70
115
|
} else if (h._resourceType === "buffer") {
|
|
71
116
|
const d = h;
|
|
72
|
-
|
|
117
|
+
l = {
|
|
73
118
|
buffer: o.buffer.getGPUBuffer(d),
|
|
74
119
|
offset: 0,
|
|
75
120
|
size: d.descriptor.size
|
|
76
121
|
};
|
|
77
122
|
} else if (h._resourceType === "bufferResource") {
|
|
78
123
|
const d = h;
|
|
79
|
-
|
|
124
|
+
l = {
|
|
80
125
|
buffer: o.buffer.getGPUBuffer(d.buffer),
|
|
81
126
|
offset: d.offset,
|
|
82
127
|
size: d.size
|
|
83
128
|
};
|
|
84
129
|
} else if (h._resourceType === "textureSampler") {
|
|
85
130
|
const d = h;
|
|
86
|
-
|
|
131
|
+
l = o.texture.getGpuSampler(d);
|
|
87
132
|
} else if (h._resourceType === "textureSource") {
|
|
88
133
|
const d = h;
|
|
89
|
-
|
|
134
|
+
l = o.texture.getTextureView(d);
|
|
90
135
|
}
|
|
91
136
|
n.push({
|
|
92
137
|
binding: i[f],
|
|
93
|
-
resource:
|
|
138
|
+
resource: l
|
|
94
139
|
});
|
|
95
140
|
}
|
|
96
141
|
const u = o.shader.getProgramData(t).bindGroups[r], c = s.createBindGroup({
|
|
@@ -103,13 +148,13 @@ class V {
|
|
|
103
148
|
this._hash = null, this._renderer = null;
|
|
104
149
|
}
|
|
105
150
|
}
|
|
106
|
-
|
|
151
|
+
N.extension = {
|
|
107
152
|
type: [
|
|
108
|
-
|
|
153
|
+
p.WebGPUSystem
|
|
109
154
|
],
|
|
110
155
|
name: "bindGroup"
|
|
111
156
|
};
|
|
112
|
-
class
|
|
157
|
+
class Le {
|
|
113
158
|
constructor(e) {
|
|
114
159
|
this.gpuBuffer = e;
|
|
115
160
|
}
|
|
@@ -117,9 +162,9 @@ class Me {
|
|
|
117
162
|
this.gpuBuffer.destroy(), this.gpuBuffer = null;
|
|
118
163
|
}
|
|
119
164
|
}
|
|
120
|
-
class
|
|
165
|
+
class j {
|
|
121
166
|
constructor(e) {
|
|
122
|
-
this._renderer = e, this._managedBuffers = new
|
|
167
|
+
this._renderer = e, this._managedBuffers = new k({
|
|
123
168
|
renderer: e,
|
|
124
169
|
type: "resource",
|
|
125
170
|
onUnload: this.onBufferUnload.bind(this),
|
|
@@ -153,12 +198,12 @@ class N {
|
|
|
153
198
|
}
|
|
154
199
|
createGPUBuffer(e) {
|
|
155
200
|
const t = this._gpu.device.createBuffer(e.descriptor);
|
|
156
|
-
return e._updateID = 0, e._resourceId =
|
|
201
|
+
return e._updateID = 0, e._resourceId = he("resource"), e.data && (ge(
|
|
157
202
|
e.data.buffer,
|
|
158
203
|
t.getMappedRange(),
|
|
159
204
|
e.data.byteOffset,
|
|
160
205
|
e.data.byteLength
|
|
161
|
-
), t.unmap()), e._gpuData[this._renderer.uid] = new
|
|
206
|
+
), t.unmap()), e._gpuData[this._renderer.uid] = new Le(t), this._managedBuffers.add(e) && (e.on("update", this.updateBuffer, this), e.on("change", this.onBufferChange, this)), t;
|
|
162
207
|
}
|
|
163
208
|
onBufferChange(e) {
|
|
164
209
|
this._managedBuffers.remove(e), e._updateID = 0, this.createGPUBuffer(e);
|
|
@@ -167,13 +212,13 @@ class N {
|
|
|
167
212
|
this._managedBuffers.destroy(), this._renderer = null, this._gpu = null;
|
|
168
213
|
}
|
|
169
214
|
}
|
|
170
|
-
|
|
215
|
+
j.extension = {
|
|
171
216
|
type: [
|
|
172
|
-
|
|
217
|
+
p.WebGPUSystem
|
|
173
218
|
],
|
|
174
219
|
name: "buffer"
|
|
175
220
|
};
|
|
176
|
-
class
|
|
221
|
+
class Ae {
|
|
177
222
|
constructor({ minUniformOffsetAlignment: e }) {
|
|
178
223
|
this._minUniformOffsetAlignment = 256, this.byteIndex = 0, this._minUniformOffsetAlignment = e, this.data = new Float32Array(65535);
|
|
179
224
|
}
|
|
@@ -199,7 +244,7 @@ class Re {
|
|
|
199
244
|
this.data = null;
|
|
200
245
|
}
|
|
201
246
|
}
|
|
202
|
-
class
|
|
247
|
+
class K {
|
|
203
248
|
constructor(e) {
|
|
204
249
|
this._colorMaskCache = 15, this._renderer = e;
|
|
205
250
|
}
|
|
@@ -210,13 +255,13 @@ class j {
|
|
|
210
255
|
this._renderer = null, this._colorMaskCache = null;
|
|
211
256
|
}
|
|
212
257
|
}
|
|
213
|
-
|
|
258
|
+
K.extension = {
|
|
214
259
|
type: [
|
|
215
|
-
|
|
260
|
+
p.WebGPUSystem
|
|
216
261
|
],
|
|
217
262
|
name: "colorMask"
|
|
218
263
|
};
|
|
219
|
-
class
|
|
264
|
+
class w {
|
|
220
265
|
/**
|
|
221
266
|
* @param {WebGPURenderer} renderer - The renderer this System works for.
|
|
222
267
|
*/
|
|
@@ -243,7 +288,7 @@ class U {
|
|
|
243
288
|
* @returns {WebGLRenderingContext} the WebGL context
|
|
244
289
|
*/
|
|
245
290
|
async _createDeviceAndAdaptor(e) {
|
|
246
|
-
const t = await
|
|
291
|
+
const t = await x.get().getNavigator().gpu.requestAdapter({
|
|
247
292
|
powerPreference: e.powerPreference,
|
|
248
293
|
forceFallbackAdapter: e.forceFallbackAdapter
|
|
249
294
|
}), r = [
|
|
@@ -259,13 +304,13 @@ class U {
|
|
|
259
304
|
this.gpu = null, this._renderer = null;
|
|
260
305
|
}
|
|
261
306
|
}
|
|
262
|
-
|
|
307
|
+
w.extension = {
|
|
263
308
|
type: [
|
|
264
|
-
|
|
309
|
+
p.WebGPUSystem
|
|
265
310
|
],
|
|
266
311
|
name: "device"
|
|
267
312
|
};
|
|
268
|
-
|
|
313
|
+
w.defaultOptions = {
|
|
269
314
|
/**
|
|
270
315
|
* {@link WebGPUOptions.powerPreference}
|
|
271
316
|
* @default default
|
|
@@ -277,7 +322,7 @@ U.defaultOptions = {
|
|
|
277
322
|
*/
|
|
278
323
|
forceFallbackAdapter: !1
|
|
279
324
|
};
|
|
280
|
-
class
|
|
325
|
+
class q {
|
|
281
326
|
constructor(e) {
|
|
282
327
|
this._boundBindGroup = /* @__PURE__ */ Object.create(null), this._boundVertexBuffer = /* @__PURE__ */ Object.create(null), this._renderer = e;
|
|
283
328
|
}
|
|
@@ -386,12 +431,12 @@ class K {
|
|
|
386
431
|
this._gpu = e;
|
|
387
432
|
}
|
|
388
433
|
}
|
|
389
|
-
|
|
390
|
-
type: [
|
|
434
|
+
q.extension = {
|
|
435
|
+
type: [p.WebGPUSystem],
|
|
391
436
|
name: "encoder",
|
|
392
437
|
priority: 1
|
|
393
438
|
};
|
|
394
|
-
class
|
|
439
|
+
class Y {
|
|
395
440
|
constructor(e) {
|
|
396
441
|
this._renderer = e;
|
|
397
442
|
}
|
|
@@ -401,20 +446,20 @@ class q {
|
|
|
401
446
|
destroy() {
|
|
402
447
|
}
|
|
403
448
|
}
|
|
404
|
-
|
|
449
|
+
Y.extension = {
|
|
405
450
|
type: [
|
|
406
|
-
|
|
451
|
+
p.WebGPUSystem
|
|
407
452
|
],
|
|
408
453
|
name: "limits"
|
|
409
454
|
};
|
|
410
|
-
class
|
|
455
|
+
class $ {
|
|
411
456
|
constructor(e) {
|
|
412
457
|
this._renderTargetStencilState = /* @__PURE__ */ Object.create(null), this._renderer = e, e.renderTarget.onRenderTargetChange.add(this);
|
|
413
458
|
}
|
|
414
459
|
onRenderTargetChange(e) {
|
|
415
460
|
let t = this._renderTargetStencilState[e.uid];
|
|
416
461
|
t || (t = this._renderTargetStencilState[e.uid] = {
|
|
417
|
-
stencilMode:
|
|
462
|
+
stencilMode: v.DISABLED,
|
|
418
463
|
stencilReference: 0
|
|
419
464
|
}), this._activeRenderTarget = e, this.setStencilMode(t.stencilMode, t.stencilReference);
|
|
420
465
|
}
|
|
@@ -428,13 +473,13 @@ class Y {
|
|
|
428
473
|
this._renderer.renderTarget.onRenderTargetChange.remove(this), this._renderer = null, this._activeRenderTarget = null, this._renderTargetStencilState = null;
|
|
429
474
|
}
|
|
430
475
|
}
|
|
431
|
-
|
|
476
|
+
$.extension = {
|
|
432
477
|
type: [
|
|
433
|
-
|
|
478
|
+
p.WebGPUSystem
|
|
434
479
|
],
|
|
435
480
|
name: "stencil"
|
|
436
481
|
};
|
|
437
|
-
const
|
|
482
|
+
const B = {
|
|
438
483
|
i32: { align: 4, size: 4 },
|
|
439
484
|
u32: { align: 4, size: 4 },
|
|
440
485
|
f32: { align: 4, size: 4 },
|
|
@@ -470,7 +515,7 @@ const P = {
|
|
|
470
515
|
"mat4x4<f32>": { align: 16, size: 64 },
|
|
471
516
|
"mat4x4<f16>": { align: 8, size: 32 }
|
|
472
517
|
};
|
|
473
|
-
function
|
|
518
|
+
function De(a) {
|
|
474
519
|
const e = a.map((r) => ({
|
|
475
520
|
data: r,
|
|
476
521
|
offset: 0,
|
|
@@ -479,16 +524,16 @@ function Ee(a) {
|
|
|
479
524
|
let t = 0;
|
|
480
525
|
for (let r = 0; r < e.length; r++) {
|
|
481
526
|
const s = e[r];
|
|
482
|
-
let i =
|
|
483
|
-
const n =
|
|
484
|
-
if (!
|
|
527
|
+
let i = B[s.data.type].size;
|
|
528
|
+
const n = B[s.data.type].align;
|
|
529
|
+
if (!B[s.data.type])
|
|
485
530
|
throw new Error(`[Pixi.js] WebGPU UniformBuffer: Unknown type ${s.data.type}`);
|
|
486
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;
|
|
487
532
|
}
|
|
488
533
|
return t = Math.ceil(t / 16) * 16, { uboElements: e, size: t };
|
|
489
534
|
}
|
|
490
|
-
function
|
|
491
|
-
const { size: t, align: r } =
|
|
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";
|
|
492
537
|
return `
|
|
493
538
|
v = uv.${a.data.name};
|
|
494
539
|
${e !== 0 ? `offset += ${e};` : ""}
|
|
@@ -507,34 +552,34 @@ function Le(a, e) {
|
|
|
507
552
|
}
|
|
508
553
|
`;
|
|
509
554
|
}
|
|
510
|
-
function
|
|
511
|
-
return
|
|
555
|
+
function ze(a) {
|
|
556
|
+
return Ge(
|
|
512
557
|
a,
|
|
513
558
|
"uboWgsl",
|
|
514
|
-
|
|
515
|
-
|
|
559
|
+
ke,
|
|
560
|
+
Pe
|
|
516
561
|
);
|
|
517
562
|
}
|
|
518
|
-
class
|
|
563
|
+
class X extends Be {
|
|
519
564
|
constructor() {
|
|
520
565
|
super({
|
|
521
|
-
createUboElements:
|
|
522
|
-
generateUboSync:
|
|
566
|
+
createUboElements: De,
|
|
567
|
+
generateUboSync: ze
|
|
523
568
|
});
|
|
524
569
|
}
|
|
525
570
|
}
|
|
526
|
-
|
|
527
|
-
type: [
|
|
571
|
+
X.extension = {
|
|
572
|
+
type: [p.WebGPUSystem],
|
|
528
573
|
name: "ubo"
|
|
529
574
|
};
|
|
530
575
|
const b = 128;
|
|
531
|
-
class
|
|
576
|
+
class Z {
|
|
532
577
|
constructor(e) {
|
|
533
|
-
this._bindGroupHash = /* @__PURE__ */ Object.create(null), this._buffers = [], this._bindGroups = [], this._bufferResources = [], this._renderer = e, this._batchBuffer = new
|
|
578
|
+
this._bindGroupHash = /* @__PURE__ */ Object.create(null), this._buffers = [], this._bindGroups = [], this._bufferResources = [], this._renderer = e, this._batchBuffer = new Ae({ minUniformOffsetAlignment: b });
|
|
534
579
|
const t = 256 / b;
|
|
535
580
|
for (let r = 0; r < t; r++) {
|
|
536
581
|
let s = T.UNIFORM | T.COPY_DST;
|
|
537
|
-
r === 0 && (s |= T.COPY_SRC), this._buffers.push(new
|
|
582
|
+
r === 0 && (s |= T.COPY_SRC), this._buffers.push(new Me({
|
|
538
583
|
data: this._batchBuffer.data,
|
|
539
584
|
usage: s
|
|
540
585
|
}));
|
|
@@ -570,7 +615,7 @@ class X {
|
|
|
570
615
|
_getBufferResource(e) {
|
|
571
616
|
if (!this._bufferResources[e]) {
|
|
572
617
|
const t = this._buffers[e % 2];
|
|
573
|
-
this._bufferResources[e] = new
|
|
618
|
+
this._bufferResources[e] = new Se({
|
|
574
619
|
buffer: t,
|
|
575
620
|
offset: (e / 2 | 0) * 256,
|
|
576
621
|
size: b
|
|
@@ -580,7 +625,7 @@ class X {
|
|
|
580
625
|
}
|
|
581
626
|
_getBindGroup(e) {
|
|
582
627
|
if (!this._bindGroups[e]) {
|
|
583
|
-
const t = new
|
|
628
|
+
const t = new I({
|
|
584
629
|
0: this._getBufferResource(e)
|
|
585
630
|
});
|
|
586
631
|
this._bindGroups[e] = t;
|
|
@@ -616,23 +661,23 @@ class X {
|
|
|
616
661
|
this._bufferResources = null, this._batchBuffer.destroy(), this._renderer = null;
|
|
617
662
|
}
|
|
618
663
|
}
|
|
619
|
-
|
|
664
|
+
Z.extension = {
|
|
620
665
|
type: [
|
|
621
|
-
|
|
666
|
+
p.WebGPUPipes
|
|
622
667
|
],
|
|
623
668
|
name: "uniformBatch"
|
|
624
669
|
};
|
|
625
|
-
const
|
|
670
|
+
const Fe = {
|
|
626
671
|
"point-list": 0,
|
|
627
672
|
"line-list": 1,
|
|
628
673
|
"line-strip": 2,
|
|
629
674
|
"triangle-list": 3,
|
|
630
675
|
"triangle-strip": 4
|
|
631
676
|
};
|
|
632
|
-
function
|
|
677
|
+
function Oe(a, e, t, r, s) {
|
|
633
678
|
return a << 24 | e << 16 | t << 10 | r << 5 | s;
|
|
634
679
|
}
|
|
635
|
-
function
|
|
680
|
+
function Ie(a, e, t, r, s) {
|
|
636
681
|
return t << 8 | a << 5 | r << 3 | s << 1 | e;
|
|
637
682
|
}
|
|
638
683
|
class J {
|
|
@@ -640,7 +685,7 @@ class J {
|
|
|
640
685
|
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;
|
|
641
686
|
}
|
|
642
687
|
contextChange(e) {
|
|
643
|
-
this._gpu = e, this.setStencilMode(
|
|
688
|
+
this._gpu = e, this.setStencilMode(v.DISABLED), this._updatePipeHash();
|
|
644
689
|
}
|
|
645
690
|
setMultisampleCount(e) {
|
|
646
691
|
this._multisampleCount !== e && (this._multisampleCount = e, this._updatePipeHash());
|
|
@@ -652,27 +697,27 @@ class J {
|
|
|
652
697
|
this._colorMask !== e && (this._colorMask = e, this._updatePipeHash());
|
|
653
698
|
}
|
|
654
699
|
setStencilMode(e) {
|
|
655
|
-
this._stencilMode !== e && (this._stencilMode = e, this._stencilState =
|
|
700
|
+
this._stencilMode !== e && (this._stencilMode = e, this._stencilState = Te[e], this._updatePipeHash());
|
|
656
701
|
}
|
|
657
702
|
setPipeline(e, t, r, s) {
|
|
658
703
|
const i = this.getPipeline(e, t, r);
|
|
659
704
|
s.setPipeline(i);
|
|
660
705
|
}
|
|
661
706
|
getPipeline(e, t, r, s) {
|
|
662
|
-
e._layoutKey || (
|
|
663
|
-
const i =
|
|
707
|
+
e._layoutKey || (ve(e, t.attributeData), this._generateBufferKey(e)), s || (s = e.topology);
|
|
708
|
+
const i = Oe(
|
|
664
709
|
e._layoutKey,
|
|
665
710
|
t._layoutKey,
|
|
666
711
|
r.data,
|
|
667
712
|
r._blendModeId,
|
|
668
|
-
|
|
713
|
+
Fe[s]
|
|
669
714
|
);
|
|
670
715
|
return this._pipeCache[i] ? this._pipeCache[i] : (this._pipeCache[i] = this._createPipeline(e, t, r, s), this._pipeCache[i]);
|
|
671
716
|
}
|
|
672
717
|
_createPipeline(e, t, r, s) {
|
|
673
|
-
const i = this._gpu.device, n = this._createVertexBufferLayouts(e, t), o = this._renderer.state.getColorTargets(r, this._colorTargetCount), u = this._stencilMode ===
|
|
674
|
-
for (let
|
|
675
|
-
o[
|
|
718
|
+
const i = this._gpu.device, n = this._createVertexBufferLayouts(e, t), o = this._renderer.state.getColorTargets(r, this._colorTargetCount), u = this._stencilMode === v.RENDERING_MASK_ADD ? 0 : this._colorMask;
|
|
719
|
+
for (let l = 0; l < o.length; l++)
|
|
720
|
+
o[l].writeMask = u;
|
|
676
721
|
const c = this._renderer.shader.getProgramData(t).pipeline, f = {
|
|
677
722
|
// TODO later check if its helpful to create..
|
|
678
723
|
// layout,
|
|
@@ -723,7 +768,7 @@ class J {
|
|
|
723
768
|
t[r++] = o.offset, t[r++] = o.format, t[r++] = o.stride, t[r++] = o.instance;
|
|
724
769
|
}
|
|
725
770
|
const i = t.join("|");
|
|
726
|
-
return e._layoutKey =
|
|
771
|
+
return e._layoutKey = E(i, "geometry"), e._layoutKey;
|
|
727
772
|
}
|
|
728
773
|
_generateAttributeLocationsKey(e) {
|
|
729
774
|
const t = [];
|
|
@@ -734,7 +779,7 @@ class J {
|
|
|
734
779
|
t[r++] = o.location;
|
|
735
780
|
}
|
|
736
781
|
const i = t.join("|");
|
|
737
|
-
return e._attributeLocationsKey =
|
|
782
|
+
return e._attributeLocationsKey = E(i, "programAttributes"), e._attributeLocationsKey;
|
|
738
783
|
}
|
|
739
784
|
/**
|
|
740
785
|
* Returns a hash of buffer names mapped to bind locations.
|
|
@@ -771,7 +816,7 @@ class J {
|
|
|
771
816
|
}, o = n.attributes;
|
|
772
817
|
for (const u in t.attributeData) {
|
|
773
818
|
const c = e.attributes[u];
|
|
774
|
-
(c.divisor ?? 1) !== 1 &&
|
|
819
|
+
(c.divisor ?? 1) !== 1 && U(`Attribute ${u} has an invalid divisor value of '${c.divisor}'. WebGPU only supports a divisor value of 1`), c.buffer === i && (n.arrayStride = c.stride, n.stepMode = c.instance ? "instance" : "vertex", o.push({
|
|
775
820
|
shaderLocation: t.attributeData[u].location,
|
|
776
821
|
offset: c.offset,
|
|
777
822
|
format: c.format
|
|
@@ -781,7 +826,7 @@ class J {
|
|
|
781
826
|
}), this._bufferLayoutsCache[r] = s, s;
|
|
782
827
|
}
|
|
783
828
|
_updatePipeHash() {
|
|
784
|
-
const e =
|
|
829
|
+
const e = Ie(
|
|
785
830
|
this._stencilMode,
|
|
786
831
|
this._multisampleCount,
|
|
787
832
|
this._colorMask,
|
|
@@ -795,15 +840,15 @@ class J {
|
|
|
795
840
|
}
|
|
796
841
|
}
|
|
797
842
|
J.extension = {
|
|
798
|
-
type: [
|
|
843
|
+
type: [p.WebGPUSystem],
|
|
799
844
|
name: "pipeline"
|
|
800
845
|
};
|
|
801
|
-
class
|
|
846
|
+
class We {
|
|
802
847
|
constructor() {
|
|
803
848
|
this.contexts = [], this.msaaTextures = [], this.msaaSamples = 1;
|
|
804
849
|
}
|
|
805
850
|
}
|
|
806
|
-
class
|
|
851
|
+
class He {
|
|
807
852
|
init(e, t) {
|
|
808
853
|
this._renderer = e, this._renderTargetSystem = t;
|
|
809
854
|
}
|
|
@@ -853,8 +898,8 @@ class Oe {
|
|
|
853
898
|
getDescriptor(e, t, r, s = 0, i = 0) {
|
|
854
899
|
typeof t == "boolean" && (t = t ? y.ALL : y.NONE);
|
|
855
900
|
const n = this._renderTargetSystem, o = n.getGpuRenderTarget(e), u = e.colorTextures.map(
|
|
856
|
-
(h,
|
|
857
|
-
const d = o.contexts[
|
|
901
|
+
(h, l) => {
|
|
902
|
+
const d = o.contexts[l];
|
|
858
903
|
let g, m;
|
|
859
904
|
if (d) {
|
|
860
905
|
if (i !== 0)
|
|
@@ -869,22 +914,22 @@ class Oe {
|
|
|
869
914
|
baseArrayLayer: i,
|
|
870
915
|
arrayLayerCount: 1
|
|
871
916
|
});
|
|
872
|
-
o.msaaTextures[
|
|
873
|
-
o.msaaTextures[
|
|
917
|
+
o.msaaTextures[l] && (m = g, g = this._renderer.texture.getTextureView(
|
|
918
|
+
o.msaaTextures[l]
|
|
874
919
|
));
|
|
875
|
-
const
|
|
920
|
+
const G = t & y.COLOR ? "clear" : "load";
|
|
876
921
|
return r ?? (r = n.defaultClearColor), {
|
|
877
922
|
view: g,
|
|
878
923
|
resolveTarget: m,
|
|
879
924
|
clearValue: r,
|
|
880
925
|
storeOp: "store",
|
|
881
|
-
loadOp:
|
|
926
|
+
loadOp: G
|
|
882
927
|
};
|
|
883
928
|
}
|
|
884
929
|
);
|
|
885
930
|
let c;
|
|
886
931
|
if ((e.stencil || e.depth) && !e.depthStencilTexture && (e.ensureDepthStencilTexture(), e.depthStencilTexture.source.sampleCount = o.msaa ? 4 : 1), e.depthStencilTexture) {
|
|
887
|
-
const h = t & y.STENCIL ? "clear" : "load",
|
|
932
|
+
const h = t & y.STENCIL ? "clear" : "load", l = t & y.DEPTH ? "clear" : "load";
|
|
888
933
|
c = {
|
|
889
934
|
view: this._renderer.texture.getGpuSource(e.depthStencilTexture.source).createView({
|
|
890
935
|
dimension: "2d",
|
|
@@ -896,7 +941,7 @@ class Oe {
|
|
|
896
941
|
stencilStoreOp: "store",
|
|
897
942
|
stencilLoadOp: h,
|
|
898
943
|
depthClearValue: 1,
|
|
899
|
-
depthLoadOp:
|
|
944
|
+
depthLoadOp: l,
|
|
900
945
|
depthStoreOp: "store"
|
|
901
946
|
};
|
|
902
947
|
}
|
|
@@ -909,7 +954,7 @@ class Oe {
|
|
|
909
954
|
if (!t) return;
|
|
910
955
|
const { gpu: o, encoder: u } = this._renderer, c = o.device;
|
|
911
956
|
if (u.commandEncoder === null) {
|
|
912
|
-
const h = c.createCommandEncoder(),
|
|
957
|
+
const h = c.createCommandEncoder(), l = this.getDescriptor(e, t, r, i, n), d = h.beginRenderPass(l);
|
|
913
958
|
d.setViewport(s.x, s.y, s.width, s.height, 0, 1), d.end();
|
|
914
959
|
const g = h.finish();
|
|
915
960
|
c.queue.submit([g]);
|
|
@@ -918,9 +963,9 @@ class Oe {
|
|
|
918
963
|
}
|
|
919
964
|
initGpuRenderTarget(e) {
|
|
920
965
|
e.isRoot = !0;
|
|
921
|
-
const t = new
|
|
966
|
+
const t = new We();
|
|
922
967
|
return t.colorTargetCount = e.colorTextures.length, e.colorTextures.forEach((r, s) => {
|
|
923
|
-
if (r instanceof
|
|
968
|
+
if (r instanceof le) {
|
|
924
969
|
const i = r.resource.getContext(
|
|
925
970
|
"webgpu"
|
|
926
971
|
), n = r.transparent ? "premultiplied" : "opaque";
|
|
@@ -937,7 +982,7 @@ class Oe {
|
|
|
937
982
|
t.contexts[s] = i;
|
|
938
983
|
}
|
|
939
984
|
if (t.msaa = r.source.antialias, r.source.antialias) {
|
|
940
|
-
const i = new
|
|
985
|
+
const i = new pe({
|
|
941
986
|
width: 0,
|
|
942
987
|
height: 0,
|
|
943
988
|
sampleCount: 4,
|
|
@@ -970,16 +1015,16 @@ class Oe {
|
|
|
970
1015
|
});
|
|
971
1016
|
}
|
|
972
1017
|
}
|
|
973
|
-
class Q extends
|
|
1018
|
+
class Q extends me {
|
|
974
1019
|
constructor(e) {
|
|
975
|
-
super(e), this.adaptor = new
|
|
1020
|
+
super(e), this.adaptor = new He(), this.adaptor.init(e, this);
|
|
976
1021
|
}
|
|
977
1022
|
}
|
|
978
1023
|
Q.extension = {
|
|
979
|
-
type: [
|
|
1024
|
+
type: [p.WebGPUSystem],
|
|
980
1025
|
name: "renderTarget"
|
|
981
1026
|
};
|
|
982
|
-
class
|
|
1027
|
+
class ee {
|
|
983
1028
|
constructor() {
|
|
984
1029
|
this._gpuProgramData = /* @__PURE__ */ Object.create(null);
|
|
985
1030
|
}
|
|
@@ -1000,9 +1045,9 @@ class Z {
|
|
|
1000
1045
|
this._gpu = null, this._gpuProgramData = null;
|
|
1001
1046
|
}
|
|
1002
1047
|
}
|
|
1003
|
-
|
|
1048
|
+
ee.extension = {
|
|
1004
1049
|
type: [
|
|
1005
|
-
|
|
1050
|
+
p.WebGPUSystem
|
|
1006
1051
|
],
|
|
1007
1052
|
name: "shader"
|
|
1008
1053
|
};
|
|
@@ -1151,9 +1196,9 @@ _.max = {
|
|
|
1151
1196
|
operation: "max"
|
|
1152
1197
|
}
|
|
1153
1198
|
};
|
|
1154
|
-
class
|
|
1199
|
+
class te {
|
|
1155
1200
|
constructor() {
|
|
1156
|
-
this.defaultState = new
|
|
1201
|
+
this.defaultState = new O(), this.defaultState.blend = !0;
|
|
1157
1202
|
}
|
|
1158
1203
|
contextChange(e) {
|
|
1159
1204
|
this.gpu = e;
|
|
@@ -1177,13 +1222,13 @@ class ee {
|
|
|
1177
1222
|
this.gpu = null;
|
|
1178
1223
|
}
|
|
1179
1224
|
}
|
|
1180
|
-
|
|
1225
|
+
te.extension = {
|
|
1181
1226
|
type: [
|
|
1182
|
-
|
|
1227
|
+
p.WebGPUSystem
|
|
1183
1228
|
],
|
|
1184
1229
|
name: "state"
|
|
1185
1230
|
};
|
|
1186
|
-
const
|
|
1231
|
+
const Ve = {
|
|
1187
1232
|
type: "image",
|
|
1188
1233
|
upload(a, e, t, r = 0) {
|
|
1189
1234
|
const s = a.resource, i = (a.pixelWidth | 0) * (a.pixelHeight | 0), n = s.byteLength / i;
|
|
@@ -1202,7 +1247,7 @@ const Ie = {
|
|
|
1202
1247
|
}
|
|
1203
1248
|
);
|
|
1204
1249
|
}
|
|
1205
|
-
},
|
|
1250
|
+
}, re = {
|
|
1206
1251
|
"bc1-rgba-unorm": { blockBytes: 8, blockWidth: 4, blockHeight: 4 },
|
|
1207
1252
|
"bc2-rgba-unorm": { blockBytes: 16, blockWidth: 4, blockHeight: 4 },
|
|
1208
1253
|
"bc3-rgba-unorm": { blockBytes: 16, blockWidth: 4, blockHeight: 4 },
|
|
@@ -1210,11 +1255,11 @@ const Ie = {
|
|
|
1210
1255
|
"etc1-rgb-unorm": { blockBytes: 8, blockWidth: 4, blockHeight: 4 },
|
|
1211
1256
|
"etc2-rgba8unorm": { blockBytes: 16, blockWidth: 4, blockHeight: 4 },
|
|
1212
1257
|
"astc-4x4-unorm": { blockBytes: 16, blockWidth: 4, blockHeight: 4 }
|
|
1213
|
-
},
|
|
1258
|
+
}, Ne = { blockBytes: 4, blockWidth: 1, blockHeight: 1 }, je = {
|
|
1214
1259
|
type: "compressed",
|
|
1215
1260
|
upload(a, e, t, r = 0) {
|
|
1216
1261
|
let s = a.pixelWidth, i = a.pixelHeight;
|
|
1217
|
-
const n =
|
|
1262
|
+
const n = re[a.format] || Ne;
|
|
1218
1263
|
for (let o = 0; o < a.resource.length; o++) {
|
|
1219
1264
|
const u = a.resource[o], c = Math.ceil(s / n.blockWidth) * n.blockBytes;
|
|
1220
1265
|
t.device.queue.writeTexture(
|
|
@@ -1236,27 +1281,27 @@ const Ie = {
|
|
|
1236
1281
|
), s = Math.max(s >> 1, 1), i = Math.max(i >> 1, 1);
|
|
1237
1282
|
}
|
|
1238
1283
|
}
|
|
1239
|
-
},
|
|
1240
|
-
function
|
|
1284
|
+
}, L = ["right", "left", "top", "bottom", "front", "back"];
|
|
1285
|
+
function Ke(a) {
|
|
1241
1286
|
return {
|
|
1242
1287
|
type: "cube",
|
|
1243
1288
|
upload(e, t, r) {
|
|
1244
1289
|
const s = e.faces;
|
|
1245
|
-
for (let i = 0; i <
|
|
1246
|
-
const n =
|
|
1290
|
+
for (let i = 0; i < L.length; i++) {
|
|
1291
|
+
const n = L[i], o = s[n];
|
|
1247
1292
|
(a[o.uploadMethodId] || a.image).upload(o, t, r, i);
|
|
1248
1293
|
}
|
|
1249
1294
|
}
|
|
1250
1295
|
};
|
|
1251
1296
|
}
|
|
1252
|
-
const
|
|
1297
|
+
const se = {
|
|
1253
1298
|
type: "image",
|
|
1254
1299
|
upload(a, e, t, r = 0) {
|
|
1255
1300
|
const s = a.resource;
|
|
1256
1301
|
if (!s) return;
|
|
1257
1302
|
if (globalThis.HTMLImageElement && s instanceof HTMLImageElement) {
|
|
1258
|
-
const u =
|
|
1259
|
-
u.getContext("2d").drawImage(s, 0, 0, s.width, s.height), a.resource = u,
|
|
1303
|
+
const u = x.get().createCanvas(s.width, s.height);
|
|
1304
|
+
u.getContext("2d").drawImage(s, 0, 0, s.width, s.height), a.resource = u, U("ImageSource: Image element passed, converting to canvas and replacing resource.");
|
|
1260
1305
|
}
|
|
1261
1306
|
const i = Math.min(e.width, a.resourceWidth || a.pixelWidth), n = Math.min(e.height, a.resourceHeight || a.pixelHeight), o = a.alphaMode === "premultiply-alpha-on-upload";
|
|
1262
1307
|
t.device.queue.copyExternalImageToTexture(
|
|
@@ -1268,13 +1313,13 @@ const re = {
|
|
|
1268
1313
|
}
|
|
1269
1314
|
);
|
|
1270
1315
|
}
|
|
1271
|
-
},
|
|
1316
|
+
}, qe = {
|
|
1272
1317
|
type: "video",
|
|
1273
1318
|
upload(a, e, t, r) {
|
|
1274
|
-
|
|
1319
|
+
se.upload(a, e, t, r);
|
|
1275
1320
|
}
|
|
1276
1321
|
};
|
|
1277
|
-
class
|
|
1322
|
+
class Ye {
|
|
1278
1323
|
constructor(e) {
|
|
1279
1324
|
this.device = e, this.sampler = e.createSampler({ minFilter: "linear" }), this.pipelines = {};
|
|
1280
1325
|
}
|
|
@@ -1356,7 +1401,7 @@ class je {
|
|
|
1356
1401
|
arrayLayerCount: 1
|
|
1357
1402
|
}), f = i ? 1 : 0;
|
|
1358
1403
|
for (let h = 1; h < e.mipLevelCount; ++h) {
|
|
1359
|
-
const
|
|
1404
|
+
const l = r.createView({
|
|
1360
1405
|
baseMipLevel: f++,
|
|
1361
1406
|
mipLevelCount: 1,
|
|
1362
1407
|
dimension: "2d",
|
|
@@ -1364,7 +1409,7 @@ class je {
|
|
|
1364
1409
|
arrayLayerCount: 1
|
|
1365
1410
|
}), d = n.beginRenderPass({
|
|
1366
1411
|
colorAttachments: [{
|
|
1367
|
-
view:
|
|
1412
|
+
view: l,
|
|
1368
1413
|
storeOp: "store",
|
|
1369
1414
|
loadOp: "clear",
|
|
1370
1415
|
clearValue: { r: 0, g: 0, b: 0, a: 0 }
|
|
@@ -1379,7 +1424,7 @@ class je {
|
|
|
1379
1424
|
resource: c
|
|
1380
1425
|
}]
|
|
1381
1426
|
});
|
|
1382
|
-
d.setPipeline(t), d.setBindGroup(0, g), d.draw(3, 1, 0, 0), d.end(), c =
|
|
1427
|
+
d.setPipeline(t), d.setBindGroup(0, g), d.draw(3, 1, 0, 0), d.end(), c = l;
|
|
1383
1428
|
}
|
|
1384
1429
|
}
|
|
1385
1430
|
if (!i) {
|
|
@@ -1400,7 +1445,7 @@ class je {
|
|
|
1400
1445
|
return this.device.queue.submit([n.finish()]), i || r.destroy(), e;
|
|
1401
1446
|
}
|
|
1402
1447
|
}
|
|
1403
|
-
class
|
|
1448
|
+
class $e {
|
|
1404
1449
|
constructor(e) {
|
|
1405
1450
|
this.textureView = null, this.gpuTexture = e;
|
|
1406
1451
|
}
|
|
@@ -1409,23 +1454,23 @@ class Ke {
|
|
|
1409
1454
|
this.gpuTexture.destroy(), this.textureView = null, this.gpuTexture = null;
|
|
1410
1455
|
}
|
|
1411
1456
|
}
|
|
1412
|
-
class
|
|
1457
|
+
class ie {
|
|
1413
1458
|
constructor(e) {
|
|
1414
|
-
this._gpuSamplers = /* @__PURE__ */ Object.create(null), this._bindGroupHash = /* @__PURE__ */ Object.create(null), this._renderer = e, e.gc.addCollection(this, "_bindGroupHash", "hash"), this._managedTextures = new
|
|
1459
|
+
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({
|
|
1415
1460
|
renderer: e,
|
|
1416
1461
|
type: "resource",
|
|
1417
1462
|
onUnload: this.onSourceUnload.bind(this),
|
|
1418
1463
|
name: "gpuTextureSource"
|
|
1419
1464
|
});
|
|
1420
1465
|
const t = {
|
|
1421
|
-
image:
|
|
1422
|
-
buffer:
|
|
1423
|
-
video:
|
|
1424
|
-
compressed:
|
|
1466
|
+
image: se,
|
|
1467
|
+
buffer: Ve,
|
|
1468
|
+
video: qe,
|
|
1469
|
+
compressed: je
|
|
1425
1470
|
};
|
|
1426
1471
|
this._uploads = {
|
|
1427
1472
|
...t,
|
|
1428
|
-
cube:
|
|
1473
|
+
cube: Ke(t)
|
|
1429
1474
|
};
|
|
1430
1475
|
}
|
|
1431
1476
|
/**
|
|
@@ -1453,7 +1498,7 @@ class se {
|
|
|
1453
1498
|
}
|
|
1454
1499
|
let t = GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST;
|
|
1455
1500
|
e.uploadMethodId !== "compressed" && (t |= GPUTextureUsage.RENDER_ATTACHMENT, t |= GPUTextureUsage.COPY_SRC);
|
|
1456
|
-
const r =
|
|
1501
|
+
const r = re[e.format] || { blockWidth: 1, blockHeight: 1 }, s = Math.ceil(e.pixelWidth / r.blockWidth) * r.blockWidth, i = Math.ceil(e.pixelHeight / r.blockHeight) * r.blockHeight, n = {
|
|
1457
1502
|
label: e.label,
|
|
1458
1503
|
size: { width: s, height: i, depthOrArrayLayers: e.arrayLayerCount },
|
|
1459
1504
|
format: e.format,
|
|
@@ -1462,14 +1507,14 @@ class se {
|
|
|
1462
1507
|
dimension: e.dimension,
|
|
1463
1508
|
usage: t
|
|
1464
1509
|
}, o = this._gpu.device.createTexture(n);
|
|
1465
|
-
return e._gpuData[this._renderer.uid] = new
|
|
1510
|
+
return e._gpuData[this._renderer.uid] = new $e(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;
|
|
1466
1511
|
}
|
|
1467
1512
|
onSourceUpdate(e) {
|
|
1468
1513
|
const t = this.getGpuSource(e);
|
|
1469
1514
|
t && (this._uploads[e.uploadMethodId] && this._uploads[e.uploadMethodId].upload(e, t, this._gpu), e.autoGenerateMipmaps && e.mipLevelCount > 1 && this.onUpdateMipmaps(e));
|
|
1470
1515
|
}
|
|
1471
1516
|
onUpdateMipmaps(e) {
|
|
1472
|
-
this._mipmapGenerator || (this._mipmapGenerator = new
|
|
1517
|
+
this._mipmapGenerator || (this._mipmapGenerator = new Ye(this._gpu.device));
|
|
1473
1518
|
const t = this.getGpuSource(e);
|
|
1474
1519
|
this._mipmapGenerator.generateMipmap(t);
|
|
1475
1520
|
}
|
|
@@ -1505,10 +1550,10 @@ class se {
|
|
|
1505
1550
|
}
|
|
1506
1551
|
_createTextureBindGroup(e) {
|
|
1507
1552
|
const t = e.source;
|
|
1508
|
-
return this._bindGroupHash[e.uid] = new
|
|
1553
|
+
return this._bindGroupHash[e.uid] = new I({
|
|
1509
1554
|
0: t,
|
|
1510
1555
|
1: t.style,
|
|
1511
|
-
2: new
|
|
1556
|
+
2: new W({
|
|
1512
1557
|
uTextureMatrix: { type: "mat3x3<f32>", value: e.textureMatrix.mapCoord }
|
|
1513
1558
|
})
|
|
1514
1559
|
}), this._bindGroupHash[e.uid];
|
|
@@ -1520,13 +1565,13 @@ class se {
|
|
|
1520
1565
|
return r || (this.initSource(t), r = t._gpuData[this._renderer.uid]), r.textureView || (r.textureView = r.gpuTexture.createView({ dimension: t.viewDimension })), r.textureView;
|
|
1521
1566
|
}
|
|
1522
1567
|
generateCanvas(e) {
|
|
1523
|
-
const t = this._renderer, r = t.gpu.device.createCommandEncoder(), s =
|
|
1568
|
+
const t = this._renderer, r = t.gpu.device.createCommandEncoder(), s = x.get().createCanvas();
|
|
1524
1569
|
s.width = e.source.pixelWidth, s.height = e.source.pixelHeight;
|
|
1525
1570
|
const i = s.getContext("webgpu");
|
|
1526
1571
|
return i.configure({
|
|
1527
1572
|
device: t.gpu.device,
|
|
1528
1573
|
usage: GPUTextureUsage.COPY_DST | GPUTextureUsage.COPY_SRC,
|
|
1529
|
-
format:
|
|
1574
|
+
format: x.get().getNavigator().gpu.getPreferredCanvasFormat(),
|
|
1530
1575
|
alphaMode: "premultiplied"
|
|
1531
1576
|
}), r.copyTextureToTexture({
|
|
1532
1577
|
texture: t.texture.getGpuSource(e.source),
|
|
@@ -1542,10 +1587,10 @@ class se {
|
|
|
1542
1587
|
}), t.gpu.device.queue.submit([r.finish()]), s;
|
|
1543
1588
|
}
|
|
1544
1589
|
getPixels(e) {
|
|
1545
|
-
const t = this.generateCanvas(e), r =
|
|
1590
|
+
const t = this.generateCanvas(e), r = C.getOptimalCanvasAndContext(t.width, t.height), s = r.context;
|
|
1546
1591
|
s.drawImage(t, 0, 0);
|
|
1547
1592
|
const { width: i, height: n } = t, o = s.getImageData(0, 0, i, n), u = new Uint8ClampedArray(o.data.buffer);
|
|
1548
|
-
return
|
|
1593
|
+
return C.returnCanvasAndContext(r), { pixels: u, width: i, height: n };
|
|
1549
1594
|
}
|
|
1550
1595
|
destroy() {
|
|
1551
1596
|
this._managedTextures.destroy();
|
|
@@ -1556,33 +1601,33 @@ class se {
|
|
|
1556
1601
|
this._renderer = null, this._gpu = null, this._mipmapGenerator = null, this._gpuSamplers = null, this._bindGroupHash = null;
|
|
1557
1602
|
}
|
|
1558
1603
|
}
|
|
1559
|
-
|
|
1604
|
+
ie.extension = {
|
|
1560
1605
|
type: [
|
|
1561
|
-
|
|
1606
|
+
p.WebGPUSystem
|
|
1562
1607
|
],
|
|
1563
1608
|
name: "texture"
|
|
1564
1609
|
};
|
|
1565
|
-
class
|
|
1610
|
+
class ne {
|
|
1566
1611
|
constructor() {
|
|
1567
1612
|
this._maxTextures = 0;
|
|
1568
1613
|
}
|
|
1569
1614
|
contextChange(e) {
|
|
1570
|
-
const t = new
|
|
1571
|
-
uTransformMatrix: { value: new
|
|
1615
|
+
const t = new W({
|
|
1616
|
+
uTransformMatrix: { value: new A(), type: "mat3x3<f32>" },
|
|
1572
1617
|
uColor: { value: new Float32Array([1, 1, 1, 1]), type: "vec4<f32>" },
|
|
1573
1618
|
uRound: { value: 0, type: "f32" }
|
|
1574
1619
|
});
|
|
1575
1620
|
this._maxTextures = e.limits.maxBatchableTextures;
|
|
1576
|
-
const r =
|
|
1621
|
+
const r = z({
|
|
1577
1622
|
name: "graphics",
|
|
1578
1623
|
bits: [
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1624
|
+
_e,
|
|
1625
|
+
be(this._maxTextures),
|
|
1626
|
+
Ce,
|
|
1627
|
+
F
|
|
1583
1628
|
]
|
|
1584
1629
|
});
|
|
1585
|
-
this.shader = new
|
|
1630
|
+
this.shader = new H({
|
|
1586
1631
|
gpuProgram: r,
|
|
1587
1632
|
resources: {
|
|
1588
1633
|
// added on the fly!
|
|
@@ -1600,20 +1645,20 @@ class ie {
|
|
|
1600
1645
|
c.setBindGroup(0, f, s.gpuProgram);
|
|
1601
1646
|
const h = i.renderPipes.uniformBatch.getUniformBindGroup(s.resources.localUniforms, !0);
|
|
1602
1647
|
c.setBindGroup(2, h, s.gpuProgram);
|
|
1603
|
-
const
|
|
1648
|
+
const l = u.instructions;
|
|
1604
1649
|
let d = null;
|
|
1605
1650
|
for (let g = 0; g < u.instructionSize; g++) {
|
|
1606
|
-
const m =
|
|
1651
|
+
const m = l[g];
|
|
1607
1652
|
if (m.topology !== d && (d = m.topology, c.setPipelineFromGeometryProgramAndState(
|
|
1608
1653
|
o.geometry,
|
|
1609
1654
|
s.gpuProgram,
|
|
1610
1655
|
e.state,
|
|
1611
1656
|
m.topology
|
|
1612
1657
|
)), s.groups[1] = m.bindGroup, !m.gpuBindGroup) {
|
|
1613
|
-
const
|
|
1614
|
-
m.bindGroup =
|
|
1615
|
-
|
|
1616
|
-
|
|
1658
|
+
const G = m.textures;
|
|
1659
|
+
m.bindGroup = D(
|
|
1660
|
+
G.textures,
|
|
1661
|
+
G.count,
|
|
1617
1662
|
this._maxTextures
|
|
1618
1663
|
), m.gpuBindGroup = i.bindGroup.getBindGroup(
|
|
1619
1664
|
m.bindGroup,
|
|
@@ -1628,29 +1673,29 @@ class ie {
|
|
|
1628
1673
|
this.shader.destroy(!0), this.shader = null;
|
|
1629
1674
|
}
|
|
1630
1675
|
}
|
|
1631
|
-
|
|
1676
|
+
ne.extension = {
|
|
1632
1677
|
type: [
|
|
1633
|
-
|
|
1678
|
+
p.WebGPUPipesAdaptor
|
|
1634
1679
|
],
|
|
1635
1680
|
name: "graphics"
|
|
1636
1681
|
};
|
|
1637
|
-
class
|
|
1682
|
+
class oe {
|
|
1638
1683
|
init() {
|
|
1639
|
-
const e =
|
|
1684
|
+
const e = z({
|
|
1640
1685
|
name: "mesh",
|
|
1641
1686
|
bits: [
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1687
|
+
Ue,
|
|
1688
|
+
we,
|
|
1689
|
+
F
|
|
1645
1690
|
]
|
|
1646
1691
|
});
|
|
1647
|
-
this._shader = new
|
|
1692
|
+
this._shader = new H({
|
|
1648
1693
|
gpuProgram: e,
|
|
1649
1694
|
resources: {
|
|
1650
1695
|
uTexture: R.EMPTY._source,
|
|
1651
1696
|
uSampler: R.EMPTY._source.style,
|
|
1652
1697
|
textureUniforms: {
|
|
1653
|
-
uTextureMatrix: { type: "mat3x3<f32>", value: new
|
|
1698
|
+
uTextureMatrix: { type: "mat3x3<f32>", value: new A() }
|
|
1654
1699
|
}
|
|
1655
1700
|
}
|
|
1656
1701
|
});
|
|
@@ -1661,7 +1706,7 @@ class ne {
|
|
|
1661
1706
|
if (!s)
|
|
1662
1707
|
s = this._shader, s.groups[2] = r.texture.getTextureBindGroup(t.texture);
|
|
1663
1708
|
else if (!s.gpuProgram) {
|
|
1664
|
-
|
|
1709
|
+
U("Mesh shader has no gpuProgram", t.shader);
|
|
1665
1710
|
return;
|
|
1666
1711
|
}
|
|
1667
1712
|
const i = s.gpuProgram;
|
|
@@ -1679,45 +1724,45 @@ class ne {
|
|
|
1679
1724
|
this._shader.destroy(!0), this._shader = null;
|
|
1680
1725
|
}
|
|
1681
1726
|
}
|
|
1682
|
-
|
|
1727
|
+
oe.extension = {
|
|
1683
1728
|
type: [
|
|
1684
|
-
|
|
1729
|
+
p.WebGPUPipesAdaptor
|
|
1685
1730
|
],
|
|
1686
1731
|
name: "mesh"
|
|
1687
1732
|
};
|
|
1688
|
-
const
|
|
1689
|
-
...
|
|
1690
|
-
|
|
1691
|
-
K,
|
|
1692
|
-
U,
|
|
1733
|
+
const Xe = [
|
|
1734
|
+
...ye,
|
|
1735
|
+
X,
|
|
1693
1736
|
q,
|
|
1694
|
-
|
|
1695
|
-
|
|
1737
|
+
w,
|
|
1738
|
+
Y,
|
|
1739
|
+
j,
|
|
1740
|
+
ie,
|
|
1696
1741
|
Q,
|
|
1697
|
-
Z,
|
|
1698
1742
|
ee,
|
|
1743
|
+
te,
|
|
1699
1744
|
J,
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
],
|
|
1704
|
-
S.handleByNamedList(
|
|
1705
|
-
S.handleByNamedList(
|
|
1706
|
-
S.handleByNamedList(
|
|
1707
|
-
S.add(...
|
|
1708
|
-
class
|
|
1745
|
+
K,
|
|
1746
|
+
$,
|
|
1747
|
+
N
|
|
1748
|
+
], Ze = [...xe, Z], Je = [V, oe, ne], ae = [], ue = [], ce = [];
|
|
1749
|
+
S.handleByNamedList(p.WebGPUSystem, ae);
|
|
1750
|
+
S.handleByNamedList(p.WebGPUPipes, ue);
|
|
1751
|
+
S.handleByNamedList(p.WebGPUPipesAdaptor, ce);
|
|
1752
|
+
S.add(...Xe, ...Ze, ...Je);
|
|
1753
|
+
class ot extends fe {
|
|
1709
1754
|
constructor() {
|
|
1710
1755
|
const e = {
|
|
1711
1756
|
name: "webgpu",
|
|
1712
|
-
type:
|
|
1713
|
-
systems:
|
|
1714
|
-
renderPipes:
|
|
1715
|
-
renderPipeAdaptors:
|
|
1757
|
+
type: Re.WEBGPU,
|
|
1758
|
+
systems: ae,
|
|
1759
|
+
renderPipes: ue,
|
|
1760
|
+
renderPipeAdaptors: ce
|
|
1716
1761
|
};
|
|
1717
1762
|
super(e);
|
|
1718
1763
|
}
|
|
1719
1764
|
}
|
|
1720
1765
|
export {
|
|
1721
|
-
|
|
1766
|
+
ot as WebGPURenderer
|
|
1722
1767
|
};
|
|
1723
|
-
//# sourceMappingURL=WebGPURenderer-
|
|
1768
|
+
//# sourceMappingURL=WebGPURenderer-CdbjQMqs.js.map
|