@carbonenginejs/runtime 0.1.0-alpha.6 → 0.1.0-alpha.7
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.
Potentially problematic release.
This version of @carbonenginejs/runtime might be problematic. Click here for more details.
- package/dist/global/consts/effectPaths.js +4 -1
- package/dist/global/consts/effectPaths.js.map +1 -1
- package/dist/global/consts/index.js +1 -1
- package/dist/global/index.js +1 -1
- package/dist/index.js +3 -3
- package/dist/resource/format/carbonEffect/carbonEffectBackendBlock.js +19 -2
- package/dist/resource/format/carbonEffect/carbonEffectBackendBlock.js.map +1 -1
- package/dist/resource/format/index.js +1 -1
- package/dist/resource/formats/hlsl/core/carbonTypedViews.js +121 -65
- package/dist/resource/formats/hlsl/core/carbonTypedViews.js.map +1 -1
- package/dist/resource/formats/webgl/core/glsl/DxbcGlslEmitter.js +10 -7
- package/dist/resource/formats/webgl/core/glsl/DxbcGlslEmitter.js.map +1 -1
- package/dist/resource/formats/webgpu/core/effectBackendBodySet.js +3 -1
- package/dist/resource/formats/webgpu/core/effectBackendBodySet.js.map +1 -1
- package/dist/resource/formats/webgpu/core/packageEffect.js +5 -0
- package/dist/resource/formats/webgpu/core/packageEffect.js.map +1 -1
- package/dist/resource/formats/webgpu/core/wgsl/emitWgsl.js +20 -0
- package/dist/resource/formats/webgpu/core/wgsl/emitWgsl.js.map +1 -1
- package/dist/resource/formats/webgpu/core/wgsl/emulatedAddressing.js +93 -4
- package/dist/resource/formats/webgpu/core/wgsl/emulatedAddressing.js.map +1 -1
- package/dist/resource/formats/webgpu/core/wgsl/lowerBindingLayout.js +74 -64
- package/dist/resource/formats/webgpu/core/wgsl/lowerBindingLayout.js.map +1 -1
- package/dist/resource/formats/webgpu/core/wgsl/lowerFragmentProgram.js +16 -7
- package/dist/resource/formats/webgpu/core/wgsl/lowerFragmentProgram.js.map +1 -1
- package/dist/resource/formats/webgpu/core/wgsl/wgslTypedViews.js +69 -27
- package/dist/resource/formats/webgpu/core/wgsl/wgslTypedViews.js.map +1 -1
- package/dist/resource/geometry/registerGeometryResources.js +10 -1
- package/dist/resource/geometry/registerGeometryResources.js.map +1 -1
- package/dist/sof/EveSOFDNA.js +4 -2
- package/dist/sof/EveSOFDNA.js.map +1 -1
- package/dist/sof/EveSOFDataMgr.js +83 -69
- package/dist/sof/EveSOFDataMgr.js.map +1 -1
- package/dist/trinity/core/Tr2Denoiser.js +6 -1
- package/dist/trinity/core/Tr2Denoiser.js.map +1 -1
- package/dist/trinity/core/Tr2ShadowMap.js +7 -2
- package/dist/trinity/core/Tr2ShadowMap.js.map +1 -1
- package/dist/trinity/core/context/Tr2RenderContext.js +43 -0
- package/dist/trinity/core/context/Tr2RenderContext.js.map +1 -1
- package/dist/trinity/core/device/Tr2GpuStructuredBuffer.js +134 -0
- package/dist/trinity/core/device/Tr2GpuStructuredBuffer.js.map +1 -0
- package/dist/trinity/core/index.js +1 -0
- package/dist/trinity/core/index.js.map +1 -1
- package/dist/trinity/core/lighting/Tr2LightManager.js +410 -124
- package/dist/trinity/core/lighting/Tr2LightManager.js.map +1 -1
- package/dist/trinity/eve/effect/lensflare/EveLensflare.js +303 -312
- package/dist/trinity/eve/effect/lensflare/EveLensflare.js.map +1 -1
- package/dist/trinity/eve/effect/lensflare/EveOccluder.js +117 -0
- package/dist/trinity/eve/effect/lensflare/EveOccluder.js.map +1 -0
- package/dist/trinity/eve/index.js +1 -0
- package/dist/trinity/eve/index.js.map +1 -1
- package/dist/trinity/eve/scene/EveSpaceScene.js +286 -6
- package/dist/trinity/eve/scene/EveSpaceScene.js.map +1 -1
- package/dist/trinity/eve/scene/EveSpaceSceneRenderDriver.js +212 -32
- package/dist/trinity/eve/scene/EveSpaceSceneRenderDriver.js.map +1 -1
- package/dist/trinity/generated/eve/effect/index.js +0 -1
- package/dist/trinity/generated/eve/effect/index.js.map +1 -1
- package/dist/trinity/generated/eve/index.js +0 -1
- package/dist/trinity/generated/eve/index.js.map +1 -1
- package/dist/trinity/generated/index.js +0 -2
- package/dist/trinity/generated/index.js.map +1 -1
- package/dist/trinity/generated/trinityCore/index.js +0 -1
- package/dist/trinity/generated/trinityCore/index.js.map +1 -1
- package/dist/trinity/index.js +2 -2
- package/dist/trinity/postProcess/Tr2PostProcessRenderer.js +4 -1
- package/dist/trinity/postProcess/Tr2PostProcessRenderer.js.map +1 -1
- package/dist/trinity/postProcess/Tr2SSAO.js +282 -21
- package/dist/trinity/postProcess/Tr2SSAO.js.map +1 -1
- package/dist/trinity/shader/parameter/Tr2RuntimeTextureParameter.js +71 -53
- package/dist/trinity/shader/parameter/Tr2RuntimeTextureParameter.js.map +1 -1
- package/dist/trinityal/webgpu/CjsWebgpuRenderContextAL.js +81 -18
- package/dist/trinityal/webgpu/CjsWebgpuRenderContextAL.js.map +1 -1
- package/dist/trinityal/webgpu/CjsWebgpuResourceSetAL.js +46 -4
- package/dist/trinityal/webgpu/CjsWebgpuResourceSetAL.js.map +1 -1
- package/dist/trinityal/webgpu/CjsWebgpuShaderAL.js +32 -1
- package/dist/trinityal/webgpu/CjsWebgpuShaderAL.js.map +1 -1
- package/dist/trinityal/webgpu/CjsWebgpuShaderProgramAL.js +27 -0
- package/dist/trinityal/webgpu/CjsWebgpuShaderProgramAL.js.map +1 -1
- package/dist/trinityal/webgpu/CjsWebgpuTextureAL.js +29 -4
- package/dist/trinityal/webgpu/CjsWebgpuTextureAL.js.map +1 -1
- package/dist/trinityal/webgpu/core/CjsWebgpuPsoDescription.js +32 -2
- package/dist/trinityal/webgpu/core/CjsWebgpuPsoDescription.js.map +1 -1
- package/dist/trinityal/webgpu/core/CjsWebgpuUtils.js +57 -5
- package/dist/trinityal/webgpu/core/CjsWebgpuUtils.js.map +1 -1
- package/dist/trinityal/webgpu/core/CjsWebgpuWorkQueue.js +111 -5
- package/dist/trinityal/webgpu/core/CjsWebgpuWorkQueue.js.map +1 -1
- package/docs/trinity/reference/classes/generated.md +20 -20
- package/docs/trinity/reference/classes/post-process.md +1 -1
- package/package.json +1 -1
- package/dist/trinity/generated/eve/effect/EveOccluder.js +0 -38
- package/dist/trinity/generated/eve/effect/EveOccluder.js.map +0 -1
- package/dist/trinity/generated/trinityCore/Tr2GpuStructuredBuffer.js +0 -48
- package/dist/trinity/generated/trinityCore/Tr2GpuStructuredBuffer.js.map +0 -1
|
@@ -79,6 +79,12 @@ class CjsWebgpuWorkQueue {
|
|
|
79
79
|
/** m_pendingRenderPassHint / m_hasPendingRenderPassHint */
|
|
80
80
|
_pendingRenderPassHint = null;
|
|
81
81
|
|
|
82
|
+
/**
|
|
83
|
+
* m_pendingClear, with the clear actions Metal writes into its pass
|
|
84
|
+
* descriptor (`ClearAttachment`), in the hint's `{ colors, depth }` form.
|
|
85
|
+
*/
|
|
86
|
+
_pendingClear = null;
|
|
87
|
+
|
|
82
88
|
/** Transitions since the last drain, in order. */
|
|
83
89
|
_events = [];
|
|
84
90
|
|
|
@@ -125,6 +131,7 @@ class CjsWebgpuWorkQueue {
|
|
|
125
131
|
if (this._inFrame) fail("BeginFrame without EndFrame");
|
|
126
132
|
this._inFrame = true;
|
|
127
133
|
this._passCount = 0;
|
|
134
|
+
this._pendingClear = null;
|
|
128
135
|
// Nothing named last frame is wanted this frame until a verb names it.
|
|
129
136
|
this._pending = {
|
|
130
137
|
pipeline: null,
|
|
@@ -146,7 +153,7 @@ class CjsWebgpuWorkQueue {
|
|
|
146
153
|
*/
|
|
147
154
|
EndFrame() {
|
|
148
155
|
if (!this._inFrame) fail("EndFrame without BeginFrame");
|
|
149
|
-
if (this._pendingRenderPassHint) this._GetRenderEncoder();
|
|
156
|
+
if (this._pendingRenderPassHint || this._pendingClear) this._GetRenderEncoder();
|
|
150
157
|
this._ReleaseEncoder();
|
|
151
158
|
this._inFrame = false;
|
|
152
159
|
this._events.push({
|
|
@@ -187,11 +194,51 @@ class CjsWebgpuWorkQueue {
|
|
|
187
194
|
* @returns {object[]} The transitions this required.
|
|
188
195
|
*/
|
|
189
196
|
EndRenderPassHint() {
|
|
190
|
-
if (this._pendingRenderPassHint) this._GetRenderEncoder();
|
|
197
|
+
if (this._pendingRenderPassHint || this._pendingClear) this._GetRenderEncoder();
|
|
191
198
|
this._ReleaseEncoder();
|
|
192
199
|
return this._Drain();
|
|
193
200
|
}
|
|
194
201
|
|
|
202
|
+
/**
|
|
203
|
+
* Carbon's `ClearAttachment` (`MetalWorkQueue.mm:2845-2881`): the clear
|
|
204
|
+
* goes on the attachments bound NOW, as the load actions of the next pass
|
|
205
|
+
* over them. Ignored while a hint is pending, whose actions govern that
|
|
206
|
+
* pass; any open encoder is ended first, so the clear starts a pass.
|
|
207
|
+
*
|
|
208
|
+
* Changing an attachment runs a pending clear before the change
|
|
209
|
+
* (`_FlushOutstandingOperations`), so a clear never lands on the targets
|
|
210
|
+
* bound after it: that is the difference from a hint.
|
|
211
|
+
*
|
|
212
|
+
* @param {object[]} colors `Tr2ColorAttachment`s for the bound slots, in order.
|
|
213
|
+
* @param {object|null} depth A `Tr2DepthAttachment`, or null.
|
|
214
|
+
* @returns {object[]} The transitions this required.
|
|
215
|
+
*/
|
|
216
|
+
ClearAttachment(colors, depth = null) {
|
|
217
|
+
if (this._pendingRenderPassHint) return this._Drain();
|
|
218
|
+
this._FlushOutstandingOperations();
|
|
219
|
+
this._pendingClear = {
|
|
220
|
+
colors,
|
|
221
|
+
depth
|
|
222
|
+
};
|
|
223
|
+
return this._Drain();
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Carbon's `FlushOutstandingOperations` (`MetalWorkQueue.mm:380-405`):
|
|
228
|
+
* ends the open encoder, then runs a pending clear in a pass of its own
|
|
229
|
+
* over the current attachments. A pending hint is set aside for that pass
|
|
230
|
+
* and stays pending, as Metal backs it up and restores it.
|
|
231
|
+
*/
|
|
232
|
+
_FlushOutstandingOperations() {
|
|
233
|
+
this._ReleaseEncoder();
|
|
234
|
+
if (!this._pendingClear || !this._inFrame) return;
|
|
235
|
+
const hint = this._pendingRenderPassHint;
|
|
236
|
+
this._pendingRenderPassHint = null;
|
|
237
|
+
this._GetRenderEncoder();
|
|
238
|
+
this._ReleaseEncoder();
|
|
239
|
+
this._pendingRenderPassHint = hint;
|
|
240
|
+
}
|
|
241
|
+
|
|
195
242
|
/** Carbon's `EndCurrentRenderPass`. @returns {object[]} The transitions. */
|
|
196
243
|
EndCurrentRenderPass() {
|
|
197
244
|
if (this._currentEncoderType === EncoderType.RENDER) this._ReleaseEncoder();
|
|
@@ -418,7 +465,7 @@ class CjsWebgpuWorkQueue {
|
|
|
418
465
|
if (!Number.isInteger(index) || index < 0) fail("a render attachment needs a slot index");
|
|
419
466
|
const current = this._colorAttachments[index] ?? null;
|
|
420
467
|
if (current?.texture === (texture ?? null)) return this._Drain();
|
|
421
|
-
this.
|
|
468
|
+
this._FlushOutstandingOperations();
|
|
422
469
|
this._colorAttachments[index] = texture ? {
|
|
423
470
|
texture,
|
|
424
471
|
slice,
|
|
@@ -436,7 +483,7 @@ class CjsWebgpuWorkQueue {
|
|
|
436
483
|
*/
|
|
437
484
|
SetDepthAttachment(texture) {
|
|
438
485
|
if (this._depthAttachment?.texture === (texture ?? null)) return this._Drain();
|
|
439
|
-
this.
|
|
486
|
+
this._FlushOutstandingOperations();
|
|
440
487
|
this._depthAttachment = texture ? {
|
|
441
488
|
texture,
|
|
442
489
|
loadOp: "load",
|
|
@@ -520,6 +567,34 @@ class CjsWebgpuWorkQueue {
|
|
|
520
567
|
bindGroups: []
|
|
521
568
|
};
|
|
522
569
|
|
|
570
|
+
/**
|
|
571
|
+
* m_viewport, null until one is set (m_validViewport). It outlives passes
|
|
572
|
+
* and frames, as Metal's does, and every new encoder applies it again.
|
|
573
|
+
*/
|
|
574
|
+
_viewport = null;
|
|
575
|
+
|
|
576
|
+
/**
|
|
577
|
+
* Metal's `SetViewport` (`MetalWorkQueue.mm:2166-2171`): held until the next
|
|
578
|
+
* draw, like the bindings above.
|
|
579
|
+
*
|
|
580
|
+
* @param {number} originX Left edge, in pixels.
|
|
581
|
+
* @param {number} originY Top edge, in pixels.
|
|
582
|
+
* @param {number} width Width, in pixels.
|
|
583
|
+
* @param {number} height Height, in pixels.
|
|
584
|
+
* @param {number} znear Depth the near plane maps to.
|
|
585
|
+
* @param {number} zfar Depth the far plane maps to.
|
|
586
|
+
*/
|
|
587
|
+
SetViewport(originX, originY, width, height, znear, zfar) {
|
|
588
|
+
this._viewport = {
|
|
589
|
+
originX,
|
|
590
|
+
originY,
|
|
591
|
+
width,
|
|
592
|
+
height,
|
|
593
|
+
znear,
|
|
594
|
+
zfar
|
|
595
|
+
};
|
|
596
|
+
}
|
|
597
|
+
|
|
523
598
|
/**
|
|
524
599
|
* Names the bind group for one group index.
|
|
525
600
|
*
|
|
@@ -580,6 +655,10 @@ class CjsWebgpuWorkQueue {
|
|
|
580
655
|
pass.setPipeline(want.pipeline);
|
|
581
656
|
live.pipeline = want.pipeline;
|
|
582
657
|
}
|
|
658
|
+
if (this._viewport && live.viewport !== this._viewport) {
|
|
659
|
+
this._EmitViewport(pass, this._viewport);
|
|
660
|
+
live.viewport = this._viewport;
|
|
661
|
+
}
|
|
583
662
|
want.bindGroups.forEach((entry, index) => {
|
|
584
663
|
if (!entry) return;
|
|
585
664
|
const bound = live.bindGroups[index];
|
|
@@ -606,6 +685,28 @@ class CjsWebgpuWorkQueue {
|
|
|
606
685
|
live.indexBuffer = entry;
|
|
607
686
|
}
|
|
608
687
|
|
|
688
|
+
/**
|
|
689
|
+
* Applies a viewport to the open pass (`MetalWorkQueue.mm:1786-1795`).
|
|
690
|
+
*
|
|
691
|
+
* WebGPU refuses a viewport reaching outside the attachments, where D3D11
|
|
692
|
+
* and Metal clip to them, so it is cut to the attachment rectangle first. A
|
|
693
|
+
* viewport that only fits a previous, larger target is thereby rescaled
|
|
694
|
+
* rather than clipped; one inside the attachments is unchanged.
|
|
695
|
+
*
|
|
696
|
+
* @param {object} pass The open `GPURenderPassEncoder`.
|
|
697
|
+
* @param {object} viewport The held viewport.
|
|
698
|
+
*/
|
|
699
|
+
_EmitViewport(pass, viewport) {
|
|
700
|
+
const attachment = this._colorAttachments.find(Boolean) ?? this._depthAttachment;
|
|
701
|
+
const width = attachment ? attachment.texture.GetWidth() : Infinity;
|
|
702
|
+
const height = attachment ? attachment.texture.GetHeight() : Infinity;
|
|
703
|
+
const x = Math.min(Math.max(viewport.originX, 0), width);
|
|
704
|
+
const y = Math.min(Math.max(viewport.originY, 0), height);
|
|
705
|
+
const minDepth = Math.min(Math.max(viewport.znear, 0), 1);
|
|
706
|
+
const maxDepth = Math.min(Math.max(viewport.zfar, minDepth), 1);
|
|
707
|
+
pass.setViewport(x, y, Math.max(Math.min(viewport.originX + viewport.width, width) - x, 0), Math.max(Math.min(viewport.originY + viewport.height, height) - y, 0), minDepth, maxDepth);
|
|
708
|
+
}
|
|
709
|
+
|
|
609
710
|
/**
|
|
610
711
|
* Records a non-indexed draw, opening a render encoder if none is current.
|
|
611
712
|
*
|
|
@@ -737,9 +838,14 @@ class CjsWebgpuWorkQueue {
|
|
|
737
838
|
/** Opens a render encoder, folding any pending hint into its descriptor. */
|
|
738
839
|
_GetRenderEncoder() {
|
|
739
840
|
this._ReleaseEncoder();
|
|
740
|
-
|
|
841
|
+
|
|
842
|
+
// A hint's actions win over a pending clear's, as Metal applies the hint
|
|
843
|
+
// over a descriptor already holding the clear; opening the pass consumes
|
|
844
|
+
// both (`ApplyRenderPassHint`, then `ResetClearState`).
|
|
845
|
+
const hint = this._pendingRenderPassHint ?? this._pendingClear;
|
|
741
846
|
const attachments = ApplyRenderPassHint(hint);
|
|
742
847
|
this._pendingRenderPassHint = null;
|
|
848
|
+
this._pendingClear = null;
|
|
743
849
|
this._passCount += 1;
|
|
744
850
|
this._currentEncoderType = EncoderType.RENDER;
|
|
745
851
|
this._events.push({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CjsWebgpuWorkQueue.js","sources":["../../../../../src/trinityal/webgpu/core/CjsWebgpuWorkQueue.js"],"sourcesContent":["// Source: trinity/trinityal/metal/MetalWorkQueue.h\n// Source: trinity/trinityal/metal/MetalWorkQueue.mm\n//\n// MODELLED ON `MetalWorkQueue`, NOT A REPLICA OF IT - which is what the\n// `modelledOn` declaration below says, and why the parity check does not hold\n// this class to that class's surface. Metal's work queue declares 113 methods\n// to this file's 27, because it is the whole command recorder; comparing them\n// would report 101 absences as debt when the surface simply lives elsewhere\n// here.\n//\n// What this file took, and where the rest of Metal's work queue went:\n//\n// ENCODER LIFETIME -> here. BeginFrame/EndFrame, SetCurrentEncoder,\n// GetRenderEncoder/ReleaseEncoder, the pass\n// hint and its attachments, the pending\n// bindings a draw needs.\n// Blend, depth, stencil, cull, -> the PIPELINE. WebGPU has no per-state\n// fill, sample state setter; `Tr2RenderStateSetup.GetWebgpuRecipe`\n// projects the authored setup and\n// `CjsWebgpuPsoDescription` resolves it once.\n// SetTextures/SetSamplers/ -> `CjsWebgpuResourceSetAL` and the bind\n// SetBuffers/SetConstants groups the render context assembles.\n// Draw*/Dispatch* -> `CjsWebgpuRenderContextAL`'s draw verbs.\n// Blit, mipmaps, MSAA resolve, -> not ported, each recorded where it refuses.\n// visibility queries, parallel\n// encoding, the drawable blit\n//\n// The encoder the backend is currently writing into, and when it has to change.\n//\n// THIS IS A PORT, NOT A DESIGN. Carbon's command-encoder backend splits into a\n// render context that answers the abstraction layer's verbs and a WORK QUEUE\n// that owns the command buffer and the encoder lifetime - `Tr2RenderContextAL`\n// holds `m_workQueue` (`Tr2RenderContextMetal.h:299`). WebGPU has the same\n// shape as Metal: one command encoder per frame, render passes with fixed\n// attachments, and compute and copies that may not happen inside one. So this\n// carries Carbon's name and Carbon's responsibilities rather than a new noun.\n//\n// It replaces `framePlan.js`, which looks AHEAD over a recorded intent stream.\n// That look-ahead exists only because the planner is not the thing issuing the\n// calls - it reads them afterwards. A work queue is called verb by verb, in\n// order, so every decision is about the call in hand. Metal's\n// `SetCurrentEncoder` (`MetalWorkQueue.mm:840-900`) is lazy for that reason and\n// has no look-ahead anywhere.\n//\n// NOT PORTED, deliberately: the blit and acceleration-structure encoders, the\n// parallel render encoder, and the drawable blit. WebGPU takes copies on the\n// command encoder directly rather than through a blit encoder, it has no\n// parallel encoder, and ray tracing is absent from this backend as it is from\n// Carbon's stub. `MTLENCODERTYPE_BLIT` therefore has no counterpart here and\n// transfers are recorded against the command encoder itself.\n\nimport { CjsSchema } from \"#schema\";\nimport { Tr2LoadAction, Tr2StoreAction } from \"#consts/render-context\";\n\n\nfunction fail(message)\n{\n const error = new Error(`CjsWebgpuWorkQueue: ${message}`);\n error.code = \"CJS_WEBGPU_WORK_QUEUE_INVALID\";\n throw error;\n}\n\n\n/** Carbon's `MetalEncoderType`, less the encoders WebGPU does not have. */\nexport const EncoderType = Object.freeze({\n NONE: \"none\",\n RENDER: \"render\",\n COMPUTE: \"compute\"\n});\n\n\n/**\n * Owns the encoder lifetime for one frame, as Carbon's `MetalWorkQueue` does.\n *\n * DEVICE-FREE, for the reason Carbon's stub backend is: the rules are the part\n * worth testing, and they need no GPU. A caller applies the transitions this\n * reports to a real command encoder.\n */\nexport class CjsWebgpuWorkQueue\n{\n /** m_currentEncoderType */\n _currentEncoderType = EncoderType.NONE;\n\n /** m_pendingRenderPassHint / m_hasPendingRenderPassHint */\n _pendingRenderPassHint = null;\n\n /** Transitions since the last drain, in order. */\n _events = [];\n\n /** Render passes begun this frame. */\n _passCount = 0;\n\n /** Whether BeginFrame has run without a matching EndFrame. */\n _inFrame = false;\n\n /** m_currentRenderPassDescriptor.colorAttachments */\n _colorAttachments = [];\n\n /** m_currentRenderPassDescriptor.depthAttachment */\n _depthAttachment = null;\n\n /**\n * The encoder currently open.\n *\n * @returns {string} An `EncoderType`.\n */\n GetCurrentEncoderType()\n {\n return this._currentEncoderType;\n }\n\n /** Render passes begun this frame. @returns {number} */\n GetPassCount()\n {\n return this._passCount;\n }\n\n /** Whether a hint is waiting to be folded in. @returns {boolean} */\n HasPendingRenderPassHint()\n {\n return this._pendingRenderPassHint !== null;\n }\n\n /**\n * Opens the frame's command buffer. Carbon's `BeginFrame`.\n *\n * Returns its transitions like every other verb here, so a caller drains one\n * list per call and never carries events into the next one.\n *\n * @returns {object[]} The transitions this required.\n */\n BeginFrame()\n {\n if (this._inFrame) fail(\"BeginFrame without EndFrame\");\n\n this._inFrame = true;\n this._passCount = 0;\n // Nothing named last frame is wanted this frame until a verb names it.\n this._pending = { pipeline: null, vertexBuffers: [], indexBuffer: null, bindGroups: [] };\n this._events.push({ type: \"begin-frame\" });\n\n return this._Drain();\n }\n\n /**\n * Closes any encoder and commits. Carbon's `EndFrame` plus\n * `CommitCommandBuffer`.\n *\n * @returns {object[]} The transitions this required, in order.\n */\n EndFrame()\n {\n if (!this._inFrame) fail(\"EndFrame without BeginFrame\");\n\n if (this._pendingRenderPassHint) this._GetRenderEncoder();\n\n this._ReleaseEncoder();\n this._inFrame = false;\n this._events.push({ type: \"commit\" });\n\n return this._Drain();\n }\n\n /**\n * Declares what the next render pass does with its attachments.\n *\n * A SECOND HINT WHILE ONE IS PENDING OPENS AND IMMEDIATELY RELEASES A RENDER\n * ENCODER (`MetalWorkQueue.mm:3282-3291`). The first hint described a pass\n * that must still happen - its load and store actions are the point even when\n * nothing drew into it - so discarding it would lose a clear.\n *\n * @param {object[]} colors `Tr2ColorAttachment`s, in slot order.\n * @param {object} [depth] A `Tr2DepthAttachment`.\n */\n RenderPassHint(colors, depth = null)\n {\n if (!Array.isArray(colors)) fail(\"RenderPassHint takes an array of colour attachments\");\n\n if (this._pendingRenderPassHint)\n {\n this._GetRenderEncoder();\n this._ReleaseEncoder();\n }\n\n this._pendingRenderPassHint = { colors, depth };\n }\n\n /**\n * Ends the declared pass, so following work opens a new one.\n *\n * Carbon flushes rather than discards, for the reason above\n * (`MetalWorkQueue.mm:3293-3300`).\n *\n * @returns {object[]} The transitions this required.\n */\n EndRenderPassHint()\n {\n if (this._pendingRenderPassHint) this._GetRenderEncoder();\n\n this._ReleaseEncoder();\n\n return this._Drain();\n }\n\n /** Carbon's `EndCurrentRenderPass`. @returns {object[]} The transitions. */\n EndCurrentRenderPass()\n {\n if (this._currentEncoderType === EncoderType.RENDER) this._ReleaseEncoder();\n\n return this._Drain();\n }\n\n /**\n * Makes an encoder of the given type current, as `SetCurrentEncoder` does.\n *\n * @param {string} encoderType An `EncoderType` other than NONE.\n * @returns {object[]} The transitions this required, in order.\n */\n SetCurrentEncoder(encoderType)\n {\n if (!this._inFrame) fail(\"SetCurrentEncoder outside a frame\");\n if (encoderType === EncoderType.NONE) fail(\"SetCurrentEncoder needs a real encoder type\");\n\n // Carbon flushes a pending hint before any NON-render encoder, because the\n // declared pass must happen before the work that follows it\n // (`MetalWorkQueue.mm:851-855`).\n if (encoderType !== EncoderType.RENDER && this._pendingRenderPassHint)\n {\n this._GetRenderEncoder();\n this._ReleaseEncoder();\n }\n\n if (this._currentEncoderType === encoderType)\n {\n // A pending hint describes the NEXT pass, so an open render encoder is\n // still the wrong one to keep drawing into.\n if (encoderType !== EncoderType.RENDER || !this._pendingRenderPassHint) return this._Drain();\n }\n\n if (encoderType === EncoderType.RENDER)\n {\n this._GetRenderEncoder();\n\n return this._Drain();\n }\n\n this._ReleaseEncoder();\n this._currentEncoderType = encoderType;\n this._events.push({ type: \"open\", encoderType });\n\n // Metal's compute encoder (`MetalWorkQueue.mm` GetComputeEncoder): a\n // compute pass on the frame's command encoder, starting with nothing bound.\n if (encoderType === EncoderType.COMPUTE && this._commandEncoder)\n {\n this._computePass = this._commandEncoder.beginComputePass({ label: \"Tr2RenderContextAL compute\" });\n this._encoderState = { pipeline: null, vertexBuffers: [], indexBuffer: null, bindGroups: [] };\n }\n\n return this._Drain();\n }\n\n /** The open compute pass, or null. */\n _computePass = null;\n\n /**\n * Regenerates a texture's mip chain, as Metal's work queue does on a blit\n * encoder: the open pass ends first, so the chain is encoded in order with\n * the work around it.\n *\n * @param {GPUTexture} texture The texture.\n * @param {CjsWebgpuMipGenerator} generator The context's generator.\n * @returns {object[]} The transitions this required.\n */\n GenerateMipMaps(texture, generator)\n {\n if (!this._inFrame) fail(\"GenerateMipMaps outside a frame\");\n\n this._ReleaseEncoder();\n this._events.push({ type: \"generate-mips\" });\n\n if (this._commandEncoder) generator.Encode(this._commandEncoder, texture);\n\n return this._Drain();\n }\n\n /**\n * Copies one texture subresource region into another: Metal's\n * `MetalWorkQueue::CopyTextureToTexture` (`MetalWorkQueue.mm:1381-1405`),\n * which records a blit and releases the encoder. WebGPU copies on the\n * command encoder itself, so the open pass is released first, as\n * `GenerateMipMaps` does.\n *\n * @param {GPUTexture} source The texture to read.\n * @param {number} sourceSlice The source array layer.\n * @param {number} sourceMip The source mip level.\n * @param {{x: number, y: number, z: number}} sourceOrigin The source origin.\n * @param {{width: number, height: number, depthOrArrayLayers: number}} size The copy size.\n * @param {GPUTexture} destination The texture to write.\n * @param {number} destinationSlice The destination array layer.\n * @param {number} destinationMip The destination mip level.\n * @param {{x: number, y: number, z: number}} destinationOrigin The destination origin.\n * @returns {object[]} The transitions this required.\n */\n CopyTextureToTexture(source, sourceSlice, sourceMip, sourceOrigin, size, destination, destinationSlice, destinationMip, destinationOrigin)\n {\n if (!this._inFrame) fail(\"CopyTextureToTexture outside a frame\");\n\n this._ReleaseEncoder();\n this._events.push({ type: \"copy-texture\" });\n\n if (this._commandEncoder)\n {\n this._commandEncoder.copyTextureToTexture(\n { texture: source, mipLevel: sourceMip, origin: { x: sourceOrigin.x, y: sourceOrigin.y, z: sourceOrigin.z + sourceSlice } },\n { texture: destination, mipLevel: destinationMip, origin: { x: destinationOrigin.x, y: destinationOrigin.y, z: destinationOrigin.z + destinationSlice } },\n size\n );\n }\n\n return this._Drain();\n }\n\n /**\n * Fills a buffer with zeros: the fast path of Metal's\n * `MetalWorkQueue::ClearBuffer` (`MetalWorkQueue.mm:1216-1225`), a blit\n * `fillBuffer` that then releases the encoder. WebGPU's `clearBuffer` is on\n * the command encoder, so the open pass is released first, as\n * `CopyTextureToTexture` does. Only zero is expressible; Metal's other\n * values go through a compute shader this queue does not have.\n *\n * @param {GPUBuffer} buffer The buffer to zero, whole.\n * @returns {object[]} The transitions this required.\n */\n ClearBuffer(buffer)\n {\n if (!this._inFrame) fail(\"ClearBuffer outside a frame\");\n\n this._ReleaseEncoder();\n this._events.push({ type: \"clear-buffer\" });\n\n if (this._commandEncoder) this._commandEncoder.clearBuffer(buffer);\n\n return this._Drain();\n }\n\n /**\n * Copies a sampled depth texture into its float shadow\n * (`CjsWebgpuTextureAL.EncodeDepthShadowCopy`), on the command encoder and\n * so outside any pass. There is no Metal counterpart: Metal and D3D sample\n * depth through a view, which WebGPU cannot make.\n *\n * @param {object} texture The depth `Tr2TextureAL` that was just unbound.\n * @returns {object[]} The transitions this required.\n */\n CopyDepthShadow(texture)\n {\n if (!this._inFrame || !this._commandEncoder) return this._Drain();\n\n this._ReleaseEncoder();\n\n if (texture.EncodeDepthShadowCopy(this._commandEncoder)) this._events.push({ type: \"copy-depth-shadow\" });\n\n return this._Drain();\n }\n\n /**\n * Names the compute pipeline the next dispatch runs.\n *\n * @param {object} pipeline A `GPUComputePipeline`.\n */\n SetComputePipeline(pipeline)\n {\n this._pending.computePipeline = pipeline;\n }\n\n /**\n * Dispatches thread groups on the compute encoder, opening one if another\n * encoder is current: Metal's `DispatchThreadgroups`, which binds the\n * pending pipeline and bind groups first.\n *\n * @param {number} x Thread groups along x.\n * @param {number} y Thread groups along y.\n * @param {number} z Thread groups along z.\n * @returns {object[]} The transitions this required.\n */\n DispatchThreadgroups(x, y, z)\n {\n if (!this._inFrame) fail(\"a dispatch outside a frame\");\n\n const events = this._currentEncoderType === EncoderType.COMPUTE ? [] : this.SetCurrentEncoder(EncoderType.COMPUTE);\n\n this._events.push(...events, { type: \"dispatch\", x, y, z });\n\n if (this._computePass)\n {\n const pass = this._computePass;\n\n pass.setPipeline(this._pending.computePipeline);\n\n for (const [ index, entry ] of this._pending.bindGroups.entries())\n {\n if (entry) pass.setBindGroup(index, entry.bindGroup, entry.dynamicOffsets ?? []);\n }\n\n pass.dispatchWorkgroups(x, y, z);\n }\n\n return this._Drain();\n }\n\n /**\n * Attaches a colour target at one slot.\n *\n * THREE BEHAVIOURS, ALL CARBON'S (`MetalWorkQueue.mm:2000-2030`), and none of\n * them guessable:\n *\n * 1. **Attaching the texture already there is a no-op.** A redundant target\n * set is common - a step that re-binds what it inherited - and cutting a\n * pass for it would double the pass count for nothing.\n * 2. **A real change flushes outstanding work**, because the attachments of\n * an open pass are fixed and the next work needs a new encoder. Carbon's\n * comment says exactly this.\n * 3. **A newly attached texture defaults to LOAD and STORE**, not clear. The\n * caller has not said the previous contents are worthless, so discarding\n * them would lose whatever is already there.\n *\n * @param {object|null} texture The target, or null to detach.\n * @param {number} [index] The slot.\n * @param {number} [slice] The array slice or cube face.\n * @returns {object[]} The transitions this required.\n */\n SetRenderAttachments(texture, index = 0, slice = 0)\n {\n if (!Number.isInteger(index) || index < 0) fail(\"a render attachment needs a slot index\");\n\n const current = this._colorAttachments[index] ?? null;\n\n if (current?.texture === (texture ?? null)) return this._Drain();\n\n this._ReleaseEncoder();\n\n this._colorAttachments[index] = texture\n ? { texture, slice, loadOp: \"load\", storeOp: \"store\" }\n : null;\n\n return this._Drain();\n }\n\n /**\n * Attaches the depth-stencil target, with the same three behaviours.\n *\n * @param {object|null} texture The depth target, or null to detach.\n * @returns {object[]} The transitions this required.\n */\n SetDepthAttachment(texture)\n {\n if (this._depthAttachment?.texture === (texture ?? null)) return this._Drain();\n\n this._ReleaseEncoder();\n\n this._depthAttachment = texture ? { texture, loadOp: \"load\", storeOp: \"store\" } : null;\n\n return this._Drain();\n }\n\n /**\n * What is currently attached, for a caller building a pass descriptor.\n *\n * @returns {object} `{ colors, depth }`.\n */\n GetAttachments()\n {\n return {\n colors: this._colorAttachments.map(attachment => (attachment ? { ...attachment } : null)),\n depth: this._depthAttachment ? { ...this._depthAttachment } : null\n };\n }\n\n /**\n * Records an indexed draw, opening a render encoder if none is current.\n *\n * THE DRAW OPENS THE ENCODER, which is why this lives here rather than the\n * caller reaching for `SetCurrentEncoder` first. Carbon's\n * `MetalWorkQueue::DrawIndexedPrimitives` (`mm:2922-2945`) begins with\n * `GetRenderEncoder()` for exactly this reason: the abstraction layer's job\n * is to validate arguments and convert primitive counts, and the work\n * queue's job is to have somewhere to put the result.\n *\n * @param {number} indexCount Indices this draw reads.\n * @param {number} instanceCount Instances to draw.\n * @param {number} startIndex First index.\n * @param {number} baseVertex Value added to every index.\n * @param {number} startInstance First instance id.\n * @returns {object[]} The transitions this required, in order.\n */\n DrawIndexedPrimitives(indexCount, instanceCount, startIndex, baseVertex, startInstance)\n {\n this._RequireRenderEncoder();\n this._events.push({\n type: \"draw\",\n indexed: true,\n indexCount,\n instanceCount,\n startIndex,\n baseVertex,\n startInstance\n });\n\n if (this._renderPass)\n {\n this._EmitRenderEncoderState(true);\n this._renderPass.drawIndexed(indexCount, instanceCount, startIndex, baseVertex, startInstance);\n }\n\n return this._Drain();\n }\n\n // THE BINDINGS A DRAW NEEDS, HELD UNTIL THE DRAW. Metal's setters write\n // shadow state and a dirty bit (`MetalWorkQueue.mm:2570-2598`) and the\n // encoder is touched only from `EmitRenderEncoderState` inside the draw\n // (`:1750-1890`). These three do the same, and the live half below compares\n // against what the CURRENT encoder has already been told, which resets when\n // an encoder opens - a new pass starts with nothing bound.\n\n /** What the next draw must have bound. */\n _pending = { pipeline: null, computePipeline: null, vertexBuffers: [], indexBuffer: null, bindGroups: [] };\n\n /** What the open encoder has been told, reset per encoder. */\n _encoderState = { pipeline: null, vertexBuffers: [], indexBuffer: null, bindGroups: [] };\n\n /**\n * Names the bind group for one group index.\n *\n * @param {number} index The group index.\n * @param {object} bindGroup A `GPUBindGroup`.\n */\n SetBindGroup(index, bindGroup, dynamicOffsets = null)\n {\n this._pending.bindGroups[index] = { bindGroup, dynamicOffsets: dynamicOffsets?.length ? dynamicOffsets.slice() : null };\n }\n\n /**\n * Names the pipeline the next draw runs.\n *\n * @param {object} pipeline A `GPURenderPipeline`.\n */\n SetRenderPipeline(pipeline)\n {\n this._pending.pipeline = pipeline;\n }\n\n /**\n * Names a vertex buffer for one slot.\n *\n * @param {number} slot The vertex buffer slot.\n * @param {object} buffer A `GPUBuffer`.\n * @param {number} [offset] Byte offset into it.\n */\n SetVertexBuffer(slot, buffer, offset = 0)\n {\n this._pending.vertexBuffers[slot] = { buffer, offset };\n }\n\n /**\n * Names the index buffer.\n *\n * @param {object} buffer A `GPUBuffer`.\n * @param {string} format `\"uint16\"` or `\"uint32\"`.\n * @param {number} [offset] Byte offset into it.\n */\n SetIndexBuffer(buffer, format, offset = 0)\n {\n this._pending.indexBuffer = { buffer, format, offset };\n }\n\n /** Metal's `EmitRenderEncoderState`: bind what differs from the encoder's. */\n _EmitRenderEncoderState(indexed)\n {\n const pass = this._renderPass;\n const live = this._encoderState;\n const want = this._pending;\n\n if (want.pipeline && live.pipeline !== want.pipeline)\n {\n pass.setPipeline(want.pipeline);\n live.pipeline = want.pipeline;\n }\n\n want.bindGroups.forEach((entry, index) =>\n {\n if (!entry) return;\n\n const bound = live.bindGroups[index];\n\n // Metal re-sets only the OFFSET when the page is unchanged\n // (`setVertexBufferOffset:`); WebGPU has no such call, so a changed\n // offset re-sets the group with its offsets.\n if (bound && bound.bindGroup === entry.bindGroup && sameOffsets(bound.dynamicOffsets, entry.dynamicOffsets)) return;\n\n if (entry.dynamicOffsets) pass.setBindGroup(index, entry.bindGroup, entry.dynamicOffsets);\n else pass.setBindGroup(index, entry.bindGroup);\n\n live.bindGroups[index] = entry;\n });\n\n want.vertexBuffers.forEach((entry, slot) =>\n {\n if (!entry) return;\n\n const bound = live.vertexBuffers[slot];\n\n if (bound && bound.buffer === entry.buffer && bound.offset === entry.offset) return;\n\n pass.setVertexBuffer(slot, entry.buffer, entry.offset);\n live.vertexBuffers[slot] = entry;\n });\n\n if (!indexed || !want.indexBuffer) return;\n\n const bound = live.indexBuffer;\n const entry = want.indexBuffer;\n\n if (bound && bound.buffer === entry.buffer && bound.format === entry.format && bound.offset === entry.offset) return;\n\n pass.setIndexBuffer(entry.buffer, entry.format, entry.offset);\n live.indexBuffer = entry;\n }\n\n /**\n * Records a non-indexed draw, opening a render encoder if none is current.\n *\n * @param {number} vertexCount Vertices this draw reads.\n * @param {number} instanceCount Instances to draw.\n * @param {number} startVertex First vertex.\n * @param {number} startInstance First instance id.\n * @returns {object[]} The transitions this required, in order.\n */\n DrawPrimitives(vertexCount, instanceCount, startVertex, startInstance)\n {\n this._RequireRenderEncoder();\n this._events.push({\n type: \"draw\",\n indexed: false,\n vertexCount,\n instanceCount,\n startVertex,\n startInstance\n });\n\n if (this._renderPass)\n {\n this._EmitRenderEncoderState(false);\n this._renderPass.draw(vertexCount, instanceCount, startVertex, startInstance);\n }\n\n return this._Drain();\n }\n\n // THE DEVICE IS OPTIONAL AND THAT IS THE WHOLE DESIGN. Everything above is\n // the RULES - when an encoder opens, what a hint folds into it, when it has\n // to close - and those need no GPU, which is why they are testable and why\n // Carbon ships a stub backend at all. What follows lets a real command\n // encoder ride along with the rules rather than reimplement them.\n //\n // Without one this queue reports transitions and draws nothing, exactly as\n // before. With one, opening an encoder also calls `beginRenderPass` and\n // closing it calls `end`, so a caller can hand the live pass to the batch\n // dispatcher. That is what stops the queue being a second recording layer.\n\n /** The live command encoder, when a frame is being encoded for real. */\n _commandEncoder = null;\n\n /** Turns folded attachments into a `GPURenderPassDescriptor`. */\n _describePass = null;\n\n /** The open `GPURenderPassEncoder`, or null. */\n _renderPass = null;\n\n /**\n * Attaches a real command encoder for this frame.\n *\n * @param {object|null} commandEncoder A `GPUCommandEncoder`, or null to detach.\n * @param {Function} [describePass] Maps folded attachments to a pass\n * descriptor. IT IS CALLED WITH NULL WHEN NO HINT WAS DECLARED, which is\n * not the same as DONT_CARE - Carbon applies load and store actions only\n * when a hint is pending, and leaves the backend's own defaults alone\n * otherwise. A describePass that assumes an object will crash on the\n * first unhinted pass, which is most of them.\n * @returns {CjsWebgpuWorkQueue} This queue.\n */\n SetCommandEncoder(commandEncoder, describePass = null)\n {\n if (commandEncoder && typeof commandEncoder.beginRenderPass !== \"function\")\n {\n fail(\"a command encoder must be a GPUCommandEncoder\");\n }\n\n if (commandEncoder && typeof describePass !== \"function\")\n {\n fail(\"a command encoder needs a describePass that returns a render-pass descriptor\");\n }\n\n this._commandEncoder = commandEncoder ?? null;\n this._describePass = commandEncoder ? describePass : null;\n\n return this;\n }\n\n /**\n * The open render pass, if one is open and a device is attached.\n *\n * @returns {object|null} A `GPURenderPassEncoder`, or null.\n */\n GetRenderPass()\n {\n return this._renderPass;\n }\n\n /**\n * Opens a render pass if one is not already open, and returns it.\n *\n * This is the verb a draw path calls: Carbon's Metal backend asks for an\n * encoder at the moment it needs one and never before, so a frame that draws\n * nothing opens nothing.\n *\n * @returns {object|null} A `GPURenderPassEncoder`, or null with no device.\n */\n /**\n * Carbon's `GetRenderEncoder` (`MetalWorkQueue.mm:2922`): opens a render\n * encoder if none is current, BEFORE the draw verb asks whether it can draw.\n * Metal opens first and then tests `EmitRenderEncoderState()`, so a draw that\n * is then refused has still opened its pass - which is why a marker pushed\n * after a refused draw lands on a pass encoder.\n *\n * @returns {object[]} The transitions this required, in order.\n */\n GetRenderEncoder()\n {\n this._RequireRenderEncoder();\n\n return this._Drain();\n }\n\n /**\n * The open `GPURenderPassEncoder` for a caller that encodes on it directly.\n *\n * @returns {object|null} The pass, after forgetting what this queue had bound.\n */\n RequireRenderPass()\n {\n this._RequireRenderEncoder();\n\n // A caller that encodes on the pass directly binds what it likes, so what\n // this queue believes the encoder holds is no longer true.\n this._encoderState = { pipeline: null, vertexBuffers: [], indexBuffer: null, bindGroups: [] };\n\n return this._renderPass;\n }\n\n /** Carbon's `GetRenderEncoder`: the current one, or a new one. */\n _RequireRenderEncoder()\n {\n if (!this._inFrame) fail(\"a draw outside a frame\");\n\n if (this._currentEncoderType === EncoderType.RENDER && !this._pendingRenderPassHint) return;\n\n this._GetRenderEncoder();\n }\n\n /** Opens a render encoder, folding any pending hint into its descriptor. */\n _GetRenderEncoder()\n {\n this._ReleaseEncoder();\n\n const hint = this._pendingRenderPassHint;\n const attachments = ApplyRenderPassHint(hint);\n\n this._pendingRenderPassHint = null;\n this._passCount += 1;\n this._currentEncoderType = EncoderType.RENDER;\n this._events.push({ type: \"open\", encoderType: EncoderType.RENDER, attachments });\n\n if (this._commandEncoder)\n {\n this._renderPass = this._commandEncoder.beginRenderPass(this._describePass(attachments));\n this._encoderState = { pipeline: null, vertexBuffers: [], indexBuffer: null, bindGroups: [] };\n }\n }\n\n /** Carbon's `ReleaseEncoder( true )`. */\n _ReleaseEncoder()\n {\n if (this._currentEncoderType === EncoderType.NONE) return;\n\n // The pass ends BEFORE the close event, so a caller draining events after\n // a close can rely on the pass already being finished rather than racing it.\n if (this._renderPass)\n {\n this._renderPass.end();\n this._renderPass = null;\n }\n\n if (this._computePass)\n {\n this._computePass.end();\n this._computePass = null;\n }\n\n this._events.push({ type: \"close\", encoderType: this._currentEncoderType });\n this._currentEncoderType = EncoderType.NONE;\n }\n\n /** Takes the recorded events, leaving the queue's list empty. */\n _Drain()\n {\n const events = this._events;\n\n this._events = [];\n\n return events;\n }\n}\n\n\n/** Whether two dynamic-offset lists bind the same regions. */\nfunction sameOffsets(first, second)\n{\n if (first === second) return true;\n if (!first || !second || first.length !== second.length) return false;\n\n for (let index = 0; index < first.length; index += 1)\n {\n if (first[index] !== second[index]) return false;\n }\n\n return true;\n}\n\n\n/**\n * Turns a declared hint into load and store operations, as Carbon's\n * `ApplyRenderPassHint` writes them into its pass descriptor\n * (`MetalWorkQueue.mm:773-809`).\n *\n * NO HINT IS NOT DONT_CARE. Carbon only applies actions when a hint is pending\n * and otherwise leaves the descriptor as it was, so an absent hint returns null\n * and the caller keeps its own defaults rather than being told to discard.\n *\n * @param {object} [hint] A pending hint.\n * @returns {object|null} `{ colors, depth }` with `load`/`store` per attachment.\n */\nexport function ApplyRenderPassHint(hint)\n{\n if (!hint) return null;\n\n return {\n colors: hint.colors.map(Describe),\n depth: hint.depth ? Describe(hint.depth) : null\n };\n}\n\nfunction Describe(attachment)\n{\n return {\n loadOp: LoadOp(attachment.load),\n storeOp: attachment.store === Tr2StoreAction.STORE ? \"store\" : \"discard\",\n clearValue: attachment.clearColor ?? attachment.clearValue ?? 0\n };\n}\n\nfunction LoadOp(action)\n{\n if (action === Tr2LoadAction.CLEAR) return \"clear\";\n if (action === Tr2LoadAction.LOAD) return \"load\";\n\n // DONT_CARE has no WebGPU spelling - the API has no \"contents are undefined\"\n // load. `clear` is the honest mapping: `load` would promise to preserve\n // contents the caller has said it does not need, which costs a fetch on\n // exactly the tile-based hardware the hint exists for.\n return \"clear\";\n}\n\n\n// DECLARED AS A CALL, NOT A DECORATOR. The abstraction layer is imported\n// straight from source by its tests - `#trinityal/...` resolves to `src/` - and\n// raw Node cannot parse decorator syntax, so a decorator here breaks every test\n// that reaches this file without a build first. `CjsSchema.define` is the same\n// metadata through the door the schema already provides for exactly this, and\n// it keeps the layer free of the decorator chain it has never carried.\nCjsSchema.define(CjsWebgpuWorkQueue, { className: \"CjsWebgpuWorkQueue\", modelledOn: \"MetalWorkQueue\" });\n"],"names":["fail","message","error","Error","code","EncoderType","Object","freeze","NONE","RENDER","COMPUTE","CjsWebgpuWorkQueue","_currentEncoderType","_pendingRenderPassHint","_events","_passCount","_inFrame","_colorAttachments","_depthAttachment","GetCurrentEncoderType","GetPassCount","HasPendingRenderPassHint","BeginFrame","_pending","pipeline","vertexBuffers","indexBuffer","bindGroups","push","type","_Drain","EndFrame","_GetRenderEncoder","_ReleaseEncoder","RenderPassHint","colors","depth","Array","isArray","EndRenderPassHint","EndCurrentRenderPass","SetCurrentEncoder","encoderType","_commandEncoder","_computePass","beginComputePass","label","_encoderState","GenerateMipMaps","texture","generator","Encode","CopyTextureToTexture","source","sourceSlice","sourceMip","sourceOrigin","size","destination","destinationSlice","destinationMip","destinationOrigin","copyTextureToTexture","mipLevel","origin","x","y","z","ClearBuffer","buffer","clearBuffer","CopyDepthShadow","EncodeDepthShadowCopy","SetComputePipeline","computePipeline","DispatchThreadgroups","events","pass","setPipeline","index","entry","entries","setBindGroup","bindGroup","dynamicOffsets","dispatchWorkgroups","SetRenderAttachments","slice","Number","isInteger","current","loadOp","storeOp","SetDepthAttachment","GetAttachments","map","attachment","DrawIndexedPrimitives","indexCount","instanceCount","startIndex","baseVertex","startInstance","_RequireRenderEncoder","indexed","_renderPass","_EmitRenderEncoderState","drawIndexed","SetBindGroup","length","SetRenderPipeline","SetVertexBuffer","slot","offset","SetIndexBuffer","format","live","want","forEach","bound","sameOffsets","setVertexBuffer","setIndexBuffer","DrawPrimitives","vertexCount","startVertex","draw","_describePass","SetCommandEncoder","commandEncoder","describePass","beginRenderPass","GetRenderPass","GetRenderEncoder","RequireRenderPass","hint","attachments","ApplyRenderPassHint","end","first","second","Describe","LoadOp","load","store","Tr2StoreAction","STORE","clearValue","clearColor","action","Tr2LoadAction","CLEAR","LOAD","CjsSchema","define","className","modelledOn"],"mappings":";;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA,SAASA,IAAIA,CAACC,OAAO,EACrB;EACE,MAAMC,KAAK,GAAG,IAAIC,KAAK,CAAC,CAAA,oBAAA,EAAuBF,OAAO,EAAE,CAAC;EACzDC,KAAK,CAACE,IAAI,GAAG,+BAA+B;AAC5C,EAAA,MAAMF,KAAK;AACb;;AAGA;MACaG,WAAW,GAAGC,MAAM,CAACC,MAAM,CAAC;AACvCC,EAAAA,IAAI,EAAE,MAAM;AACZC,EAAAA,MAAM,EAAE,QAAQ;AAChBC,EAAAA,OAAO,EAAE;AACX,CAAC;;AAGD;AACA;AACA;AACA;AACA;AACA;AACA;AAC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AAI;AACb;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS0D,mBAAmBA,CAACF,IAAI,EACxC;AACE,EAAA,IAAI,CAACA,IAAI,EAAE,OAAO,IAAI;EAEtB,OAAO;IACLpG,MAAM,EAAEoG,IAAI,CAACpG,MAAM,CAAC4D,GAAG,CAAC8C,QAAQ,CAAC;IACjCzG,KAAK,EAAEmG,IAAI,CAACnG,KAAK,GAAGyG,QAAQ,CAACN,IAAI,CAACnG,KAAK,CAAC,GAAG;GAC5C;AACH;AAEA,SAASyG,QAAQA,CAAC7C,UAAU,EAC5B;EACE,OAAO;AACLL,IAAAA,MAAM,EAAEmD,MAAM,CAAC9C,UAAU,CAAC+C,IAAI,CAAC;IAC/BnD,OAAO,EAAEI,UAAU,CAACgD,KAAK,KAAKC,cAAc,CAACC,KAAK,GAAG,OAAO,GAAG,SAAS;IACxEC,UAAU,EAAEnD,UAAU,CAACoD,UAAU,IAAIpD,UAAU,CAACmD,UAAU,IAAI;GAC/D;AACH;AAEA,SAASL,MAAMA,CAACO,MAAM,EACtB;AACE,EAAA,IAAIA,MAAM,KAAKC,aAAa,CAACC,KAAK,EAAE,OAAO,OAAO;AAClD,EAAA,IAAIF,MAAM,KAAKC,aAAa,CAACE,IAAI,EAAE,OAAO,MAAM;;AAEhD;AACA;AACA;AACA;AACA,EAAA,OAAO,OAAO;AAChB;;AAGA;AACA;AACA;AACA;AACA;AACA;AACAC,SAAS,CAACC,MAAM,CAAC/I,kBAAkB,EAAE;AAAEgJ,EAAAA,SAAS,EAAE,oBAAoB;AAAEC,EAAAA,UAAU,EAAE;AAAiB,CAAC,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"CjsWebgpuWorkQueue.js","sources":["../../../../../src/trinityal/webgpu/core/CjsWebgpuWorkQueue.js"],"sourcesContent":["// Source: trinity/trinityal/metal/MetalWorkQueue.h\n// Source: trinity/trinityal/metal/MetalWorkQueue.mm\n//\n// MODELLED ON `MetalWorkQueue`, NOT A REPLICA OF IT - which is what the\n// `modelledOn` declaration below says, and why the parity check does not hold\n// this class to that class's surface. Metal's work queue declares 113 methods\n// to this file's 27, because it is the whole command recorder; comparing them\n// would report 101 absences as debt when the surface simply lives elsewhere\n// here.\n//\n// What this file took, and where the rest of Metal's work queue went:\n//\n// ENCODER LIFETIME -> here. BeginFrame/EndFrame, SetCurrentEncoder,\n// GetRenderEncoder/ReleaseEncoder, the pass\n// hint and its attachments, the pending\n// bindings a draw needs.\n// Blend, depth, stencil, cull, -> the PIPELINE. WebGPU has no per-state\n// fill, sample state setter; `Tr2RenderStateSetup.GetWebgpuRecipe`\n// projects the authored setup and\n// `CjsWebgpuPsoDescription` resolves it once.\n// SetTextures/SetSamplers/ -> `CjsWebgpuResourceSetAL` and the bind\n// SetBuffers/SetConstants groups the render context assembles.\n// Draw*/Dispatch* -> `CjsWebgpuRenderContextAL`'s draw verbs.\n// Blit, mipmaps, MSAA resolve, -> not ported, each recorded where it refuses.\n// visibility queries, parallel\n// encoding, the drawable blit\n//\n// The encoder the backend is currently writing into, and when it has to change.\n//\n// THIS IS A PORT, NOT A DESIGN. Carbon's command-encoder backend splits into a\n// render context that answers the abstraction layer's verbs and a WORK QUEUE\n// that owns the command buffer and the encoder lifetime - `Tr2RenderContextAL`\n// holds `m_workQueue` (`Tr2RenderContextMetal.h:299`). WebGPU has the same\n// shape as Metal: one command encoder per frame, render passes with fixed\n// attachments, and compute and copies that may not happen inside one. So this\n// carries Carbon's name and Carbon's responsibilities rather than a new noun.\n//\n// It replaces `framePlan.js`, which looks AHEAD over a recorded intent stream.\n// That look-ahead exists only because the planner is not the thing issuing the\n// calls - it reads them afterwards. A work queue is called verb by verb, in\n// order, so every decision is about the call in hand. Metal's\n// `SetCurrentEncoder` (`MetalWorkQueue.mm:840-900`) is lazy for that reason and\n// has no look-ahead anywhere.\n//\n// NOT PORTED, deliberately: the blit and acceleration-structure encoders, the\n// parallel render encoder, and the drawable blit. WebGPU takes copies on the\n// command encoder directly rather than through a blit encoder, it has no\n// parallel encoder, and ray tracing is absent from this backend as it is from\n// Carbon's stub. `MTLENCODERTYPE_BLIT` therefore has no counterpart here and\n// transfers are recorded against the command encoder itself.\n\nimport { CjsSchema } from \"#schema\";\nimport { Tr2LoadAction, Tr2StoreAction } from \"#consts/render-context\";\n\n\nfunction fail(message)\n{\n const error = new Error(`CjsWebgpuWorkQueue: ${message}`);\n error.code = \"CJS_WEBGPU_WORK_QUEUE_INVALID\";\n throw error;\n}\n\n\n/** Carbon's `MetalEncoderType`, less the encoders WebGPU does not have. */\nexport const EncoderType = Object.freeze({\n NONE: \"none\",\n RENDER: \"render\",\n COMPUTE: \"compute\"\n});\n\n\n/**\n * Owns the encoder lifetime for one frame, as Carbon's `MetalWorkQueue` does.\n *\n * DEVICE-FREE, for the reason Carbon's stub backend is: the rules are the part\n * worth testing, and they need no GPU. A caller applies the transitions this\n * reports to a real command encoder.\n */\nexport class CjsWebgpuWorkQueue\n{\n /** m_currentEncoderType */\n _currentEncoderType = EncoderType.NONE;\n\n /** m_pendingRenderPassHint / m_hasPendingRenderPassHint */\n _pendingRenderPassHint = null;\n\n /**\n * m_pendingClear, with the clear actions Metal writes into its pass\n * descriptor (`ClearAttachment`), in the hint's `{ colors, depth }` form.\n */\n _pendingClear = null;\n\n /** Transitions since the last drain, in order. */\n _events = [];\n\n /** Render passes begun this frame. */\n _passCount = 0;\n\n /** Whether BeginFrame has run without a matching EndFrame. */\n _inFrame = false;\n\n /** m_currentRenderPassDescriptor.colorAttachments */\n _colorAttachments = [];\n\n /** m_currentRenderPassDescriptor.depthAttachment */\n _depthAttachment = null;\n\n /**\n * The encoder currently open.\n *\n * @returns {string} An `EncoderType`.\n */\n GetCurrentEncoderType()\n {\n return this._currentEncoderType;\n }\n\n /** Render passes begun this frame. @returns {number} */\n GetPassCount()\n {\n return this._passCount;\n }\n\n /** Whether a hint is waiting to be folded in. @returns {boolean} */\n HasPendingRenderPassHint()\n {\n return this._pendingRenderPassHint !== null;\n }\n\n /**\n * Opens the frame's command buffer. Carbon's `BeginFrame`.\n *\n * Returns its transitions like every other verb here, so a caller drains one\n * list per call and never carries events into the next one.\n *\n * @returns {object[]} The transitions this required.\n */\n BeginFrame()\n {\n if (this._inFrame) fail(\"BeginFrame without EndFrame\");\n\n this._inFrame = true;\n this._passCount = 0;\n this._pendingClear = null;\n // Nothing named last frame is wanted this frame until a verb names it.\n this._pending = { pipeline: null, vertexBuffers: [], indexBuffer: null, bindGroups: [] };\n this._events.push({ type: \"begin-frame\" });\n\n return this._Drain();\n }\n\n /**\n * Closes any encoder and commits. Carbon's `EndFrame` plus\n * `CommitCommandBuffer`.\n *\n * @returns {object[]} The transitions this required, in order.\n */\n EndFrame()\n {\n if (!this._inFrame) fail(\"EndFrame without BeginFrame\");\n\n if (this._pendingRenderPassHint || this._pendingClear) this._GetRenderEncoder();\n\n this._ReleaseEncoder();\n this._inFrame = false;\n this._events.push({ type: \"commit\" });\n\n return this._Drain();\n }\n\n /**\n * Declares what the next render pass does with its attachments.\n *\n * A SECOND HINT WHILE ONE IS PENDING OPENS AND IMMEDIATELY RELEASES A RENDER\n * ENCODER (`MetalWorkQueue.mm:3282-3291`). The first hint described a pass\n * that must still happen - its load and store actions are the point even when\n * nothing drew into it - so discarding it would lose a clear.\n *\n * @param {object[]} colors `Tr2ColorAttachment`s, in slot order.\n * @param {object} [depth] A `Tr2DepthAttachment`.\n */\n RenderPassHint(colors, depth = null)\n {\n if (!Array.isArray(colors)) fail(\"RenderPassHint takes an array of colour attachments\");\n\n if (this._pendingRenderPassHint)\n {\n this._GetRenderEncoder();\n this._ReleaseEncoder();\n }\n\n this._pendingRenderPassHint = { colors, depth };\n }\n\n /**\n * Ends the declared pass, so following work opens a new one.\n *\n * Carbon flushes rather than discards, for the reason above\n * (`MetalWorkQueue.mm:3293-3300`).\n *\n * @returns {object[]} The transitions this required.\n */\n EndRenderPassHint()\n {\n if (this._pendingRenderPassHint || this._pendingClear) this._GetRenderEncoder();\n\n this._ReleaseEncoder();\n\n return this._Drain();\n }\n\n /**\n * Carbon's `ClearAttachment` (`MetalWorkQueue.mm:2845-2881`): the clear\n * goes on the attachments bound NOW, as the load actions of the next pass\n * over them. Ignored while a hint is pending, whose actions govern that\n * pass; any open encoder is ended first, so the clear starts a pass.\n *\n * Changing an attachment runs a pending clear before the change\n * (`_FlushOutstandingOperations`), so a clear never lands on the targets\n * bound after it: that is the difference from a hint.\n *\n * @param {object[]} colors `Tr2ColorAttachment`s for the bound slots, in order.\n * @param {object|null} depth A `Tr2DepthAttachment`, or null.\n * @returns {object[]} The transitions this required.\n */\n ClearAttachment(colors, depth = null)\n {\n if (this._pendingRenderPassHint) return this._Drain();\n\n this._FlushOutstandingOperations();\n this._pendingClear = { colors, depth };\n\n return this._Drain();\n }\n\n /**\n * Carbon's `FlushOutstandingOperations` (`MetalWorkQueue.mm:380-405`):\n * ends the open encoder, then runs a pending clear in a pass of its own\n * over the current attachments. A pending hint is set aside for that pass\n * and stays pending, as Metal backs it up and restores it.\n */\n _FlushOutstandingOperations()\n {\n this._ReleaseEncoder();\n\n if (!this._pendingClear || !this._inFrame) return;\n\n const hint = this._pendingRenderPassHint;\n\n this._pendingRenderPassHint = null;\n this._GetRenderEncoder();\n this._ReleaseEncoder();\n this._pendingRenderPassHint = hint;\n }\n\n /** Carbon's `EndCurrentRenderPass`. @returns {object[]} The transitions. */\n EndCurrentRenderPass()\n {\n if (this._currentEncoderType === EncoderType.RENDER) this._ReleaseEncoder();\n\n return this._Drain();\n }\n\n /**\n * Makes an encoder of the given type current, as `SetCurrentEncoder` does.\n *\n * @param {string} encoderType An `EncoderType` other than NONE.\n * @returns {object[]} The transitions this required, in order.\n */\n SetCurrentEncoder(encoderType)\n {\n if (!this._inFrame) fail(\"SetCurrentEncoder outside a frame\");\n if (encoderType === EncoderType.NONE) fail(\"SetCurrentEncoder needs a real encoder type\");\n\n // Carbon flushes a pending hint before any NON-render encoder, because the\n // declared pass must happen before the work that follows it\n // (`MetalWorkQueue.mm:851-855`).\n if (encoderType !== EncoderType.RENDER && this._pendingRenderPassHint)\n {\n this._GetRenderEncoder();\n this._ReleaseEncoder();\n }\n\n if (this._currentEncoderType === encoderType)\n {\n // A pending hint describes the NEXT pass, so an open render encoder is\n // still the wrong one to keep drawing into.\n if (encoderType !== EncoderType.RENDER || !this._pendingRenderPassHint) return this._Drain();\n }\n\n if (encoderType === EncoderType.RENDER)\n {\n this._GetRenderEncoder();\n\n return this._Drain();\n }\n\n this._ReleaseEncoder();\n this._currentEncoderType = encoderType;\n this._events.push({ type: \"open\", encoderType });\n\n // Metal's compute encoder (`MetalWorkQueue.mm` GetComputeEncoder): a\n // compute pass on the frame's command encoder, starting with nothing bound.\n if (encoderType === EncoderType.COMPUTE && this._commandEncoder)\n {\n this._computePass = this._commandEncoder.beginComputePass({ label: \"Tr2RenderContextAL compute\" });\n this._encoderState = { pipeline: null, vertexBuffers: [], indexBuffer: null, bindGroups: [] };\n }\n\n return this._Drain();\n }\n\n /** The open compute pass, or null. */\n _computePass = null;\n\n /**\n * Regenerates a texture's mip chain, as Metal's work queue does on a blit\n * encoder: the open pass ends first, so the chain is encoded in order with\n * the work around it.\n *\n * @param {GPUTexture} texture The texture.\n * @param {CjsWebgpuMipGenerator} generator The context's generator.\n * @returns {object[]} The transitions this required.\n */\n GenerateMipMaps(texture, generator)\n {\n if (!this._inFrame) fail(\"GenerateMipMaps outside a frame\");\n\n this._ReleaseEncoder();\n this._events.push({ type: \"generate-mips\" });\n\n if (this._commandEncoder) generator.Encode(this._commandEncoder, texture);\n\n return this._Drain();\n }\n\n /**\n * Copies one texture subresource region into another: Metal's\n * `MetalWorkQueue::CopyTextureToTexture` (`MetalWorkQueue.mm:1381-1405`),\n * which records a blit and releases the encoder. WebGPU copies on the\n * command encoder itself, so the open pass is released first, as\n * `GenerateMipMaps` does.\n *\n * @param {GPUTexture} source The texture to read.\n * @param {number} sourceSlice The source array layer.\n * @param {number} sourceMip The source mip level.\n * @param {{x: number, y: number, z: number}} sourceOrigin The source origin.\n * @param {{width: number, height: number, depthOrArrayLayers: number}} size The copy size.\n * @param {GPUTexture} destination The texture to write.\n * @param {number} destinationSlice The destination array layer.\n * @param {number} destinationMip The destination mip level.\n * @param {{x: number, y: number, z: number}} destinationOrigin The destination origin.\n * @returns {object[]} The transitions this required.\n */\n CopyTextureToTexture(source, sourceSlice, sourceMip, sourceOrigin, size, destination, destinationSlice, destinationMip, destinationOrigin)\n {\n if (!this._inFrame) fail(\"CopyTextureToTexture outside a frame\");\n\n this._ReleaseEncoder();\n this._events.push({ type: \"copy-texture\" });\n\n if (this._commandEncoder)\n {\n this._commandEncoder.copyTextureToTexture(\n { texture: source, mipLevel: sourceMip, origin: { x: sourceOrigin.x, y: sourceOrigin.y, z: sourceOrigin.z + sourceSlice } },\n { texture: destination, mipLevel: destinationMip, origin: { x: destinationOrigin.x, y: destinationOrigin.y, z: destinationOrigin.z + destinationSlice } },\n size\n );\n }\n\n return this._Drain();\n }\n\n /**\n * Fills a buffer with zeros: the fast path of Metal's\n * `MetalWorkQueue::ClearBuffer` (`MetalWorkQueue.mm:1216-1225`), a blit\n * `fillBuffer` that then releases the encoder. WebGPU's `clearBuffer` is on\n * the command encoder, so the open pass is released first, as\n * `CopyTextureToTexture` does. Only zero is expressible; Metal's other\n * values go through a compute shader this queue does not have.\n *\n * @param {GPUBuffer} buffer The buffer to zero, whole.\n * @returns {object[]} The transitions this required.\n */\n ClearBuffer(buffer)\n {\n if (!this._inFrame) fail(\"ClearBuffer outside a frame\");\n\n this._ReleaseEncoder();\n this._events.push({ type: \"clear-buffer\" });\n\n if (this._commandEncoder) this._commandEncoder.clearBuffer(buffer);\n\n return this._Drain();\n }\n\n /**\n * Copies a sampled depth texture into its float shadow\n * (`CjsWebgpuTextureAL.EncodeDepthShadowCopy`), on the command encoder and\n * so outside any pass. There is no Metal counterpart: Metal and D3D sample\n * depth through a view, which WebGPU cannot make.\n *\n * @param {object} texture The depth `Tr2TextureAL` that was just unbound.\n * @returns {object[]} The transitions this required.\n */\n CopyDepthShadow(texture)\n {\n if (!this._inFrame || !this._commandEncoder) return this._Drain();\n\n this._ReleaseEncoder();\n\n if (texture.EncodeDepthShadowCopy(this._commandEncoder)) this._events.push({ type: \"copy-depth-shadow\" });\n\n return this._Drain();\n }\n\n /**\n * Names the compute pipeline the next dispatch runs.\n *\n * @param {object} pipeline A `GPUComputePipeline`.\n */\n SetComputePipeline(pipeline)\n {\n this._pending.computePipeline = pipeline;\n }\n\n /**\n * Dispatches thread groups on the compute encoder, opening one if another\n * encoder is current: Metal's `DispatchThreadgroups`, which binds the\n * pending pipeline and bind groups first.\n *\n * @param {number} x Thread groups along x.\n * @param {number} y Thread groups along y.\n * @param {number} z Thread groups along z.\n * @returns {object[]} The transitions this required.\n */\n DispatchThreadgroups(x, y, z)\n {\n if (!this._inFrame) fail(\"a dispatch outside a frame\");\n\n const events = this._currentEncoderType === EncoderType.COMPUTE ? [] : this.SetCurrentEncoder(EncoderType.COMPUTE);\n\n this._events.push(...events, { type: \"dispatch\", x, y, z });\n\n if (this._computePass)\n {\n const pass = this._computePass;\n\n pass.setPipeline(this._pending.computePipeline);\n\n for (const [ index, entry ] of this._pending.bindGroups.entries())\n {\n if (entry) pass.setBindGroup(index, entry.bindGroup, entry.dynamicOffsets ?? []);\n }\n\n pass.dispatchWorkgroups(x, y, z);\n }\n\n return this._Drain();\n }\n\n /**\n * Attaches a colour target at one slot.\n *\n * THREE BEHAVIOURS, ALL CARBON'S (`MetalWorkQueue.mm:2000-2030`), and none of\n * them guessable:\n *\n * 1. **Attaching the texture already there is a no-op.** A redundant target\n * set is common - a step that re-binds what it inherited - and cutting a\n * pass for it would double the pass count for nothing.\n * 2. **A real change flushes outstanding work**, because the attachments of\n * an open pass are fixed and the next work needs a new encoder. Carbon's\n * comment says exactly this.\n * 3. **A newly attached texture defaults to LOAD and STORE**, not clear. The\n * caller has not said the previous contents are worthless, so discarding\n * them would lose whatever is already there.\n *\n * @param {object|null} texture The target, or null to detach.\n * @param {number} [index] The slot.\n * @param {number} [slice] The array slice or cube face.\n * @returns {object[]} The transitions this required.\n */\n SetRenderAttachments(texture, index = 0, slice = 0)\n {\n if (!Number.isInteger(index) || index < 0) fail(\"a render attachment needs a slot index\");\n\n const current = this._colorAttachments[index] ?? null;\n\n if (current?.texture === (texture ?? null)) return this._Drain();\n\n this._FlushOutstandingOperations();\n\n this._colorAttachments[index] = texture\n ? { texture, slice, loadOp: \"load\", storeOp: \"store\" }\n : null;\n\n return this._Drain();\n }\n\n /**\n * Attaches the depth-stencil target, with the same three behaviours.\n *\n * @param {object|null} texture The depth target, or null to detach.\n * @returns {object[]} The transitions this required.\n */\n SetDepthAttachment(texture)\n {\n if (this._depthAttachment?.texture === (texture ?? null)) return this._Drain();\n\n this._FlushOutstandingOperations();\n\n this._depthAttachment = texture ? { texture, loadOp: \"load\", storeOp: \"store\" } : null;\n\n return this._Drain();\n }\n\n /**\n * What is currently attached, for a caller building a pass descriptor.\n *\n * @returns {object} `{ colors, depth }`.\n */\n GetAttachments()\n {\n return {\n colors: this._colorAttachments.map(attachment => (attachment ? { ...attachment } : null)),\n depth: this._depthAttachment ? { ...this._depthAttachment } : null\n };\n }\n\n /**\n * Records an indexed draw, opening a render encoder if none is current.\n *\n * THE DRAW OPENS THE ENCODER, which is why this lives here rather than the\n * caller reaching for `SetCurrentEncoder` first. Carbon's\n * `MetalWorkQueue::DrawIndexedPrimitives` (`mm:2922-2945`) begins with\n * `GetRenderEncoder()` for exactly this reason: the abstraction layer's job\n * is to validate arguments and convert primitive counts, and the work\n * queue's job is to have somewhere to put the result.\n *\n * @param {number} indexCount Indices this draw reads.\n * @param {number} instanceCount Instances to draw.\n * @param {number} startIndex First index.\n * @param {number} baseVertex Value added to every index.\n * @param {number} startInstance First instance id.\n * @returns {object[]} The transitions this required, in order.\n */\n DrawIndexedPrimitives(indexCount, instanceCount, startIndex, baseVertex, startInstance)\n {\n this._RequireRenderEncoder();\n this._events.push({\n type: \"draw\",\n indexed: true,\n indexCount,\n instanceCount,\n startIndex,\n baseVertex,\n startInstance\n });\n\n if (this._renderPass)\n {\n this._EmitRenderEncoderState(true);\n this._renderPass.drawIndexed(indexCount, instanceCount, startIndex, baseVertex, startInstance);\n }\n\n return this._Drain();\n }\n\n // THE BINDINGS A DRAW NEEDS, HELD UNTIL THE DRAW. Metal's setters write\n // shadow state and a dirty bit (`MetalWorkQueue.mm:2570-2598`) and the\n // encoder is touched only from `EmitRenderEncoderState` inside the draw\n // (`:1750-1890`). These three do the same, and the live half below compares\n // against what the CURRENT encoder has already been told, which resets when\n // an encoder opens - a new pass starts with nothing bound.\n\n /** What the next draw must have bound. */\n _pending = { pipeline: null, computePipeline: null, vertexBuffers: [], indexBuffer: null, bindGroups: [] };\n\n /** What the open encoder has been told, reset per encoder. */\n _encoderState = { pipeline: null, vertexBuffers: [], indexBuffer: null, bindGroups: [] };\n\n /**\n * m_viewport, null until one is set (m_validViewport). It outlives passes\n * and frames, as Metal's does, and every new encoder applies it again.\n */\n _viewport = null;\n\n /**\n * Metal's `SetViewport` (`MetalWorkQueue.mm:2166-2171`): held until the next\n * draw, like the bindings above.\n *\n * @param {number} originX Left edge, in pixels.\n * @param {number} originY Top edge, in pixels.\n * @param {number} width Width, in pixels.\n * @param {number} height Height, in pixels.\n * @param {number} znear Depth the near plane maps to.\n * @param {number} zfar Depth the far plane maps to.\n */\n SetViewport(originX, originY, width, height, znear, zfar)\n {\n this._viewport = { originX, originY, width, height, znear, zfar };\n }\n\n /**\n * Names the bind group for one group index.\n *\n * @param {number} index The group index.\n * @param {object} bindGroup A `GPUBindGroup`.\n */\n SetBindGroup(index, bindGroup, dynamicOffsets = null)\n {\n this._pending.bindGroups[index] = { bindGroup, dynamicOffsets: dynamicOffsets?.length ? dynamicOffsets.slice() : null };\n }\n\n /**\n * Names the pipeline the next draw runs.\n *\n * @param {object} pipeline A `GPURenderPipeline`.\n */\n SetRenderPipeline(pipeline)\n {\n this._pending.pipeline = pipeline;\n }\n\n /**\n * Names a vertex buffer for one slot.\n *\n * @param {number} slot The vertex buffer slot.\n * @param {object} buffer A `GPUBuffer`.\n * @param {number} [offset] Byte offset into it.\n */\n SetVertexBuffer(slot, buffer, offset = 0)\n {\n this._pending.vertexBuffers[slot] = { buffer, offset };\n }\n\n /**\n * Names the index buffer.\n *\n * @param {object} buffer A `GPUBuffer`.\n * @param {string} format `\"uint16\"` or `\"uint32\"`.\n * @param {number} [offset] Byte offset into it.\n */\n SetIndexBuffer(buffer, format, offset = 0)\n {\n this._pending.indexBuffer = { buffer, format, offset };\n }\n\n /** Metal's `EmitRenderEncoderState`: bind what differs from the encoder's. */\n _EmitRenderEncoderState(indexed)\n {\n const pass = this._renderPass;\n const live = this._encoderState;\n const want = this._pending;\n\n if (want.pipeline && live.pipeline !== want.pipeline)\n {\n pass.setPipeline(want.pipeline);\n live.pipeline = want.pipeline;\n }\n\n if (this._viewport && live.viewport !== this._viewport)\n {\n this._EmitViewport(pass, this._viewport);\n live.viewport = this._viewport;\n }\n\n want.bindGroups.forEach((entry, index) =>\n {\n if (!entry) return;\n\n const bound = live.bindGroups[index];\n\n // Metal re-sets only the OFFSET when the page is unchanged\n // (`setVertexBufferOffset:`); WebGPU has no such call, so a changed\n // offset re-sets the group with its offsets.\n if (bound && bound.bindGroup === entry.bindGroup && sameOffsets(bound.dynamicOffsets, entry.dynamicOffsets)) return;\n\n if (entry.dynamicOffsets) pass.setBindGroup(index, entry.bindGroup, entry.dynamicOffsets);\n else pass.setBindGroup(index, entry.bindGroup);\n\n live.bindGroups[index] = entry;\n });\n\n want.vertexBuffers.forEach((entry, slot) =>\n {\n if (!entry) return;\n\n const bound = live.vertexBuffers[slot];\n\n if (bound && bound.buffer === entry.buffer && bound.offset === entry.offset) return;\n\n pass.setVertexBuffer(slot, entry.buffer, entry.offset);\n live.vertexBuffers[slot] = entry;\n });\n\n if (!indexed || !want.indexBuffer) return;\n\n const bound = live.indexBuffer;\n const entry = want.indexBuffer;\n\n if (bound && bound.buffer === entry.buffer && bound.format === entry.format && bound.offset === entry.offset) return;\n\n pass.setIndexBuffer(entry.buffer, entry.format, entry.offset);\n live.indexBuffer = entry;\n }\n\n /**\n * Applies a viewport to the open pass (`MetalWorkQueue.mm:1786-1795`).\n *\n * WebGPU refuses a viewport reaching outside the attachments, where D3D11\n * and Metal clip to them, so it is cut to the attachment rectangle first. A\n * viewport that only fits a previous, larger target is thereby rescaled\n * rather than clipped; one inside the attachments is unchanged.\n *\n * @param {object} pass The open `GPURenderPassEncoder`.\n * @param {object} viewport The held viewport.\n */\n _EmitViewport(pass, viewport)\n {\n const attachment = this._colorAttachments.find(Boolean) ?? this._depthAttachment;\n const width = attachment ? attachment.texture.GetWidth() : Infinity;\n const height = attachment ? attachment.texture.GetHeight() : Infinity;\n const x = Math.min(Math.max(viewport.originX, 0), width);\n const y = Math.min(Math.max(viewport.originY, 0), height);\n const minDepth = Math.min(Math.max(viewport.znear, 0), 1);\n const maxDepth = Math.min(Math.max(viewport.zfar, minDepth), 1);\n\n pass.setViewport(\n x,\n y,\n Math.max(Math.min(viewport.originX + viewport.width, width) - x, 0),\n Math.max(Math.min(viewport.originY + viewport.height, height) - y, 0),\n minDepth,\n maxDepth\n );\n }\n\n /**\n * Records a non-indexed draw, opening a render encoder if none is current.\n *\n * @param {number} vertexCount Vertices this draw reads.\n * @param {number} instanceCount Instances to draw.\n * @param {number} startVertex First vertex.\n * @param {number} startInstance First instance id.\n * @returns {object[]} The transitions this required, in order.\n */\n DrawPrimitives(vertexCount, instanceCount, startVertex, startInstance)\n {\n this._RequireRenderEncoder();\n this._events.push({\n type: \"draw\",\n indexed: false,\n vertexCount,\n instanceCount,\n startVertex,\n startInstance\n });\n\n if (this._renderPass)\n {\n this._EmitRenderEncoderState(false);\n this._renderPass.draw(vertexCount, instanceCount, startVertex, startInstance);\n }\n\n return this._Drain();\n }\n\n // THE DEVICE IS OPTIONAL AND THAT IS THE WHOLE DESIGN. Everything above is\n // the RULES - when an encoder opens, what a hint folds into it, when it has\n // to close - and those need no GPU, which is why they are testable and why\n // Carbon ships a stub backend at all. What follows lets a real command\n // encoder ride along with the rules rather than reimplement them.\n //\n // Without one this queue reports transitions and draws nothing, exactly as\n // before. With one, opening an encoder also calls `beginRenderPass` and\n // closing it calls `end`, so a caller can hand the live pass to the batch\n // dispatcher. That is what stops the queue being a second recording layer.\n\n /** The live command encoder, when a frame is being encoded for real. */\n _commandEncoder = null;\n\n /** Turns folded attachments into a `GPURenderPassDescriptor`. */\n _describePass = null;\n\n /** The open `GPURenderPassEncoder`, or null. */\n _renderPass = null;\n\n /**\n * Attaches a real command encoder for this frame.\n *\n * @param {object|null} commandEncoder A `GPUCommandEncoder`, or null to detach.\n * @param {Function} [describePass] Maps folded attachments to a pass\n * descriptor. IT IS CALLED WITH NULL WHEN NO HINT WAS DECLARED, which is\n * not the same as DONT_CARE - Carbon applies load and store actions only\n * when a hint is pending, and leaves the backend's own defaults alone\n * otherwise. A describePass that assumes an object will crash on the\n * first unhinted pass, which is most of them.\n * @returns {CjsWebgpuWorkQueue} This queue.\n */\n SetCommandEncoder(commandEncoder, describePass = null)\n {\n if (commandEncoder && typeof commandEncoder.beginRenderPass !== \"function\")\n {\n fail(\"a command encoder must be a GPUCommandEncoder\");\n }\n\n if (commandEncoder && typeof describePass !== \"function\")\n {\n fail(\"a command encoder needs a describePass that returns a render-pass descriptor\");\n }\n\n this._commandEncoder = commandEncoder ?? null;\n this._describePass = commandEncoder ? describePass : null;\n\n return this;\n }\n\n /**\n * The open render pass, if one is open and a device is attached.\n *\n * @returns {object|null} A `GPURenderPassEncoder`, or null.\n */\n GetRenderPass()\n {\n return this._renderPass;\n }\n\n /**\n * Opens a render pass if one is not already open, and returns it.\n *\n * This is the verb a draw path calls: Carbon's Metal backend asks for an\n * encoder at the moment it needs one and never before, so a frame that draws\n * nothing opens nothing.\n *\n * @returns {object|null} A `GPURenderPassEncoder`, or null with no device.\n */\n /**\n * Carbon's `GetRenderEncoder` (`MetalWorkQueue.mm:2922`): opens a render\n * encoder if none is current, BEFORE the draw verb asks whether it can draw.\n * Metal opens first and then tests `EmitRenderEncoderState()`, so a draw that\n * is then refused has still opened its pass - which is why a marker pushed\n * after a refused draw lands on a pass encoder.\n *\n * @returns {object[]} The transitions this required, in order.\n */\n GetRenderEncoder()\n {\n this._RequireRenderEncoder();\n\n return this._Drain();\n }\n\n /**\n * The open `GPURenderPassEncoder` for a caller that encodes on it directly.\n *\n * @returns {object|null} The pass, after forgetting what this queue had bound.\n */\n RequireRenderPass()\n {\n this._RequireRenderEncoder();\n\n // A caller that encodes on the pass directly binds what it likes, so what\n // this queue believes the encoder holds is no longer true.\n this._encoderState = { pipeline: null, vertexBuffers: [], indexBuffer: null, bindGroups: [] };\n\n return this._renderPass;\n }\n\n /** Carbon's `GetRenderEncoder`: the current one, or a new one. */\n _RequireRenderEncoder()\n {\n if (!this._inFrame) fail(\"a draw outside a frame\");\n\n if (this._currentEncoderType === EncoderType.RENDER && !this._pendingRenderPassHint) return;\n\n this._GetRenderEncoder();\n }\n\n /** Opens a render encoder, folding any pending hint into its descriptor. */\n _GetRenderEncoder()\n {\n this._ReleaseEncoder();\n\n // A hint's actions win over a pending clear's, as Metal applies the hint\n // over a descriptor already holding the clear; opening the pass consumes\n // both (`ApplyRenderPassHint`, then `ResetClearState`).\n const hint = this._pendingRenderPassHint ?? this._pendingClear;\n const attachments = ApplyRenderPassHint(hint);\n\n this._pendingRenderPassHint = null;\n this._pendingClear = null;\n this._passCount += 1;\n this._currentEncoderType = EncoderType.RENDER;\n this._events.push({ type: \"open\", encoderType: EncoderType.RENDER, attachments });\n\n if (this._commandEncoder)\n {\n this._renderPass = this._commandEncoder.beginRenderPass(this._describePass(attachments));\n this._encoderState = { pipeline: null, vertexBuffers: [], indexBuffer: null, bindGroups: [] };\n }\n }\n\n /** Carbon's `ReleaseEncoder( true )`. */\n _ReleaseEncoder()\n {\n if (this._currentEncoderType === EncoderType.NONE) return;\n\n // The pass ends BEFORE the close event, so a caller draining events after\n // a close can rely on the pass already being finished rather than racing it.\n if (this._renderPass)\n {\n this._renderPass.end();\n this._renderPass = null;\n }\n\n if (this._computePass)\n {\n this._computePass.end();\n this._computePass = null;\n }\n\n this._events.push({ type: \"close\", encoderType: this._currentEncoderType });\n this._currentEncoderType = EncoderType.NONE;\n }\n\n /** Takes the recorded events, leaving the queue's list empty. */\n _Drain()\n {\n const events = this._events;\n\n this._events = [];\n\n return events;\n }\n}\n\n\n/** Whether two dynamic-offset lists bind the same regions. */\nfunction sameOffsets(first, second)\n{\n if (first === second) return true;\n if (!first || !second || first.length !== second.length) return false;\n\n for (let index = 0; index < first.length; index += 1)\n {\n if (first[index] !== second[index]) return false;\n }\n\n return true;\n}\n\n\n/**\n * Turns a declared hint into load and store operations, as Carbon's\n * `ApplyRenderPassHint` writes them into its pass descriptor\n * (`MetalWorkQueue.mm:773-809`).\n *\n * NO HINT IS NOT DONT_CARE. Carbon only applies actions when a hint is pending\n * and otherwise leaves the descriptor as it was, so an absent hint returns null\n * and the caller keeps its own defaults rather than being told to discard.\n *\n * @param {object} [hint] A pending hint.\n * @returns {object|null} `{ colors, depth }` with `load`/`store` per attachment.\n */\nexport function ApplyRenderPassHint(hint)\n{\n if (!hint) return null;\n\n return {\n colors: hint.colors.map(Describe),\n depth: hint.depth ? Describe(hint.depth) : null\n };\n}\n\nfunction Describe(attachment)\n{\n return {\n loadOp: LoadOp(attachment.load),\n storeOp: attachment.store === Tr2StoreAction.STORE ? \"store\" : \"discard\",\n clearValue: attachment.clearColor ?? attachment.clearValue ?? 0\n };\n}\n\nfunction LoadOp(action)\n{\n if (action === Tr2LoadAction.CLEAR) return \"clear\";\n if (action === Tr2LoadAction.LOAD) return \"load\";\n\n // DONT_CARE has no WebGPU spelling - the API has no \"contents are undefined\"\n // load. `clear` is the honest mapping: `load` would promise to preserve\n // contents the caller has said it does not need, which costs a fetch on\n // exactly the tile-based hardware the hint exists for.\n return \"clear\";\n}\n\n\n// DECLARED AS A CALL, NOT A DECORATOR. The abstraction layer is imported\n// straight from source by its tests - `#trinityal/...` resolves to `src/` - and\n// raw Node cannot parse decorator syntax, so a decorator here breaks every test\n// that reaches this file without a build first. `CjsSchema.define` is the same\n// metadata through the door the schema already provides for exactly this, and\n// it keeps the layer free of the decorator chain it has never carried.\nCjsSchema.define(CjsWebgpuWorkQueue, { className: \"CjsWebgpuWorkQueue\", modelledOn: \"MetalWorkQueue\" });\n"],"names":["fail","message","error","Error","code","EncoderType","Object","freeze","NONE","RENDER","COMPUTE","CjsWebgpuWorkQueue","_currentEncoderType","_pendingRenderPassHint","_pendingClear","_events","_passCount","_inFrame","_colorAttachments","_depthAttachment","GetCurrentEncoderType","GetPassCount","HasPendingRenderPassHint","BeginFrame","_pending","pipeline","vertexBuffers","indexBuffer","bindGroups","push","type","_Drain","EndFrame","_GetRenderEncoder","_ReleaseEncoder","RenderPassHint","colors","depth","Array","isArray","EndRenderPassHint","ClearAttachment","_FlushOutstandingOperations","hint","EndCurrentRenderPass","SetCurrentEncoder","encoderType","_commandEncoder","_computePass","beginComputePass","label","_encoderState","GenerateMipMaps","texture","generator","Encode","CopyTextureToTexture","source","sourceSlice","sourceMip","sourceOrigin","size","destination","destinationSlice","destinationMip","destinationOrigin","copyTextureToTexture","mipLevel","origin","x","y","z","ClearBuffer","buffer","clearBuffer","CopyDepthShadow","EncodeDepthShadowCopy","SetComputePipeline","computePipeline","DispatchThreadgroups","events","pass","setPipeline","index","entry","entries","setBindGroup","bindGroup","dynamicOffsets","dispatchWorkgroups","SetRenderAttachments","slice","Number","isInteger","current","loadOp","storeOp","SetDepthAttachment","GetAttachments","map","attachment","DrawIndexedPrimitives","indexCount","instanceCount","startIndex","baseVertex","startInstance","_RequireRenderEncoder","indexed","_renderPass","_EmitRenderEncoderState","drawIndexed","_viewport","SetViewport","originX","originY","width","height","znear","zfar","SetBindGroup","length","SetRenderPipeline","SetVertexBuffer","slot","offset","SetIndexBuffer","format","live","want","viewport","_EmitViewport","forEach","bound","sameOffsets","setVertexBuffer","setIndexBuffer","find","Boolean","GetWidth","Infinity","GetHeight","Math","min","max","minDepth","maxDepth","setViewport","DrawPrimitives","vertexCount","startVertex","draw","_describePass","SetCommandEncoder","commandEncoder","describePass","beginRenderPass","GetRenderPass","GetRenderEncoder","RequireRenderPass","attachments","ApplyRenderPassHint","end","first","second","Describe","LoadOp","load","store","Tr2StoreAction","STORE","clearValue","clearColor","action","Tr2LoadAction","CLEAR","LOAD","CjsSchema","define","className","modelledOn"],"mappings":";;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA,SAASA,IAAIA,CAACC,OAAO,EACrB;EACE,MAAMC,KAAK,GAAG,IAAIC,KAAK,CAAC,CAAA,oBAAA,EAAuBF,OAAO,EAAE,CAAC;EACzDC,KAAK,CAACE,IAAI,GAAG,+BAA+B;AAC5C,EAAA,MAAMF,KAAK;AACb;;AAGA;MACaG,WAAW,GAAGC,MAAM,CAACC,MAAM,CAAC;AACvCC,EAAAA,IAAI,EAAE,MAAM;AACZC,EAAAA,MAAM,EAAE,QAAQ;AAChBC,EAAAA,OAAO,EAAE;AACX,CAAC;;AAGD;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,kBAAkB,CAC/B;AACE;EACAC,mBAAmB,GAAGP,WAAW,CAACG,IAAI;;AAEtC;AACAK,EAAAA,sBAAsB,GAAG,IAAI;;AAE7B;AACF;AACA;AACA;AACEC,EAAAA,aAAa,GAAG,IAAI;;AAEpB;AACAC,EAAAA,OAAO,GAAG,EAAE;;AAEZ;AACAC,EAAAA,UAAU,GAAG,CAAC;;AAEd;AACAC,EAAAA,QA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-10,6 +10,16 @@ behavior is still generator-owned. Package visibility is recorded from the
|
|
|
10
10
|
actual export graph; a source-level `export class` alone does not make a class
|
|
11
11
|
part of the public package API.
|
|
12
12
|
|
|
13
|
+
<!-- class:Tr2GpuStructuredBuffer -->
|
|
14
|
+
## `Tr2GpuStructuredBuffer`
|
|
15
|
+
|
|
16
|
+
Describes the element count, stride, and creation flags of a GPU structured buffer.
|
|
17
|
+
|
|
18
|
+
- Export: `@carbonenginejs/runtime/trinity/core`
|
|
19
|
+
- Source: `src/trinity/core/device/Tr2GpuStructuredBuffer.js`
|
|
20
|
+
- Visibility: Public
|
|
21
|
+
- Kind: Carbon
|
|
22
|
+
|
|
13
23
|
<!-- class:Tr2ReflectionProbe -->
|
|
14
24
|
## `Tr2ReflectionProbe`
|
|
15
25
|
|
|
@@ -20,23 +30,23 @@ Filters a cube into the prefiltered HDR reflection cube Eve's scene binds as its
|
|
|
20
30
|
- Visibility: Public
|
|
21
31
|
- Kind: Carbon
|
|
22
32
|
|
|
23
|
-
<!-- class:
|
|
24
|
-
## `
|
|
33
|
+
<!-- class:EveOccluder -->
|
|
34
|
+
## `EveOccluder`
|
|
25
35
|
|
|
26
|
-
|
|
36
|
+
A lens flare's occlusion test: sprites drawn against the scene depth whose shader counts, into the flare's FlareOcclusionBuffer slot, how many of their pixels pass.
|
|
27
37
|
|
|
28
|
-
- Export: `@carbonenginejs/runtime/trinity/
|
|
29
|
-
- Source: `src/trinity/
|
|
38
|
+
- Export: `@carbonenginejs/runtime/trinity/eve`
|
|
39
|
+
- Source: `src/trinity/eve/effect/lensflare/EveOccluder.js`
|
|
30
40
|
- Visibility: Public
|
|
31
|
-
- Kind: Carbon
|
|
41
|
+
- Kind: Carbon
|
|
32
42
|
|
|
33
|
-
<!-- class:
|
|
34
|
-
## `
|
|
43
|
+
<!-- class:EveCloudEditableVolume -->
|
|
44
|
+
## `EveCloudEditableVolume`
|
|
35
45
|
|
|
36
|
-
|
|
46
|
+
Holds the editable voxel dimensions, bitmap and texture backing, control balls, and curve sets used to author a cloud volume.
|
|
37
47
|
|
|
38
48
|
- Export: `@carbonenginejs/runtime/trinity/generated`
|
|
39
|
-
- Source: `src/trinity/generated/eve/
|
|
49
|
+
- Source: `src/trinity/generated/eve/child/EveCloudEditableVolume.js`
|
|
40
50
|
- Visibility: Public
|
|
41
51
|
- Kind: Carbon generated
|
|
42
52
|
|
|
@@ -300,16 +310,6 @@ Carries nested GPU timing zones, frame fences, messages, and capture state for o
|
|
|
300
310
|
- Visibility: Public
|
|
301
311
|
- Kind: Carbon generated
|
|
302
312
|
|
|
303
|
-
<!-- class:Tr2GpuStructuredBuffer -->
|
|
304
|
-
## `Tr2GpuStructuredBuffer`
|
|
305
|
-
|
|
306
|
-
Describes the element count, stride, and creation flags of a GPU structured buffer.
|
|
307
|
-
|
|
308
|
-
- Export: `@carbonenginejs/runtime/trinity/generated`
|
|
309
|
-
- Source: `src/trinity/generated/trinityCore/Tr2GpuStructuredBuffer.js`
|
|
310
|
-
- Visibility: Public
|
|
311
|
-
- Kind: Carbon generated
|
|
312
|
-
|
|
313
313
|
<!-- class:Tr2GrannyPrimitiveSet -->
|
|
314
314
|
## `Tr2GrannyPrimitiveSet`
|
|
315
315
|
|
|
@@ -228,7 +228,7 @@ Carbon's post-process renderer: the chain from the scene's colour buffer to the
|
|
|
228
228
|
<!-- class:Tr2SSAO -->
|
|
229
229
|
## `Tr2SSAO`
|
|
230
230
|
|
|
231
|
-
Carbon's authored
|
|
231
|
+
Carbon's SSAO: its authored settings and quality controls, and the CORTAO filter that turns the depth and normal maps into the SSAOMap.
|
|
232
232
|
|
|
233
233
|
- Export: `@carbonenginejs/runtime/trinity/postProcess`
|
|
234
234
|
- Source: `src/trinity/postProcess/Tr2SSAO.js`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@carbonenginejs/runtime",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.7",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Browser-safe CarbonEngineJS runtime: resource and format readers, the Trinity/EVE object graph, SOF, audio, character, and the WebGPU renderer.",
|
|
6
6
|
"type": "module",
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { applyDecs2311 as _applyDecs2311 } from '../../../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
-
import { edit, type } from '#schema';
|
|
3
|
-
import { CjsModel } from '#model';
|
|
4
|
-
|
|
5
|
-
let _initClass, _init_sprites, _init_extra_sprites, _init_name, _init_extra_name, _init_display, _init_extra_display;
|
|
6
|
-
|
|
7
|
-
/** Groups sprite occlusion elements that can be displayed as one named EVE scene effect. */
|
|
8
|
-
let _EveOccluder;
|
|
9
|
-
class EveOccluder extends CjsModel {
|
|
10
|
-
static {
|
|
11
|
-
({
|
|
12
|
-
e: [_init_sprites, _init_extra_sprites, _init_name, _init_extra_name, _init_display, _init_extra_display],
|
|
13
|
-
c: [_EveOccluder, _initClass]
|
|
14
|
-
} = _applyDecs2311(this, [type.define({
|
|
15
|
-
className: "EveOccluder",
|
|
16
|
-
family: "eve/effect",
|
|
17
|
-
purpose: "Groups sprite occlusion elements that can be displayed as one named EVE scene effect."
|
|
18
|
-
})], [[[edit, edit.read, edit, edit.persist, void 0, type.list("EveTransform")], 16, "sprites"], [[edit, edit.readwrite, edit, edit.persist, type, type.string], 16, "name"], [[edit, edit.readwrite, edit, edit.persist, type, type.boolean], 16, "display"]], 0, void 0, CjsModel));
|
|
19
|
-
}
|
|
20
|
-
constructor(...args) {
|
|
21
|
-
super(...args);
|
|
22
|
-
_init_extra_display(this);
|
|
23
|
-
}
|
|
24
|
-
/** m_sprites (PEveTransformVector) [READ, PERSIST] */
|
|
25
|
-
sprites = _init_sprites(this, []);
|
|
26
|
-
|
|
27
|
-
/** m_name (std::string) [READWRITE, PERSIST] */
|
|
28
|
-
name = (_init_extra_sprites(this), _init_name(this, ""));
|
|
29
|
-
|
|
30
|
-
/** m_display (bool) [READWRITE, PERSIST] */
|
|
31
|
-
display = (_init_extra_name(this), _init_display(this, true));
|
|
32
|
-
static {
|
|
33
|
-
_initClass();
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export { _EveOccluder as EveOccluder };
|
|
38
|
-
//# sourceMappingURL=EveOccluder.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EveOccluder.js","sources":["../../../../../../src/trinity/generated/eve/effect/EveOccluder.js"],"sourcesContent":["// Source: trinity/trinity/Eve/EveOccluder.h\n// Generated by format-carbon carbon-class --emit. Verify against eve/effect/EveOccluder.json.\r\nimport { edit, type } from \"#schema\";\r\nimport { CjsModel } from \"#model\";\r\n\r\n/** Groups sprite occlusion elements that can be displayed as one named EVE scene effect. */\n@type.define({ className: \"EveOccluder\", family: \"eve/effect\", purpose: \"Groups sprite occlusion elements that can be displayed as one named EVE scene effect.\" })\r\nexport class EveOccluder extends CjsModel\r\n{\r\n\r\n /** m_sprites (PEveTransformVector) [READ, PERSIST] */\r\n @edit.read\r\n @edit.persist\r\n @type.list(\"EveTransform\")\r\n sprites = [];\r\n\r\n /** m_name (std::string) [READWRITE, PERSIST] */\r\n @edit.readwrite\r\n @edit.persist\r\n @type.string\r\n name = \"\";\r\n\r\n /** m_display (bool) [READWRITE, PERSIST] */\r\n @edit.readwrite\r\n @edit.persist\r\n @type.boolean\r\n display = true;\r\n\r\n}\r\n"],"names":["_EveOccluder","EveOccluder","CjsModel","e","_init_sprites","_init_extra_sprites","_init_name","_init_extra_name","_init_display","_init_extra_display","c","_initClass","_applyDecs","type","define","className","family","purpose","edit","read","persist","list","readwrite","string","boolean","constructor","args","sprites","name","display"],"mappings":";;;;;;AAKA;AAAA,IAAAA;AACA,MAAAC,WAAA,SACiCC,QAAQ,CACzC;AAAA,EAAA;AAAA,IAAA,CAAA;MAAAC,CAAA,EAAA,CAAAC,aAAA,EAAAC,mBAAA,EAAAC,UAAA,EAA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