@forgeax/engine-rhi-debug 0.1.28 → 0.1.30

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.
Files changed (75) hide show
  1. package/README.md +32 -7
  2. package/dist/__tests__/query-set-lifecycle.unit.test.d.ts +2 -0
  3. package/dist/__tests__/query-set-lifecycle.unit.test.d.ts.map +1 -0
  4. package/dist/__tests__/query-set-replay-fixture.d.ts +39 -0
  5. package/dist/__tests__/query-set-replay-fixture.d.ts.map +1 -0
  6. package/dist/__tests__/recorder-canvas-context.unit.test.d.ts +2 -0
  7. package/dist/__tests__/recorder-canvas-context.unit.test.d.ts.map +1 -0
  8. package/dist/__tests__/timestamp-query-capture.dawn.test.d.ts +2 -0
  9. package/dist/__tests__/timestamp-query-capture.dawn.test.d.ts.map +1 -0
  10. package/dist/index.d.ts +1 -1
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.mjs +527 -58
  13. package/dist/index.mjs.map +1 -1
  14. package/dist/protocol/event-semantics.d.ts +1 -1
  15. package/dist/protocol/event-semantics.d.ts.map +1 -1
  16. package/dist/protocol/types.d.ts +1 -1
  17. package/dist/protocol/types.d.ts.map +1 -1
  18. package/dist/recorder/closure.d.ts.map +1 -1
  19. package/dist/recorder/core.d.ts +10 -1
  20. package/dist/recorder/core.d.ts.map +1 -1
  21. package/dist/recorder/device.d.ts.map +1 -1
  22. package/dist/recorder/encoder.d.ts.map +1 -1
  23. package/dist/recorder/pass.d.ts.map +1 -1
  24. package/dist/recorder/pipeline.d.ts +5 -0
  25. package/dist/recorder/pipeline.d.ts.map +1 -0
  26. package/dist/recorder/proxy.d.ts +3 -1
  27. package/dist/recorder/proxy.d.ts.map +1 -1
  28. package/dist/recorder/session.d.ts +1 -1
  29. package/dist/recorder/session.d.ts.map +1 -1
  30. package/dist/recorder/shader.d.ts +3 -1
  31. package/dist/recorder/shader.d.ts.map +1 -1
  32. package/dist/recorder.d.ts +2 -2
  33. package/dist/recorder.d.ts.map +1 -1
  34. package/dist/replay/execute.d.ts.map +1 -1
  35. package/dist/replay/resources.d.ts +4 -1
  36. package/dist/replay/resources.d.ts.map +1 -1
  37. package/dist/replay/session.d.ts +7 -0
  38. package/dist/replay/session.d.ts.map +1 -1
  39. package/dist/types.d.ts +45 -6
  40. package/dist/types.d.ts.map +1 -1
  41. package/package.json +6 -6
  42. package/src/__tests__/coverage-invariant.test-d.ts +4 -5
  43. package/src/__tests__/coverage-invariant.unit.test.ts +6 -17
  44. package/src/__tests__/e2e.browser.test.ts +50 -0
  45. package/src/__tests__/guard-gates.test.ts +1 -1
  46. package/src/__tests__/query-set-lifecycle.unit.test.ts +265 -0
  47. package/src/__tests__/query-set-replay-fixture.ts +553 -0
  48. package/src/__tests__/readback-format-matrix.dawn.test.ts +9 -2
  49. package/src/__tests__/recorder-canvas-context.unit.test.ts +67 -0
  50. package/src/__tests__/recorder-session.integration.test.ts +55 -0
  51. package/src/__tests__/recorder-session.unit.test.ts +18 -1
  52. package/src/__tests__/replay-session.dawn.test.ts +171 -0
  53. package/src/__tests__/replay-session.test-d.ts +1 -0
  54. package/src/__tests__/rhi-debug-fresh-replay.dawn.test.ts +61 -0
  55. package/src/__tests__/timestamp-query-capture.dawn.test.ts +61 -0
  56. package/src/index.ts +1 -0
  57. package/src/protocol/event-semantics.ts +21 -2
  58. package/src/protocol/types.ts +1 -0
  59. package/src/protocol/validation.ts +36 -0
  60. package/src/recorder/assemble.ts +8 -1
  61. package/src/recorder/closure.ts +21 -1
  62. package/src/recorder/core.ts +11 -0
  63. package/src/recorder/device.ts +33 -6
  64. package/src/recorder/encoder.ts +60 -6
  65. package/src/recorder/pass.ts +7 -2
  66. package/src/recorder/pipeline.ts +31 -0
  67. package/src/recorder/proxy.ts +58 -2
  68. package/src/recorder/session.ts +1 -1
  69. package/src/recorder/shader.ts +29 -22
  70. package/src/recorder.ts +6 -2
  71. package/src/replay/execute.ts +143 -1
  72. package/src/replay/readback.ts +15 -3
  73. package/src/replay/resources.ts +6 -0
  74. package/src/replay/session.ts +241 -27
  75. package/src/types.ts +61 -14
package/src/types.ts CHANGED
@@ -2,9 +2,8 @@
2
2
  //
3
3
  // Shape:
4
4
  // - RhiCallEvent: closed union (~40 kind incl. initialData + frameMark), each kind name 1:1 with RHI method name.
5
- // The ForgeaX encodeEmptyComputePass compound operation is represented by
6
- // its existing beginComputePass/endComputePass event pair.
7
- // Excludes: resolveQuerySet (per OOS-3).
5
+ // Query-set lifecycle and occlusion resolve calls are ordinary events;
6
+ // timestamp writes and render-bundle execution remain deferred.
8
7
  // Includes: core RHI + copyExternalImageToTexture + clearBuffer (per IS-11).
9
8
  // - Tape: header with formatVersion, rhiCapsRecorded, events array, blobPool map.
10
9
  // - InspectReport: frameIdx, workIndex, bindings, drawCall, rt (path string, not inline base64).
@@ -100,6 +99,17 @@ export interface RhiCallEventDestroyTexture {
100
99
  readonly handleId: HandleId;
101
100
  }
102
101
 
102
+ export interface RhiCallEventCreateQuerySet {
103
+ readonly kind: 'createQuerySet';
104
+ readonly handleId: HandleId;
105
+ readonly desc: Pick<GPUQuerySetDescriptor, 'label' | 'type' | 'count'>;
106
+ }
107
+
108
+ export interface RhiCallEventDestroyQuerySet {
109
+ readonly kind: 'destroyQuerySet';
110
+ readonly handleId: HandleId;
111
+ }
112
+
103
113
  export interface RhiCallEventCreateTextureView {
104
114
  readonly kind: 'createTextureView';
105
115
  readonly sourceHandleId: HandleId;
@@ -122,6 +132,13 @@ export interface RhiCallEventCreateSampler {
122
132
  readonly desc?: Partial<GPUSamplerDescriptor> | undefined;
123
133
  }
124
134
 
135
+ export interface RhiCallEventGetBindGroupLayout {
136
+ readonly kind: 'getBindGroupLayout';
137
+ readonly handleId: HandleId;
138
+ readonly pipelineHandleId: HandleId;
139
+ readonly index: number;
140
+ }
141
+
125
142
  export interface RhiCallEventCreateBindGroupLayout {
126
143
  readonly kind: 'createBindGroupLayout';
127
144
  readonly handleId: HandleId;
@@ -289,8 +306,8 @@ export interface RhiCallEventBeginRenderPass {
289
306
  readonly [key: string]: unknown;
290
307
  }
291
308
  | undefined;
292
- readonly occlusionQuerySet?: unknown | undefined;
293
- readonly timestampWrites?: unknown | undefined;
309
+ /** The opaque query set is represented by the parallel handle id below. */
310
+ readonly timestampWrites?: Omit<GPURenderPassTimestampWrites, 'querySet'> | undefined;
294
311
  readonly maxDrawCount?: number | undefined;
295
312
  };
296
313
  readonly colorAttachmentViewHandleIds: readonly (HandleId | undefined)[];
@@ -301,13 +318,20 @@ export interface RhiCallEventBeginRenderPass {
301
318
  */
302
319
  readonly colorAttachmentResolveTargetHandleIds?: readonly (HandleId | undefined)[];
303
320
  readonly depthStencilViewHandleId?: HandleId | undefined;
321
+ readonly occlusionQuerySetHandleId?: HandleId | undefined;
322
+ readonly timestampQuerySetHandleId?: HandleId | undefined;
304
323
  }
305
324
 
306
325
  export interface RhiCallEventBeginComputePass {
307
326
  readonly kind: 'beginComputePass';
327
+ readonly timestampQuerySetHandleId?: HandleId | undefined;
308
328
  readonly cmdHandleId: HandleId;
309
329
  readonly passHandleId: HandleId;
310
- readonly desc?: Partial<GPUComputePassDescriptor> | undefined;
330
+ readonly desc?:
331
+ | (Omit<Partial<GPUComputePassDescriptor>, 'timestampWrites'> & {
332
+ readonly timestampWrites?: Omit<GPUComputePassTimestampWrites, 'querySet'> | undefined;
333
+ })
334
+ | undefined;
311
335
  }
312
336
 
313
337
  export interface RhiCallEventCopyBufferToBuffer {
@@ -362,6 +386,16 @@ export interface RhiCallEventClearBuffer {
362
386
  readonly size?: number | undefined;
363
387
  }
364
388
 
389
+ export interface RhiCallEventResolveQuerySet {
390
+ readonly kind: 'resolveQuerySet';
391
+ readonly cmdHandleId: HandleId;
392
+ readonly querySetHandleId: HandleId;
393
+ readonly firstQuery: number;
394
+ readonly queryCount: number;
395
+ readonly destinationHandleId: HandleId;
396
+ readonly destinationOffset: number;
397
+ }
398
+
365
399
  export interface RhiCallEventPushDebugGroup {
366
400
  readonly kind: 'pushDebugGroup';
367
401
  readonly cmdHandleId: HandleId;
@@ -468,6 +502,17 @@ export interface RhiCallEventEndRenderPass {
468
502
  readonly passHandleId: HandleId;
469
503
  }
470
504
 
505
+ export interface RhiCallEventBeginOcclusionQuery {
506
+ readonly kind: 'beginOcclusionQuery';
507
+ readonly passHandleId: HandleId;
508
+ readonly queryIndex: number;
509
+ }
510
+
511
+ export interface RhiCallEventEndOcclusionQuery {
512
+ readonly kind: 'endOcclusionQuery';
513
+ readonly passHandleId: HandleId;
514
+ }
515
+
471
516
  export interface RhiCallEventSetBlendConstant {
472
517
  readonly kind: 'setBlendConstant';
473
518
  readonly passHandleId: HandleId;
@@ -555,8 +600,9 @@ export interface RhiCallEventInitialData {
555
600
  * Closed union of all recordable RHI call events.
556
601
  *
557
602
  * v1 covers: core RHI methods + copyExternalImageToTexture + clearBuffer (IS-11).
558
- * Excludes: resolveQuerySet (OOS-3),
559
- * executeBundles (OOS-10), beginOcclusionQuery/endOcclusionQuery.
603
+ * Timestamp writes and render-bundle execution remain deferred; query-set
604
+ * lifecycle, resolve, and occlusion-query events are represented as ordinary
605
+ * events.
560
606
  *
561
607
  * Kinds are named 1:1 with RHI method names per plan-strategy §8 naming convention.
562
608
  * The frameMark kind is the only non-method event — it marks frame boundaries.
@@ -567,9 +613,12 @@ export type RhiCallEvent =
567
613
  | RhiCallEventCreateTexture
568
614
  | RhiCallEventDestroyBuffer
569
615
  | RhiCallEventDestroyTexture
616
+ | RhiCallEventCreateQuerySet
617
+ | RhiCallEventDestroyQuerySet
570
618
  | RhiCallEventCreateTextureView
571
619
  | RhiCallEventCreateSampler
572
620
  | RhiCallEventCreateBindGroupLayout
621
+ | RhiCallEventGetBindGroupLayout
573
622
  | RhiCallEventCreateBindGroup
574
623
  | RhiCallEventCreatePipelineLayout
575
624
  | RhiCallEventCreateRenderPipeline
@@ -587,6 +636,7 @@ export type RhiCallEvent =
587
636
  | RhiCallEventCopyTextureToBuffer
588
637
  | RhiCallEventCopyTextureToTexture
589
638
  | RhiCallEventClearBuffer
639
+ | RhiCallEventResolveQuerySet
590
640
  | RhiCallEventPushDebugGroup
591
641
  | RhiCallEventPopDebugGroup
592
642
  | RhiCallEventInsertDebugMarker
@@ -601,6 +651,8 @@ export type RhiCallEvent =
601
651
  | RhiCallEventSetScissorRect
602
652
  | RhiCallEventSetStencilReference
603
653
  | RhiCallEventEndRenderPass
654
+ | RhiCallEventBeginOcclusionQuery
655
+ | RhiCallEventEndOcclusionQuery
604
656
  | RhiCallEventSetBlendConstant
605
657
  | RhiCallEventDrawIndirect
606
658
  | RhiCallEventDrawIndexedIndirect
@@ -881,9 +933,4 @@ export type InspectFields = 'bindings' | 'drawCall' | 'rt';
881
933
  *
882
934
  * @internal
883
935
  */
884
- export const DEFERRED_COMMANDS = new Set<string>([
885
- 'beginOcclusionQuery',
886
- 'endOcclusionQuery',
887
- 'executeBundles',
888
- 'resolveQuerySet',
889
- ]);
936
+ export const DEFERRED_COMMANDS = new Set<string>(['executeBundles', 'writeTimestamp']);