@forgeax/engine-rhi-debug 0.0.0-dev.8d955ade1c79
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/README.md +178 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/__tests__/bootstrap-integration.test.d.ts +2 -0
- package/dist/__tests__/bootstrap-integration.test.d.ts.map +1 -0
- package/dist/__tests__/consumer-inventory.unit.test.d.ts +2 -0
- package/dist/__tests__/consumer-inventory.unit.test.d.ts.map +1 -0
- package/dist/__tests__/copy-src-usage-validity.dawn.test.d.ts +15 -0
- package/dist/__tests__/copy-src-usage-validity.dawn.test.d.ts.map +1 -0
- package/dist/__tests__/coverage-invariant.test-d.d.ts +2 -0
- package/dist/__tests__/coverage-invariant.test-d.d.ts.map +1 -0
- package/dist/__tests__/coverage-invariant.unit.test.d.ts +2 -0
- package/dist/__tests__/coverage-invariant.unit.test.d.ts.map +1 -0
- package/dist/__tests__/e2e.browser.test.d.ts +2 -0
- package/dist/__tests__/e2e.browser.test.d.ts.map +1 -0
- package/dist/__tests__/error-code-narrowing.test-d.d.ts +2 -0
- package/dist/__tests__/error-code-narrowing.test-d.d.ts.map +1 -0
- package/dist/__tests__/errors-v7.test-d.d.ts +2 -0
- package/dist/__tests__/errors-v7.test-d.d.ts.map +1 -0
- package/dist/__tests__/errors-v7.unit.test.d.ts +2 -0
- package/dist/__tests__/errors-v7.unit.test.d.ts.map +1 -0
- package/dist/__tests__/errors.unit.test.d.ts +2 -0
- package/dist/__tests__/errors.unit.test.d.ts.map +1 -0
- package/dist/__tests__/event-semantics-coverage.unit.test.d.ts +2 -0
- package/dist/__tests__/event-semantics-coverage.unit.test.d.ts.map +1 -0
- package/dist/__tests__/format-info.unit.test.d.ts +2 -0
- package/dist/__tests__/format-info.unit.test.d.ts.map +1 -0
- package/dist/__tests__/frame-model-parity.test-d.d.ts +2 -0
- package/dist/__tests__/frame-model-parity.test-d.d.ts.map +1 -0
- package/dist/__tests__/frame-model-parity.unit.test.d.ts +2 -0
- package/dist/__tests__/frame-model-parity.unit.test.d.ts.map +1 -0
- package/dist/__tests__/guard-gates.test.d.ts +2 -0
- package/dist/__tests__/guard-gates.test.d.ts.map +1 -0
- package/dist/__tests__/public-surface.integration.test.d.ts +2 -0
- package/dist/__tests__/public-surface.integration.test.d.ts.map +1 -0
- package/dist/__tests__/readback-fault-cleanup.unit.test.d.ts +2 -0
- package/dist/__tests__/readback-fault-cleanup.unit.test.d.ts.map +1 -0
- package/dist/__tests__/readback-format-matrix.dawn.test.d.ts +2 -0
- package/dist/__tests__/readback-format-matrix.dawn.test.d.ts.map +1 -0
- package/dist/__tests__/readback-format-matrix.unit.test.d.ts +2 -0
- package/dist/__tests__/readback-format-matrix.unit.test.d.ts.map +1 -0
- package/dist/__tests__/readback-matrix-fixture.d.ts +32 -0
- package/dist/__tests__/readback-matrix-fixture.d.ts.map +1 -0
- package/dist/__tests__/recorder-bootstrap.unit.test.d.ts +2 -0
- package/dist/__tests__/recorder-bootstrap.unit.test.d.ts.map +1 -0
- package/dist/__tests__/recorder-budget.unit.test.d.ts +2 -0
- package/dist/__tests__/recorder-budget.unit.test.d.ts.map +1 -0
- package/dist/__tests__/recorder-fail-fast.unit.test.d.ts +2 -0
- package/dist/__tests__/recorder-fail-fast.unit.test.d.ts.map +1 -0
- package/dist/__tests__/recorder-lifecycle.unit.test.d.ts +2 -0
- package/dist/__tests__/recorder-lifecycle.unit.test.d.ts.map +1 -0
- package/dist/__tests__/recorder-push-event.unit.test.d.ts +2 -0
- package/dist/__tests__/recorder-push-event.unit.test.d.ts.map +1 -0
- package/dist/__tests__/recorder-session.integration.test.d.ts +2 -0
- package/dist/__tests__/recorder-session.integration.test.d.ts.map +1 -0
- package/dist/__tests__/recorder-session.unit.test.d.ts +2 -0
- package/dist/__tests__/recorder-session.unit.test.d.ts.map +1 -0
- package/dist/__tests__/recorder-steady-frame.dawn.test.d.ts +2 -0
- package/dist/__tests__/recorder-steady-frame.dawn.test.d.ts.map +1 -0
- package/dist/__tests__/replay-fail-fast.unit.test.d.ts +2 -0
- package/dist/__tests__/replay-fail-fast.unit.test.d.ts.map +1 -0
- package/dist/__tests__/replay-session.dawn.test.d.ts +2 -0
- package/dist/__tests__/replay-session.dawn.test.d.ts.map +1 -0
- package/dist/__tests__/replay-session.test-d.d.ts +2 -0
- package/dist/__tests__/replay-session.test-d.d.ts.map +1 -0
- package/dist/__tests__/replay-session.unit.test.d.ts +2 -0
- package/dist/__tests__/replay-session.unit.test.d.ts.map +1 -0
- package/dist/__tests__/resolve-texture-descriptor.unit.test.d.ts +2 -0
- package/dist/__tests__/resolve-texture-descriptor.unit.test.d.ts.map +1 -0
- package/dist/__tests__/resource-lifecycle.unit.test.d.ts +2 -0
- package/dist/__tests__/resource-lifecycle.unit.test.d.ts.map +1 -0
- package/dist/__tests__/rhi-debug-fresh-replay.dawn.test.d.ts +2 -0
- package/dist/__tests__/rhi-debug-fresh-replay.dawn.test.d.ts.map +1 -0
- package/dist/__tests__/tape-index.unit.test.d.ts +2 -0
- package/dist/__tests__/tape-index.unit.test.d.ts.map +1 -0
- package/dist/__tests__/tape-v7-invalid.unit.test.d.ts +2 -0
- package/dist/__tests__/tape-v7-invalid.unit.test.d.ts.map +1 -0
- package/dist/__tests__/tape-v7-roundtrip.unit.test.d.ts +2 -0
- package/dist/__tests__/tape-v7-roundtrip.unit.test.d.ts.map +1 -0
- package/dist/__tests__/tape-v7-version.unit.test.d.ts +2 -0
- package/dist/__tests__/tape-v7-version.unit.test.d.ts.map +1 -0
- package/dist/__tests__/tree-shake.unit.test.d.ts +2 -0
- package/dist/__tests__/tree-shake.unit.test.d.ts.map +1 -0
- package/dist/__tests__/types.test.d.ts +2 -0
- package/dist/__tests__/types.test.d.ts.map +1 -0
- package/dist/browser.d.ts +45 -0
- package/dist/browser.d.ts.map +1 -0
- package/dist/browser.mjs +83 -0
- package/dist/browser.mjs.map +1 -0
- package/dist/errors.d.ts +85 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/frame-model.d.ts +158 -0
- package/dist/frame-model.d.ts.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.mjs +10415 -0
- package/dist/index.mjs.map +1 -0
- package/dist/protocol/codec.d.ts +6 -0
- package/dist/protocol/codec.d.ts.map +1 -0
- package/dist/protocol/event-semantics.d.ts +15 -0
- package/dist/protocol/event-semantics.d.ts.map +1 -0
- package/dist/protocol/tape-index.d.ts +30 -0
- package/dist/protocol/tape-index.d.ts.map +1 -0
- package/dist/protocol/types.d.ts +44 -0
- package/dist/protocol/types.d.ts.map +1 -0
- package/dist/protocol/validation.d.ts +7 -0
- package/dist/protocol/validation.d.ts.map +1 -0
- package/dist/readback.d.ts +156 -0
- package/dist/readback.d.ts.map +1 -0
- package/dist/recorder/assemble.d.ts +11 -0
- package/dist/recorder/assemble.d.ts.map +1 -0
- package/dist/recorder/closure.d.ts +39 -0
- package/dist/recorder/closure.d.ts.map +1 -0
- package/dist/recorder/core.d.ts +296 -0
- package/dist/recorder/core.d.ts.map +1 -0
- package/dist/recorder/device.d.ts +4 -0
- package/dist/recorder/device.d.ts.map +1 -0
- package/dist/recorder/encoder.d.ts +5 -0
- package/dist/recorder/encoder.d.ts.map +1 -0
- package/dist/recorder/lifecycle.d.ts +20 -0
- package/dist/recorder/lifecycle.d.ts.map +1 -0
- package/dist/recorder/pass.d.ts +6 -0
- package/dist/recorder/pass.d.ts.map +1 -0
- package/dist/recorder/proxy.d.ts +19 -0
- package/dist/recorder/proxy.d.ts.map +1 -0
- package/dist/recorder/queue.d.ts +4 -0
- package/dist/recorder/queue.d.ts.map +1 -0
- package/dist/recorder/resource-registry.d.ts +15 -0
- package/dist/recorder/resource-registry.d.ts.map +1 -0
- package/dist/recorder/session.d.ts +25 -0
- package/dist/recorder/session.d.ts.map +1 -0
- package/dist/recorder/shader.d.ts +3 -0
- package/dist/recorder/shader.d.ts.map +1 -0
- package/dist/recorder/snapshot.d.ts +10 -0
- package/dist/recorder/snapshot.d.ts.map +1 -0
- package/dist/recorder/wrap.d.ts +4 -0
- package/dist/recorder/wrap.d.ts.map +1 -0
- package/dist/recorder.d.ts +7 -0
- package/dist/recorder.d.ts.map +1 -0
- package/dist/replay/device-request.d.ts +8 -0
- package/dist/replay/device-request.d.ts.map +1 -0
- package/dist/replay/execute-support.d.ts +33 -0
- package/dist/replay/execute-support.d.ts.map +1 -0
- package/dist/replay/execute.d.ts +18 -0
- package/dist/replay/execute.d.ts.map +1 -0
- package/dist/replay/readback.d.ts +32 -0
- package/dist/replay/readback.d.ts.map +1 -0
- package/dist/replay/resources.d.ts +57 -0
- package/dist/replay/resources.d.ts.map +1 -0
- package/dist/replay/session.d.ts +49 -0
- package/dist/replay/session.d.ts.map +1 -0
- package/dist/replay/texture-format.d.ts +21 -0
- package/dist/replay/texture-format.d.ts.map +1 -0
- package/dist/texel-decode.d.ts +35 -0
- package/dist/texel-decode.d.ts.map +1 -0
- package/dist/texel-layout.d.ts +76 -0
- package/dist/texel-layout.d.ts.map +1 -0
- package/dist/types.d.ts +722 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +72 -0
- package/src/__tests__/bootstrap-integration.test.ts +268 -0
- package/src/__tests__/consumer-inventory.unit.test.ts +154 -0
- package/src/__tests__/copy-src-usage-validity.dawn.test.ts +117 -0
- package/src/__tests__/coverage-invariant.test-d.ts +115 -0
- package/src/__tests__/coverage-invariant.unit.test.ts +45 -0
- package/src/__tests__/e2e.browser.test.ts +239 -0
- package/src/__tests__/error-code-narrowing.test-d.ts +32 -0
- package/src/__tests__/errors-v7.test-d.ts +19 -0
- package/src/__tests__/errors-v7.unit.test.ts +15 -0
- package/src/__tests__/errors.unit.test.ts +83 -0
- package/src/__tests__/event-semantics-coverage.unit.test.ts +22 -0
- package/src/__tests__/format-info.unit.test.ts +85 -0
- package/src/__tests__/frame-model-parity.test-d.ts +20 -0
- package/src/__tests__/frame-model-parity.unit.test.ts +285 -0
- package/src/__tests__/guard-gates.test.ts +317 -0
- package/src/__tests__/public-surface.integration.test.ts +38 -0
- package/src/__tests__/readback-fault-cleanup.unit.test.ts +66 -0
- package/src/__tests__/readback-format-matrix.dawn.test.ts +378 -0
- package/src/__tests__/readback-format-matrix.unit.test.ts +120 -0
- package/src/__tests__/readback-matrix-fixture.ts +20 -0
- package/src/__tests__/recorder-bootstrap.unit.test.ts +302 -0
- package/src/__tests__/recorder-budget.unit.test.ts +42 -0
- package/src/__tests__/recorder-fail-fast.unit.test.ts +434 -0
- package/src/__tests__/recorder-lifecycle.unit.test.ts +42 -0
- package/src/__tests__/recorder-push-event.unit.test.ts +573 -0
- package/src/__tests__/recorder-session.integration.test.ts +32 -0
- package/src/__tests__/recorder-session.unit.test.ts +63 -0
- package/src/__tests__/recorder-steady-frame.dawn.test.ts +52 -0
- package/src/__tests__/replay-fail-fast.unit.test.ts +155 -0
- package/src/__tests__/replay-session.dawn.test.ts +220 -0
- package/src/__tests__/replay-session.test-d.ts +27 -0
- package/src/__tests__/replay-session.unit.test.ts +171 -0
- package/src/__tests__/resolve-texture-descriptor.unit.test.ts +144 -0
- package/src/__tests__/resource-lifecycle.unit.test.ts +114 -0
- package/src/__tests__/rhi-debug-fresh-replay.dawn.test.ts +178 -0
- package/src/__tests__/tape-index.unit.test.ts +56 -0
- package/src/__tests__/tape-v7-invalid.unit.test.ts +45 -0
- package/src/__tests__/tape-v7-roundtrip.unit.test.ts +66 -0
- package/src/__tests__/tape-v7-version.unit.test.ts +13 -0
- package/src/__tests__/tree-shake.unit.test.ts +151 -0
- package/src/__tests__/types.test.ts +257 -0
- package/src/browser.ts +146 -0
- package/src/errors.ts +173 -0
- package/src/frame-model.ts +753 -0
- package/src/index.ts +92 -0
- package/src/pako.d.ts +8 -0
- package/src/protocol/codec.ts +220 -0
- package/src/protocol/event-semantics.ts +180 -0
- package/src/protocol/tape-index.ts +120 -0
- package/src/protocol/types.ts +60 -0
- package/src/protocol/validation.ts +173 -0
- package/src/readback.ts +804 -0
- package/src/recorder/assemble.ts +192 -0
- package/src/recorder/closure.ts +408 -0
- package/src/recorder/core.ts +587 -0
- package/src/recorder/device.ts +474 -0
- package/src/recorder/encoder.ts +251 -0
- package/src/recorder/lifecycle.ts +847 -0
- package/src/recorder/pass.ts +241 -0
- package/src/recorder/proxy.ts +59 -0
- package/src/recorder/queue.ts +109 -0
- package/src/recorder/resource-registry.ts +53 -0
- package/src/recorder/session.ts +152 -0
- package/src/recorder/shader.ts +47 -0
- package/src/recorder/snapshot.ts +38 -0
- package/src/recorder/wrap.ts +157 -0
- package/src/recorder.ts +15 -0
- package/src/replay/device-request.ts +38 -0
- package/src/replay/execute-support.ts +243 -0
- package/src/replay/execute.ts +870 -0
- package/src/replay/readback.ts +671 -0
- package/src/replay/resources.ts +154 -0
- package/src/replay/session.ts +509 -0
- package/src/replay/texture-format.ts +99 -0
- package/src/texel-decode.ts +289 -0
- package/src/texel-layout.ts +324 -0
- package/src/types.ts +888 -0
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
// @forgeax/engine-rhi-debug/src/recorder/encoder -- command encoder proxy owner.
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
Buffer,
|
|
5
|
+
ComputePassDescriptor,
|
|
6
|
+
RenderPassDescriptor,
|
|
7
|
+
RhiCommandEncoder,
|
|
8
|
+
} from '@forgeax/engine-rhi';
|
|
9
|
+
import type { HandleId } from '../types';
|
|
10
|
+
import type { RecorderInternal } from './core';
|
|
11
|
+
import { allocHandleId, getHandleId, pushEvent } from './core';
|
|
12
|
+
import { createComputePassProxy, createRenderPassProxy } from './pass';
|
|
13
|
+
|
|
14
|
+
export function createCommandEncoderProxy(
|
|
15
|
+
s: RecorderInternal,
|
|
16
|
+
realEnc: RhiCommandEncoder,
|
|
17
|
+
cmdHId: HandleId,
|
|
18
|
+
): RhiCommandEncoder {
|
|
19
|
+
return {
|
|
20
|
+
beginRenderPass(desc: RenderPassDescriptor) {
|
|
21
|
+
const passHId = allocHandleId('renderPass');
|
|
22
|
+
// I-2 fix-up (round 1, dawn smoke): walk colorAttachments +
|
|
23
|
+
// depthStencilAttachment to extract the textureView handleIds
|
|
24
|
+
// recorded under createTextureView. Without this the replayer
|
|
25
|
+
// would dereference the original GPUTextureView brand directly,
|
|
26
|
+
// which fails on a fresh device (cross-device GPU object reuse).
|
|
27
|
+
const colorAttachmentViewHandleIds: (HandleId | undefined)[] = [];
|
|
28
|
+
const colorAttachmentResolveTargetHandleIds: (HandleId | undefined)[] = [];
|
|
29
|
+
for (const att of desc.colorAttachments) {
|
|
30
|
+
if (att === null || att === undefined) {
|
|
31
|
+
colorAttachmentViewHandleIds.push(undefined);
|
|
32
|
+
colorAttachmentResolveTargetHandleIds.push(undefined);
|
|
33
|
+
} else {
|
|
34
|
+
const view = att.view;
|
|
35
|
+
const id =
|
|
36
|
+
view !== undefined && view !== null ? s.handleMap.get(view as object) : undefined;
|
|
37
|
+
colorAttachmentViewHandleIds.push(id);
|
|
38
|
+
const resolveTarget = att.resolveTarget;
|
|
39
|
+
const resolveTargetId =
|
|
40
|
+
resolveTarget !== undefined && resolveTarget !== null
|
|
41
|
+
? s.handleMap.get(resolveTarget as object)
|
|
42
|
+
: undefined;
|
|
43
|
+
colorAttachmentResolveTargetHandleIds.push(resolveTargetId);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
let depthStencilViewHandleId: HandleId | undefined;
|
|
47
|
+
if (desc.depthStencilAttachment !== undefined) {
|
|
48
|
+
const dsView = desc.depthStencilAttachment.view;
|
|
49
|
+
if (dsView !== undefined && dsView !== null) {
|
|
50
|
+
depthStencilViewHandleId = s.handleMap.get(dsView as object);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
pushEvent(s, {
|
|
54
|
+
kind: 'beginRenderPass',
|
|
55
|
+
cmdHandleId: cmdHId,
|
|
56
|
+
passHandleId: passHId,
|
|
57
|
+
desc: {
|
|
58
|
+
colorAttachments: Array.from(desc.colorAttachments).map((attachment) =>
|
|
59
|
+
attachment === null || attachment === undefined ? attachment : { ...attachment },
|
|
60
|
+
),
|
|
61
|
+
...(desc.depthStencilAttachment === undefined
|
|
62
|
+
? {}
|
|
63
|
+
: { depthStencilAttachment: { ...desc.depthStencilAttachment } }),
|
|
64
|
+
...(desc.occlusionQuerySet === undefined
|
|
65
|
+
? {}
|
|
66
|
+
: { occlusionQuerySet: desc.occlusionQuerySet }),
|
|
67
|
+
...(desc.timestampWrites === undefined ? {} : { timestampWrites: desc.timestampWrites }),
|
|
68
|
+
...(desc.maxDrawCount === undefined ? {} : { maxDrawCount: desc.maxDrawCount }),
|
|
69
|
+
},
|
|
70
|
+
colorAttachmentViewHandleIds,
|
|
71
|
+
colorAttachmentResolveTargetHandleIds,
|
|
72
|
+
depthStencilViewHandleId,
|
|
73
|
+
});
|
|
74
|
+
const realPass = realEnc.beginRenderPass(desc);
|
|
75
|
+
return createRenderPassProxy(s, realPass, passHId);
|
|
76
|
+
},
|
|
77
|
+
beginComputePass(desc?: ComputePassDescriptor | undefined) {
|
|
78
|
+
const passHId = allocHandleId('computePass');
|
|
79
|
+
pushEvent(s, {
|
|
80
|
+
kind: 'beginComputePass',
|
|
81
|
+
cmdHandleId: cmdHId,
|
|
82
|
+
passHandleId: passHId,
|
|
83
|
+
desc: desc as Partial<GPUComputePassDescriptor> | undefined,
|
|
84
|
+
});
|
|
85
|
+
const realPass = realEnc.beginComputePass(desc);
|
|
86
|
+
return createComputePassProxy(s, realPass, passHId);
|
|
87
|
+
},
|
|
88
|
+
// Passthrough copy/clear methods (event recording added where types permit)
|
|
89
|
+
copyBufferToBuffer(...args: unknown[]) {
|
|
90
|
+
// Overloaded: 3-arg or 5-arg
|
|
91
|
+
if (typeof args[1] === 'number') {
|
|
92
|
+
// 5-arg form: (source, sourceOffset, destination, destinationOffset, size)
|
|
93
|
+
const sourceId = getHandleId(s, args[0] as object, 'buffer');
|
|
94
|
+
const destinationId = getHandleId(s, args[2] as object, 'buffer');
|
|
95
|
+
pushEvent(s, {
|
|
96
|
+
kind: 'copyBufferToBuffer',
|
|
97
|
+
cmdHandleId: cmdHId,
|
|
98
|
+
sourceHandleId: sourceId,
|
|
99
|
+
sourceOffset: args[1] as number,
|
|
100
|
+
destinationHandleId: destinationId,
|
|
101
|
+
destinationOffset: args[3] as number,
|
|
102
|
+
size: args[4] as number,
|
|
103
|
+
});
|
|
104
|
+
(realEnc.copyBufferToBuffer as (...args: unknown[]) => void)(...args);
|
|
105
|
+
} else {
|
|
106
|
+
// 3-arg form: (source, destination, size?)
|
|
107
|
+
const sourceId = getHandleId(s, args[0] as object, 'buffer');
|
|
108
|
+
const destinationId = getHandleId(s, args[1] as object, 'buffer');
|
|
109
|
+
const size = args[2] as number | undefined;
|
|
110
|
+
pushEvent(s, {
|
|
111
|
+
kind: 'copyBufferToBuffer',
|
|
112
|
+
cmdHandleId: cmdHId,
|
|
113
|
+
sourceHandleId: sourceId,
|
|
114
|
+
sourceOffset: 0,
|
|
115
|
+
destinationHandleId: destinationId,
|
|
116
|
+
destinationOffset: 0,
|
|
117
|
+
size: (size ?? 0) as number,
|
|
118
|
+
});
|
|
119
|
+
realEnc.copyBufferToBuffer(args[0] as Buffer, args[1] as Buffer, size);
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
copyBufferToTexture(source, destination, copySize) {
|
|
123
|
+
const bufId = getHandleId(s, (source as { buffer: object }).buffer as object, 'buffer');
|
|
124
|
+
const texId = getHandleId(
|
|
125
|
+
s,
|
|
126
|
+
(destination as { texture: object }).texture as object,
|
|
127
|
+
'texture',
|
|
128
|
+
);
|
|
129
|
+
const dstPayload: Record<string, unknown> = { textureHandleId: texId };
|
|
130
|
+
if (destination.mipLevel !== undefined) dstPayload.mipLevel = destination.mipLevel;
|
|
131
|
+
if (destination.origin !== undefined) dstPayload.origin = destination.origin;
|
|
132
|
+
if (destination.aspect !== undefined) dstPayload.aspect = destination.aspect;
|
|
133
|
+
pushEvent(s, {
|
|
134
|
+
kind: 'copyBufferToTexture',
|
|
135
|
+
cmdHandleId: cmdHId,
|
|
136
|
+
source: {
|
|
137
|
+
bufferHandleId: bufId,
|
|
138
|
+
offset: source.offset ?? 0,
|
|
139
|
+
bytesPerRow: source.bytesPerRow ?? 0,
|
|
140
|
+
rowsPerImage: source.rowsPerImage ?? 0,
|
|
141
|
+
},
|
|
142
|
+
destination: dstPayload as Omit<GPUTexelCopyTextureInfo, 'texture'> & {
|
|
143
|
+
readonly textureHandleId: HandleId;
|
|
144
|
+
},
|
|
145
|
+
copySize,
|
|
146
|
+
});
|
|
147
|
+
realEnc.copyBufferToTexture(source, destination, copySize);
|
|
148
|
+
},
|
|
149
|
+
copyTextureToBuffer(source, destination, copySize) {
|
|
150
|
+
const texId = getHandleId(s, (source as { texture: object }).texture as object, 'texture');
|
|
151
|
+
const bufId = getHandleId(s, (destination as { buffer: object }).buffer as object, 'buffer');
|
|
152
|
+
const srcPayload: Record<string, unknown> = { textureHandleId: texId };
|
|
153
|
+
if (source.mipLevel !== undefined) srcPayload.mipLevel = source.mipLevel;
|
|
154
|
+
if (source.origin !== undefined) srcPayload.origin = source.origin;
|
|
155
|
+
if (source.aspect !== undefined) srcPayload.aspect = source.aspect;
|
|
156
|
+
pushEvent(s, {
|
|
157
|
+
kind: 'copyTextureToBuffer',
|
|
158
|
+
cmdHandleId: cmdHId,
|
|
159
|
+
source: srcPayload as Omit<GPUTexelCopyTextureInfo, 'texture'> & {
|
|
160
|
+
readonly textureHandleId: HandleId;
|
|
161
|
+
},
|
|
162
|
+
destination: {
|
|
163
|
+
bufferHandleId: bufId,
|
|
164
|
+
offset: destination.offset ?? 0,
|
|
165
|
+
bytesPerRow: destination.bytesPerRow ?? 0,
|
|
166
|
+
rowsPerImage: destination.rowsPerImage ?? 0,
|
|
167
|
+
},
|
|
168
|
+
copySize,
|
|
169
|
+
});
|
|
170
|
+
realEnc.copyTextureToBuffer(source, destination, copySize);
|
|
171
|
+
},
|
|
172
|
+
copyTextureToTexture(source, destination, copySize) {
|
|
173
|
+
const srcTexId = getHandleId(s, (source as { texture: object }).texture as object, 'texture');
|
|
174
|
+
const dstTexId = getHandleId(
|
|
175
|
+
s,
|
|
176
|
+
(destination as { texture: object }).texture as object,
|
|
177
|
+
'texture',
|
|
178
|
+
);
|
|
179
|
+
const srcPayload: Record<string, unknown> = { textureHandleId: srcTexId };
|
|
180
|
+
if (source.mipLevel !== undefined) srcPayload.mipLevel = source.mipLevel;
|
|
181
|
+
if (source.origin !== undefined) srcPayload.origin = source.origin;
|
|
182
|
+
if (source.aspect !== undefined) srcPayload.aspect = source.aspect;
|
|
183
|
+
const dstPayload: Record<string, unknown> = { textureHandleId: dstTexId };
|
|
184
|
+
if (destination.mipLevel !== undefined) dstPayload.mipLevel = destination.mipLevel;
|
|
185
|
+
if (destination.origin !== undefined) dstPayload.origin = destination.origin;
|
|
186
|
+
if (destination.aspect !== undefined) dstPayload.aspect = destination.aspect;
|
|
187
|
+
pushEvent(s, {
|
|
188
|
+
kind: 'copyTextureToTexture',
|
|
189
|
+
cmdHandleId: cmdHId,
|
|
190
|
+
source: srcPayload as Omit<GPUTexelCopyTextureInfo, 'texture'> & {
|
|
191
|
+
readonly textureHandleId: HandleId;
|
|
192
|
+
},
|
|
193
|
+
destination: dstPayload as Omit<GPUTexelCopyTextureInfo, 'texture'> & {
|
|
194
|
+
readonly textureHandleId: HandleId;
|
|
195
|
+
},
|
|
196
|
+
copySize,
|
|
197
|
+
});
|
|
198
|
+
realEnc.copyTextureToTexture(source, destination, copySize);
|
|
199
|
+
},
|
|
200
|
+
clearBuffer(buffer, offset, size) {
|
|
201
|
+
const bufId = getHandleId(s, buffer as object, 'buffer');
|
|
202
|
+
pushEvent(s, {
|
|
203
|
+
kind: 'clearBuffer',
|
|
204
|
+
cmdHandleId: cmdHId,
|
|
205
|
+
handleId: bufId,
|
|
206
|
+
offset,
|
|
207
|
+
size,
|
|
208
|
+
});
|
|
209
|
+
realEnc.clearBuffer(buffer, offset, size);
|
|
210
|
+
},
|
|
211
|
+
resolveQuerySet(querySet, firstQuery, queryCount, destination, destinationOffset) {
|
|
212
|
+
return realEnc.resolveQuerySet(
|
|
213
|
+
querySet,
|
|
214
|
+
firstQuery,
|
|
215
|
+
queryCount,
|
|
216
|
+
destination,
|
|
217
|
+
destinationOffset,
|
|
218
|
+
);
|
|
219
|
+
},
|
|
220
|
+
writeTimestamp(querySet, queryIndex) {
|
|
221
|
+
realEnc.writeTimestamp(querySet, queryIndex);
|
|
222
|
+
},
|
|
223
|
+
pushDebugGroup(groupLabel) {
|
|
224
|
+
pushEvent(s, { kind: 'pushDebugGroup', cmdHandleId: cmdHId, groupLabel });
|
|
225
|
+
realEnc.pushDebugGroup(groupLabel);
|
|
226
|
+
},
|
|
227
|
+
popDebugGroup() {
|
|
228
|
+
pushEvent(s, { kind: 'popDebugGroup', cmdHandleId: cmdHId });
|
|
229
|
+
realEnc.popDebugGroup();
|
|
230
|
+
},
|
|
231
|
+
insertDebugMarker(markerLabel) {
|
|
232
|
+
pushEvent(s, { kind: 'insertDebugMarker', cmdHandleId: cmdHId, markerLabel });
|
|
233
|
+
realEnc.insertDebugMarker(markerLabel);
|
|
234
|
+
},
|
|
235
|
+
finish() {
|
|
236
|
+
pushEvent(s, { kind: 'finish', cmdHandleId: cmdHId });
|
|
237
|
+
const res = realEnc.finish();
|
|
238
|
+
// I-2 fix-up (round 1, dawn smoke handle-graph integrity):
|
|
239
|
+
// alias the resulting CommandBuffer object to the encoder's
|
|
240
|
+
// cmdHandleId so subsequent queue.submit() handle lookups resolve
|
|
241
|
+
// to the SAME id that the createCommandEncoder/finish event pair
|
|
242
|
+
// declared. Without this, submit would register a fresh handleId
|
|
243
|
+
// for the CommandBuffer object and the tape's handle graph
|
|
244
|
+
// integrity check would reject the tape on deserialize.
|
|
245
|
+
if (res.ok) {
|
|
246
|
+
s.handleMap.set(res.value as object, cmdHId);
|
|
247
|
+
}
|
|
248
|
+
return res;
|
|
249
|
+
},
|
|
250
|
+
};
|
|
251
|
+
}
|