@blueking/monitor-trace-log 1.0.0-beta.3 → 1.0.0-beta.5

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/751.js ADDED
@@ -0,0 +1,2518 @@
1
+ export const __webpack_id__ = 751;
2
+ export const __webpack_ids__ = [751];
3
+ export const __webpack_modules__ = {
4
+
5
+ /***/ 4751:
6
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
7
+
8
+
9
+ // EXPORTS
10
+ __webpack_require__.d(__webpack_exports__, {
11
+ WebGPURenderer: () => (/* binding */ WebGPURenderer)
12
+ });
13
+
14
+ // EXTERNAL MODULE: ./node_modules/pixi.js/lib/extensions/Extensions.mjs
15
+ var Extensions = __webpack_require__(8507);
16
+ // EXTERNAL MODULE: ./node_modules/pixi.js/lib/maths/matrix/Matrix.mjs
17
+ var Matrix = __webpack_require__(9313);
18
+ // EXTERNAL MODULE: ./node_modules/pixi.js/lib/rendering/batcher/gl/utils/maxRecommendedTextures.mjs + 1 modules
19
+ var maxRecommendedTextures = __webpack_require__(6563);
20
+ // EXTERNAL MODULE: ./node_modules/pixi.js/lib/rendering/batcher/gpu/getTextureBatchBindGroup.mjs
21
+ var getTextureBatchBindGroup = __webpack_require__(341);
22
+ // EXTERNAL MODULE: ./node_modules/pixi.js/lib/rendering/high-shader/compileHighShaderToProgram.mjs + 8 modules
23
+ var compileHighShaderToProgram = __webpack_require__(5611);
24
+ // EXTERNAL MODULE: ./node_modules/pixi.js/lib/rendering/high-shader/shader-bits/colorBit.mjs
25
+ var colorBit = __webpack_require__(4459);
26
+ // EXTERNAL MODULE: ./node_modules/pixi.js/lib/rendering/high-shader/shader-bits/generateTextureBatchBit.mjs
27
+ var generateTextureBatchBit = __webpack_require__(4000);
28
+ // EXTERNAL MODULE: ./node_modules/pixi.js/lib/rendering/high-shader/shader-bits/localUniformBit.mjs
29
+ var localUniformBit = __webpack_require__(2067);
30
+ // EXTERNAL MODULE: ./node_modules/pixi.js/lib/rendering/high-shader/shader-bits/roundPixelsBit.mjs
31
+ var roundPixelsBit = __webpack_require__(6665);
32
+ // EXTERNAL MODULE: ./node_modules/pixi.js/lib/rendering/renderers/shared/shader/Shader.mjs
33
+ var Shader = __webpack_require__(8475);
34
+ // EXTERNAL MODULE: ./node_modules/pixi.js/lib/rendering/renderers/shared/shader/UniformGroup.mjs + 2 modules
35
+ var UniformGroup = __webpack_require__(5811);
36
+ ;// ./node_modules/pixi.js/lib/scene/graphics/gpu/GpuGraphicsAdaptor.mjs
37
+
38
+
39
+
40
+
41
+
42
+
43
+
44
+
45
+
46
+
47
+
48
+
49
+ "use strict";
50
+ class GpuGraphicsAdaptor {
51
+ init() {
52
+ const localUniforms = new UniformGroup.UniformGroup({
53
+ uTransformMatrix: { value: new Matrix.Matrix(), type: "mat3x3<f32>" },
54
+ uColor: { value: new Float32Array([1, 1, 1, 1]), type: "vec4<f32>" },
55
+ uRound: { value: 0, type: "f32" }
56
+ });
57
+ const gpuProgram = (0,compileHighShaderToProgram.compileHighShaderGpuProgram)({
58
+ name: "graphics",
59
+ bits: [
60
+ colorBit.colorBit,
61
+ (0,generateTextureBatchBit.generateTextureBatchBit)((0,maxRecommendedTextures.getMaxTexturesPerBatch)()),
62
+ localUniformBit.localUniformBitGroup2,
63
+ roundPixelsBit.roundPixelsBit
64
+ ]
65
+ });
66
+ this.shader = new Shader.Shader({
67
+ gpuProgram,
68
+ resources: {
69
+ // added on the fly!
70
+ localUniforms
71
+ }
72
+ });
73
+ }
74
+ execute(graphicsPipe, renderable) {
75
+ const context = renderable.context;
76
+ const shader = context.customShader || this.shader;
77
+ const renderer = graphicsPipe.renderer;
78
+ const contextSystem = renderer.graphicsContext;
79
+ const {
80
+ batcher,
81
+ instructions
82
+ } = contextSystem.getContextRenderData(context);
83
+ const encoder = renderer.encoder;
84
+ encoder.setGeometry(batcher.geometry, shader.gpuProgram);
85
+ const globalUniformsBindGroup = renderer.globalUniforms.bindGroup;
86
+ encoder.setBindGroup(0, globalUniformsBindGroup, shader.gpuProgram);
87
+ const localBindGroup = renderer.renderPipes.uniformBatch.getUniformBindGroup(shader.resources.localUniforms, true);
88
+ encoder.setBindGroup(2, localBindGroup, shader.gpuProgram);
89
+ const batches = instructions.instructions;
90
+ let topology = null;
91
+ for (let i = 0; i < instructions.instructionSize; i++) {
92
+ const batch = batches[i];
93
+ if (batch.topology !== topology) {
94
+ topology = batch.topology;
95
+ encoder.setPipelineFromGeometryProgramAndState(
96
+ batcher.geometry,
97
+ shader.gpuProgram,
98
+ graphicsPipe.state,
99
+ batch.topology
100
+ );
101
+ }
102
+ shader.groups[1] = batch.bindGroup;
103
+ if (!batch.gpuBindGroup) {
104
+ const textureBatch = batch.textures;
105
+ batch.bindGroup = (0,getTextureBatchBindGroup.getTextureBatchBindGroup)(textureBatch.textures, textureBatch.count);
106
+ batch.gpuBindGroup = renderer.bindGroup.getBindGroup(
107
+ batch.bindGroup,
108
+ shader.gpuProgram,
109
+ 1
110
+ );
111
+ }
112
+ encoder.setBindGroup(1, batch.bindGroup, shader.gpuProgram);
113
+ encoder.renderPassEncoder.drawIndexed(batch.size, 1, batch.start);
114
+ }
115
+ }
116
+ destroy() {
117
+ this.shader.destroy(true);
118
+ this.shader = null;
119
+ }
120
+ }
121
+ /** @ignore */
122
+ GpuGraphicsAdaptor.extension = {
123
+ type: [
124
+ Extensions.ExtensionType.WebGPUPipesAdaptor
125
+ ],
126
+ name: "graphics"
127
+ };
128
+
129
+
130
+ //# sourceMappingURL=GpuGraphicsAdaptor.mjs.map
131
+
132
+ // EXTERNAL MODULE: ./node_modules/pixi.js/lib/rendering/high-shader/shader-bits/textureBit.mjs
133
+ var textureBit = __webpack_require__(3391);
134
+ // EXTERNAL MODULE: ./node_modules/pixi.js/lib/rendering/renderers/shared/texture/Texture.mjs + 2 modules
135
+ var Texture = __webpack_require__(4492);
136
+ // EXTERNAL MODULE: ./node_modules/pixi.js/lib/utils/logging/warn.mjs
137
+ var warn = __webpack_require__(268);
138
+ ;// ./node_modules/pixi.js/lib/scene/mesh/gpu/GpuMeshAdapter.mjs
139
+
140
+
141
+
142
+
143
+
144
+
145
+
146
+
147
+
148
+
149
+ "use strict";
150
+ class GpuMeshAdapter {
151
+ init() {
152
+ const gpuProgram = (0,compileHighShaderToProgram.compileHighShaderGpuProgram)({
153
+ name: "mesh",
154
+ bits: [
155
+ localUniformBit.localUniformBit,
156
+ textureBit.textureBit,
157
+ roundPixelsBit.roundPixelsBit
158
+ ]
159
+ });
160
+ this._shader = new Shader.Shader({
161
+ gpuProgram,
162
+ resources: {
163
+ uTexture: Texture.Texture.EMPTY._source,
164
+ uSampler: Texture.Texture.EMPTY._source.style,
165
+ textureUniforms: {
166
+ uTextureMatrix: { type: "mat3x3<f32>", value: new Matrix.Matrix() }
167
+ }
168
+ }
169
+ });
170
+ }
171
+ execute(meshPipe, mesh) {
172
+ const renderer = meshPipe.renderer;
173
+ let shader = mesh._shader;
174
+ if (!shader) {
175
+ shader = this._shader;
176
+ shader.groups[2] = renderer.texture.getTextureBindGroup(mesh.texture);
177
+ } else if (!shader.gpuProgram) {
178
+ (0,warn.warn)("Mesh shader has no gpuProgram", mesh.shader);
179
+ return;
180
+ }
181
+ const gpuProgram = shader.gpuProgram;
182
+ if (gpuProgram.autoAssignGlobalUniforms) {
183
+ shader.groups[0] = renderer.globalUniforms.bindGroup;
184
+ }
185
+ if (gpuProgram.autoAssignLocalUniforms) {
186
+ const localUniforms = meshPipe.localUniforms;
187
+ shader.groups[1] = renderer.renderPipes.uniformBatch.getUniformBindGroup(localUniforms, true);
188
+ }
189
+ renderer.encoder.draw({
190
+ geometry: mesh._geometry,
191
+ shader,
192
+ state: mesh.state
193
+ });
194
+ }
195
+ destroy() {
196
+ this._shader.destroy(true);
197
+ this._shader = null;
198
+ }
199
+ }
200
+ /** @ignore */
201
+ GpuMeshAdapter.extension = {
202
+ type: [
203
+ Extensions.ExtensionType.WebGPUPipesAdaptor
204
+ ],
205
+ name: "mesh"
206
+ };
207
+
208
+
209
+ //# sourceMappingURL=GpuMeshAdapter.mjs.map
210
+
211
+ // EXTERNAL MODULE: ./node_modules/pixi.js/lib/rendering/renderers/shared/state/State.mjs
212
+ var State = __webpack_require__(7547);
213
+ ;// ./node_modules/pixi.js/lib/rendering/batcher/gpu/GpuBatchAdaptor.mjs
214
+
215
+
216
+
217
+
218
+ "use strict";
219
+ const tempState = State.State.for2d();
220
+ class GpuBatchAdaptor {
221
+ start(batchPipe, geometry, shader) {
222
+ const renderer = batchPipe.renderer;
223
+ const encoder = renderer.encoder;
224
+ const program = shader.gpuProgram;
225
+ this._shader = shader;
226
+ this._geometry = geometry;
227
+ encoder.setGeometry(geometry, program);
228
+ tempState.blendMode = "normal";
229
+ renderer.pipeline.getPipeline(
230
+ geometry,
231
+ program,
232
+ tempState
233
+ );
234
+ const globalUniformsBindGroup = renderer.globalUniforms.bindGroup;
235
+ encoder.resetBindGroup(1);
236
+ encoder.setBindGroup(0, globalUniformsBindGroup, program);
237
+ }
238
+ execute(batchPipe, batch) {
239
+ const program = this._shader.gpuProgram;
240
+ const renderer = batchPipe.renderer;
241
+ const encoder = renderer.encoder;
242
+ if (!batch.bindGroup) {
243
+ const textureBatch = batch.textures;
244
+ batch.bindGroup = (0,getTextureBatchBindGroup.getTextureBatchBindGroup)(textureBatch.textures, textureBatch.count);
245
+ }
246
+ tempState.blendMode = batch.blendMode;
247
+ const gpuBindGroup = renderer.bindGroup.getBindGroup(
248
+ batch.bindGroup,
249
+ program,
250
+ 1
251
+ );
252
+ const pipeline = renderer.pipeline.getPipeline(
253
+ this._geometry,
254
+ program,
255
+ tempState,
256
+ batch.topology
257
+ );
258
+ batch.bindGroup._touch(renderer.textureGC.count);
259
+ encoder.setPipeline(pipeline);
260
+ encoder.renderPassEncoder.setBindGroup(1, gpuBindGroup);
261
+ encoder.renderPassEncoder.drawIndexed(batch.size, 1, batch.start);
262
+ }
263
+ }
264
+ /** @ignore */
265
+ GpuBatchAdaptor.extension = {
266
+ type: [
267
+ Extensions.ExtensionType.WebGPUPipesAdaptor
268
+ ],
269
+ name: "batch"
270
+ };
271
+
272
+
273
+ //# sourceMappingURL=GpuBatchAdaptor.mjs.map
274
+
275
+ // EXTERNAL MODULE: ./node_modules/pixi.js/lib/rendering/renderers/shared/system/AbstractRenderer.mjs + 1 modules
276
+ var AbstractRenderer = __webpack_require__(800);
277
+ // EXTERNAL MODULE: ./node_modules/pixi.js/lib/rendering/renderers/shared/system/SharedSystems.mjs + 31 modules
278
+ var SharedSystems = __webpack_require__(3996);
279
+ // EXTERNAL MODULE: ./node_modules/pixi.js/lib/rendering/renderers/types.mjs
280
+ var types = __webpack_require__(5099);
281
+ ;// ./node_modules/pixi.js/lib/rendering/renderers/gpu/BindGroupSystem.mjs
282
+
283
+
284
+ "use strict";
285
+ class BindGroupSystem {
286
+ constructor(renderer) {
287
+ this._hash = /* @__PURE__ */ Object.create(null);
288
+ this._renderer = renderer;
289
+ this._renderer.renderableGC.addManagedHash(this, "_hash");
290
+ }
291
+ contextChange(gpu) {
292
+ this._gpu = gpu;
293
+ }
294
+ getBindGroup(bindGroup, program, groupIndex) {
295
+ bindGroup._updateKey();
296
+ const gpuBindGroup = this._hash[bindGroup._key] || this._createBindGroup(bindGroup, program, groupIndex);
297
+ return gpuBindGroup;
298
+ }
299
+ _createBindGroup(group, program, groupIndex) {
300
+ const device = this._gpu.device;
301
+ const groupLayout = program.layout[groupIndex];
302
+ const entries = [];
303
+ const renderer = this._renderer;
304
+ for (const j in groupLayout) {
305
+ const resource = group.resources[j] ?? group.resources[groupLayout[j]];
306
+ let gpuResource;
307
+ if (resource._resourceType === "uniformGroup") {
308
+ const uniformGroup = resource;
309
+ renderer.ubo.updateUniformGroup(uniformGroup);
310
+ const buffer = uniformGroup.buffer;
311
+ gpuResource = {
312
+ buffer: renderer.buffer.getGPUBuffer(buffer),
313
+ offset: 0,
314
+ size: buffer.descriptor.size
315
+ };
316
+ } else if (resource._resourceType === "buffer") {
317
+ const buffer = resource;
318
+ gpuResource = {
319
+ buffer: renderer.buffer.getGPUBuffer(buffer),
320
+ offset: 0,
321
+ size: buffer.descriptor.size
322
+ };
323
+ } else if (resource._resourceType === "bufferResource") {
324
+ const bufferResource = resource;
325
+ gpuResource = {
326
+ buffer: renderer.buffer.getGPUBuffer(bufferResource.buffer),
327
+ offset: bufferResource.offset,
328
+ size: bufferResource.size
329
+ };
330
+ } else if (resource._resourceType === "textureSampler") {
331
+ const sampler = resource;
332
+ gpuResource = renderer.texture.getGpuSampler(sampler);
333
+ } else if (resource._resourceType === "textureSource") {
334
+ const texture = resource;
335
+ gpuResource = renderer.texture.getGpuSource(texture).createView({});
336
+ }
337
+ entries.push({
338
+ binding: groupLayout[j],
339
+ resource: gpuResource
340
+ });
341
+ }
342
+ const layout = renderer.shader.getProgramData(program).bindGroups[groupIndex];
343
+ const gpuBindGroup = device.createBindGroup({
344
+ layout,
345
+ entries
346
+ });
347
+ this._hash[group._key] = gpuBindGroup;
348
+ return gpuBindGroup;
349
+ }
350
+ destroy() {
351
+ for (const key of Object.keys(this._hash)) {
352
+ this._hash[key] = null;
353
+ }
354
+ this._hash = null;
355
+ this._renderer = null;
356
+ }
357
+ }
358
+ /** @ignore */
359
+ BindGroupSystem.extension = {
360
+ type: [
361
+ Extensions.ExtensionType.WebGPUSystem
362
+ ],
363
+ name: "bindGroup"
364
+ };
365
+
366
+
367
+ //# sourceMappingURL=BindGroupSystem.mjs.map
368
+
369
+ // EXTERNAL MODULE: ./node_modules/pixi.js/lib/rendering/renderers/shared/buffer/utils/fastCopy.mjs
370
+ var fastCopy = __webpack_require__(6736);
371
+ ;// ./node_modules/pixi.js/lib/rendering/renderers/gpu/buffer/GpuBufferSystem.mjs
372
+
373
+
374
+
375
+ "use strict";
376
+ class GpuBufferSystem {
377
+ constructor(renderer) {
378
+ this._gpuBuffers = /* @__PURE__ */ Object.create(null);
379
+ this._managedBuffers = [];
380
+ renderer.renderableGC.addManagedHash(this, "_gpuBuffers");
381
+ }
382
+ contextChange(gpu) {
383
+ this._gpu = gpu;
384
+ }
385
+ getGPUBuffer(buffer) {
386
+ return this._gpuBuffers[buffer.uid] || this.createGPUBuffer(buffer);
387
+ }
388
+ updateBuffer(buffer) {
389
+ const gpuBuffer = this._gpuBuffers[buffer.uid] || this.createGPUBuffer(buffer);
390
+ const data = buffer.data;
391
+ if (buffer._updateID && data) {
392
+ buffer._updateID = 0;
393
+ this._gpu.device.queue.writeBuffer(
394
+ gpuBuffer,
395
+ 0,
396
+ data.buffer,
397
+ 0,
398
+ // round to the nearest 4 bytes
399
+ (buffer._updateSize || data.byteLength) + 3 & ~3
400
+ );
401
+ }
402
+ return gpuBuffer;
403
+ }
404
+ /** dispose all WebGL resources of all managed buffers */
405
+ destroyAll() {
406
+ for (const id in this._gpuBuffers) {
407
+ this._gpuBuffers[id].destroy();
408
+ }
409
+ this._gpuBuffers = {};
410
+ }
411
+ createGPUBuffer(buffer) {
412
+ if (!this._gpuBuffers[buffer.uid]) {
413
+ buffer.on("update", this.updateBuffer, this);
414
+ buffer.on("change", this.onBufferChange, this);
415
+ buffer.on("destroy", this.onBufferDestroy, this);
416
+ this._managedBuffers.push(buffer);
417
+ }
418
+ const gpuBuffer = this._gpu.device.createBuffer(buffer.descriptor);
419
+ buffer._updateID = 0;
420
+ if (buffer.data) {
421
+ (0,fastCopy.fastCopy)(buffer.data.buffer, gpuBuffer.getMappedRange());
422
+ gpuBuffer.unmap();
423
+ }
424
+ this._gpuBuffers[buffer.uid] = gpuBuffer;
425
+ return gpuBuffer;
426
+ }
427
+ onBufferChange(buffer) {
428
+ const gpuBuffer = this._gpuBuffers[buffer.uid];
429
+ gpuBuffer.destroy();
430
+ buffer._updateID = 0;
431
+ this._gpuBuffers[buffer.uid] = this.createGPUBuffer(buffer);
432
+ }
433
+ /**
434
+ * Disposes buffer
435
+ * @param buffer - buffer with data
436
+ */
437
+ onBufferDestroy(buffer) {
438
+ this._managedBuffers.splice(this._managedBuffers.indexOf(buffer), 1);
439
+ this._destroyBuffer(buffer);
440
+ }
441
+ destroy() {
442
+ this._managedBuffers.forEach((buffer) => this._destroyBuffer(buffer));
443
+ this._managedBuffers = null;
444
+ this._gpuBuffers = null;
445
+ }
446
+ _destroyBuffer(buffer) {
447
+ const gpuBuffer = this._gpuBuffers[buffer.uid];
448
+ gpuBuffer.destroy();
449
+ buffer.off("update", this.updateBuffer, this);
450
+ buffer.off("change", this.onBufferChange, this);
451
+ buffer.off("destroy", this.onBufferDestroy, this);
452
+ this._gpuBuffers[buffer.uid] = null;
453
+ }
454
+ }
455
+ /** @ignore */
456
+ GpuBufferSystem.extension = {
457
+ type: [
458
+ Extensions.ExtensionType.WebGPUSystem
459
+ ],
460
+ name: "buffer"
461
+ };
462
+
463
+
464
+ //# sourceMappingURL=GpuBufferSystem.mjs.map
465
+
466
+ ;// ./node_modules/pixi.js/lib/rendering/renderers/gpu/GpuColorMaskSystem.mjs
467
+
468
+
469
+ "use strict";
470
+ class GpuColorMaskSystem {
471
+ constructor(renderer) {
472
+ this._colorMaskCache = 15;
473
+ this._renderer = renderer;
474
+ }
475
+ setMask(colorMask) {
476
+ if (this._colorMaskCache === colorMask)
477
+ return;
478
+ this._colorMaskCache = colorMask;
479
+ this._renderer.pipeline.setColorMask(colorMask);
480
+ }
481
+ destroy() {
482
+ this._renderer = null;
483
+ this._colorMaskCache = null;
484
+ }
485
+ }
486
+ /** @ignore */
487
+ GpuColorMaskSystem.extension = {
488
+ type: [
489
+ Extensions.ExtensionType.WebGPUSystem
490
+ ],
491
+ name: "colorMask"
492
+ };
493
+
494
+
495
+ //# sourceMappingURL=GpuColorMaskSystem.mjs.map
496
+
497
+ // EXTERNAL MODULE: ./node_modules/pixi.js/lib/environment/adapter.mjs + 1 modules
498
+ var environment_adapter = __webpack_require__(1761);
499
+ ;// ./node_modules/pixi.js/lib/rendering/renderers/gpu/GpuDeviceSystem.mjs
500
+
501
+
502
+
503
+ "use strict";
504
+ class GpuDeviceSystem {
505
+ /**
506
+ * @param {WebGPURenderer} renderer - The renderer this System works for.
507
+ */
508
+ constructor(renderer) {
509
+ this._renderer = renderer;
510
+ }
511
+ async init(options) {
512
+ if (this._initPromise)
513
+ return this._initPromise;
514
+ this._initPromise = this._createDeviceAndAdaptor(options).then((gpu) => {
515
+ this.gpu = gpu;
516
+ this._renderer.runners.contextChange.emit(this.gpu);
517
+ });
518
+ return this._initPromise;
519
+ }
520
+ /**
521
+ * Handle the context change event
522
+ * @param gpu
523
+ */
524
+ contextChange(gpu) {
525
+ this._renderer.gpu = gpu;
526
+ }
527
+ /**
528
+ * Helper class to create a WebGL Context
529
+ * @param {object} options - An options object that gets passed in to the canvas element containing the
530
+ * context attributes
531
+ * @see https://developer.mozilla.org/en/docs/Web/API/HTMLCanvasElement/getContext
532
+ * @returns {WebGLRenderingContext} the WebGL context
533
+ */
534
+ async _createDeviceAndAdaptor(options) {
535
+ const adapter = await environment_adapter.DOMAdapter.get().getNavigator().gpu.requestAdapter({
536
+ powerPreference: options.powerPreference,
537
+ forceFallbackAdapter: options.forceFallbackAdapter
538
+ });
539
+ const requiredFeatures = [
540
+ "texture-compression-bc",
541
+ "texture-compression-astc",
542
+ "texture-compression-etc2"
543
+ ].filter((feature) => adapter.features.has(feature));
544
+ const device = await adapter.requestDevice({
545
+ requiredFeatures
546
+ });
547
+ return { adapter, device };
548
+ }
549
+ destroy() {
550
+ this.gpu = null;
551
+ this._renderer = null;
552
+ }
553
+ }
554
+ /** @ignore */
555
+ GpuDeviceSystem.extension = {
556
+ type: [
557
+ Extensions.ExtensionType.WebGPUSystem
558
+ ],
559
+ name: "device"
560
+ };
561
+ /** The default options for the GpuDeviceSystem. */
562
+ GpuDeviceSystem.defaultOptions = {
563
+ /**
564
+ * {@link WebGPUOptions.powerPreference}
565
+ * @default default
566
+ */
567
+ powerPreference: void 0,
568
+ /**
569
+ * Force the use of the fallback adapter
570
+ * @default false
571
+ */
572
+ forceFallbackAdapter: false
573
+ };
574
+
575
+
576
+ //# sourceMappingURL=GpuDeviceSystem.mjs.map
577
+
578
+ ;// ./node_modules/pixi.js/lib/rendering/renderers/gpu/GpuEncoderSystem.mjs
579
+
580
+
581
+ "use strict";
582
+ class GpuEncoderSystem {
583
+ constructor(renderer) {
584
+ this._boundBindGroup = /* @__PURE__ */ Object.create(null);
585
+ this._boundVertexBuffer = /* @__PURE__ */ Object.create(null);
586
+ this._renderer = renderer;
587
+ }
588
+ renderStart() {
589
+ this.commandFinished = new Promise((resolve) => {
590
+ this._resolveCommandFinished = resolve;
591
+ });
592
+ this.commandEncoder = this._renderer.gpu.device.createCommandEncoder();
593
+ }
594
+ beginRenderPass(gpuRenderTarget) {
595
+ this.endRenderPass();
596
+ this._clearCache();
597
+ this.renderPassEncoder = this.commandEncoder.beginRenderPass(gpuRenderTarget.descriptor);
598
+ }
599
+ endRenderPass() {
600
+ if (this.renderPassEncoder) {
601
+ this.renderPassEncoder.end();
602
+ }
603
+ this.renderPassEncoder = null;
604
+ }
605
+ setViewport(viewport) {
606
+ this.renderPassEncoder.setViewport(viewport.x, viewport.y, viewport.width, viewport.height, 0, 1);
607
+ }
608
+ setPipelineFromGeometryProgramAndState(geometry, program, state, topology) {
609
+ const pipeline = this._renderer.pipeline.getPipeline(geometry, program, state, topology);
610
+ this.setPipeline(pipeline);
611
+ }
612
+ setPipeline(pipeline) {
613
+ if (this._boundPipeline === pipeline)
614
+ return;
615
+ this._boundPipeline = pipeline;
616
+ this.renderPassEncoder.setPipeline(pipeline);
617
+ }
618
+ _setVertexBuffer(index, buffer) {
619
+ if (this._boundVertexBuffer[index] === buffer)
620
+ return;
621
+ this._boundVertexBuffer[index] = buffer;
622
+ this.renderPassEncoder.setVertexBuffer(index, this._renderer.buffer.updateBuffer(buffer));
623
+ }
624
+ _setIndexBuffer(buffer) {
625
+ if (this._boundIndexBuffer === buffer)
626
+ return;
627
+ this._boundIndexBuffer = buffer;
628
+ const indexFormat = buffer.data.BYTES_PER_ELEMENT === 2 ? "uint16" : "uint32";
629
+ this.renderPassEncoder.setIndexBuffer(this._renderer.buffer.updateBuffer(buffer), indexFormat);
630
+ }
631
+ resetBindGroup(index) {
632
+ this._boundBindGroup[index] = null;
633
+ }
634
+ setBindGroup(index, bindGroup, program) {
635
+ if (this._boundBindGroup[index] === bindGroup)
636
+ return;
637
+ this._boundBindGroup[index] = bindGroup;
638
+ bindGroup._touch(this._renderer.textureGC.count);
639
+ const gpuBindGroup = this._renderer.bindGroup.getBindGroup(bindGroup, program, index);
640
+ this.renderPassEncoder.setBindGroup(index, gpuBindGroup);
641
+ }
642
+ setGeometry(geometry, program) {
643
+ const buffersToBind = this._renderer.pipeline.getBufferNamesToBind(geometry, program);
644
+ for (const i in buffersToBind) {
645
+ this._setVertexBuffer(i, geometry.attributes[buffersToBind[i]].buffer);
646
+ }
647
+ if (geometry.indexBuffer) {
648
+ this._setIndexBuffer(geometry.indexBuffer);
649
+ }
650
+ }
651
+ _setShaderBindGroups(shader, skipSync) {
652
+ for (const i in shader.groups) {
653
+ const bindGroup = shader.groups[i];
654
+ if (!skipSync) {
655
+ this._syncBindGroup(bindGroup);
656
+ }
657
+ this.setBindGroup(i, bindGroup, shader.gpuProgram);
658
+ }
659
+ }
660
+ _syncBindGroup(bindGroup) {
661
+ for (const j in bindGroup.resources) {
662
+ const resource = bindGroup.resources[j];
663
+ if (resource.isUniformGroup) {
664
+ this._renderer.ubo.updateUniformGroup(resource);
665
+ }
666
+ }
667
+ }
668
+ draw(options) {
669
+ const { geometry, shader, state, topology, size, start, instanceCount, skipSync } = options;
670
+ this.setPipelineFromGeometryProgramAndState(geometry, shader.gpuProgram, state, topology);
671
+ this.setGeometry(geometry, shader.gpuProgram);
672
+ this._setShaderBindGroups(shader, skipSync);
673
+ if (geometry.indexBuffer) {
674
+ this.renderPassEncoder.drawIndexed(
675
+ size || geometry.indexBuffer.data.length,
676
+ instanceCount ?? geometry.instanceCount,
677
+ start || 0
678
+ );
679
+ } else {
680
+ this.renderPassEncoder.draw(size || geometry.getSize(), instanceCount ?? geometry.instanceCount, start || 0);
681
+ }
682
+ }
683
+ finishRenderPass() {
684
+ if (this.renderPassEncoder) {
685
+ this.renderPassEncoder.end();
686
+ this.renderPassEncoder = null;
687
+ }
688
+ }
689
+ postrender() {
690
+ this.finishRenderPass();
691
+ this._gpu.device.queue.submit([this.commandEncoder.finish()]);
692
+ this._resolveCommandFinished();
693
+ this.commandEncoder = null;
694
+ }
695
+ // restores a render pass if finishRenderPass was called
696
+ // not optimised as really used for debugging!
697
+ // used when we want to stop drawing and log a texture..
698
+ restoreRenderPass() {
699
+ const descriptor = this._renderer.renderTarget.adaptor.getDescriptor(
700
+ this._renderer.renderTarget.renderTarget,
701
+ false,
702
+ [0, 0, 0, 1]
703
+ );
704
+ this.renderPassEncoder = this.commandEncoder.beginRenderPass(descriptor);
705
+ const boundPipeline = this._boundPipeline;
706
+ const boundVertexBuffer = { ...this._boundVertexBuffer };
707
+ const boundIndexBuffer = this._boundIndexBuffer;
708
+ const boundBindGroup = { ...this._boundBindGroup };
709
+ this._clearCache();
710
+ const viewport = this._renderer.renderTarget.viewport;
711
+ this.renderPassEncoder.setViewport(viewport.x, viewport.y, viewport.width, viewport.height, 0, 1);
712
+ this.setPipeline(boundPipeline);
713
+ for (const i in boundVertexBuffer) {
714
+ this._setVertexBuffer(i, boundVertexBuffer[i]);
715
+ }
716
+ for (const i in boundBindGroup) {
717
+ this.setBindGroup(i, boundBindGroup[i], null);
718
+ }
719
+ this._setIndexBuffer(boundIndexBuffer);
720
+ }
721
+ _clearCache() {
722
+ for (let i = 0; i < 16; i++) {
723
+ this._boundBindGroup[i] = null;
724
+ this._boundVertexBuffer[i] = null;
725
+ }
726
+ this._boundIndexBuffer = null;
727
+ this._boundPipeline = null;
728
+ }
729
+ destroy() {
730
+ this._renderer = null;
731
+ this._gpu = null;
732
+ this._boundBindGroup = null;
733
+ this._boundVertexBuffer = null;
734
+ this._boundIndexBuffer = null;
735
+ this._boundPipeline = null;
736
+ }
737
+ contextChange(gpu) {
738
+ this._gpu = gpu;
739
+ }
740
+ }
741
+ /** @ignore */
742
+ GpuEncoderSystem.extension = {
743
+ type: [Extensions.ExtensionType.WebGPUSystem],
744
+ name: "encoder",
745
+ priority: 1
746
+ };
747
+
748
+
749
+ //# sourceMappingURL=GpuEncoderSystem.mjs.map
750
+
751
+ // EXTERNAL MODULE: ./node_modules/pixi.js/lib/rendering/renderers/shared/state/const.mjs
752
+ var state_const = __webpack_require__(1957);
753
+ ;// ./node_modules/pixi.js/lib/rendering/renderers/gpu/GpuStencilSystem.mjs
754
+
755
+
756
+
757
+ "use strict";
758
+ class GpuStencilSystem {
759
+ constructor(renderer) {
760
+ this._renderTargetStencilState = /* @__PURE__ */ Object.create(null);
761
+ this._renderer = renderer;
762
+ renderer.renderTarget.onRenderTargetChange.add(this);
763
+ }
764
+ onRenderTargetChange(renderTarget) {
765
+ let stencilState = this._renderTargetStencilState[renderTarget.uid];
766
+ if (!stencilState) {
767
+ stencilState = this._renderTargetStencilState[renderTarget.uid] = {
768
+ stencilMode: state_const.STENCIL_MODES.DISABLED,
769
+ stencilReference: 0
770
+ };
771
+ }
772
+ this._activeRenderTarget = renderTarget;
773
+ this.setStencilMode(stencilState.stencilMode, stencilState.stencilReference);
774
+ }
775
+ setStencilMode(stencilMode, stencilReference) {
776
+ const stencilState = this._renderTargetStencilState[this._activeRenderTarget.uid];
777
+ stencilState.stencilMode = stencilMode;
778
+ stencilState.stencilReference = stencilReference;
779
+ const renderer = this._renderer;
780
+ renderer.pipeline.setStencilMode(stencilMode);
781
+ renderer.encoder.renderPassEncoder.setStencilReference(stencilReference);
782
+ }
783
+ destroy() {
784
+ this._renderer.renderTarget.onRenderTargetChange.remove(this);
785
+ this._renderer = null;
786
+ this._activeRenderTarget = null;
787
+ this._renderTargetStencilState = null;
788
+ }
789
+ }
790
+ /** @ignore */
791
+ GpuStencilSystem.extension = {
792
+ type: [
793
+ Extensions.ExtensionType.WebGPUSystem
794
+ ],
795
+ name: "stencil"
796
+ };
797
+
798
+
799
+ //# sourceMappingURL=GpuStencilSystem.mjs.map
800
+
801
+ // EXTERNAL MODULE: ./node_modules/pixi.js/lib/rendering/renderers/shared/shader/UboSystem.mjs
802
+ var UboSystem = __webpack_require__(7047);
803
+ ;// ./node_modules/pixi.js/lib/rendering/renderers/gpu/shader/utils/createUboElementsWGSL.mjs
804
+
805
+ const WGSL_ALIGN_SIZE_DATA = {
806
+ i32: { align: 4, size: 4 },
807
+ u32: { align: 4, size: 4 },
808
+ f32: { align: 4, size: 4 },
809
+ f16: { align: 2, size: 2 },
810
+ "vec2<i32>": { align: 8, size: 8 },
811
+ "vec2<u32>": { align: 8, size: 8 },
812
+ "vec2<f32>": { align: 8, size: 8 },
813
+ "vec2<f16>": { align: 4, size: 4 },
814
+ "vec3<i32>": { align: 16, size: 12 },
815
+ "vec3<u32>": { align: 16, size: 12 },
816
+ "vec3<f32>": { align: 16, size: 12 },
817
+ "vec3<f16>": { align: 8, size: 6 },
818
+ "vec4<i32>": { align: 16, size: 16 },
819
+ "vec4<u32>": { align: 16, size: 16 },
820
+ "vec4<f32>": { align: 16, size: 16 },
821
+ "vec4<f16>": { align: 8, size: 8 },
822
+ "mat2x2<f32>": { align: 8, size: 16 },
823
+ "mat2x2<f16>": { align: 4, size: 8 },
824
+ "mat3x2<f32>": { align: 8, size: 24 },
825
+ "mat3x2<f16>": { align: 4, size: 12 },
826
+ "mat4x2<f32>": { align: 8, size: 32 },
827
+ "mat4x2<f16>": { align: 4, size: 16 },
828
+ "mat2x3<f32>": { align: 16, size: 32 },
829
+ "mat2x3<f16>": { align: 8, size: 16 },
830
+ "mat3x3<f32>": { align: 16, size: 48 },
831
+ "mat3x3<f16>": { align: 8, size: 24 },
832
+ "mat4x3<f32>": { align: 16, size: 64 },
833
+ "mat4x3<f16>": { align: 8, size: 32 },
834
+ "mat2x4<f32>": { align: 16, size: 32 },
835
+ "mat2x4<f16>": { align: 8, size: 16 },
836
+ "mat3x4<f32>": { align: 16, size: 48 },
837
+ "mat3x4<f16>": { align: 8, size: 24 },
838
+ "mat4x4<f32>": { align: 16, size: 64 },
839
+ "mat4x4<f16>": { align: 8, size: 32 }
840
+ };
841
+ function createUboElementsWGSL(uniformData) {
842
+ const uboElements = uniformData.map((data) => ({
843
+ data,
844
+ offset: 0,
845
+ size: 0
846
+ }));
847
+ let offset = 0;
848
+ for (let i = 0; i < uboElements.length; i++) {
849
+ const uboElement = uboElements[i];
850
+ let size = WGSL_ALIGN_SIZE_DATA[uboElement.data.type].size;
851
+ const align = WGSL_ALIGN_SIZE_DATA[uboElement.data.type].align;
852
+ if (!WGSL_ALIGN_SIZE_DATA[uboElement.data.type]) {
853
+ throw new Error(`[Pixi.js] WebGPU UniformBuffer: Unknown type ${uboElement.data.type}`);
854
+ }
855
+ if (uboElement.data.size > 1) {
856
+ size = Math.max(size, align) * uboElement.data.size;
857
+ }
858
+ offset = Math.ceil(offset / align) * align;
859
+ uboElement.size = size;
860
+ uboElement.offset = offset;
861
+ offset += size;
862
+ }
863
+ offset = Math.ceil(offset / 16) * 16;
864
+ return { uboElements, size: offset };
865
+ }
866
+
867
+
868
+ //# sourceMappingURL=createUboElementsWGSL.mjs.map
869
+
870
+ // EXTERNAL MODULE: ./node_modules/pixi.js/lib/rendering/renderers/shared/shader/utils/createUboSyncFunction.mjs
871
+ var createUboSyncFunction = __webpack_require__(6423);
872
+ // EXTERNAL MODULE: ./node_modules/pixi.js/lib/rendering/renderers/shared/shader/utils/uboSyncFunctions.mjs
873
+ var uboSyncFunctions = __webpack_require__(1266);
874
+ ;// ./node_modules/pixi.js/lib/rendering/renderers/gpu/shader/utils/generateArraySyncWGSL.mjs
875
+
876
+
877
+ "use strict";
878
+ function generateArraySyncWGSL(uboElement, offsetToAdd) {
879
+ const { size, align } = WGSL_ALIGN_SIZE_DATA[uboElement.data.type];
880
+ const remainder = (align - size) / 4;
881
+ const data = uboElement.data.type.indexOf("i32") >= 0 ? "dataInt32" : "data";
882
+ return `
883
+ v = uv.${uboElement.data.name};
884
+ ${offsetToAdd !== 0 ? `offset += ${offsetToAdd};` : ""}
885
+
886
+ arrayOffset = offset;
887
+
888
+ t = 0;
889
+
890
+ for(var i=0; i < ${uboElement.data.size * (size / 4)}; i++)
891
+ {
892
+ for(var j = 0; j < ${size / 4}; j++)
893
+ {
894
+ ${data}[arrayOffset++] = v[t++];
895
+ }
896
+ ${remainder !== 0 ? `arrayOffset += ${remainder};` : ""}
897
+ }
898
+ `;
899
+ }
900
+
901
+
902
+ //# sourceMappingURL=generateArraySyncWGSL.mjs.map
903
+
904
+ ;// ./node_modules/pixi.js/lib/rendering/renderers/gpu/shader/utils/createUboSyncFunctionWGSL.mjs
905
+
906
+
907
+
908
+
909
+ "use strict";
910
+ function createUboSyncFunctionWGSL(uboElements) {
911
+ return (0,createUboSyncFunction.createUboSyncFunction)(
912
+ uboElements,
913
+ "uboWgsl",
914
+ generateArraySyncWGSL,
915
+ uboSyncFunctions.uboSyncFunctionsWGSL
916
+ );
917
+ }
918
+
919
+
920
+ //# sourceMappingURL=createUboSyncFunctionWGSL.mjs.map
921
+
922
+ ;// ./node_modules/pixi.js/lib/rendering/renderers/gpu/GpuUboSystem.mjs
923
+
924
+
925
+
926
+
927
+
928
+ "use strict";
929
+ class GpuUboSystem extends UboSystem.UboSystem {
930
+ constructor() {
931
+ super({
932
+ createUboElements: createUboElementsWGSL,
933
+ generateUboSync: createUboSyncFunctionWGSL
934
+ });
935
+ }
936
+ }
937
+ /** @ignore */
938
+ GpuUboSystem.extension = {
939
+ type: [Extensions.ExtensionType.WebGPUSystem],
940
+ name: "ubo"
941
+ };
942
+
943
+
944
+ //# sourceMappingURL=GpuUboSystem.mjs.map
945
+
946
+ // EXTERNAL MODULE: ./node_modules/pixi.js/lib/rendering/renderers/shared/buffer/Buffer.mjs
947
+ var Buffer = __webpack_require__(949);
948
+ // EXTERNAL MODULE: ./node_modules/pixi.js/lib/rendering/renderers/shared/buffer/BufferResource.mjs
949
+ var BufferResource = __webpack_require__(581);
950
+ // EXTERNAL MODULE: ./node_modules/pixi.js/lib/rendering/renderers/shared/buffer/const.mjs
951
+ var buffer_const = __webpack_require__(1132);
952
+ ;// ./node_modules/pixi.js/lib/rendering/renderers/gpu/buffer/UboBatch.mjs
953
+
954
+ class UboBatch {
955
+ constructor({ minUniformOffsetAlignment }) {
956
+ this._minUniformOffsetAlignment = 256;
957
+ this.byteIndex = 0;
958
+ this._minUniformOffsetAlignment = minUniformOffsetAlignment;
959
+ this.data = new Float32Array(65535);
960
+ }
961
+ clear() {
962
+ this.byteIndex = 0;
963
+ }
964
+ addEmptyGroup(size) {
965
+ if (size > this._minUniformOffsetAlignment / 4) {
966
+ throw new Error(`UniformBufferBatch: array is too large: ${size * 4}`);
967
+ }
968
+ const start = this.byteIndex;
969
+ let newSize = start + size * 4;
970
+ newSize = Math.ceil(newSize / this._minUniformOffsetAlignment) * this._minUniformOffsetAlignment;
971
+ if (newSize > this.data.length * 4) {
972
+ throw new Error("UniformBufferBatch: ubo batch got too big");
973
+ }
974
+ this.byteIndex = newSize;
975
+ return start;
976
+ }
977
+ addGroup(array) {
978
+ const offset = this.addEmptyGroup(array.length);
979
+ for (let i = 0; i < array.length; i++) {
980
+ this.data[offset / 4 + i] = array[i];
981
+ }
982
+ return offset;
983
+ }
984
+ destroy() {
985
+ this.data = null;
986
+ }
987
+ }
988
+
989
+
990
+ //# sourceMappingURL=UboBatch.mjs.map
991
+
992
+ // EXTERNAL MODULE: ./node_modules/pixi.js/lib/rendering/renderers/gpu/shader/BindGroup.mjs
993
+ var BindGroup = __webpack_require__(3513);
994
+ ;// ./node_modules/pixi.js/lib/rendering/renderers/gpu/GpuUniformBatchPipe.mjs
995
+
996
+
997
+
998
+
999
+
1000
+
1001
+
1002
+ "use strict";
1003
+ const minUniformOffsetAlignment = 128;
1004
+ class GpuUniformBatchPipe {
1005
+ constructor(renderer) {
1006
+ this._bindGroupHash = /* @__PURE__ */ Object.create(null);
1007
+ // number of buffers..
1008
+ this._buffers = [];
1009
+ this._bindGroups = [];
1010
+ this._bufferResources = [];
1011
+ this._renderer = renderer;
1012
+ this._renderer.renderableGC.addManagedHash(this, "_bindGroupHash");
1013
+ this._batchBuffer = new UboBatch({ minUniformOffsetAlignment });
1014
+ const totalBuffers = 256 / minUniformOffsetAlignment;
1015
+ for (let i = 0; i < totalBuffers; i++) {
1016
+ let usage = buffer_const.BufferUsage.UNIFORM | buffer_const.BufferUsage.COPY_DST;
1017
+ if (i === 0)
1018
+ usage |= buffer_const.BufferUsage.COPY_SRC;
1019
+ this._buffers.push(new Buffer.Buffer({
1020
+ data: this._batchBuffer.data,
1021
+ usage
1022
+ }));
1023
+ }
1024
+ }
1025
+ renderEnd() {
1026
+ this._uploadBindGroups();
1027
+ this._resetBindGroups();
1028
+ }
1029
+ _resetBindGroups() {
1030
+ for (const i in this._bindGroupHash) {
1031
+ this._bindGroupHash[i] = null;
1032
+ }
1033
+ this._batchBuffer.clear();
1034
+ }
1035
+ // just works for single bind groups for now
1036
+ getUniformBindGroup(group, duplicate) {
1037
+ if (!duplicate && this._bindGroupHash[group.uid]) {
1038
+ return this._bindGroupHash[group.uid];
1039
+ }
1040
+ this._renderer.ubo.ensureUniformGroup(group);
1041
+ const data = group.buffer.data;
1042
+ const offset = this._batchBuffer.addEmptyGroup(data.length);
1043
+ this._renderer.ubo.syncUniformGroup(group, this._batchBuffer.data, offset / 4);
1044
+ this._bindGroupHash[group.uid] = this._getBindGroup(offset / minUniformOffsetAlignment);
1045
+ return this._bindGroupHash[group.uid];
1046
+ }
1047
+ getUboResource(group) {
1048
+ this._renderer.ubo.updateUniformGroup(group);
1049
+ const data = group.buffer.data;
1050
+ const offset = this._batchBuffer.addGroup(data);
1051
+ return this._getBufferResource(offset / minUniformOffsetAlignment);
1052
+ }
1053
+ getArrayBindGroup(data) {
1054
+ const offset = this._batchBuffer.addGroup(data);
1055
+ return this._getBindGroup(offset / minUniformOffsetAlignment);
1056
+ }
1057
+ getArrayBufferResource(data) {
1058
+ const offset = this._batchBuffer.addGroup(data);
1059
+ const index = offset / minUniformOffsetAlignment;
1060
+ return this._getBufferResource(index);
1061
+ }
1062
+ _getBufferResource(index) {
1063
+ if (!this._bufferResources[index]) {
1064
+ const buffer = this._buffers[index % 2];
1065
+ this._bufferResources[index] = new BufferResource.BufferResource({
1066
+ buffer,
1067
+ offset: (index / 2 | 0) * 256,
1068
+ size: minUniformOffsetAlignment
1069
+ });
1070
+ }
1071
+ return this._bufferResources[index];
1072
+ }
1073
+ _getBindGroup(index) {
1074
+ if (!this._bindGroups[index]) {
1075
+ const bindGroup = new BindGroup.BindGroup({
1076
+ 0: this._getBufferResource(index)
1077
+ });
1078
+ this._bindGroups[index] = bindGroup;
1079
+ }
1080
+ return this._bindGroups[index];
1081
+ }
1082
+ _uploadBindGroups() {
1083
+ const bufferSystem = this._renderer.buffer;
1084
+ const firstBuffer = this._buffers[0];
1085
+ firstBuffer.update(this._batchBuffer.byteIndex);
1086
+ bufferSystem.updateBuffer(firstBuffer);
1087
+ const commandEncoder = this._renderer.gpu.device.createCommandEncoder();
1088
+ for (let i = 1; i < this._buffers.length; i++) {
1089
+ const buffer = this._buffers[i];
1090
+ commandEncoder.copyBufferToBuffer(
1091
+ bufferSystem.getGPUBuffer(firstBuffer),
1092
+ minUniformOffsetAlignment,
1093
+ bufferSystem.getGPUBuffer(buffer),
1094
+ 0,
1095
+ this._batchBuffer.byteIndex
1096
+ );
1097
+ }
1098
+ this._renderer.gpu.device.queue.submit([commandEncoder.finish()]);
1099
+ }
1100
+ destroy() {
1101
+ for (let i = 0; i < this._bindGroups.length; i++) {
1102
+ this._bindGroups[i].destroy();
1103
+ }
1104
+ this._bindGroups = null;
1105
+ this._bindGroupHash = null;
1106
+ for (let i = 0; i < this._buffers.length; i++) {
1107
+ this._buffers[i].destroy();
1108
+ }
1109
+ this._buffers = null;
1110
+ for (let i = 0; i < this._bufferResources.length; i++) {
1111
+ this._bufferResources[i].destroy();
1112
+ }
1113
+ this._bufferResources = null;
1114
+ this._batchBuffer.destroy();
1115
+ this._bindGroupHash = null;
1116
+ this._renderer = null;
1117
+ }
1118
+ }
1119
+ /** @ignore */
1120
+ GpuUniformBatchPipe.extension = {
1121
+ type: [
1122
+ Extensions.ExtensionType.WebGPUPipes
1123
+ ],
1124
+ name: "uniformBatch"
1125
+ };
1126
+
1127
+
1128
+ //# sourceMappingURL=GpuUniformBatchPipe.mjs.map
1129
+
1130
+ // EXTERNAL MODULE: ./node_modules/pixi.js/lib/rendering/renderers/gl/shader/program/ensureAttributes.mjs
1131
+ var ensureAttributes = __webpack_require__(7084);
1132
+ // EXTERNAL MODULE: ./node_modules/pixi.js/lib/rendering/renderers/shared/utils/createIdFromString.mjs
1133
+ var createIdFromString = __webpack_require__(7952);
1134
+ // EXTERNAL MODULE: ./node_modules/pixi.js/lib/rendering/renderers/gpu/state/GpuStencilModesToPixi.mjs
1135
+ var GpuStencilModesToPixi = __webpack_require__(1172);
1136
+ ;// ./node_modules/pixi.js/lib/rendering/renderers/gpu/pipeline/PipelineSystem.mjs
1137
+
1138
+
1139
+
1140
+
1141
+
1142
+
1143
+
1144
+ "use strict";
1145
+ const topologyStringToId = {
1146
+ "point-list": 0,
1147
+ "line-list": 1,
1148
+ "line-strip": 2,
1149
+ "triangle-list": 3,
1150
+ "triangle-strip": 4
1151
+ };
1152
+ function getGraphicsStateKey(geometryLayout, shaderKey, state, blendMode, topology) {
1153
+ return geometryLayout << 24 | shaderKey << 16 | state << 10 | blendMode << 5 | topology;
1154
+ }
1155
+ function getGlobalStateKey(stencilStateId, multiSampleCount, colorMask, renderTarget) {
1156
+ return colorMask << 6 | stencilStateId << 3 | renderTarget << 1 | multiSampleCount;
1157
+ }
1158
+ class PipelineSystem {
1159
+ constructor(renderer) {
1160
+ this._moduleCache = /* @__PURE__ */ Object.create(null);
1161
+ this._bufferLayoutsCache = /* @__PURE__ */ Object.create(null);
1162
+ this._bindingNamesCache = /* @__PURE__ */ Object.create(null);
1163
+ this._pipeCache = /* @__PURE__ */ Object.create(null);
1164
+ this._pipeStateCaches = /* @__PURE__ */ Object.create(null);
1165
+ this._colorMask = 15;
1166
+ this._multisampleCount = 1;
1167
+ this._renderer = renderer;
1168
+ }
1169
+ contextChange(gpu) {
1170
+ this._gpu = gpu;
1171
+ this.setStencilMode(state_const.STENCIL_MODES.DISABLED);
1172
+ this._updatePipeHash();
1173
+ }
1174
+ setMultisampleCount(multisampleCount) {
1175
+ if (this._multisampleCount === multisampleCount)
1176
+ return;
1177
+ this._multisampleCount = multisampleCount;
1178
+ this._updatePipeHash();
1179
+ }
1180
+ setRenderTarget(renderTarget) {
1181
+ this._multisampleCount = renderTarget.msaaSamples;
1182
+ this._depthStencilAttachment = renderTarget.descriptor.depthStencilAttachment ? 1 : 0;
1183
+ this._updatePipeHash();
1184
+ }
1185
+ setColorMask(colorMask) {
1186
+ if (this._colorMask === colorMask)
1187
+ return;
1188
+ this._colorMask = colorMask;
1189
+ this._updatePipeHash();
1190
+ }
1191
+ setStencilMode(stencilMode) {
1192
+ if (this._stencilMode === stencilMode)
1193
+ return;
1194
+ this._stencilMode = stencilMode;
1195
+ this._stencilState = GpuStencilModesToPixi.GpuStencilModesToPixi[stencilMode];
1196
+ this._updatePipeHash();
1197
+ }
1198
+ setPipeline(geometry, program, state, passEncoder) {
1199
+ const pipeline = this.getPipeline(geometry, program, state);
1200
+ passEncoder.setPipeline(pipeline);
1201
+ }
1202
+ getPipeline(geometry, program, state, topology) {
1203
+ if (!geometry._layoutKey) {
1204
+ (0,ensureAttributes.ensureAttributes)(geometry, program.attributeData);
1205
+ this._generateBufferKey(geometry);
1206
+ }
1207
+ topology || (topology = geometry.topology);
1208
+ const key = getGraphicsStateKey(
1209
+ geometry._layoutKey,
1210
+ program._layoutKey,
1211
+ state.data,
1212
+ state._blendModeId,
1213
+ topologyStringToId[topology]
1214
+ );
1215
+ if (this._pipeCache[key])
1216
+ return this._pipeCache[key];
1217
+ this._pipeCache[key] = this._createPipeline(geometry, program, state, topology);
1218
+ return this._pipeCache[key];
1219
+ }
1220
+ _createPipeline(geometry, program, state, topology) {
1221
+ const device = this._gpu.device;
1222
+ const buffers = this._createVertexBufferLayouts(geometry, program);
1223
+ const blendModes = this._renderer.state.getColorTargets(state);
1224
+ blendModes[0].writeMask = this._stencilMode === state_const.STENCIL_MODES.RENDERING_MASK_ADD ? 0 : this._colorMask;
1225
+ const layout = this._renderer.shader.getProgramData(program).pipeline;
1226
+ const descriptor = {
1227
+ // TODO later check if its helpful to create..
1228
+ // layout,
1229
+ vertex: {
1230
+ module: this._getModule(program.vertex.source),
1231
+ entryPoint: program.vertex.entryPoint,
1232
+ // geometry..
1233
+ buffers
1234
+ },
1235
+ fragment: {
1236
+ module: this._getModule(program.fragment.source),
1237
+ entryPoint: program.fragment.entryPoint,
1238
+ targets: blendModes
1239
+ },
1240
+ primitive: {
1241
+ topology,
1242
+ cullMode: state.cullMode
1243
+ },
1244
+ layout,
1245
+ multisample: {
1246
+ count: this._multisampleCount
1247
+ },
1248
+ // depthStencil,
1249
+ label: `PIXI Pipeline`
1250
+ };
1251
+ if (this._depthStencilAttachment) {
1252
+ descriptor.depthStencil = {
1253
+ ...this._stencilState,
1254
+ format: "depth24plus-stencil8",
1255
+ depthWriteEnabled: state.depthTest,
1256
+ depthCompare: state.depthTest ? "less" : "always"
1257
+ };
1258
+ }
1259
+ const pipeline = device.createRenderPipeline(descriptor);
1260
+ return pipeline;
1261
+ }
1262
+ _getModule(code) {
1263
+ return this._moduleCache[code] || this._createModule(code);
1264
+ }
1265
+ _createModule(code) {
1266
+ const device = this._gpu.device;
1267
+ this._moduleCache[code] = device.createShaderModule({
1268
+ code
1269
+ });
1270
+ return this._moduleCache[code];
1271
+ }
1272
+ _generateBufferKey(geometry) {
1273
+ const keyGen = [];
1274
+ let index = 0;
1275
+ const attributeKeys = Object.keys(geometry.attributes).sort();
1276
+ for (let i = 0; i < attributeKeys.length; i++) {
1277
+ const attribute = geometry.attributes[attributeKeys[i]];
1278
+ keyGen[index++] = attribute.offset;
1279
+ keyGen[index++] = attribute.format;
1280
+ keyGen[index++] = attribute.stride;
1281
+ keyGen[index++] = attribute.instance;
1282
+ }
1283
+ const stringKey = keyGen.join("|");
1284
+ geometry._layoutKey = (0,createIdFromString.createIdFromString)(stringKey, "geometry");
1285
+ return geometry._layoutKey;
1286
+ }
1287
+ _generateAttributeLocationsKey(program) {
1288
+ const keyGen = [];
1289
+ let index = 0;
1290
+ const attributeKeys = Object.keys(program.attributeData).sort();
1291
+ for (let i = 0; i < attributeKeys.length; i++) {
1292
+ const attribute = program.attributeData[attributeKeys[i]];
1293
+ keyGen[index++] = attribute.location;
1294
+ }
1295
+ const stringKey = keyGen.join("|");
1296
+ program._attributeLocationsKey = (0,createIdFromString.createIdFromString)(stringKey, "programAttributes");
1297
+ return program._attributeLocationsKey;
1298
+ }
1299
+ /**
1300
+ * Returns a hash of buffer names mapped to bind locations.
1301
+ * This is used to bind the correct buffer to the correct location in the shader.
1302
+ * @param geometry - The geometry where to get the buffer names
1303
+ * @param program - The program where to get the buffer names
1304
+ * @returns An object of buffer names mapped to the bind location.
1305
+ */
1306
+ getBufferNamesToBind(geometry, program) {
1307
+ const key = geometry._layoutKey << 16 | program._attributeLocationsKey;
1308
+ if (this._bindingNamesCache[key])
1309
+ return this._bindingNamesCache[key];
1310
+ const data = this._createVertexBufferLayouts(geometry, program);
1311
+ const bufferNamesToBind = /* @__PURE__ */ Object.create(null);
1312
+ const attributeData = program.attributeData;
1313
+ for (let i = 0; i < data.length; i++) {
1314
+ const attributes = Object.values(data[i].attributes);
1315
+ const shaderLocation = attributes[0].shaderLocation;
1316
+ for (const j in attributeData) {
1317
+ if (attributeData[j].location === shaderLocation) {
1318
+ bufferNamesToBind[i] = j;
1319
+ break;
1320
+ }
1321
+ }
1322
+ }
1323
+ this._bindingNamesCache[key] = bufferNamesToBind;
1324
+ return bufferNamesToBind;
1325
+ }
1326
+ _createVertexBufferLayouts(geometry, program) {
1327
+ if (!program._attributeLocationsKey)
1328
+ this._generateAttributeLocationsKey(program);
1329
+ const key = geometry._layoutKey << 16 | program._attributeLocationsKey;
1330
+ if (this._bufferLayoutsCache[key]) {
1331
+ return this._bufferLayoutsCache[key];
1332
+ }
1333
+ const vertexBuffersLayout = [];
1334
+ geometry.buffers.forEach((buffer) => {
1335
+ const bufferEntry = {
1336
+ arrayStride: 0,
1337
+ stepMode: "vertex",
1338
+ attributes: []
1339
+ };
1340
+ const bufferEntryAttributes = bufferEntry.attributes;
1341
+ for (const i in program.attributeData) {
1342
+ const attribute = geometry.attributes[i];
1343
+ if ((attribute.divisor ?? 1) !== 1) {
1344
+ (0,warn.warn)(`Attribute ${i} has an invalid divisor value of '${attribute.divisor}'. WebGPU only supports a divisor value of 1`);
1345
+ }
1346
+ if (attribute.buffer === buffer) {
1347
+ bufferEntry.arrayStride = attribute.stride;
1348
+ bufferEntry.stepMode = attribute.instance ? "instance" : "vertex";
1349
+ bufferEntryAttributes.push({
1350
+ shaderLocation: program.attributeData[i].location,
1351
+ offset: attribute.offset,
1352
+ format: attribute.format
1353
+ });
1354
+ }
1355
+ }
1356
+ if (bufferEntryAttributes.length) {
1357
+ vertexBuffersLayout.push(bufferEntry);
1358
+ }
1359
+ });
1360
+ this._bufferLayoutsCache[key] = vertexBuffersLayout;
1361
+ return vertexBuffersLayout;
1362
+ }
1363
+ _updatePipeHash() {
1364
+ const key = getGlobalStateKey(
1365
+ this._stencilMode,
1366
+ this._multisampleCount,
1367
+ this._colorMask,
1368
+ this._depthStencilAttachment
1369
+ );
1370
+ if (!this._pipeStateCaches[key]) {
1371
+ this._pipeStateCaches[key] = /* @__PURE__ */ Object.create(null);
1372
+ }
1373
+ this._pipeCache = this._pipeStateCaches[key];
1374
+ }
1375
+ destroy() {
1376
+ this._renderer = null;
1377
+ this._bufferLayoutsCache = null;
1378
+ }
1379
+ }
1380
+ /** @ignore */
1381
+ PipelineSystem.extension = {
1382
+ type: [Extensions.ExtensionType.WebGPUSystem],
1383
+ name: "pipeline"
1384
+ };
1385
+
1386
+
1387
+ //# sourceMappingURL=PipelineSystem.mjs.map
1388
+
1389
+ // EXTERNAL MODULE: ./node_modules/pixi.js/lib/rendering/renderers/shared/renderTarget/RenderTargetSystem.mjs + 2 modules
1390
+ var RenderTargetSystem = __webpack_require__(7238);
1391
+ // EXTERNAL MODULE: ./node_modules/pixi.js/lib/rendering/renderers/gl/const.mjs
1392
+ var gl_const = __webpack_require__(1257);
1393
+ // EXTERNAL MODULE: ./node_modules/pixi.js/lib/rendering/renderers/shared/texture/sources/CanvasSource.mjs
1394
+ var CanvasSource = __webpack_require__(4884);
1395
+ // EXTERNAL MODULE: ./node_modules/pixi.js/lib/rendering/renderers/shared/texture/sources/TextureSource.mjs + 1 modules
1396
+ var TextureSource = __webpack_require__(1285);
1397
+ ;// ./node_modules/pixi.js/lib/rendering/renderers/gpu/renderTarget/GpuRenderTarget.mjs
1398
+
1399
+ class GpuRenderTarget {
1400
+ constructor() {
1401
+ this.contexts = [];
1402
+ this.msaaTextures = [];
1403
+ this.msaaSamples = 1;
1404
+ }
1405
+ }
1406
+
1407
+
1408
+ //# sourceMappingURL=GpuRenderTarget.mjs.map
1409
+
1410
+ ;// ./node_modules/pixi.js/lib/rendering/renderers/gpu/renderTarget/GpuRenderTargetAdaptor.mjs
1411
+
1412
+
1413
+
1414
+
1415
+
1416
+ "use strict";
1417
+ class GpuRenderTargetAdaptor {
1418
+ init(renderer, renderTargetSystem) {
1419
+ this._renderer = renderer;
1420
+ this._renderTargetSystem = renderTargetSystem;
1421
+ }
1422
+ copyToTexture(sourceRenderSurfaceTexture, destinationTexture, originSrc, size, originDest) {
1423
+ const renderer = this._renderer;
1424
+ const baseGpuTexture = this._getGpuColorTexture(
1425
+ sourceRenderSurfaceTexture
1426
+ );
1427
+ const backGpuTexture = renderer.texture.getGpuSource(
1428
+ destinationTexture.source
1429
+ );
1430
+ renderer.encoder.commandEncoder.copyTextureToTexture(
1431
+ {
1432
+ texture: baseGpuTexture,
1433
+ origin: originSrc
1434
+ },
1435
+ {
1436
+ texture: backGpuTexture,
1437
+ origin: originDest
1438
+ },
1439
+ size
1440
+ );
1441
+ return destinationTexture;
1442
+ }
1443
+ startRenderPass(renderTarget, clear = true, clearColor, viewport) {
1444
+ const renderTargetSystem = this._renderTargetSystem;
1445
+ const gpuRenderTarget = renderTargetSystem.getGpuRenderTarget(renderTarget);
1446
+ const descriptor = this.getDescriptor(renderTarget, clear, clearColor);
1447
+ gpuRenderTarget.descriptor = descriptor;
1448
+ this._renderer.pipeline.setRenderTarget(gpuRenderTarget);
1449
+ this._renderer.encoder.beginRenderPass(gpuRenderTarget);
1450
+ this._renderer.encoder.setViewport(viewport);
1451
+ }
1452
+ finishRenderPass() {
1453
+ this._renderer.encoder.endRenderPass();
1454
+ }
1455
+ /**
1456
+ * returns the gpu texture for the first color texture in the render target
1457
+ * mainly used by the filter manager to get copy the texture for blending
1458
+ * @param renderTarget
1459
+ * @returns a gpu texture
1460
+ */
1461
+ _getGpuColorTexture(renderTarget) {
1462
+ const gpuRenderTarget = this._renderTargetSystem.getGpuRenderTarget(renderTarget);
1463
+ if (gpuRenderTarget.contexts[0]) {
1464
+ return gpuRenderTarget.contexts[0].getCurrentTexture();
1465
+ }
1466
+ return this._renderer.texture.getGpuSource(
1467
+ renderTarget.colorTextures[0].source
1468
+ );
1469
+ }
1470
+ getDescriptor(renderTarget, clear, clearValue) {
1471
+ if (typeof clear === "boolean") {
1472
+ clear = clear ? gl_const.CLEAR.ALL : gl_const.CLEAR.NONE;
1473
+ }
1474
+ const renderTargetSystem = this._renderTargetSystem;
1475
+ const gpuRenderTarget = renderTargetSystem.getGpuRenderTarget(renderTarget);
1476
+ const colorAttachments = renderTarget.colorTextures.map(
1477
+ (texture, i) => {
1478
+ const context = gpuRenderTarget.contexts[i];
1479
+ let view;
1480
+ let resolveTarget;
1481
+ if (context) {
1482
+ const currentTexture = context.getCurrentTexture();
1483
+ const canvasTextureView = currentTexture.createView();
1484
+ view = canvasTextureView;
1485
+ } else {
1486
+ view = this._renderer.texture.getGpuSource(texture).createView({
1487
+ mipLevelCount: 1
1488
+ });
1489
+ }
1490
+ if (gpuRenderTarget.msaaTextures[i]) {
1491
+ resolveTarget = view;
1492
+ view = this._renderer.texture.getTextureView(
1493
+ gpuRenderTarget.msaaTextures[i]
1494
+ );
1495
+ }
1496
+ const loadOp = clear & gl_const.CLEAR.COLOR ? "clear" : "load";
1497
+ clearValue ?? (clearValue = renderTargetSystem.defaultClearColor);
1498
+ return {
1499
+ view,
1500
+ resolveTarget,
1501
+ clearValue,
1502
+ storeOp: "store",
1503
+ loadOp
1504
+ };
1505
+ }
1506
+ );
1507
+ let depthStencilAttachment;
1508
+ if ((renderTarget.stencil || renderTarget.depth) && !renderTarget.depthStencilTexture) {
1509
+ renderTarget.ensureDepthStencilTexture();
1510
+ renderTarget.depthStencilTexture.source.sampleCount = gpuRenderTarget.msaa ? 4 : 1;
1511
+ }
1512
+ if (renderTarget.depthStencilTexture) {
1513
+ const stencilLoadOp = clear & gl_const.CLEAR.STENCIL ? "clear" : "load";
1514
+ const depthLoadOp = clear & gl_const.CLEAR.DEPTH ? "clear" : "load";
1515
+ depthStencilAttachment = {
1516
+ view: this._renderer.texture.getGpuSource(renderTarget.depthStencilTexture.source).createView(),
1517
+ stencilStoreOp: "store",
1518
+ stencilLoadOp,
1519
+ depthClearValue: 1,
1520
+ depthLoadOp,
1521
+ depthStoreOp: "store"
1522
+ };
1523
+ }
1524
+ const descriptor = {
1525
+ colorAttachments,
1526
+ depthStencilAttachment
1527
+ };
1528
+ return descriptor;
1529
+ }
1530
+ clear(renderTarget, clear = true, clearColor, viewport) {
1531
+ if (!clear)
1532
+ return;
1533
+ const { gpu, encoder } = this._renderer;
1534
+ const device = gpu.device;
1535
+ const standAlone = encoder.commandEncoder === null;
1536
+ if (standAlone) {
1537
+ const commandEncoder = device.createCommandEncoder();
1538
+ const renderPassDescriptor = this.getDescriptor(renderTarget, clear, clearColor);
1539
+ const passEncoder = commandEncoder.beginRenderPass(renderPassDescriptor);
1540
+ passEncoder.setViewport(viewport.x, viewport.y, viewport.width, viewport.height, 0, 1);
1541
+ passEncoder.end();
1542
+ const gpuCommands = commandEncoder.finish();
1543
+ device.queue.submit([gpuCommands]);
1544
+ } else {
1545
+ this.startRenderPass(renderTarget, clear, clearColor, viewport);
1546
+ }
1547
+ }
1548
+ initGpuRenderTarget(renderTarget) {
1549
+ renderTarget.isRoot = true;
1550
+ const gpuRenderTarget = new GpuRenderTarget();
1551
+ renderTarget.colorTextures.forEach((colorTexture, i) => {
1552
+ if (CanvasSource.CanvasSource.test(colorTexture.resource)) {
1553
+ const context = colorTexture.resource.getContext(
1554
+ "webgpu"
1555
+ );
1556
+ const alphaMode = colorTexture.transparent ? "premultiplied" : "opaque";
1557
+ try {
1558
+ context.configure({
1559
+ device: this._renderer.gpu.device,
1560
+ usage: GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST | GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.COPY_SRC,
1561
+ format: "bgra8unorm",
1562
+ alphaMode
1563
+ });
1564
+ } catch (e) {
1565
+ console.error(e);
1566
+ }
1567
+ gpuRenderTarget.contexts[i] = context;
1568
+ }
1569
+ gpuRenderTarget.msaa = colorTexture.source.antialias;
1570
+ if (colorTexture.source.antialias) {
1571
+ const msaaTexture = new TextureSource.TextureSource({
1572
+ width: 0,
1573
+ height: 0,
1574
+ sampleCount: 4
1575
+ });
1576
+ gpuRenderTarget.msaaTextures[i] = msaaTexture;
1577
+ }
1578
+ });
1579
+ if (gpuRenderTarget.msaa) {
1580
+ gpuRenderTarget.msaaSamples = 4;
1581
+ if (renderTarget.depthStencilTexture) {
1582
+ renderTarget.depthStencilTexture.source.sampleCount = 4;
1583
+ }
1584
+ }
1585
+ return gpuRenderTarget;
1586
+ }
1587
+ destroyGpuRenderTarget(gpuRenderTarget) {
1588
+ gpuRenderTarget.contexts.forEach((context) => {
1589
+ context.unconfigure();
1590
+ });
1591
+ gpuRenderTarget.msaaTextures.forEach((texture) => {
1592
+ texture.destroy();
1593
+ });
1594
+ gpuRenderTarget.msaaTextures.length = 0;
1595
+ gpuRenderTarget.contexts.length = 0;
1596
+ }
1597
+ ensureDepthStencilTexture(renderTarget) {
1598
+ const gpuRenderTarget = this._renderTargetSystem.getGpuRenderTarget(renderTarget);
1599
+ if (renderTarget.depthStencilTexture && gpuRenderTarget.msaa) {
1600
+ renderTarget.depthStencilTexture.source.sampleCount = 4;
1601
+ }
1602
+ }
1603
+ resizeGpuRenderTarget(renderTarget) {
1604
+ const gpuRenderTarget = this._renderTargetSystem.getGpuRenderTarget(renderTarget);
1605
+ gpuRenderTarget.width = renderTarget.width;
1606
+ gpuRenderTarget.height = renderTarget.height;
1607
+ if (gpuRenderTarget.msaa) {
1608
+ renderTarget.colorTextures.forEach((colorTexture, i) => {
1609
+ const msaaTexture = gpuRenderTarget.msaaTextures[i];
1610
+ msaaTexture?.resize(
1611
+ colorTexture.source.width,
1612
+ colorTexture.source.height,
1613
+ colorTexture.source._resolution
1614
+ );
1615
+ });
1616
+ }
1617
+ }
1618
+ }
1619
+
1620
+
1621
+ //# sourceMappingURL=GpuRenderTargetAdaptor.mjs.map
1622
+
1623
+ ;// ./node_modules/pixi.js/lib/rendering/renderers/gpu/renderTarget/GpuRenderTargetSystem.mjs
1624
+
1625
+
1626
+
1627
+
1628
+ "use strict";
1629
+ class GpuRenderTargetSystem extends RenderTargetSystem.RenderTargetSystem {
1630
+ constructor(renderer) {
1631
+ super(renderer);
1632
+ this.adaptor = new GpuRenderTargetAdaptor();
1633
+ this.adaptor.init(renderer, this);
1634
+ }
1635
+ }
1636
+ /** @ignore */
1637
+ GpuRenderTargetSystem.extension = {
1638
+ type: [Extensions.ExtensionType.WebGPUSystem],
1639
+ name: "renderTarget"
1640
+ };
1641
+
1642
+
1643
+ //# sourceMappingURL=GpuRenderTargetSystem.mjs.map
1644
+
1645
+ ;// ./node_modules/pixi.js/lib/rendering/renderers/gpu/shader/GpuShaderSystem.mjs
1646
+
1647
+
1648
+ "use strict";
1649
+ class GpuShaderSystem {
1650
+ constructor() {
1651
+ this._gpuProgramData = /* @__PURE__ */ Object.create(null);
1652
+ }
1653
+ contextChange(gpu) {
1654
+ this._gpu = gpu;
1655
+ this.maxTextures = gpu.device.limits.maxSampledTexturesPerShaderStage;
1656
+ }
1657
+ getProgramData(program) {
1658
+ return this._gpuProgramData[program._layoutKey] || this._createGPUProgramData(program);
1659
+ }
1660
+ _createGPUProgramData(program) {
1661
+ const device = this._gpu.device;
1662
+ const bindGroups = program.gpuLayout.map((group) => device.createBindGroupLayout({ entries: group }));
1663
+ const pipelineLayoutDesc = { bindGroupLayouts: bindGroups };
1664
+ this._gpuProgramData[program._layoutKey] = {
1665
+ bindGroups,
1666
+ pipeline: device.createPipelineLayout(pipelineLayoutDesc)
1667
+ };
1668
+ return this._gpuProgramData[program._layoutKey];
1669
+ }
1670
+ destroy() {
1671
+ this._gpu = null;
1672
+ this._gpuProgramData = null;
1673
+ }
1674
+ }
1675
+ /** @ignore */
1676
+ GpuShaderSystem.extension = {
1677
+ type: [
1678
+ Extensions.ExtensionType.WebGPUSystem
1679
+ ],
1680
+ name: "shader"
1681
+ };
1682
+
1683
+
1684
+ //# sourceMappingURL=GpuShaderSystem.mjs.map
1685
+
1686
+ ;// ./node_modules/pixi.js/lib/rendering/renderers/gpu/state/GpuBlendModesToPixi.mjs
1687
+
1688
+ const GpuBlendModesToPixi = {};
1689
+ GpuBlendModesToPixi.normal = {
1690
+ alpha: {
1691
+ srcFactor: "one",
1692
+ dstFactor: "one-minus-src-alpha",
1693
+ operation: "add"
1694
+ },
1695
+ color: {
1696
+ srcFactor: "one",
1697
+ dstFactor: "one-minus-src-alpha",
1698
+ operation: "add"
1699
+ }
1700
+ };
1701
+ GpuBlendModesToPixi.add = {
1702
+ alpha: {
1703
+ srcFactor: "src-alpha",
1704
+ dstFactor: "one-minus-src-alpha",
1705
+ operation: "add"
1706
+ },
1707
+ color: {
1708
+ srcFactor: "one",
1709
+ dstFactor: "one",
1710
+ operation: "add"
1711
+ }
1712
+ };
1713
+ GpuBlendModesToPixi.multiply = {
1714
+ alpha: {
1715
+ srcFactor: "one",
1716
+ dstFactor: "one-minus-src-alpha",
1717
+ operation: "add"
1718
+ },
1719
+ color: {
1720
+ srcFactor: "dst",
1721
+ dstFactor: "one-minus-src-alpha",
1722
+ operation: "add"
1723
+ }
1724
+ };
1725
+ GpuBlendModesToPixi.screen = {
1726
+ alpha: {
1727
+ srcFactor: "one",
1728
+ dstFactor: "one-minus-src-alpha",
1729
+ operation: "add"
1730
+ },
1731
+ color: {
1732
+ srcFactor: "one",
1733
+ dstFactor: "one-minus-src",
1734
+ operation: "add"
1735
+ }
1736
+ };
1737
+ GpuBlendModesToPixi.overlay = {
1738
+ alpha: {
1739
+ srcFactor: "one",
1740
+ dstFactor: "one-minus-src-alpha",
1741
+ operation: "add"
1742
+ },
1743
+ color: {
1744
+ srcFactor: "one",
1745
+ dstFactor: "one-minus-src",
1746
+ operation: "add"
1747
+ }
1748
+ };
1749
+ GpuBlendModesToPixi.none = {
1750
+ alpha: {
1751
+ srcFactor: "one",
1752
+ dstFactor: "one-minus-src-alpha",
1753
+ operation: "add"
1754
+ },
1755
+ color: {
1756
+ srcFactor: "zero",
1757
+ dstFactor: "zero",
1758
+ operation: "add"
1759
+ }
1760
+ };
1761
+ GpuBlendModesToPixi["normal-npm"] = {
1762
+ alpha: {
1763
+ srcFactor: "one",
1764
+ dstFactor: "one-minus-src-alpha",
1765
+ operation: "add"
1766
+ },
1767
+ color: {
1768
+ srcFactor: "src-alpha",
1769
+ dstFactor: "one-minus-src-alpha",
1770
+ operation: "add"
1771
+ }
1772
+ };
1773
+ GpuBlendModesToPixi["add-npm"] = {
1774
+ alpha: {
1775
+ srcFactor: "one",
1776
+ dstFactor: "one",
1777
+ operation: "add"
1778
+ },
1779
+ color: {
1780
+ srcFactor: "src-alpha",
1781
+ dstFactor: "one",
1782
+ operation: "add"
1783
+ }
1784
+ };
1785
+ GpuBlendModesToPixi["screen-npm"] = {
1786
+ alpha: {
1787
+ srcFactor: "one",
1788
+ dstFactor: "one-minus-src-alpha",
1789
+ operation: "add"
1790
+ },
1791
+ color: {
1792
+ srcFactor: "src-alpha",
1793
+ dstFactor: "one-minus-src",
1794
+ operation: "add"
1795
+ }
1796
+ };
1797
+ GpuBlendModesToPixi.erase = {
1798
+ alpha: {
1799
+ srcFactor: "zero",
1800
+ dstFactor: "one-minus-src-alpha",
1801
+ operation: "add"
1802
+ },
1803
+ color: {
1804
+ srcFactor: "zero",
1805
+ dstFactor: "one-minus-src",
1806
+ operation: "add"
1807
+ }
1808
+ };
1809
+ GpuBlendModesToPixi.min = {
1810
+ alpha: {
1811
+ srcFactor: "one",
1812
+ dstFactor: "one",
1813
+ operation: "min"
1814
+ },
1815
+ color: {
1816
+ srcFactor: "one",
1817
+ dstFactor: "one",
1818
+ operation: "min"
1819
+ }
1820
+ };
1821
+ GpuBlendModesToPixi.max = {
1822
+ alpha: {
1823
+ srcFactor: "one",
1824
+ dstFactor: "one",
1825
+ operation: "max"
1826
+ },
1827
+ color: {
1828
+ srcFactor: "one",
1829
+ dstFactor: "one",
1830
+ operation: "max"
1831
+ }
1832
+ };
1833
+
1834
+
1835
+ //# sourceMappingURL=GpuBlendModesToPixi.mjs.map
1836
+
1837
+ ;// ./node_modules/pixi.js/lib/rendering/renderers/gpu/state/GpuStateSystem.mjs
1838
+
1839
+
1840
+
1841
+
1842
+ "use strict";
1843
+ class GpuStateSystem {
1844
+ constructor() {
1845
+ this.defaultState = new State.State();
1846
+ this.defaultState.blend = true;
1847
+ }
1848
+ contextChange(gpu) {
1849
+ this.gpu = gpu;
1850
+ }
1851
+ /**
1852
+ * Gets the blend mode data for the current state
1853
+ * @param state - The state to get the blend mode from
1854
+ */
1855
+ getColorTargets(state) {
1856
+ const blend = GpuBlendModesToPixi[state.blendMode] || GpuBlendModesToPixi.normal;
1857
+ return [
1858
+ {
1859
+ format: "bgra8unorm",
1860
+ writeMask: 0,
1861
+ blend
1862
+ }
1863
+ ];
1864
+ }
1865
+ destroy() {
1866
+ this.gpu = null;
1867
+ }
1868
+ }
1869
+ /** @ignore */
1870
+ GpuStateSystem.extension = {
1871
+ type: [
1872
+ Extensions.ExtensionType.WebGPUSystem
1873
+ ],
1874
+ name: "state"
1875
+ };
1876
+
1877
+
1878
+ //# sourceMappingURL=GpuStateSystem.mjs.map
1879
+
1880
+ // EXTERNAL MODULE: ./node_modules/pixi.js/lib/rendering/renderers/shared/texture/CanvasPool.mjs
1881
+ var CanvasPool = __webpack_require__(7608);
1882
+ ;// ./node_modules/pixi.js/lib/rendering/renderers/gpu/texture/uploaders/gpuUploadBufferImageResource.mjs
1883
+
1884
+ const gpuUploadBufferImageResource = {
1885
+ type: "image",
1886
+ upload(source, gpuTexture, gpu) {
1887
+ const resource = source.resource;
1888
+ const total = (source.pixelWidth | 0) * (source.pixelHeight | 0);
1889
+ const bytesPerPixel = resource.byteLength / total;
1890
+ gpu.device.queue.writeTexture(
1891
+ { texture: gpuTexture },
1892
+ resource,
1893
+ {
1894
+ offset: 0,
1895
+ rowsPerImage: source.pixelHeight,
1896
+ bytesPerRow: source.pixelHeight * bytesPerPixel
1897
+ },
1898
+ {
1899
+ width: source.pixelWidth,
1900
+ height: source.pixelHeight,
1901
+ depthOrArrayLayers: 1
1902
+ }
1903
+ );
1904
+ }
1905
+ };
1906
+
1907
+
1908
+ //# sourceMappingURL=gpuUploadBufferImageResource.mjs.map
1909
+
1910
+ ;// ./node_modules/pixi.js/lib/rendering/renderers/gpu/texture/uploaders/gpuUploadCompressedTextureResource.mjs
1911
+
1912
+ const blockDataMap = {
1913
+ "bc1-rgba-unorm": { blockBytes: 8, blockWidth: 4, blockHeight: 4 },
1914
+ "bc2-rgba-unorm": { blockBytes: 16, blockWidth: 4, blockHeight: 4 },
1915
+ "bc3-rgba-unorm": { blockBytes: 16, blockWidth: 4, blockHeight: 4 },
1916
+ "bc7-rgba-unorm": { blockBytes: 16, blockWidth: 4, blockHeight: 4 },
1917
+ "etc1-rgb-unorm": { blockBytes: 8, blockWidth: 4, blockHeight: 4 },
1918
+ "etc2-rgba8unorm": { blockBytes: 16, blockWidth: 4, blockHeight: 4 },
1919
+ "astc-4x4-unorm": { blockBytes: 16, blockWidth: 4, blockHeight: 4 }
1920
+ };
1921
+ const defaultBlockData = { blockBytes: 4, blockWidth: 1, blockHeight: 1 };
1922
+ const gpuUploadCompressedTextureResource = {
1923
+ type: "compressed",
1924
+ upload(source, gpuTexture, gpu) {
1925
+ let mipWidth = source.pixelWidth;
1926
+ let mipHeight = source.pixelHeight;
1927
+ const blockData = blockDataMap[source.format] || defaultBlockData;
1928
+ for (let i = 0; i < source.resource.length; i++) {
1929
+ const levelBuffer = source.resource[i];
1930
+ const bytesPerRow = Math.ceil(mipWidth / blockData.blockWidth) * blockData.blockBytes;
1931
+ gpu.device.queue.writeTexture(
1932
+ {
1933
+ texture: gpuTexture,
1934
+ mipLevel: i
1935
+ },
1936
+ levelBuffer,
1937
+ {
1938
+ offset: 0,
1939
+ bytesPerRow
1940
+ },
1941
+ {
1942
+ width: Math.ceil(mipWidth / blockData.blockWidth) * blockData.blockWidth,
1943
+ height: Math.ceil(mipHeight / blockData.blockHeight) * blockData.blockHeight,
1944
+ depthOrArrayLayers: 1
1945
+ }
1946
+ );
1947
+ mipWidth = Math.max(mipWidth >> 1, 1);
1948
+ mipHeight = Math.max(mipHeight >> 1, 1);
1949
+ }
1950
+ }
1951
+ };
1952
+
1953
+
1954
+ //# sourceMappingURL=gpuUploadCompressedTextureResource.mjs.map
1955
+
1956
+ ;// ./node_modules/pixi.js/lib/rendering/renderers/gpu/texture/uploaders/gpuUploadImageSource.mjs
1957
+
1958
+ const gpuUploadImageResource = {
1959
+ type: "image",
1960
+ upload(source, gpuTexture, gpu) {
1961
+ const resource = source.resource;
1962
+ if (!resource)
1963
+ return;
1964
+ const width = Math.min(gpuTexture.width, source.resourceWidth || source.pixelWidth);
1965
+ const height = Math.min(gpuTexture.height, source.resourceHeight || source.pixelHeight);
1966
+ const premultipliedAlpha = source.alphaMode === "premultiply-alpha-on-upload";
1967
+ gpu.device.queue.copyExternalImageToTexture(
1968
+ { source: resource },
1969
+ { texture: gpuTexture, premultipliedAlpha },
1970
+ {
1971
+ width,
1972
+ height
1973
+ }
1974
+ );
1975
+ }
1976
+ };
1977
+
1978
+
1979
+ //# sourceMappingURL=gpuUploadImageSource.mjs.map
1980
+
1981
+ ;// ./node_modules/pixi.js/lib/rendering/renderers/gpu/texture/uploaders/gpuUploadVideoSource.mjs
1982
+
1983
+
1984
+ "use strict";
1985
+ const gpuUploadVideoResource = {
1986
+ type: "video",
1987
+ upload(source, gpuTexture, gpu) {
1988
+ gpuUploadImageResource.upload(source, gpuTexture, gpu);
1989
+ }
1990
+ };
1991
+
1992
+
1993
+ //# sourceMappingURL=gpuUploadVideoSource.mjs.map
1994
+
1995
+ ;// ./node_modules/pixi.js/lib/rendering/renderers/gpu/texture/utils/GpuMipmapGenerator.mjs
1996
+
1997
+ class GpuMipmapGenerator {
1998
+ constructor(device) {
1999
+ this.device = device;
2000
+ this.sampler = device.createSampler({ minFilter: "linear" });
2001
+ this.pipelines = {};
2002
+ }
2003
+ _getMipmapPipeline(format) {
2004
+ let pipeline = this.pipelines[format];
2005
+ if (!pipeline) {
2006
+ if (!this.mipmapShaderModule) {
2007
+ this.mipmapShaderModule = this.device.createShaderModule({
2008
+ code: (
2009
+ /* wgsl */
2010
+ `
2011
+ var<private> pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
2012
+ vec2<f32>(-1.0, -1.0), vec2<f32>(-1.0, 3.0), vec2<f32>(3.0, -1.0));
2013
+
2014
+ struct VertexOutput {
2015
+ @builtin(position) position : vec4<f32>,
2016
+ @location(0) texCoord : vec2<f32>,
2017
+ };
2018
+
2019
+ @vertex
2020
+ fn vertexMain(@builtin(vertex_index) vertexIndex : u32) -> VertexOutput {
2021
+ var output : VertexOutput;
2022
+ output.texCoord = pos[vertexIndex] * vec2<f32>(0.5, -0.5) + vec2<f32>(0.5);
2023
+ output.position = vec4<f32>(pos[vertexIndex], 0.0, 1.0);
2024
+ return output;
2025
+ }
2026
+
2027
+ @group(0) @binding(0) var imgSampler : sampler;
2028
+ @group(0) @binding(1) var img : texture_2d<f32>;
2029
+
2030
+ @fragment
2031
+ fn fragmentMain(@location(0) texCoord : vec2<f32>) -> @location(0) vec4<f32> {
2032
+ return textureSample(img, imgSampler, texCoord);
2033
+ }
2034
+ `
2035
+ )
2036
+ });
2037
+ }
2038
+ pipeline = this.device.createRenderPipeline({
2039
+ layout: "auto",
2040
+ vertex: {
2041
+ module: this.mipmapShaderModule,
2042
+ entryPoint: "vertexMain"
2043
+ },
2044
+ fragment: {
2045
+ module: this.mipmapShaderModule,
2046
+ entryPoint: "fragmentMain",
2047
+ targets: [{ format }]
2048
+ }
2049
+ });
2050
+ this.pipelines[format] = pipeline;
2051
+ }
2052
+ return pipeline;
2053
+ }
2054
+ /**
2055
+ * Generates mipmaps for the given GPUTexture from the data in level 0.
2056
+ * @param {module:External.GPUTexture} texture - Texture to generate mipmaps for.
2057
+ * @returns {module:External.GPUTexture} - The originally passed texture
2058
+ */
2059
+ generateMipmap(texture) {
2060
+ const pipeline = this._getMipmapPipeline(texture.format);
2061
+ if (texture.dimension === "3d" || texture.dimension === "1d") {
2062
+ throw new Error("Generating mipmaps for non-2d textures is currently unsupported!");
2063
+ }
2064
+ let mipTexture = texture;
2065
+ const arrayLayerCount = texture.depthOrArrayLayers || 1;
2066
+ const renderToSource = texture.usage & GPUTextureUsage.RENDER_ATTACHMENT;
2067
+ if (!renderToSource) {
2068
+ const mipTextureDescriptor = {
2069
+ size: {
2070
+ width: Math.ceil(texture.width / 2),
2071
+ height: Math.ceil(texture.height / 2),
2072
+ depthOrArrayLayers: arrayLayerCount
2073
+ },
2074
+ format: texture.format,
2075
+ usage: GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_SRC | GPUTextureUsage.RENDER_ATTACHMENT,
2076
+ mipLevelCount: texture.mipLevelCount - 1
2077
+ };
2078
+ mipTexture = this.device.createTexture(mipTextureDescriptor);
2079
+ }
2080
+ const commandEncoder = this.device.createCommandEncoder({});
2081
+ const bindGroupLayout = pipeline.getBindGroupLayout(0);
2082
+ for (let arrayLayer = 0; arrayLayer < arrayLayerCount; ++arrayLayer) {
2083
+ let srcView = texture.createView({
2084
+ baseMipLevel: 0,
2085
+ mipLevelCount: 1,
2086
+ dimension: "2d",
2087
+ baseArrayLayer: arrayLayer,
2088
+ arrayLayerCount: 1
2089
+ });
2090
+ let dstMipLevel = renderToSource ? 1 : 0;
2091
+ for (let i = 1; i < texture.mipLevelCount; ++i) {
2092
+ const dstView = mipTexture.createView({
2093
+ baseMipLevel: dstMipLevel++,
2094
+ mipLevelCount: 1,
2095
+ dimension: "2d",
2096
+ baseArrayLayer: arrayLayer,
2097
+ arrayLayerCount: 1
2098
+ });
2099
+ const passEncoder = commandEncoder.beginRenderPass({
2100
+ colorAttachments: [{
2101
+ view: dstView,
2102
+ storeOp: "store",
2103
+ loadOp: "clear",
2104
+ clearValue: { r: 0, g: 0, b: 0, a: 0 }
2105
+ }]
2106
+ });
2107
+ const bindGroup = this.device.createBindGroup({
2108
+ layout: bindGroupLayout,
2109
+ entries: [{
2110
+ binding: 0,
2111
+ resource: this.sampler
2112
+ }, {
2113
+ binding: 1,
2114
+ resource: srcView
2115
+ }]
2116
+ });
2117
+ passEncoder.setPipeline(pipeline);
2118
+ passEncoder.setBindGroup(0, bindGroup);
2119
+ passEncoder.draw(3, 1, 0, 0);
2120
+ passEncoder.end();
2121
+ srcView = dstView;
2122
+ }
2123
+ }
2124
+ if (!renderToSource) {
2125
+ const mipLevelSize = {
2126
+ width: Math.ceil(texture.width / 2),
2127
+ height: Math.ceil(texture.height / 2),
2128
+ depthOrArrayLayers: arrayLayerCount
2129
+ };
2130
+ for (let i = 1; i < texture.mipLevelCount; ++i) {
2131
+ commandEncoder.copyTextureToTexture({
2132
+ texture: mipTexture,
2133
+ mipLevel: i - 1
2134
+ }, {
2135
+ texture,
2136
+ mipLevel: i
2137
+ }, mipLevelSize);
2138
+ mipLevelSize.width = Math.ceil(mipLevelSize.width / 2);
2139
+ mipLevelSize.height = Math.ceil(mipLevelSize.height / 2);
2140
+ }
2141
+ }
2142
+ this.device.queue.submit([commandEncoder.finish()]);
2143
+ if (!renderToSource) {
2144
+ mipTexture.destroy();
2145
+ }
2146
+ return texture;
2147
+ }
2148
+ }
2149
+
2150
+
2151
+ //# sourceMappingURL=GpuMipmapGenerator.mjs.map
2152
+
2153
+ ;// ./node_modules/pixi.js/lib/rendering/renderers/gpu/texture/GpuTextureSystem.mjs
2154
+
2155
+
2156
+
2157
+
2158
+
2159
+
2160
+
2161
+
2162
+
2163
+
2164
+
2165
+ "use strict";
2166
+ class GpuTextureSystem {
2167
+ constructor(renderer) {
2168
+ this.managedTextures = [];
2169
+ this._gpuSources = /* @__PURE__ */ Object.create(null);
2170
+ this._gpuSamplers = /* @__PURE__ */ Object.create(null);
2171
+ this._bindGroupHash = /* @__PURE__ */ Object.create(null);
2172
+ this._textureViewHash = /* @__PURE__ */ Object.create(null);
2173
+ this._uploads = {
2174
+ image: gpuUploadImageResource,
2175
+ buffer: gpuUploadBufferImageResource,
2176
+ video: gpuUploadVideoResource,
2177
+ compressed: gpuUploadCompressedTextureResource
2178
+ };
2179
+ this._renderer = renderer;
2180
+ renderer.renderableGC.addManagedHash(this, "_gpuSources");
2181
+ renderer.renderableGC.addManagedHash(this, "_gpuSamplers");
2182
+ renderer.renderableGC.addManagedHash(this, "_bindGroupHash");
2183
+ renderer.renderableGC.addManagedHash(this, "_textureViewHash");
2184
+ }
2185
+ contextChange(gpu) {
2186
+ this._gpu = gpu;
2187
+ }
2188
+ initSource(source) {
2189
+ if (source.autoGenerateMipmaps) {
2190
+ const biggestDimension = Math.max(source.pixelWidth, source.pixelHeight);
2191
+ source.mipLevelCount = Math.floor(Math.log2(biggestDimension)) + 1;
2192
+ }
2193
+ let usage = GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST;
2194
+ if (source.uploadMethodId !== "compressed") {
2195
+ usage |= GPUTextureUsage.RENDER_ATTACHMENT;
2196
+ usage |= GPUTextureUsage.COPY_SRC;
2197
+ }
2198
+ const blockData = blockDataMap[source.format] || { blockBytes: 4, blockWidth: 1, blockHeight: 1 };
2199
+ const width = Math.ceil(source.pixelWidth / blockData.blockWidth) * blockData.blockWidth;
2200
+ const height = Math.ceil(source.pixelHeight / blockData.blockHeight) * blockData.blockHeight;
2201
+ const textureDescriptor = {
2202
+ label: source.label,
2203
+ size: { width, height },
2204
+ format: source.format,
2205
+ sampleCount: source.sampleCount,
2206
+ mipLevelCount: source.mipLevelCount,
2207
+ dimension: source.dimension,
2208
+ usage
2209
+ };
2210
+ const gpuTexture = this._gpu.device.createTexture(textureDescriptor);
2211
+ this._gpuSources[source.uid] = gpuTexture;
2212
+ if (!this.managedTextures.includes(source)) {
2213
+ source.on("update", this.onSourceUpdate, this);
2214
+ source.on("resize", this.onSourceResize, this);
2215
+ source.on("destroy", this.onSourceDestroy, this);
2216
+ source.on("unload", this.onSourceUnload, this);
2217
+ source.on("updateMipmaps", this.onUpdateMipmaps, this);
2218
+ this.managedTextures.push(source);
2219
+ }
2220
+ this.onSourceUpdate(source);
2221
+ return gpuTexture;
2222
+ }
2223
+ onSourceUpdate(source) {
2224
+ const gpuTexture = this.getGpuSource(source);
2225
+ if (!gpuTexture)
2226
+ return;
2227
+ if (this._uploads[source.uploadMethodId]) {
2228
+ this._uploads[source.uploadMethodId].upload(source, gpuTexture, this._gpu);
2229
+ }
2230
+ if (source.autoGenerateMipmaps && source.mipLevelCount > 1) {
2231
+ this.onUpdateMipmaps(source);
2232
+ }
2233
+ }
2234
+ onSourceUnload(source) {
2235
+ const gpuTexture = this._gpuSources[source.uid];
2236
+ if (gpuTexture) {
2237
+ this._gpuSources[source.uid] = null;
2238
+ gpuTexture.destroy();
2239
+ }
2240
+ }
2241
+ onUpdateMipmaps(source) {
2242
+ if (!this._mipmapGenerator) {
2243
+ this._mipmapGenerator = new GpuMipmapGenerator(this._gpu.device);
2244
+ }
2245
+ const gpuTexture = this.getGpuSource(source);
2246
+ this._mipmapGenerator.generateMipmap(gpuTexture);
2247
+ }
2248
+ onSourceDestroy(source) {
2249
+ source.off("update", this.onSourceUpdate, this);
2250
+ source.off("unload", this.onSourceUnload, this);
2251
+ source.off("destroy", this.onSourceDestroy, this);
2252
+ source.off("resize", this.onSourceResize, this);
2253
+ source.off("updateMipmaps", this.onUpdateMipmaps, this);
2254
+ this.managedTextures.splice(this.managedTextures.indexOf(source), 1);
2255
+ this.onSourceUnload(source);
2256
+ }
2257
+ onSourceResize(source) {
2258
+ const gpuTexture = this._gpuSources[source.uid];
2259
+ if (!gpuTexture) {
2260
+ this.initSource(source);
2261
+ } else if (gpuTexture.width !== source.pixelWidth || gpuTexture.height !== source.pixelHeight) {
2262
+ this._textureViewHash[source.uid] = null;
2263
+ this._bindGroupHash[source.uid] = null;
2264
+ this.onSourceUnload(source);
2265
+ this.initSource(source);
2266
+ }
2267
+ }
2268
+ _initSampler(sampler) {
2269
+ this._gpuSamplers[sampler._resourceId] = this._gpu.device.createSampler(sampler);
2270
+ return this._gpuSamplers[sampler._resourceId];
2271
+ }
2272
+ getGpuSampler(sampler) {
2273
+ return this._gpuSamplers[sampler._resourceId] || this._initSampler(sampler);
2274
+ }
2275
+ getGpuSource(source) {
2276
+ return this._gpuSources[source.uid] || this.initSource(source);
2277
+ }
2278
+ /**
2279
+ * this returns s bind group for a specific texture, the bind group contains
2280
+ * - the texture source
2281
+ * - the texture style
2282
+ * - the texture matrix
2283
+ * This is cached so the bind group should only be created once per texture
2284
+ * @param texture - the texture you want the bindgroup for
2285
+ * @returns the bind group for the texture
2286
+ */
2287
+ getTextureBindGroup(texture) {
2288
+ return this._bindGroupHash[texture.uid] ?? this._createTextureBindGroup(texture);
2289
+ }
2290
+ _createTextureBindGroup(texture) {
2291
+ const source = texture.source;
2292
+ this._bindGroupHash[texture.uid] = new BindGroup.BindGroup({
2293
+ 0: source,
2294
+ 1: source.style,
2295
+ 2: new UniformGroup.UniformGroup({
2296
+ uTextureMatrix: { type: "mat3x3<f32>", value: texture.textureMatrix.mapCoord }
2297
+ })
2298
+ });
2299
+ return this._bindGroupHash[texture.uid];
2300
+ }
2301
+ getTextureView(texture) {
2302
+ const source = texture.source;
2303
+ return this._textureViewHash[source.uid] ?? this._createTextureView(source);
2304
+ }
2305
+ _createTextureView(texture) {
2306
+ this._textureViewHash[texture.uid] = this.getGpuSource(texture).createView();
2307
+ return this._textureViewHash[texture.uid];
2308
+ }
2309
+ generateCanvas(texture) {
2310
+ const renderer = this._renderer;
2311
+ const commandEncoder = renderer.gpu.device.createCommandEncoder();
2312
+ const canvas = environment_adapter.DOMAdapter.get().createCanvas();
2313
+ canvas.width = texture.source.pixelWidth;
2314
+ canvas.height = texture.source.pixelHeight;
2315
+ const context = canvas.getContext("webgpu");
2316
+ context.configure({
2317
+ device: renderer.gpu.device,
2318
+ usage: GPUTextureUsage.COPY_DST | GPUTextureUsage.COPY_SRC,
2319
+ format: environment_adapter.DOMAdapter.get().getNavigator().gpu.getPreferredCanvasFormat(),
2320
+ alphaMode: "premultiplied"
2321
+ });
2322
+ commandEncoder.copyTextureToTexture({
2323
+ texture: renderer.texture.getGpuSource(texture.source),
2324
+ origin: {
2325
+ x: 0,
2326
+ y: 0
2327
+ }
2328
+ }, {
2329
+ texture: context.getCurrentTexture()
2330
+ }, {
2331
+ width: canvas.width,
2332
+ height: canvas.height
2333
+ });
2334
+ renderer.gpu.device.queue.submit([commandEncoder.finish()]);
2335
+ return canvas;
2336
+ }
2337
+ getPixels(texture) {
2338
+ const webGPUCanvas = this.generateCanvas(texture);
2339
+ const canvasAndContext = CanvasPool.CanvasPool.getOptimalCanvasAndContext(webGPUCanvas.width, webGPUCanvas.height);
2340
+ const context = canvasAndContext.context;
2341
+ context.drawImage(webGPUCanvas, 0, 0);
2342
+ const { width, height } = webGPUCanvas;
2343
+ const imageData = context.getImageData(0, 0, width, height);
2344
+ const pixels = new Uint8ClampedArray(imageData.data.buffer);
2345
+ CanvasPool.CanvasPool.returnCanvasAndContext(canvasAndContext);
2346
+ return { pixels, width, height };
2347
+ }
2348
+ destroy() {
2349
+ this.managedTextures.slice().forEach((source) => this.onSourceDestroy(source));
2350
+ this.managedTextures = null;
2351
+ for (const k of Object.keys(this._bindGroupHash)) {
2352
+ const key = Number(k);
2353
+ const bindGroup = this._bindGroupHash[key];
2354
+ bindGroup?.destroy();
2355
+ this._bindGroupHash[key] = null;
2356
+ }
2357
+ this._gpu = null;
2358
+ this._mipmapGenerator = null;
2359
+ this._gpuSources = null;
2360
+ this._bindGroupHash = null;
2361
+ this._textureViewHash = null;
2362
+ this._gpuSamplers = null;
2363
+ }
2364
+ }
2365
+ /** @ignore */
2366
+ GpuTextureSystem.extension = {
2367
+ type: [
2368
+ Extensions.ExtensionType.WebGPUSystem
2369
+ ],
2370
+ name: "texture"
2371
+ };
2372
+
2373
+
2374
+ //# sourceMappingURL=GpuTextureSystem.mjs.map
2375
+
2376
+ ;// ./node_modules/pixi.js/lib/rendering/renderers/gpu/WebGPURenderer.mjs
2377
+
2378
+
2379
+
2380
+
2381
+
2382
+
2383
+
2384
+
2385
+
2386
+
2387
+
2388
+
2389
+
2390
+
2391
+
2392
+
2393
+
2394
+
2395
+
2396
+
2397
+
2398
+ "use strict";
2399
+ const DefaultWebGPUSystems = [
2400
+ ...SharedSystems.SharedSystems,
2401
+ GpuUboSystem,
2402
+ GpuEncoderSystem,
2403
+ GpuDeviceSystem,
2404
+ GpuBufferSystem,
2405
+ GpuTextureSystem,
2406
+ GpuRenderTargetSystem,
2407
+ GpuShaderSystem,
2408
+ GpuStateSystem,
2409
+ PipelineSystem,
2410
+ GpuColorMaskSystem,
2411
+ GpuStencilSystem,
2412
+ BindGroupSystem
2413
+ ];
2414
+ const DefaultWebGPUPipes = [...SharedSystems.SharedRenderPipes, GpuUniformBatchPipe];
2415
+ const DefaultWebGPUAdapters = [GpuBatchAdaptor, GpuMeshAdapter, GpuGraphicsAdaptor];
2416
+ const systems = [];
2417
+ const renderPipes = [];
2418
+ const renderPipeAdaptors = [];
2419
+ Extensions.extensions.handleByNamedList(Extensions.ExtensionType.WebGPUSystem, systems);
2420
+ Extensions.extensions.handleByNamedList(Extensions.ExtensionType.WebGPUPipes, renderPipes);
2421
+ Extensions.extensions.handleByNamedList(Extensions.ExtensionType.WebGPUPipesAdaptor, renderPipeAdaptors);
2422
+ Extensions.extensions.add(...DefaultWebGPUSystems, ...DefaultWebGPUPipes, ...DefaultWebGPUAdapters);
2423
+ class WebGPURenderer extends AbstractRenderer.AbstractRenderer {
2424
+ constructor() {
2425
+ const systemConfig = {
2426
+ name: "webgpu",
2427
+ type: types.RendererType.WEBGPU,
2428
+ systems,
2429
+ renderPipes,
2430
+ renderPipeAdaptors
2431
+ };
2432
+ super(systemConfig);
2433
+ }
2434
+ }
2435
+
2436
+
2437
+ //# sourceMappingURL=WebGPURenderer.mjs.map
2438
+
2439
+
2440
+ /***/ }),
2441
+
2442
+ /***/ 7608:
2443
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
2444
+
2445
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2446
+ /* harmony export */ CanvasPool: () => (/* binding */ CanvasPool)
2447
+ /* harmony export */ });
2448
+ /* unused harmony export CanvasPoolClass */
2449
+ /* harmony import */ var _environment_adapter_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1761);
2450
+ /* harmony import */ var _maths_misc_pow2_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(9939);
2451
+
2452
+
2453
+
2454
+ "use strict";
2455
+ class CanvasPoolClass {
2456
+ constructor(canvasOptions) {
2457
+ this._canvasPool = /* @__PURE__ */ Object.create(null);
2458
+ this.canvasOptions = canvasOptions || {};
2459
+ this.enableFullScreen = false;
2460
+ }
2461
+ /**
2462
+ * Creates texture with params that were specified in pool constructor.
2463
+ * @param pixelWidth - Width of texture in pixels.
2464
+ * @param pixelHeight - Height of texture in pixels.
2465
+ */
2466
+ _createCanvasAndContext(pixelWidth, pixelHeight) {
2467
+ const canvas = _environment_adapter_mjs__WEBPACK_IMPORTED_MODULE_0__.DOMAdapter.get().createCanvas();
2468
+ canvas.width = pixelWidth;
2469
+ canvas.height = pixelHeight;
2470
+ const context = canvas.getContext("2d");
2471
+ return { canvas, context };
2472
+ }
2473
+ /**
2474
+ * Gets a Power-of-Two render texture or fullScreen texture
2475
+ * @param minWidth - The minimum width of the render texture.
2476
+ * @param minHeight - The minimum height of the render texture.
2477
+ * @param resolution - The resolution of the render texture.
2478
+ * @returns The new render texture.
2479
+ */
2480
+ getOptimalCanvasAndContext(minWidth, minHeight, resolution = 1) {
2481
+ minWidth = Math.ceil(minWidth * resolution - 1e-6);
2482
+ minHeight = Math.ceil(minHeight * resolution - 1e-6);
2483
+ minWidth = (0,_maths_misc_pow2_mjs__WEBPACK_IMPORTED_MODULE_1__.nextPow2)(minWidth);
2484
+ minHeight = (0,_maths_misc_pow2_mjs__WEBPACK_IMPORTED_MODULE_1__.nextPow2)(minHeight);
2485
+ const key = (minWidth << 17) + (minHeight << 1);
2486
+ if (!this._canvasPool[key]) {
2487
+ this._canvasPool[key] = [];
2488
+ }
2489
+ let canvasAndContext = this._canvasPool[key].pop();
2490
+ if (!canvasAndContext) {
2491
+ canvasAndContext = this._createCanvasAndContext(minWidth, minHeight);
2492
+ }
2493
+ return canvasAndContext;
2494
+ }
2495
+ /**
2496
+ * Place a render texture back into the pool.
2497
+ * @param canvasAndContext
2498
+ */
2499
+ returnCanvasAndContext(canvasAndContext) {
2500
+ const canvas = canvasAndContext.canvas;
2501
+ const { width, height } = canvas;
2502
+ const key = (width << 17) + (height << 1);
2503
+ canvasAndContext.context.clearRect(0, 0, width, height);
2504
+ this._canvasPool[key].push(canvasAndContext);
2505
+ }
2506
+ clear() {
2507
+ this._canvasPool = {};
2508
+ }
2509
+ }
2510
+ const CanvasPool = new CanvasPoolClass();
2511
+
2512
+
2513
+ //# sourceMappingURL=CanvasPool.mjs.map
2514
+
2515
+
2516
+ /***/ })
2517
+
2518
+ };