@plasius/gpu-debug 0.2.4 → 0.2.6

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.
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/validation.ts","../src/session.ts"],"sourcesContent":["export {\n createGpuDebugSession,\n estimateDispatchInvocations,\n summarizeWavefrontTelemetry,\n} from \"./session.js\";\nexport {\n gpuDebugQueueClasses,\n gpuPipelinePhases,\n gpuResourceCategories,\n} from \"./validation.js\";\nexport type * from \"./types.js\";\n","import type {\n GpuDebugAdapterInfo,\n GpuPipelinePhase,\n GpuDebugQueueClass,\n GpuResourceCategory,\n GpuVector3,\n} from \"./types.js\";\n\nconst IDENTIFIER_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,63}$/u;\n\nexport const gpuDebugQueueClasses = Object.freeze([\n \"render\",\n \"simulation\",\n \"lighting\",\n \"post-processing\",\n \"voxel\",\n \"transfer\",\n \"custom\",\n]) satisfies readonly GpuDebugQueueClass[];\n\nexport const gpuResourceCategories = Object.freeze([\n \"buffer\",\n \"texture\",\n \"bind-group\",\n \"pipeline\",\n \"custom\",\n]) satisfies readonly GpuResourceCategory[];\n\nexport const gpuPipelinePhases = Object.freeze([\n \"simulation\",\n \"secondary-simulation\",\n \"scene-preparation\",\n \"render\",\n]) satisfies readonly GpuPipelinePhase[];\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nexport function assertIdentifier(name: string, value: unknown): string {\n if (typeof value !== \"string\" || !IDENTIFIER_PATTERN.test(value)) {\n throw new Error(\n `${name} must match ${IDENTIFIER_PATTERN.toString()} and be at most 64 characters long.`\n );\n }\n\n return value;\n}\n\nexport function assertEnumValue<T extends string>(\n name: string,\n value: unknown,\n allowedValues: readonly T[]\n): T {\n if (typeof value !== \"string\" || !allowedValues.includes(value as T)) {\n throw new Error(`${name} must be one of: ${allowedValues.join(\", \")}.`);\n }\n\n return value as T;\n}\n\nexport function readPositiveNumber(\n name: string,\n value: unknown\n): number | undefined {\n if (value === undefined) {\n return undefined;\n }\n\n if (typeof value !== \"number\" || !Number.isFinite(value) || value <= 0) {\n throw new Error(`${name} must be a finite number greater than zero.`);\n }\n\n return value;\n}\n\nexport function readNonNegativeNumber(\n name: string,\n value: unknown\n): number | undefined {\n if (value === undefined) {\n return undefined;\n }\n\n if (typeof value !== \"number\" || !Number.isFinite(value) || value < 0) {\n throw new Error(`${name} must be a finite number greater than or equal to zero.`);\n }\n\n return value;\n}\n\nexport function readPositiveInteger(\n name: string,\n value: unknown\n): number | undefined {\n const parsed = readPositiveNumber(name, value);\n if (parsed === undefined) {\n return undefined;\n }\n\n if (!Number.isInteger(parsed)) {\n throw new Error(`${name} must be an integer greater than zero.`);\n }\n\n return parsed;\n}\n\nexport function normalizePlainObject(\n name: string,\n value: unknown\n): Readonly<Record<string, unknown>> {\n if (value === undefined) {\n return Object.freeze({});\n }\n\n if (!isRecord(value)) {\n throw new Error(`${name} must be a plain object when provided.`);\n }\n\n return Object.freeze({ ...value });\n}\n\nexport function normalizeVector(\n name: string,\n value: GpuVector3\n): Required<GpuVector3> {\n const x = readPositiveInteger(`${name}.x`, value.x) ?? 1;\n const y = readPositiveInteger(`${name}.y`, value.y) ?? 1;\n const z = readPositiveInteger(`${name}.z`, value.z) ?? 1;\n return { x, y, z };\n}\n\nexport function isAbortSignalLike(value: unknown): value is AbortSignal {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"aborted\" in value &&\n typeof (value as AbortSignal).aborted === \"boolean\"\n );\n}\n\nexport function normalizeAdapterInfo(\n value: GpuDebugAdapterInfo | undefined\n): Readonly<GpuDebugAdapterInfo> {\n if (value === undefined) {\n return Object.freeze({});\n }\n\n const adapter: GpuDebugAdapterInfo = {};\n\n if (value.label !== undefined) {\n adapter.label = String(value.label).trim().slice(0, 120);\n }\n if (value.vendor !== undefined) {\n adapter.vendor = String(value.vendor).trim().slice(0, 120);\n }\n if (value.architecture !== undefined) {\n adapter.architecture = String(value.architecture).trim().slice(0, 120);\n }\n if (value.driver !== undefined) {\n adapter.driver = String(value.driver).trim().slice(0, 120);\n }\n\n adapter.maxBufferSizeBytes = readPositiveInteger(\n \"adapter.maxBufferSizeBytes\",\n value.maxBufferSizeBytes\n );\n adapter.maxStorageBufferBindingSizeBytes = readPositiveInteger(\n \"adapter.maxStorageBufferBindingSizeBytes\",\n value.maxStorageBufferBindingSizeBytes\n );\n adapter.maxComputeInvocationsPerWorkgroup = readPositiveInteger(\n \"adapter.maxComputeInvocationsPerWorkgroup\",\n value.maxComputeInvocationsPerWorkgroup\n );\n adapter.maxComputeWorkgroupsPerDimension = readPositiveInteger(\n \"adapter.maxComputeWorkgroupsPerDimension\",\n value.maxComputeWorkgroupsPerDimension\n );\n adapter.memoryCapacityHintBytes = readPositiveInteger(\n \"adapter.memoryCapacityHintBytes\",\n value.memoryCapacityHintBytes\n );\n adapter.coreCountHint = readPositiveInteger(\n \"adapter.coreCountHint\",\n value.coreCountHint\n );\n adapter.metadata = normalizePlainObject(\"adapter.metadata\", value.metadata);\n\n return Object.freeze(adapter);\n}\n","import type {\n GpuDebugDagSnapshot,\n GpuDebugDispatchSnapshot,\n GpuDebugPipelineSnapshot,\n GpuDebugQueueSnapshot,\n GpuDebugSession,\n GpuDebugSessionOptions,\n GpuDebugSnapshot,\n GpuDebugWavefrontSnapshot,\n GpuDependencyUnlockSample,\n GpuDispatchSample,\n GpuFrameSample,\n GpuPipelinePhaseSample,\n GpuQueueSample,\n GpuReadyLaneSample,\n GpuResourceCategory,\n GpuWavefrontHitKindSample,\n GpuWavefrontTerminationSample,\n GpuWavefrontTelemetrySample,\n TrackedGpuAllocation,\n} from \"./types.js\";\nimport {\n assertEnumValue,\n assertIdentifier,\n gpuDebugQueueClasses,\n gpuPipelinePhases,\n gpuResourceCategories,\n isAbortSignalLike,\n normalizeAdapterInfo,\n normalizeVector,\n readNonNegativeNumber,\n readPositiveInteger,\n readPositiveNumber,\n} from \"./validation.js\";\n\nconst DEFAULT_OPTIONS = Object.freeze({\n enabled: false,\n maxRetainedDispatches: 240,\n maxRetainedQueueSamples: 240,\n maxRetainedReadyLaneSamples: 240,\n maxRetainedDependencyUnlockSamples: 240,\n maxRetainedPipelinePhaseSamples: 240,\n maxRetainedWavefrontSamples: 240,\n maxRetainedFrameSamples: 240,\n maxTrackedAllocations: 512,\n});\n\nconst LIMITATIONS = Object.freeze([\n \"Tracked memory reflects only allocations reported to this debug session.\",\n \"Portable WebGPU does not expose authoritative live GPU core-count or total-memory counters.\",\n \"Hardware hints are optional caller-supplied metadata and may be platform-specific.\",\n \"Ready-lane and dependency-unlock diagnostics are caller-reported integration samples, not automatic WebGPU counters.\",\n \"Pipeline phase and snapshot-lag diagnostics are caller-reported integration samples, not automatic WebGPU counters.\",\n \"Wavefront queue, hit-buffer, and termination diagnostics are caller-reported summaries rather than full GPU buffer dumps.\",\n]);\n\ninterface NormalizedAllocation extends Omit<TrackedGpuAllocation, \"signal\"> {\n label?: string;\n}\n\ntype NormalizedQueueSample = Omit<GpuQueueSample, \"signal\">;\n\ninterface NormalizedReadyLaneSample extends Omit<GpuReadyLaneSample, \"signal\"> {\n priority?: number;\n}\n\ninterface NormalizedDispatchSample extends Omit<GpuDispatchSample, \"signal\"> {\n workgroups: { x: number; y: number; z: number };\n workgroupSize: { x: number; y: number; z: number };\n}\n\ntype NormalizedFrameSample = Omit<GpuFrameSample, \"signal\">;\n\ninterface NormalizedDependencyUnlockSample\n extends Omit<GpuDependencyUnlockSample, \"signal\"> {\n priority?: number;\n unlockCount: number;\n}\n\ninterface NormalizedPipelinePhaseSample\n extends Omit<GpuPipelinePhaseSample, \"signal\"> {\n durationMs?: number;\n snapshotAgeFrames?: number;\n snapshotAgeMs?: number;\n}\n\ntype NormalizedWavefrontHitKindSample = GpuWavefrontHitKindSample;\n\ntype NormalizedWavefrontTerminationSample = GpuWavefrontTerminationSample;\n\ninterface NormalizedWavefrontTelemetrySample\n extends Omit<\n GpuWavefrontTelemetrySample,\n \"signal\" | \"hitKinds\" | \"terminationReasons\"\n > {\n hitKinds: readonly NormalizedWavefrontHitKindSample[];\n terminationReasons: readonly NormalizedWavefrontTerminationSample[];\n bounceDepth: number;\n activeRayCount: number;\n queueCapacity?: number;\n overflowCount: number;\n hitBufferCount?: number;\n}\n\nfunction clampCount(value: number | undefined, fallback: number): number {\n if (!value || !Number.isFinite(value) || value <= 0) {\n return fallback;\n }\n\n return Math.min(Math.round(value), 4096);\n}\n\nfunction trimHistory<T>(items: T[], maxEntries: number): void {\n while (items.length > maxEntries) {\n items.shift();\n }\n}\n\nfunction average(values: readonly number[]): number | undefined {\n if (values.length === 0) {\n return undefined;\n }\n\n return values.reduce((total, value) => total + value, 0) / values.length;\n}\n\nfunction pushAggregate<T extends string | number>(\n map: Map<T, number>,\n key: T,\n value: number\n): void {\n map.set(key, (map.get(key) ?? 0) + value);\n}\n\nfunction normalizeAllocation(allocation: TrackedGpuAllocation): NormalizedAllocation {\n if (allocation.signal !== undefined && !isAbortSignalLike(allocation.signal)) {\n throw new Error(\"allocation.signal must be an AbortSignal when provided.\");\n }\n\n return {\n id: assertIdentifier(\"allocation.id\", allocation.id),\n owner: assertIdentifier(\"allocation.owner\", allocation.owner),\n category: assertEnumValue(\n \"allocation.category\",\n allocation.category,\n gpuResourceCategories\n ),\n sizeBytes: readPositiveInteger(\"allocation.sizeBytes\", allocation.sizeBytes) ?? 1,\n label:\n allocation.label === undefined\n ? undefined\n : String(allocation.label).trim().slice(0, 120),\n };\n}\n\nfunction normalizeQueueSample(sample: GpuQueueSample): NormalizedQueueSample {\n if (sample.signal !== undefined && !isAbortSignalLike(sample.signal)) {\n throw new Error(\"queue.signal must be an AbortSignal when provided.\");\n }\n\n const capacity = readPositiveInteger(\"queue.capacity\", sample.capacity);\n const depth = readNonNegativeNumber(\"queue.depth\", sample.depth) ?? 0;\n\n if (capacity !== undefined && depth > capacity) {\n throw new Error(\"queue.depth cannot exceed queue.capacity.\");\n }\n\n return {\n owner: assertIdentifier(\"queue.owner\", sample.owner),\n queueClass: assertEnumValue(\n \"queue.queueClass\",\n sample.queueClass,\n gpuDebugQueueClasses\n ),\n depth,\n capacity,\n frameId:\n sample.frameId === undefined\n ? undefined\n : assertIdentifier(\"queue.frameId\", sample.frameId),\n };\n}\n\nfunction normalizeReadyLaneSample(\n sample: GpuReadyLaneSample\n): NormalizedReadyLaneSample {\n if (sample.signal !== undefined && !isAbortSignalLike(sample.signal)) {\n throw new Error(\"readyLane.signal must be an AbortSignal when provided.\");\n }\n\n const capacity = readPositiveInteger(\"readyLane.capacity\", sample.capacity);\n const depth = readNonNegativeNumber(\"readyLane.depth\", sample.depth) ?? 0;\n\n if (capacity !== undefined && depth > capacity) {\n throw new Error(\"readyLane.depth cannot exceed readyLane.capacity.\");\n }\n\n const priority = readNonNegativeNumber(\"readyLane.priority\", sample.priority);\n if (priority !== undefined && !Number.isInteger(priority)) {\n throw new Error(\"readyLane.priority must be an integer greater than or equal to zero.\");\n }\n\n return {\n owner: assertIdentifier(\"readyLane.owner\", sample.owner),\n queueClass: assertEnumValue(\n \"readyLane.queueClass\",\n sample.queueClass,\n gpuDebugQueueClasses\n ),\n laneId: assertIdentifier(\"readyLane.laneId\", sample.laneId),\n priority,\n depth,\n capacity,\n frameId:\n sample.frameId === undefined\n ? undefined\n : assertIdentifier(\"readyLane.frameId\", sample.frameId),\n };\n}\n\nfunction normalizeDispatchSample(\n sample: GpuDispatchSample\n): NormalizedDispatchSample {\n if (sample.signal !== undefined && !isAbortSignalLike(sample.signal)) {\n throw new Error(\"dispatch.signal must be an AbortSignal when provided.\");\n }\n\n return {\n id:\n sample.id === undefined ? undefined : assertIdentifier(\"dispatch.id\", sample.id),\n owner: assertIdentifier(\"dispatch.owner\", sample.owner),\n queueClass: assertEnumValue(\n \"dispatch.queueClass\",\n sample.queueClass,\n gpuDebugQueueClasses\n ),\n jobType: assertIdentifier(\"dispatch.jobType\", sample.jobType),\n frameId:\n sample.frameId === undefined\n ? undefined\n : assertIdentifier(\"dispatch.frameId\", sample.frameId),\n durationMs: readNonNegativeNumber(\"dispatch.durationMs\", sample.durationMs),\n workgroups: normalizeVector(\"dispatch.workgroups\", sample.workgroups),\n workgroupSize: normalizeVector(\n \"dispatch.workgroupSize\",\n sample.workgroupSize ?? { x: 1, y: 1, z: 1 }\n ),\n bytesRead: readNonNegativeNumber(\"dispatch.bytesRead\", sample.bytesRead),\n bytesWritten: readNonNegativeNumber(\"dispatch.bytesWritten\", sample.bytesWritten),\n };\n}\n\nfunction normalizeFrameSample(sample: GpuFrameSample): NormalizedFrameSample {\n if (sample.signal !== undefined && !isAbortSignalLike(sample.signal)) {\n throw new Error(\"frame.signal must be an AbortSignal when provided.\");\n }\n\n if (sample.dropped !== undefined && typeof sample.dropped !== \"boolean\") {\n throw new Error(\"frame.dropped must be a boolean when provided.\");\n }\n\n return {\n frameId:\n sample.frameId === undefined\n ? undefined\n : assertIdentifier(\"frame.frameId\", sample.frameId),\n frameTimeMs: readPositiveNumber(\"frame.frameTimeMs\", sample.frameTimeMs) ?? 0,\n targetFrameTimeMs: readPositiveNumber(\n \"frame.targetFrameTimeMs\",\n sample.targetFrameTimeMs\n ),\n gpuBusyMs: readNonNegativeNumber(\"frame.gpuBusyMs\", sample.gpuBusyMs),\n dropped: sample.dropped,\n };\n}\n\nfunction normalizeDependencyUnlockSample(\n sample: GpuDependencyUnlockSample\n): NormalizedDependencyUnlockSample {\n if (sample.signal !== undefined && !isAbortSignalLike(sample.signal)) {\n throw new Error(\"dependencyUnlock.signal must be an AbortSignal when provided.\");\n }\n\n const priority = readNonNegativeNumber(\n \"dependencyUnlock.priority\",\n sample.priority\n );\n if (priority !== undefined && !Number.isInteger(priority)) {\n throw new Error(\n \"dependencyUnlock.priority must be an integer greater than or equal to zero.\"\n );\n }\n\n return {\n owner: assertIdentifier(\"dependencyUnlock.owner\", sample.owner),\n queueClass: assertEnumValue(\n \"dependencyUnlock.queueClass\",\n sample.queueClass,\n gpuDebugQueueClasses\n ),\n sourceJobType: assertIdentifier(\n \"dependencyUnlock.sourceJobType\",\n sample.sourceJobType\n ),\n unlockedJobType: assertIdentifier(\n \"dependencyUnlock.unlockedJobType\",\n sample.unlockedJobType\n ),\n priority,\n unlockCount:\n readPositiveInteger(\"dependencyUnlock.unlockCount\", sample.unlockCount) ?? 1,\n frameId:\n sample.frameId === undefined\n ? undefined\n : assertIdentifier(\"dependencyUnlock.frameId\", sample.frameId),\n };\n}\n\nfunction normalizePipelinePhaseSample(\n sample: GpuPipelinePhaseSample\n): NormalizedPipelinePhaseSample {\n if (sample.signal !== undefined && !isAbortSignalLike(sample.signal)) {\n throw new Error(\"pipelinePhase.signal must be an AbortSignal when provided.\");\n }\n\n const snapshotAgeFrames = readNonNegativeNumber(\n \"pipelinePhase.snapshotAgeFrames\",\n sample.snapshotAgeFrames\n );\n if (snapshotAgeFrames !== undefined && !Number.isInteger(snapshotAgeFrames)) {\n throw new Error(\n \"pipelinePhase.snapshotAgeFrames must be an integer greater than or equal to zero.\"\n );\n }\n\n return {\n owner: assertIdentifier(\"pipelinePhase.owner\", sample.owner),\n pipeline: assertEnumValue(\n \"pipelinePhase.pipeline\",\n sample.pipeline,\n gpuPipelinePhases\n ),\n stage: assertIdentifier(\"pipelinePhase.stage\", sample.stage),\n frameId:\n sample.frameId === undefined\n ? undefined\n : assertIdentifier(\"pipelinePhase.frameId\", sample.frameId),\n durationMs: readNonNegativeNumber(\n \"pipelinePhase.durationMs\",\n sample.durationMs\n ),\n snapshotFrameId:\n sample.snapshotFrameId === undefined\n ? undefined\n : assertIdentifier(\"pipelinePhase.snapshotFrameId\", sample.snapshotFrameId),\n snapshotAgeFrames,\n snapshotAgeMs: readNonNegativeNumber(\n \"pipelinePhase.snapshotAgeMs\",\n sample.snapshotAgeMs\n ),\n };\n}\n\nfunction normalizeWavefrontHitKinds(\n entries: GpuWavefrontTelemetrySample[\"hitKinds\"]\n): readonly NormalizedWavefrontHitKindSample[] {\n if (entries === undefined) {\n return Object.freeze([]);\n }\n if (!Array.isArray(entries)) {\n throw new Error(\"wavefront.hitKinds must be an array when provided.\");\n }\n return Object.freeze(\n entries.map((entry, index) => {\n if (!entry || typeof entry !== \"object\" || Array.isArray(entry)) {\n throw new Error(`wavefront.hitKinds[${index}] must be an object.`);\n }\n return Object.freeze({\n kind: assertIdentifier(`wavefront.hitKinds[${index}].kind`, entry.kind),\n count:\n readPositiveInteger(`wavefront.hitKinds[${index}].count`, entry.count) ??\n 1,\n });\n })\n );\n}\n\nfunction normalizeWavefrontTerminationReasons(\n entries: GpuWavefrontTelemetrySample[\"terminationReasons\"]\n): readonly NormalizedWavefrontTerminationSample[] {\n if (entries === undefined) {\n return Object.freeze([]);\n }\n if (!Array.isArray(entries)) {\n throw new Error(\n \"wavefront.terminationReasons must be an array when provided.\"\n );\n }\n return Object.freeze(\n entries.map((entry, index) => {\n if (!entry || typeof entry !== \"object\" || Array.isArray(entry)) {\n throw new Error(\n `wavefront.terminationReasons[${index}] must be an object.`\n );\n }\n return Object.freeze({\n reason: assertIdentifier(\n `wavefront.terminationReasons[${index}].reason`,\n entry.reason\n ),\n count:\n readPositiveInteger(\n `wavefront.terminationReasons[${index}].count`,\n entry.count\n ) ?? 1,\n });\n })\n );\n}\n\nfunction normalizeWavefrontTelemetrySample(\n sample: GpuWavefrontTelemetrySample\n): NormalizedWavefrontTelemetrySample {\n if (sample.signal !== undefined && !isAbortSignalLike(sample.signal)) {\n throw new Error(\"wavefront.signal must be an AbortSignal when provided.\");\n }\n\n const queueCapacity = readPositiveInteger(\n \"wavefront.queueCapacity\",\n sample.queueCapacity\n );\n const activeRayCount =\n readNonNegativeNumber(\"wavefront.activeRayCount\", sample.activeRayCount) ?? 0;\n if (!Number.isInteger(activeRayCount)) {\n throw new Error(\"wavefront.activeRayCount must be an integer greater than or equal to zero.\");\n }\n if (queueCapacity !== undefined && activeRayCount > queueCapacity) {\n throw new Error(\n \"wavefront.activeRayCount cannot exceed wavefront.queueCapacity.\"\n );\n }\n\n const bounceDepth =\n readNonNegativeNumber(\"wavefront.bounceDepth\", sample.bounceDepth) ?? 0;\n if (!Number.isInteger(bounceDepth)) {\n throw new Error(\"wavefront.bounceDepth must be an integer greater than or equal to zero.\");\n }\n\n const overflowCount =\n readNonNegativeNumber(\"wavefront.overflowCount\", sample.overflowCount) ?? 0;\n if (!Number.isInteger(overflowCount)) {\n throw new Error(\"wavefront.overflowCount must be an integer greater than or equal to zero.\");\n }\n\n const hitBufferCount = readNonNegativeNumber(\n \"wavefront.hitBufferCount\",\n sample.hitBufferCount\n );\n if (hitBufferCount !== undefined && !Number.isInteger(hitBufferCount)) {\n throw new Error(\n \"wavefront.hitBufferCount must be an integer greater than or equal to zero.\"\n );\n }\n\n return {\n owner: assertIdentifier(\"wavefront.owner\", sample.owner),\n queueClass: assertEnumValue(\n \"wavefront.queueClass\",\n sample.queueClass,\n gpuDebugQueueClasses\n ),\n frameId:\n sample.frameId === undefined\n ? undefined\n : assertIdentifier(\"wavefront.frameId\", sample.frameId),\n bounceDepth,\n activeRayCount,\n queueCapacity,\n overflowCount,\n hitBufferCount,\n hitKinds: normalizeWavefrontHitKinds(sample.hitKinds),\n terminationReasons: normalizeWavefrontTerminationReasons(\n sample.terminationReasons\n ),\n };\n}\n\nexport function estimateDispatchInvocations(sample: GpuDispatchSample): number {\n const normalized = normalizeDispatchSample(sample);\n return (\n normalized.workgroups.x *\n normalized.workgroups.y *\n normalized.workgroups.z *\n normalized.workgroupSize.x *\n normalized.workgroupSize.y *\n normalized.workgroupSize.z\n );\n}\n\nexport function createGpuDebugSession(\n options: GpuDebugSessionOptions = {}\n): GpuDebugSession {\n const settings = {\n enabled: options.enabled ?? DEFAULT_OPTIONS.enabled,\n maxRetainedDispatches: clampCount(\n options.maxRetainedDispatches,\n DEFAULT_OPTIONS.maxRetainedDispatches\n ),\n maxRetainedQueueSamples: clampCount(\n options.maxRetainedQueueSamples,\n DEFAULT_OPTIONS.maxRetainedQueueSamples\n ),\n maxRetainedReadyLaneSamples: clampCount(\n options.maxRetainedReadyLaneSamples,\n DEFAULT_OPTIONS.maxRetainedReadyLaneSamples\n ),\n maxRetainedDependencyUnlockSamples: clampCount(\n options.maxRetainedDependencyUnlockSamples,\n DEFAULT_OPTIONS.maxRetainedDependencyUnlockSamples\n ),\n maxRetainedPipelinePhaseSamples: clampCount(\n options.maxRetainedPipelinePhaseSamples,\n DEFAULT_OPTIONS.maxRetainedPipelinePhaseSamples\n ),\n maxRetainedWavefrontSamples: clampCount(\n options.maxRetainedWavefrontSamples,\n DEFAULT_OPTIONS.maxRetainedWavefrontSamples\n ),\n maxRetainedFrameSamples: clampCount(\n options.maxRetainedFrameSamples,\n DEFAULT_OPTIONS.maxRetainedFrameSamples\n ),\n maxTrackedAllocations: clampCount(\n options.maxTrackedAllocations,\n DEFAULT_OPTIONS.maxTrackedAllocations\n ),\n };\n\n const adapter = normalizeAdapterInfo(options.adapter);\n let enabled = settings.enabled;\n const allocations = new Map<string, NormalizedAllocation>();\n const allocationOrder: string[] = [];\n const queueSamples: NormalizedQueueSample[] = [];\n const readyLaneSamples: NormalizedReadyLaneSample[] = [];\n const dispatchSamples: NormalizedDispatchSample[] = [];\n const dependencyUnlockSamples: NormalizedDependencyUnlockSample[] = [];\n const pipelinePhaseSamples: NormalizedPipelinePhaseSample[] = [];\n const wavefrontSamples: NormalizedWavefrontTelemetrySample[] = [];\n const frameSamples: NormalizedFrameSample[] = [];\n let peakTrackedBytes = 0;\n\n const totalTrackedBytes = (): number =>\n [...allocations.values()].reduce((total, allocation) => total + allocation.sizeBytes, 0);\n\n const updatePeakTrackedBytes = (): void => {\n peakTrackedBytes = Math.max(peakTrackedBytes, totalTrackedBytes());\n };\n\n const ensureAllocationCapacity = (): void => {\n while (allocationOrder.length > settings.maxTrackedAllocations) {\n const oldestId = allocationOrder.shift();\n if (oldestId !== undefined) {\n allocations.delete(oldestId);\n }\n }\n };\n\n const buildDispatchSnapshot = (): GpuDebugDispatchSnapshot => {\n const durations = dispatchSamples\n .map((sample) => sample.durationMs)\n .filter((value): value is number => value !== undefined);\n const bytesRead = dispatchSamples\n .map((sample) => sample.bytesRead)\n .filter((value): value is number => value !== undefined);\n const bytesWritten = dispatchSamples\n .map((sample) => sample.bytesWritten)\n .filter((value): value is number => value !== undefined);\n\n const byQueueClass = new Map<\n NormalizedDispatchSample[\"queueClass\"],\n {\n queueClass: NormalizedDispatchSample[\"queueClass\"];\n dispatches: number;\n totalDurationMs: number;\n estimatedInvocations: number;\n }\n >();\n\n let estimatedWorkgroups = 0;\n let estimatedInvocations = 0;\n\n for (const sample of dispatchSamples) {\n const workgroupCount =\n sample.workgroups.x * sample.workgroups.y * sample.workgroups.z;\n const invocationCount =\n workgroupCount *\n sample.workgroupSize.x *\n sample.workgroupSize.y *\n sample.workgroupSize.z;\n estimatedWorkgroups += workgroupCount;\n estimatedInvocations += invocationCount;\n\n const bucket = byQueueClass.get(sample.queueClass) ?? {\n queueClass: sample.queueClass,\n dispatches: 0,\n totalDurationMs: 0,\n estimatedInvocations: 0,\n };\n bucket.dispatches += 1;\n bucket.totalDurationMs += sample.durationMs ?? 0;\n bucket.estimatedInvocations += invocationCount;\n byQueueClass.set(sample.queueClass, bucket);\n }\n\n const frameTimes = frameSamples.map((sample) => sample.frameTimeMs);\n const totalFrameTimeMs = frameTimes.reduce((total, value) => total + value, 0);\n const totalDurationMs = durations.reduce((total, value) => total + value, 0);\n\n return {\n sampleCount: dispatchSamples.length,\n totalDurationMs,\n averageDurationMs: average(durations),\n estimatedWorkgroups,\n estimatedInvocations,\n averageBytesRead: average(bytesRead),\n averageBytesWritten: average(bytesWritten),\n busyRatio:\n totalFrameTimeMs > 0 ? Math.min(totalDurationMs / totalFrameTimeMs, 1) : undefined,\n byQueueClass: [...byQueueClass.values()].sort(\n (left, right) => right.totalDurationMs - left.totalDurationMs\n ),\n };\n };\n\n const buildQueueSnapshot = (): GpuDebugQueueSnapshot => {\n const depths = queueSamples.map((sample) => sample.depth);\n const hottestQueues = queueSamples\n .map((sample) => ({\n owner: sample.owner,\n queueClass: sample.queueClass,\n depth: sample.depth,\n capacity: sample.capacity,\n utilizationRatio:\n sample.capacity !== undefined ? sample.depth / sample.capacity : undefined,\n }))\n .sort((left, right) => {\n const leftScore = left.utilizationRatio ?? left.depth;\n const rightScore = right.utilizationRatio ?? right.depth;\n return rightScore - leftScore;\n })\n .slice(0, 5);\n\n const peakUtilizationRatio = queueSamples.reduce<number | undefined>(\n (peak, sample) => {\n if (sample.capacity === undefined) {\n return peak;\n }\n\n const nextRatio = sample.depth / sample.capacity;\n return peak === undefined ? nextRatio : Math.max(peak, nextRatio);\n },\n undefined\n );\n\n return {\n sampleCount: queueSamples.length,\n averageDepth: average(depths) ?? 0,\n peakDepth: depths.length === 0 ? 0 : Math.max(...depths),\n peakUtilizationRatio,\n hottestQueues,\n };\n };\n\n const buildDagSnapshot = (): GpuDebugDagSnapshot => {\n const laneDepths = readyLaneSamples.map((sample) => sample.depth);\n const hottestReadyLanes = readyLaneSamples\n .map((sample) => ({\n owner: sample.owner,\n queueClass: sample.queueClass,\n laneId: sample.laneId,\n priority: sample.priority,\n depth: sample.depth,\n capacity: sample.capacity,\n utilizationRatio:\n sample.capacity !== undefined ? sample.depth / sample.capacity : undefined,\n }))\n .sort((left, right) => {\n const leftScore = left.utilizationRatio ?? left.depth;\n const rightScore = right.utilizationRatio ?? right.depth;\n return rightScore - leftScore;\n })\n .slice(0, 5);\n\n const peakReadyLaneUtilizationRatio = readyLaneSamples.reduce<number | undefined>(\n (peak, sample) => {\n if (sample.capacity === undefined) {\n return peak;\n }\n\n const nextRatio = sample.depth / sample.capacity;\n return peak === undefined ? nextRatio : Math.max(peak, nextRatio);\n },\n undefined\n );\n\n const bySourceJobType = new Map<\n string,\n {\n owner: string;\n queueClass: NormalizedDependencyUnlockSample[\"queueClass\"];\n sourceJobType: string;\n unlockCount: number;\n }\n >();\n const byUnlockedJobType = new Map<\n string,\n {\n owner: string;\n queueClass: NormalizedDependencyUnlockSample[\"queueClass\"];\n unlockedJobType: string;\n priority?: number;\n unlockCount: number;\n }\n >();\n\n let totalUnlockCount = 0;\n\n for (const sample of dependencyUnlockSamples) {\n totalUnlockCount += sample.unlockCount;\n\n const sourceKey = `${sample.owner}:${sample.queueClass}:${sample.sourceJobType}`;\n const unlockedKey =\n `${sample.owner}:${sample.queueClass}:` +\n `${sample.unlockedJobType}:${sample.priority ?? \"none\"}`;\n\n const sourceBucket = bySourceJobType.get(sourceKey) ?? {\n owner: sample.owner,\n queueClass: sample.queueClass,\n sourceJobType: sample.sourceJobType,\n unlockCount: 0,\n };\n sourceBucket.unlockCount += sample.unlockCount;\n bySourceJobType.set(sourceKey, sourceBucket);\n\n const unlockedBucket = byUnlockedJobType.get(unlockedKey) ?? {\n owner: sample.owner,\n queueClass: sample.queueClass,\n unlockedJobType: sample.unlockedJobType,\n priority: sample.priority,\n unlockCount: 0,\n };\n unlockedBucket.unlockCount += sample.unlockCount;\n byUnlockedJobType.set(unlockedKey, unlockedBucket);\n }\n\n return {\n readyLaneSampleCount: readyLaneSamples.length,\n averageReadyLaneDepth: average(laneDepths) ?? 0,\n peakReadyLaneDepth: laneDepths.length === 0 ? 0 : Math.max(...laneDepths),\n peakReadyLaneUtilizationRatio,\n hottestReadyLanes,\n dependencyUnlockSampleCount: dependencyUnlockSamples.length,\n totalUnlockCount,\n bySourceJobType: [...bySourceJobType.values()].sort(\n (left, right) => right.unlockCount - left.unlockCount\n ),\n byUnlockedJobType: [...byUnlockedJobType.values()].sort(\n (left, right) => right.unlockCount - left.unlockCount\n ),\n };\n };\n\n const buildPipelineSnapshot = (): GpuDebugPipelineSnapshot => {\n const durations = pipelinePhaseSamples\n .map((sample) => sample.durationMs)\n .filter((value): value is number => value !== undefined);\n const snapshotAgeMsValues = pipelinePhaseSamples\n .map((sample) => sample.snapshotAgeMs)\n .filter((value): value is number => value !== undefined);\n const snapshotAgeFrameValues = pipelinePhaseSamples\n .map((sample) => sample.snapshotAgeFrames)\n .filter((value): value is number => value !== undefined);\n\n const byPipeline = new Map<\n NormalizedPipelinePhaseSample[\"pipeline\"],\n {\n pipeline: NormalizedPipelinePhaseSample[\"pipeline\"];\n sampleCount: number;\n totalDurationMs: number;\n durationValues: number[];\n snapshotAgeMsValues: number[];\n snapshotAgeFramesValues: number[];\n }\n >();\n\n for (const sample of pipelinePhaseSamples) {\n const bucket = byPipeline.get(sample.pipeline) ?? {\n pipeline: sample.pipeline,\n sampleCount: 0,\n totalDurationMs: 0,\n durationValues: [],\n snapshotAgeMsValues: [],\n snapshotAgeFramesValues: [],\n };\n bucket.sampleCount += 1;\n bucket.totalDurationMs += sample.durationMs ?? 0;\n if (sample.durationMs !== undefined) {\n bucket.durationValues.push(sample.durationMs);\n }\n if (sample.snapshotAgeMs !== undefined) {\n bucket.snapshotAgeMsValues.push(sample.snapshotAgeMs);\n }\n if (sample.snapshotAgeFrames !== undefined) {\n bucket.snapshotAgeFramesValues.push(sample.snapshotAgeFrames);\n }\n byPipeline.set(sample.pipeline, bucket);\n }\n\n const hottestStages = pipelinePhaseSamples\n .map((sample) => ({\n owner: sample.owner,\n pipeline: sample.pipeline,\n stage: sample.stage,\n frameId: sample.frameId,\n durationMs: sample.durationMs,\n snapshotFrameId: sample.snapshotFrameId,\n snapshotAgeFrames: sample.snapshotAgeFrames,\n snapshotAgeMs: sample.snapshotAgeMs,\n }))\n .sort((left, right) => {\n const leftScore =\n left.durationMs ??\n left.snapshotAgeMs ??\n left.snapshotAgeFrames ??\n 0;\n const rightScore =\n right.durationMs ??\n right.snapshotAgeMs ??\n right.snapshotAgeFrames ??\n 0;\n return rightScore - leftScore;\n })\n .slice(0, 5);\n\n return {\n sampleCount: pipelinePhaseSamples.length,\n totalDurationMs: durations.reduce((total, value) => total + value, 0),\n averageDurationMs: average(durations),\n averageSnapshotAgeMs: average(snapshotAgeMsValues),\n maxSnapshotAgeMs:\n snapshotAgeMsValues.length > 0 ? Math.max(...snapshotAgeMsValues) : undefined,\n maxSnapshotAgeFrames:\n snapshotAgeFrameValues.length > 0\n ? Math.max(...snapshotAgeFrameValues)\n : undefined,\n byPipeline: [...byPipeline.values()]\n .map((bucket) => ({\n pipeline: bucket.pipeline,\n sampleCount: bucket.sampleCount,\n totalDurationMs: bucket.totalDurationMs,\n averageDurationMs: average(bucket.durationValues),\n averageSnapshotAgeMs: average(bucket.snapshotAgeMsValues),\n maxSnapshotAgeMs:\n bucket.snapshotAgeMsValues.length > 0\n ? Math.max(...bucket.snapshotAgeMsValues)\n : undefined,\n maxSnapshotAgeFrames:\n bucket.snapshotAgeFramesValues.length > 0\n ? Math.max(...bucket.snapshotAgeFramesValues)\n : undefined,\n }))\n .sort((left, right) => right.totalDurationMs - left.totalDurationMs),\n hottestStages,\n };\n };\n\n const buildWavefrontSnapshot = (): GpuDebugWavefrontSnapshot => {\n const activeRayCounts = wavefrontSamples.map((sample) => sample.activeRayCount);\n const hitBufferCounts = wavefrontSamples\n .map((sample) => sample.hitBufferCount)\n .filter((value): value is number => value !== undefined);\n\n const byBounceDepth = new Map<\n number,\n {\n bounceDepth: number;\n sampleCount: number;\n activeRayCounts: number[];\n hitBufferCounts: number[];\n totalOverflowCount: number;\n }\n >();\n const byTerminationReason = new Map<string, number>();\n const byHitKind = new Map<string, number>();\n\n const peakQueueUtilizationRatio = wavefrontSamples.reduce<number | undefined>(\n (peak, sample) => {\n if (sample.queueCapacity === undefined) {\n return peak;\n }\n const ratio = sample.activeRayCount / sample.queueCapacity;\n return peak === undefined ? ratio : Math.max(peak, ratio);\n },\n undefined\n );\n\n let totalOverflowCount = 0;\n let peakOverflowCount = 0;\n let maxBounceDepth: number | undefined;\n\n for (const sample of wavefrontSamples) {\n totalOverflowCount += sample.overflowCount;\n peakOverflowCount = Math.max(peakOverflowCount, sample.overflowCount);\n maxBounceDepth =\n maxBounceDepth === undefined\n ? sample.bounceDepth\n : Math.max(maxBounceDepth, sample.bounceDepth);\n\n const bucket = byBounceDepth.get(sample.bounceDepth) ?? {\n bounceDepth: sample.bounceDepth,\n sampleCount: 0,\n activeRayCounts: [],\n hitBufferCounts: [],\n totalOverflowCount: 0,\n };\n bucket.sampleCount += 1;\n bucket.activeRayCounts.push(sample.activeRayCount);\n if (sample.hitBufferCount !== undefined) {\n bucket.hitBufferCounts.push(sample.hitBufferCount);\n }\n bucket.totalOverflowCount += sample.overflowCount;\n byBounceDepth.set(sample.bounceDepth, bucket);\n\n for (const reason of sample.terminationReasons) {\n pushAggregate(byTerminationReason, reason.reason, reason.count);\n }\n for (const kind of sample.hitKinds) {\n pushAggregate(byHitKind, kind.kind, kind.count);\n }\n }\n\n return {\n sampleCount: wavefrontSamples.length,\n averageActiveRayCount: average(activeRayCounts) ?? 0,\n peakActiveRayCount:\n activeRayCounts.length > 0 ? Math.max(...activeRayCounts) : 0,\n peakQueueUtilizationRatio,\n maxBounceDepth,\n totalOverflowCount,\n peakOverflowCount,\n averageHitBufferCount: average(hitBufferCounts),\n peakHitBufferCount:\n hitBufferCounts.length > 0 ? Math.max(...hitBufferCounts) : undefined,\n byBounceDepth: [...byBounceDepth.values()]\n .map((bucket) => ({\n bounceDepth: bucket.bounceDepth,\n sampleCount: bucket.sampleCount,\n averageActiveRayCount: average(bucket.activeRayCounts) ?? 0,\n peakActiveRayCount: Math.max(...bucket.activeRayCounts),\n averageHitBufferCount: average(bucket.hitBufferCounts),\n peakHitBufferCount:\n bucket.hitBufferCounts.length > 0\n ? Math.max(...bucket.hitBufferCounts)\n : undefined,\n totalOverflowCount: bucket.totalOverflowCount,\n }))\n .sort((left, right) => left.bounceDepth - right.bounceDepth),\n byTerminationReason: [...byTerminationReason.entries()]\n .map(([reason, count]) => ({ reason, count }))\n .sort((left, right) => right.count - left.count),\n byHitKind: [...byHitKind.entries()]\n .map(([kind, count]) => ({ kind, count }))\n .sort((left, right) => right.count - left.count),\n };\n };\n\n return {\n isEnabled() {\n return enabled;\n },\n setEnabled(nextEnabled) {\n enabled = Boolean(nextEnabled);\n },\n trackAllocation(allocation) {\n if (!enabled || allocation.signal?.aborted === true) {\n return () => {};\n }\n\n const normalized = normalizeAllocation(allocation);\n if (!allocations.has(normalized.id)) {\n allocationOrder.push(normalized.id);\n }\n allocations.set(normalized.id, normalized);\n ensureAllocationCapacity();\n updatePeakTrackedBytes();\n\n return () => {\n this.releaseAllocation(normalized.id);\n };\n },\n releaseAllocation(id) {\n const normalizedId = assertIdentifier(\"allocation.id\", id);\n const deleted = allocations.delete(normalizedId);\n if (!deleted) {\n return false;\n }\n\n const index = allocationOrder.indexOf(normalizedId);\n if (index >= 0) {\n allocationOrder.splice(index, 1);\n }\n\n return true;\n },\n recordQueue(sample) {\n if (!enabled || sample.signal?.aborted === true) {\n return false;\n }\n\n queueSamples.push(normalizeQueueSample(sample));\n trimHistory(queueSamples, settings.maxRetainedQueueSamples);\n return true;\n },\n recordReadyLane(sample) {\n if (!enabled || sample.signal?.aborted === true) {\n return false;\n }\n\n readyLaneSamples.push(normalizeReadyLaneSample(sample));\n trimHistory(readyLaneSamples, settings.maxRetainedReadyLaneSamples);\n return true;\n },\n recordDispatch(sample) {\n if (!enabled || sample.signal?.aborted === true) {\n return false;\n }\n\n dispatchSamples.push(normalizeDispatchSample(sample));\n trimHistory(dispatchSamples, settings.maxRetainedDispatches);\n return true;\n },\n recordDependencyUnlock(sample) {\n if (!enabled || sample.signal?.aborted === true) {\n return false;\n }\n\n dependencyUnlockSamples.push(normalizeDependencyUnlockSample(sample));\n trimHistory(\n dependencyUnlockSamples,\n settings.maxRetainedDependencyUnlockSamples\n );\n return true;\n },\n recordPipelinePhase(sample) {\n if (!enabled || sample.signal?.aborted === true) {\n return false;\n }\n\n pipelinePhaseSamples.push(normalizePipelinePhaseSample(sample));\n trimHistory(\n pipelinePhaseSamples,\n settings.maxRetainedPipelinePhaseSamples\n );\n return true;\n },\n recordWavefrontTelemetry(sample) {\n if (!enabled || sample.signal?.aborted === true) {\n return false;\n }\n\n wavefrontSamples.push(normalizeWavefrontTelemetrySample(sample));\n trimHistory(wavefrontSamples, settings.maxRetainedWavefrontSamples);\n return true;\n },\n recordFrame(sample) {\n if (!enabled || sample.signal?.aborted === true) {\n return false;\n }\n\n frameSamples.push(normalizeFrameSample(sample));\n trimHistory(frameSamples, settings.maxRetainedFrameSamples);\n return true;\n },\n getSnapshot() {\n const memoryByOwner = new Map<string, number>();\n const memoryByCategory = new Map<GpuResourceCategory, number>();\n for (const allocation of allocations.values()) {\n pushAggregate(memoryByOwner, allocation.owner, allocation.sizeBytes);\n pushAggregate(memoryByCategory, allocation.category, allocation.sizeBytes);\n }\n\n const totalBytes = totalTrackedBytes();\n const frameTimes = frameSamples.map((sample) => sample.frameTimeMs);\n const targetFrameTimes = frameSamples\n .map((sample) => sample.targetFrameTimeMs)\n .filter((value): value is number => value !== undefined);\n const gpuBusyTimes = frameSamples\n .map((sample) => sample.gpuBusyMs)\n .filter((value): value is number => value !== undefined);\n\n const snapshot: GpuDebugSnapshot = {\n enabled,\n adapter,\n memory: {\n totalTrackedBytes: totalBytes,\n peakTrackedBytes,\n allocationCount: allocations.size,\n trackedUsageRatio:\n adapter.memoryCapacityHintBytes !== undefined\n ? totalBytes / adapter.memoryCapacityHintBytes\n : undefined,\n byOwner: [...memoryByOwner.entries()]\n .map(([owner, bytes]) => ({ owner, bytes }))\n .sort((left, right) => right.bytes - left.bytes),\n byCategory: [...memoryByCategory.entries()]\n .map(([category, bytes]) => ({ category, bytes }))\n .sort((left, right) => right.bytes - left.bytes),\n },\n dispatch: buildDispatchSnapshot(),\n queues: buildQueueSnapshot(),\n frames: {\n sampleCount: frameSamples.length,\n latestFrameTimeMs: frameSamples[frameSamples.length - 1]?.frameTimeMs,\n averageFrameTimeMs: average(frameTimes),\n averageTargetFrameTimeMs: average(targetFrameTimes),\n droppedFrameRatio:\n frameSamples.length > 0\n ? frameSamples.filter((sample) => sample.dropped === true).length /\n frameSamples.length\n : undefined,\n averageGpuBusyMs: average(gpuBusyTimes),\n },\n dag: buildDagSnapshot(),\n pipeline: buildPipelineSnapshot(),\n wavefront: buildWavefrontSnapshot(),\n limitations: LIMITATIONS,\n };\n\n return snapshot;\n },\n reset() {\n allocations.clear();\n allocationOrder.splice(0, allocationOrder.length);\n queueSamples.splice(0, queueSamples.length);\n readyLaneSamples.splice(0, readyLaneSamples.length);\n dispatchSamples.splice(0, dispatchSamples.length);\n dependencyUnlockSamples.splice(0, dependencyUnlockSamples.length);\n pipelinePhaseSamples.splice(0, pipelinePhaseSamples.length);\n wavefrontSamples.splice(0, wavefrontSamples.length);\n frameSamples.splice(0, frameSamples.length);\n peakTrackedBytes = 0;\n },\n };\n}\n\nexport function summarizeWavefrontTelemetry(\n snapshot: GpuDebugWavefrontSnapshot | undefined\n): readonly string[] {\n if (!snapshot || snapshot.sampleCount === 0) {\n return Object.freeze([\"Wavefront telemetry: no samples recorded.\"]);\n }\n\n const lines = [\n `Wavefront telemetry: ${snapshot.sampleCount} samples, peak ${snapshot.peakActiveRayCount} active rays, overflow ${snapshot.totalOverflowCount}, max bounce ${snapshot.maxBounceDepth ?? 0}.`,\n ];\n\n if (snapshot.byTerminationReason.length > 0) {\n lines.push(\n `Termination reasons: ${snapshot.byTerminationReason\n .slice(0, 3)\n .map((entry) => `${entry.reason}=${entry.count}`)\n .join(\", \")}.`\n );\n } else {\n lines.push(\"Termination reasons: none recorded.\");\n }\n\n if (snapshot.byHitKind.length > 0) {\n lines.push(\n `Hit kinds: ${snapshot.byHitKind\n .slice(0, 3)\n .map((entry) => `${entry.kind}=${entry.count}`)\n .join(\", \")}.`\n );\n } else {\n lines.push(\"Hit kinds: none recorded.\");\n }\n\n lines.push(\n `Bounce depth: ${snapshot.byBounceDepth\n .map(\n (entry) =>\n `b${entry.bounceDepth} avg=${entry.averageActiveRayCount.toFixed(1)} peak=${entry.peakActiveRayCount}`\n )\n .join(\"; \")}.`\n );\n\n return Object.freeze(lines);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;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C3C,UAAM;AAAA,MACJ,wBAAwB,SAAS,oBAC9B,MAAM,GAAG,CAAC,EACV,IAAI,CAAC,UAAU,GAAG,MAAM,MAAM,IAAI,MAAM,KAAK,EAAE,EAC/C,KAAK,IAAI,CAAC;AAAA,IACf;AAAA,EACF,OAAO;AACL,UAAM,KAAK,qCAAqC;AAAA,EAClD;AAEA,MAAI,SAAS,UAAU,SAAS,GAAG;AACjC,UAAM;AAAA,MACJ,cAAc,SAAS,UACpB,MAAM,GAAG,CAAC,EACV,IAAI,CAAC,UAAU,GAAG,MAAM,IAAI,IAAI,MAAM,KAAK,EAAE,EAC7C,KAAK,IAAI,CAAC;AAAA,IACf;AAAA,EACF,OAAO;AACL,UAAM,KAAK,2BAA2B;AAAA,EACxC;AAEA,QAAM;AAAA,IACJ,iBAAiB,SAAS,cACvB;AAAA,MACC,CAAC,UACC,IAAI,MAAM,WAAW,QAAQ,MAAM,sBAAsB,QAAQ,CAAC,CAAC,SAAS,MAAM,kBAAkB;AAAA,IACxG,EACC,KAAK,IAAI,CAAC;AAAA,EACf;AAEA,SAAO,OAAO,OAAO,KAAK;AAC5B;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts","../src/validation.ts","../src/session.ts"],"sourcesContent":["export {\n createGpuDebugSession,\n estimateDispatchInvocations,\n summarizeFixedSppTelemetry,\n summarizeWavefrontTelemetry,\n} from \"./session.js\";\nexport {\n gpuDebugQueueClasses,\n gpuPipelinePhases,\n gpuResourceCategories,\n} from \"./validation.js\";\nexport type * from \"./types.js\";\n","import type {\n GpuDebugAdapterInfo,\n GpuPipelinePhase,\n GpuDebugQueueClass,\n GpuResourceCategory,\n GpuVector3,\n} from \"./types.js\";\n\nconst IDENTIFIER_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,63}$/u;\n\nexport const gpuDebugQueueClasses = Object.freeze([\n \"render\",\n \"simulation\",\n \"lighting\",\n \"post-processing\",\n \"voxel\",\n \"transfer\",\n \"custom\",\n]) satisfies readonly GpuDebugQueueClass[];\n\nexport const gpuResourceCategories = Object.freeze([\n \"buffer\",\n \"texture\",\n \"bind-group\",\n \"pipeline\",\n \"custom\",\n]) satisfies readonly GpuResourceCategory[];\n\nexport const gpuPipelinePhases = Object.freeze([\n \"simulation\",\n \"secondary-simulation\",\n \"scene-preparation\",\n \"render\",\n]) satisfies readonly GpuPipelinePhase[];\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nexport function assertIdentifier(name: string, value: unknown): string {\n if (typeof value !== \"string\" || !IDENTIFIER_PATTERN.test(value)) {\n throw new Error(\n `${name} must match ${IDENTIFIER_PATTERN.toString()} and be at most 64 characters long.`\n );\n }\n\n return value;\n}\n\nexport function assertEnumValue<T extends string>(\n name: string,\n value: unknown,\n allowedValues: readonly T[]\n): T {\n if (typeof value !== \"string\" || !allowedValues.includes(value as T)) {\n throw new Error(`${name} must be one of: ${allowedValues.join(\", \")}.`);\n }\n\n return value as T;\n}\n\nexport function readPositiveNumber(\n name: string,\n value: unknown\n): number | undefined {\n if (value === undefined) {\n return undefined;\n }\n\n if (typeof value !== \"number\" || !Number.isFinite(value) || value <= 0) {\n throw new Error(`${name} must be a finite number greater than zero.`);\n }\n\n return value;\n}\n\nexport function readNonNegativeNumber(\n name: string,\n value: unknown\n): number | undefined {\n if (value === undefined) {\n return undefined;\n }\n\n if (typeof value !== \"number\" || !Number.isFinite(value) || value < 0) {\n throw new Error(`${name} must be a finite number greater than or equal to zero.`);\n }\n\n return value;\n}\n\nexport function readPositiveInteger(\n name: string,\n value: unknown\n): number | undefined {\n const parsed = readPositiveNumber(name, value);\n if (parsed === undefined) {\n return undefined;\n }\n\n if (!Number.isInteger(parsed)) {\n throw new Error(`${name} must be an integer greater than zero.`);\n }\n\n return parsed;\n}\n\nexport function normalizePlainObject(\n name: string,\n value: unknown\n): Readonly<Record<string, unknown>> {\n if (value === undefined) {\n return Object.freeze({});\n }\n\n if (!isRecord(value)) {\n throw new Error(`${name} must be a plain object when provided.`);\n }\n\n return Object.freeze({ ...value });\n}\n\nexport function normalizeVector(\n name: string,\n value: GpuVector3\n): Required<GpuVector3> {\n const x = readPositiveInteger(`${name}.x`, value.x) ?? 1;\n const y = readPositiveInteger(`${name}.y`, value.y) ?? 1;\n const z = readPositiveInteger(`${name}.z`, value.z) ?? 1;\n return { x, y, z };\n}\n\nexport function isAbortSignalLike(value: unknown): value is AbortSignal {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"aborted\" in value &&\n typeof (value as AbortSignal).aborted === \"boolean\"\n );\n}\n\nexport function normalizeAdapterInfo(\n value: GpuDebugAdapterInfo | undefined\n): Readonly<GpuDebugAdapterInfo> {\n if (value === undefined) {\n return Object.freeze({});\n }\n\n const adapter: GpuDebugAdapterInfo = {};\n\n if (value.label !== undefined) {\n adapter.label = String(value.label).trim().slice(0, 120);\n }\n if (value.vendor !== undefined) {\n adapter.vendor = String(value.vendor).trim().slice(0, 120);\n }\n if (value.architecture !== undefined) {\n adapter.architecture = String(value.architecture).trim().slice(0, 120);\n }\n if (value.driver !== undefined) {\n adapter.driver = String(value.driver).trim().slice(0, 120);\n }\n\n adapter.maxBufferSizeBytes = readPositiveInteger(\n \"adapter.maxBufferSizeBytes\",\n value.maxBufferSizeBytes\n );\n adapter.maxStorageBufferBindingSizeBytes = readPositiveInteger(\n \"adapter.maxStorageBufferBindingSizeBytes\",\n value.maxStorageBufferBindingSizeBytes\n );\n adapter.maxComputeInvocationsPerWorkgroup = readPositiveInteger(\n \"adapter.maxComputeInvocationsPerWorkgroup\",\n value.maxComputeInvocationsPerWorkgroup\n );\n adapter.maxComputeWorkgroupsPerDimension = readPositiveInteger(\n \"adapter.maxComputeWorkgroupsPerDimension\",\n value.maxComputeWorkgroupsPerDimension\n );\n adapter.memoryCapacityHintBytes = readPositiveInteger(\n \"adapter.memoryCapacityHintBytes\",\n value.memoryCapacityHintBytes\n );\n adapter.coreCountHint = readPositiveInteger(\n \"adapter.coreCountHint\",\n value.coreCountHint\n );\n adapter.metadata = normalizePlainObject(\"adapter.metadata\", value.metadata);\n\n return Object.freeze(adapter);\n}\n","import type {\n GpuDebugDagSnapshot,\n GpuDebugDispatchSnapshot,\n GpuDebugFixedSppSnapshot,\n GpuDebugPipelineSnapshot,\n GpuDebugQueueSnapshot,\n GpuDebugSession,\n GpuDebugSessionOptions,\n GpuDebugSnapshot,\n GpuDebugWavefrontSnapshot,\n GpuDependencyUnlockSample,\n GpuDispatchSample,\n GpuFixedSppFrameTimingTelemetry,\n GpuFixedSppRayCountTelemetry,\n GpuFixedSppTelemetrySample,\n GpuFrameSample,\n GpuPipelinePhaseSample,\n GpuQueueSample,\n GpuReadyLaneSample,\n GpuResourceCategory,\n GpuWavefrontHitKindSample,\n GpuWavefrontTerminationSample,\n GpuWavefrontTelemetrySample,\n TrackedGpuAllocation,\n} from \"./types.js\";\nimport {\n assertEnumValue,\n assertIdentifier,\n gpuDebugQueueClasses,\n gpuPipelinePhases,\n gpuResourceCategories,\n isAbortSignalLike,\n normalizeAdapterInfo,\n normalizeVector,\n readNonNegativeNumber,\n readPositiveInteger,\n readPositiveNumber,\n} from \"./validation.js\";\n\nconst DEFAULT_OPTIONS = Object.freeze({\n enabled: false,\n maxRetainedDispatches: 240,\n maxRetainedQueueSamples: 240,\n maxRetainedReadyLaneSamples: 240,\n maxRetainedDependencyUnlockSamples: 240,\n maxRetainedPipelinePhaseSamples: 240,\n maxRetainedWavefrontSamples: 240,\n maxRetainedFixedSppSamples: 240,\n maxRetainedFrameSamples: 240,\n maxTrackedAllocations: 512,\n});\n\nconst LIMITATIONS = Object.freeze([\n \"Tracked memory reflects only allocations reported to this debug session.\",\n \"Portable WebGPU does not expose authoritative live GPU core-count or total-memory counters.\",\n \"Hardware hints are optional caller-supplied metadata and may be platform-specific.\",\n \"Ready-lane and dependency-unlock diagnostics are caller-reported integration samples, not automatic WebGPU counters.\",\n \"Pipeline phase and snapshot-lag diagnostics are caller-reported integration samples, not automatic WebGPU counters.\",\n \"Wavefront queue, hit-buffer, and termination diagnostics are caller-reported summaries rather than full GPU buffer dumps.\",\n \"Fixed-SPP ray and timing evidence is retained from caller-resolved renderer statistics; this package does not initiate GPU readbacks.\",\n]);\n\nconst FIXED_SPP_RAY_COUNT_STATUSES = Object.freeze([\n \"not-requested\",\n \"available\",\n \"unavailable\",\n \"failed\",\n] as const);\n\nconst FIXED_SPP_TIMING_STATUSES = Object.freeze([\n \"not-requested\",\n \"available\",\n \"fallback\",\n \"unavailable\",\n \"failed\",\n] as const);\n\nconst FIXED_SPP_TIMESTAMP_QUERY_STATUSES = Object.freeze([\n \"not-recorded\",\n \"available\",\n \"unsupported\",\n \"failed\",\n] as const);\n\nconst FIXED_SPP_TIMING_SOURCES = Object.freeze([\n \"timestamp-query\",\n \"queue-completion\",\n \"cpu-submit\",\n] as const);\n\ninterface NormalizedAllocation extends Omit<TrackedGpuAllocation, \"signal\"> {\n label?: string;\n}\n\ntype NormalizedQueueSample = Omit<GpuQueueSample, \"signal\">;\n\ninterface NormalizedReadyLaneSample extends Omit<GpuReadyLaneSample, \"signal\"> {\n priority?: number;\n}\n\ninterface NormalizedDispatchSample extends Omit<GpuDispatchSample, \"signal\"> {\n workgroups: { x: number; y: number; z: number };\n workgroupSize: { x: number; y: number; z: number };\n}\n\ntype NormalizedFrameSample = Omit<GpuFrameSample, \"signal\">;\n\ninterface NormalizedDependencyUnlockSample\n extends Omit<GpuDependencyUnlockSample, \"signal\"> {\n priority?: number;\n unlockCount: number;\n}\n\ninterface NormalizedPipelinePhaseSample\n extends Omit<GpuPipelinePhaseSample, \"signal\"> {\n durationMs?: number;\n snapshotAgeFrames?: number;\n snapshotAgeMs?: number;\n}\n\ntype NormalizedWavefrontHitKindSample = GpuWavefrontHitKindSample;\n\ntype NormalizedWavefrontTerminationSample = GpuWavefrontTerminationSample;\n\ninterface NormalizedWavefrontTelemetrySample\n extends Omit<\n GpuWavefrontTelemetrySample,\n \"signal\" | \"hitKinds\" | \"terminationReasons\"\n > {\n hitKinds: readonly NormalizedWavefrontHitKindSample[];\n terminationReasons: readonly NormalizedWavefrontTerminationSample[];\n bounceDepth: number;\n activeRayCount: number;\n queueCapacity?: number;\n overflowCount: number;\n hitBufferCount?: number;\n}\n\ninterface NormalizedFixedSppTelemetrySample\n extends Omit<GpuFixedSppTelemetrySample, \"signal\" | \"rayCounts\" | \"timings\"> {\n rayCounts: Readonly<GpuFixedSppRayCountTelemetry>;\n timings: Readonly<GpuFixedSppFrameTimingTelemetry>;\n}\n\nfunction clampCount(value: number | undefined, fallback: number): number {\n if (!value || !Number.isFinite(value) || value <= 0) {\n return fallback;\n }\n\n return Math.min(Math.round(value), 4096);\n}\n\nfunction trimHistory<T>(items: T[], maxEntries: number): void {\n while (items.length > maxEntries) {\n items.shift();\n }\n}\n\nfunction average(values: readonly number[]): number | undefined {\n if (values.length === 0) {\n return undefined;\n }\n\n return values.reduce((total, value) => total + value, 0) / values.length;\n}\n\nfunction pushAggregate<T extends string | number>(\n map: Map<T, number>,\n key: T,\n value: number\n): void {\n map.set(key, (map.get(key) ?? 0) + value);\n}\n\nfunction normalizeAllocation(allocation: TrackedGpuAllocation): NormalizedAllocation {\n if (allocation.signal !== undefined && !isAbortSignalLike(allocation.signal)) {\n throw new Error(\"allocation.signal must be an AbortSignal when provided.\");\n }\n\n return {\n id: assertIdentifier(\"allocation.id\", allocation.id),\n owner: assertIdentifier(\"allocation.owner\", allocation.owner),\n category: assertEnumValue(\n \"allocation.category\",\n allocation.category,\n gpuResourceCategories\n ),\n sizeBytes: readPositiveInteger(\"allocation.sizeBytes\", allocation.sizeBytes) ?? 1,\n label:\n allocation.label === undefined\n ? undefined\n : String(allocation.label).trim().slice(0, 120),\n };\n}\n\nfunction normalizeQueueSample(sample: GpuQueueSample): NormalizedQueueSample {\n if (sample.signal !== undefined && !isAbortSignalLike(sample.signal)) {\n throw new Error(\"queue.signal must be an AbortSignal when provided.\");\n }\n\n const capacity = readPositiveInteger(\"queue.capacity\", sample.capacity);\n const depth = readNonNegativeNumber(\"queue.depth\", sample.depth) ?? 0;\n\n if (capacity !== undefined && depth > capacity) {\n throw new Error(\"queue.depth cannot exceed queue.capacity.\");\n }\n\n return {\n owner: assertIdentifier(\"queue.owner\", sample.owner),\n queueClass: assertEnumValue(\n \"queue.queueClass\",\n sample.queueClass,\n gpuDebugQueueClasses\n ),\n depth,\n capacity,\n frameId:\n sample.frameId === undefined\n ? undefined\n : assertIdentifier(\"queue.frameId\", sample.frameId),\n };\n}\n\nfunction normalizeReadyLaneSample(\n sample: GpuReadyLaneSample\n): NormalizedReadyLaneSample {\n if (sample.signal !== undefined && !isAbortSignalLike(sample.signal)) {\n throw new Error(\"readyLane.signal must be an AbortSignal when provided.\");\n }\n\n const capacity = readPositiveInteger(\"readyLane.capacity\", sample.capacity);\n const depth = readNonNegativeNumber(\"readyLane.depth\", sample.depth) ?? 0;\n\n if (capacity !== undefined && depth > capacity) {\n throw new Error(\"readyLane.depth cannot exceed readyLane.capacity.\");\n }\n\n const priority = readNonNegativeNumber(\"readyLane.priority\", sample.priority);\n if (priority !== undefined && !Number.isInteger(priority)) {\n throw new Error(\"readyLane.priority must be an integer greater than or equal to zero.\");\n }\n\n return {\n owner: assertIdentifier(\"readyLane.owner\", sample.owner),\n queueClass: assertEnumValue(\n \"readyLane.queueClass\",\n sample.queueClass,\n gpuDebugQueueClasses\n ),\n laneId: assertIdentifier(\"readyLane.laneId\", sample.laneId),\n priority,\n depth,\n capacity,\n frameId:\n sample.frameId === undefined\n ? undefined\n : assertIdentifier(\"readyLane.frameId\", sample.frameId),\n };\n}\n\nfunction normalizeDispatchSample(\n sample: GpuDispatchSample\n): NormalizedDispatchSample {\n if (sample.signal !== undefined && !isAbortSignalLike(sample.signal)) {\n throw new Error(\"dispatch.signal must be an AbortSignal when provided.\");\n }\n\n return {\n id:\n sample.id === undefined ? undefined : assertIdentifier(\"dispatch.id\", sample.id),\n owner: assertIdentifier(\"dispatch.owner\", sample.owner),\n queueClass: assertEnumValue(\n \"dispatch.queueClass\",\n sample.queueClass,\n gpuDebugQueueClasses\n ),\n jobType: assertIdentifier(\"dispatch.jobType\", sample.jobType),\n frameId:\n sample.frameId === undefined\n ? undefined\n : assertIdentifier(\"dispatch.frameId\", sample.frameId),\n durationMs: readNonNegativeNumber(\"dispatch.durationMs\", sample.durationMs),\n workgroups: normalizeVector(\"dispatch.workgroups\", sample.workgroups),\n workgroupSize: normalizeVector(\n \"dispatch.workgroupSize\",\n sample.workgroupSize ?? { x: 1, y: 1, z: 1 }\n ),\n bytesRead: readNonNegativeNumber(\"dispatch.bytesRead\", sample.bytesRead),\n bytesWritten: readNonNegativeNumber(\"dispatch.bytesWritten\", sample.bytesWritten),\n };\n}\n\nfunction normalizeFrameSample(sample: GpuFrameSample): NormalizedFrameSample {\n if (sample.signal !== undefined && !isAbortSignalLike(sample.signal)) {\n throw new Error(\"frame.signal must be an AbortSignal when provided.\");\n }\n\n if (sample.dropped !== undefined && typeof sample.dropped !== \"boolean\") {\n throw new Error(\"frame.dropped must be a boolean when provided.\");\n }\n\n return {\n frameId:\n sample.frameId === undefined\n ? undefined\n : assertIdentifier(\"frame.frameId\", sample.frameId),\n frameTimeMs: readPositiveNumber(\"frame.frameTimeMs\", sample.frameTimeMs) ?? 0,\n targetFrameTimeMs: readPositiveNumber(\n \"frame.targetFrameTimeMs\",\n sample.targetFrameTimeMs\n ),\n gpuBusyMs: readNonNegativeNumber(\"frame.gpuBusyMs\", sample.gpuBusyMs),\n dropped: sample.dropped,\n };\n}\n\nfunction normalizeDependencyUnlockSample(\n sample: GpuDependencyUnlockSample\n): NormalizedDependencyUnlockSample {\n if (sample.signal !== undefined && !isAbortSignalLike(sample.signal)) {\n throw new Error(\"dependencyUnlock.signal must be an AbortSignal when provided.\");\n }\n\n const priority = readNonNegativeNumber(\n \"dependencyUnlock.priority\",\n sample.priority\n );\n if (priority !== undefined && !Number.isInteger(priority)) {\n throw new Error(\n \"dependencyUnlock.priority must be an integer greater than or equal to zero.\"\n );\n }\n\n return {\n owner: assertIdentifier(\"dependencyUnlock.owner\", sample.owner),\n queueClass: assertEnumValue(\n \"dependencyUnlock.queueClass\",\n sample.queueClass,\n gpuDebugQueueClasses\n ),\n sourceJobType: assertIdentifier(\n \"dependencyUnlock.sourceJobType\",\n sample.sourceJobType\n ),\n unlockedJobType: assertIdentifier(\n \"dependencyUnlock.unlockedJobType\",\n sample.unlockedJobType\n ),\n priority,\n unlockCount:\n readPositiveInteger(\"dependencyUnlock.unlockCount\", sample.unlockCount) ?? 1,\n frameId:\n sample.frameId === undefined\n ? undefined\n : assertIdentifier(\"dependencyUnlock.frameId\", sample.frameId),\n };\n}\n\nfunction normalizePipelinePhaseSample(\n sample: GpuPipelinePhaseSample\n): NormalizedPipelinePhaseSample {\n if (sample.signal !== undefined && !isAbortSignalLike(sample.signal)) {\n throw new Error(\"pipelinePhase.signal must be an AbortSignal when provided.\");\n }\n\n const snapshotAgeFrames = readNonNegativeNumber(\n \"pipelinePhase.snapshotAgeFrames\",\n sample.snapshotAgeFrames\n );\n if (snapshotAgeFrames !== undefined && !Number.isInteger(snapshotAgeFrames)) {\n throw new Error(\n \"pipelinePhase.snapshotAgeFrames must be an integer greater than or equal to zero.\"\n );\n }\n\n return {\n owner: assertIdentifier(\"pipelinePhase.owner\", sample.owner),\n pipeline: assertEnumValue(\n \"pipelinePhase.pipeline\",\n sample.pipeline,\n gpuPipelinePhases\n ),\n stage: assertIdentifier(\"pipelinePhase.stage\", sample.stage),\n frameId:\n sample.frameId === undefined\n ? undefined\n : assertIdentifier(\"pipelinePhase.frameId\", sample.frameId),\n durationMs: readNonNegativeNumber(\n \"pipelinePhase.durationMs\",\n sample.durationMs\n ),\n snapshotFrameId:\n sample.snapshotFrameId === undefined\n ? undefined\n : assertIdentifier(\"pipelinePhase.snapshotFrameId\", sample.snapshotFrameId),\n snapshotAgeFrames,\n snapshotAgeMs: readNonNegativeNumber(\n \"pipelinePhase.snapshotAgeMs\",\n sample.snapshotAgeMs\n ),\n };\n}\n\nfunction normalizeWavefrontHitKinds(\n entries: GpuWavefrontTelemetrySample[\"hitKinds\"]\n): readonly NormalizedWavefrontHitKindSample[] {\n if (entries === undefined) {\n return Object.freeze([]);\n }\n if (!Array.isArray(entries)) {\n throw new Error(\"wavefront.hitKinds must be an array when provided.\");\n }\n return Object.freeze(\n entries.map((entry, index) => {\n if (!entry || typeof entry !== \"object\" || Array.isArray(entry)) {\n throw new Error(`wavefront.hitKinds[${index}] must be an object.`);\n }\n return Object.freeze({\n kind: assertIdentifier(`wavefront.hitKinds[${index}].kind`, entry.kind),\n count:\n readPositiveInteger(`wavefront.hitKinds[${index}].count`, entry.count) ??\n 1,\n });\n })\n );\n}\n\nfunction normalizeWavefrontTerminationReasons(\n entries: GpuWavefrontTelemetrySample[\"terminationReasons\"]\n): readonly NormalizedWavefrontTerminationSample[] {\n if (entries === undefined) {\n return Object.freeze([]);\n }\n if (!Array.isArray(entries)) {\n throw new Error(\n \"wavefront.terminationReasons must be an array when provided.\"\n );\n }\n return Object.freeze(\n entries.map((entry, index) => {\n if (!entry || typeof entry !== \"object\" || Array.isArray(entry)) {\n throw new Error(\n `wavefront.terminationReasons[${index}] must be an object.`\n );\n }\n return Object.freeze({\n reason: assertIdentifier(\n `wavefront.terminationReasons[${index}].reason`,\n entry.reason\n ),\n count:\n readPositiveInteger(\n `wavefront.terminationReasons[${index}].count`,\n entry.count\n ) ?? 1,\n });\n })\n );\n}\n\nfunction normalizeWavefrontTelemetrySample(\n sample: GpuWavefrontTelemetrySample\n): NormalizedWavefrontTelemetrySample {\n if (sample.signal !== undefined && !isAbortSignalLike(sample.signal)) {\n throw new Error(\"wavefront.signal must be an AbortSignal when provided.\");\n }\n\n const queueCapacity = readPositiveInteger(\n \"wavefront.queueCapacity\",\n sample.queueCapacity\n );\n const activeRayCount =\n readNonNegativeNumber(\"wavefront.activeRayCount\", sample.activeRayCount) ?? 0;\n if (!Number.isInteger(activeRayCount)) {\n throw new Error(\"wavefront.activeRayCount must be an integer greater than or equal to zero.\");\n }\n if (queueCapacity !== undefined && activeRayCount > queueCapacity) {\n throw new Error(\n \"wavefront.activeRayCount cannot exceed wavefront.queueCapacity.\"\n );\n }\n\n const bounceDepth =\n readNonNegativeNumber(\"wavefront.bounceDepth\", sample.bounceDepth) ?? 0;\n if (!Number.isInteger(bounceDepth)) {\n throw new Error(\"wavefront.bounceDepth must be an integer greater than or equal to zero.\");\n }\n\n const overflowCount =\n readNonNegativeNumber(\"wavefront.overflowCount\", sample.overflowCount) ?? 0;\n if (!Number.isInteger(overflowCount)) {\n throw new Error(\"wavefront.overflowCount must be an integer greater than or equal to zero.\");\n }\n\n const hitBufferCount = readNonNegativeNumber(\n \"wavefront.hitBufferCount\",\n sample.hitBufferCount\n );\n if (hitBufferCount !== undefined && !Number.isInteger(hitBufferCount)) {\n throw new Error(\n \"wavefront.hitBufferCount must be an integer greater than or equal to zero.\"\n );\n }\n\n return {\n owner: assertIdentifier(\"wavefront.owner\", sample.owner),\n queueClass: assertEnumValue(\n \"wavefront.queueClass\",\n sample.queueClass,\n gpuDebugQueueClasses\n ),\n frameId:\n sample.frameId === undefined\n ? undefined\n : assertIdentifier(\"wavefront.frameId\", sample.frameId),\n bounceDepth,\n activeRayCount,\n queueCapacity,\n overflowCount,\n hitBufferCount,\n hitKinds: normalizeWavefrontHitKinds(sample.hitKinds),\n terminationReasons: normalizeWavefrontTerminationReasons(\n sample.terminationReasons\n ),\n };\n}\n\nfunction readNullableNonNegativeInteger(\n name: string,\n value: unknown\n): number | null {\n if (value === null) {\n return null;\n }\n const parsed = readNonNegativeNumber(name, value);\n if (parsed === undefined || !Number.isInteger(parsed)) {\n throw new Error(`${name} must be null or an integer greater than or equal to zero.`);\n }\n return parsed;\n}\n\nfunction readRequiredNonNegativeInteger(name: string, value: unknown): number {\n const parsed = readNonNegativeNumber(name, value);\n if (parsed === undefined || !Number.isInteger(parsed)) {\n throw new Error(`${name} must be an integer greater than or equal to zero.`);\n }\n return parsed;\n}\n\nfunction readRequiredPositiveInteger(name: string, value: unknown): number {\n const parsed = readPositiveInteger(name, value);\n if (parsed === undefined) {\n throw new Error(`${name} must be an integer greater than zero.`);\n }\n return parsed;\n}\n\nfunction readRequiredNonNegativeNumber(name: string, value: unknown): number {\n const parsed = readNonNegativeNumber(name, value);\n if (parsed === undefined) {\n throw new Error(`${name} must be a finite number greater than or equal to zero.`);\n }\n return parsed;\n}\n\nfunction readNullableNonNegativeNumber(\n name: string,\n value: unknown\n): number | null {\n if (value === null) {\n return null;\n }\n const parsed = readNonNegativeNumber(name, value);\n if (parsed === undefined) {\n throw new Error(`${name} must be null or a finite number greater than or equal to zero.`);\n }\n return parsed;\n}\n\nfunction normalizeEvidenceReason(name: string, value: unknown): string | null {\n if (value === null) {\n return null;\n }\n if (typeof value !== \"string\" || value.trim().length === 0) {\n throw new Error(`${name} must be null or a non-empty string.`);\n }\n return value.trim().slice(0, 240);\n}\n\nfunction normalizeFixedSppRayCounts(\n value: GpuFixedSppRayCountTelemetry\n): Readonly<GpuFixedSppRayCountTelemetry> {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) {\n throw new Error(\"fixedSpp.rayCounts must be an object.\");\n }\n if (!Array.isArray(value.bounceHistogram)) {\n throw new Error(\"fixedSpp.rayCounts.bounceHistogram must be an array.\");\n }\n\n const status = assertEnumValue(\n \"fixedSpp.rayCounts.status\",\n value.status,\n FIXED_SPP_RAY_COUNT_STATUSES\n );\n const source =\n value.source === null\n ? null\n : assertEnumValue(\n \"fixedSpp.rayCounts.source\",\n value.source,\n [\"gpu-active-queue-readback\"] as const\n );\n const expectedPrimaryRays = readNullableNonNegativeInteger(\n \"fixedSpp.rayCounts.expectedPrimaryRays\",\n value.expectedPrimaryRays\n );\n const observedPrimaryRays = readNullableNonNegativeInteger(\n \"fixedSpp.rayCounts.observedPrimaryRays\",\n value.observedPrimaryRays\n );\n const secondaryRays = readNullableNonNegativeInteger(\n \"fixedSpp.rayCounts.secondaryRays\",\n value.secondaryRays\n );\n const totalPathSegments = readNullableNonNegativeInteger(\n \"fixedSpp.rayCounts.totalPathSegments\",\n value.totalPathSegments\n );\n const bounceHistogram = Object.freeze(\n value.bounceHistogram.map((count, index) =>\n readRequiredNonNegativeInteger(\n `fixedSpp.rayCounts.bounceHistogram[${index}]`,\n count\n )\n )\n );\n const capturedRayCounts = readRequiredNonNegativeInteger(\n \"fixedSpp.rayCounts.capturedRayCounts\",\n value.capturedRayCounts\n );\n const expectedRayCounts = readRequiredNonNegativeInteger(\n \"fixedSpp.rayCounts.expectedRayCounts\",\n value.expectedRayCounts\n );\n const reason = normalizeEvidenceReason(\n \"fixedSpp.rayCounts.reason\",\n value.reason\n );\n\n if (capturedRayCounts !== bounceHistogram.length) {\n throw new Error(\n \"fixedSpp.rayCounts.capturedRayCounts must match the bounce histogram length.\"\n );\n }\n if (\n status === \"available\" &&\n (source === null ||\n expectedPrimaryRays === null ||\n observedPrimaryRays === null ||\n secondaryRays === null ||\n totalPathSegments === null)\n ) {\n throw new Error(\n \"available fixedSpp.rayCounts require a source and complete ray measurements.\"\n );\n }\n if (\n status === \"available\" &&\n bounceHistogram.reduce((total, count) => total + count, 0) !==\n totalPathSegments\n ) {\n throw new Error(\n \"available fixedSpp.rayCounts bounce histogram must sum to totalPathSegments.\"\n );\n }\n\n return Object.freeze({\n status,\n source,\n expectedPrimaryRays,\n observedPrimaryRays,\n secondaryRays,\n totalPathSegments,\n bounceHistogram,\n capturedRayCounts,\n expectedRayCounts,\n reason,\n });\n}\n\nfunction normalizeFixedSppTimings(\n value: GpuFixedSppFrameTimingTelemetry\n): Readonly<GpuFixedSppFrameTimingTelemetry> {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) {\n throw new Error(\"fixedSpp.timings must be an object.\");\n }\n\n const status = assertEnumValue(\n \"fixedSpp.timings.status\",\n value.status,\n FIXED_SPP_TIMING_STATUSES\n );\n const source =\n value.source === null\n ? null\n : assertEnumValue(\n \"fixedSpp.timings.source\",\n value.source,\n FIXED_SPP_TIMING_SOURCES\n );\n const timestampQueryStatus = assertEnumValue(\n \"fixedSpp.timings.timestampQueryStatus\",\n value.timestampQueryStatus,\n FIXED_SPP_TIMESTAMP_QUERY_STATUSES\n );\n const totalGpuTimeMs = readNullableNonNegativeNumber(\n \"fixedSpp.timings.totalGpuTimeMs\",\n value.totalGpuTimeMs\n );\n const totalRenderJobTimeMs = readRequiredNonNegativeNumber(\n \"fixedSpp.timings.totalRenderJobTimeMs\",\n value.totalRenderJobTimeMs\n );\n const classificationTimeMs = readNullableNonNegativeNumber(\n \"fixedSpp.timings.classificationTimeMs\",\n value.classificationTimeMs\n );\n const compactionTimeMs = readNullableNonNegativeNumber(\n \"fixedSpp.timings.compactionTimeMs\",\n value.compactionTimeMs\n );\n const samplingTimeMs = readNullableNonNegativeNumber(\n \"fixedSpp.timings.samplingTimeMs\",\n value.samplingTimeMs\n );\n const reason = normalizeEvidenceReason(\"fixedSpp.timings.reason\", value.reason);\n\n if (\n timestampQueryStatus === \"available\" &&\n (status !== \"available\" || source !== \"timestamp-query\" || totalGpuTimeMs === null)\n ) {\n throw new Error(\n \"available timestamp-query evidence requires available timestamp timing and totalGpuTimeMs.\"\n );\n }\n\n return Object.freeze({\n status,\n source,\n timestampQueryStatus,\n totalGpuTimeMs,\n totalRenderJobTimeMs,\n classificationTimeMs,\n compactionTimeMs,\n samplingTimeMs,\n reason,\n });\n}\n\nfunction normalizeFixedSppTelemetrySample(\n sample: GpuFixedSppTelemetrySample\n): NormalizedFixedSppTelemetrySample {\n if (sample.signal !== undefined && !isAbortSignalLike(sample.signal)) {\n throw new Error(\"fixedSpp.signal must be an AbortSignal when provided.\");\n }\n\n const samplesPerPixel = readRequiredPositiveInteger(\n \"fixedSpp.samplesPerPixel\",\n sample.samplesPerPixel\n );\n const renderedSamplesPerPixel = readRequiredPositiveInteger(\n \"fixedSpp.renderedSamplesPerPixel\",\n sample.renderedSamplesPerPixel\n );\n if (renderedSamplesPerPixel > samplesPerPixel) {\n throw new Error(\n \"fixedSpp.renderedSamplesPerPixel cannot exceed fixedSpp.samplesPerPixel.\"\n );\n }\n\n const primaryRays = readRequiredNonNegativeInteger(\n \"fixedSpp.primaryRays\",\n sample.primaryRays\n );\n const secondaryRays = readNullableNonNegativeInteger(\n \"fixedSpp.secondaryRays\",\n sample.secondaryRays\n );\n const totalPathSegments = readNullableNonNegativeInteger(\n \"fixedSpp.totalPathSegments\",\n sample.totalPathSegments\n );\n const rayCounts = normalizeFixedSppRayCounts(sample.rayCounts);\n const timings = normalizeFixedSppTimings(sample.timings);\n const telemetryMemoryBytes = readRequiredNonNegativeInteger(\n \"fixedSpp.telemetryMemoryBytes\",\n sample.telemetryMemoryBytes\n );\n\n if (secondaryRays !== rayCounts.secondaryRays) {\n throw new Error(\n \"fixedSpp.secondaryRays must match fixedSpp.rayCounts.secondaryRays.\"\n );\n }\n if (totalPathSegments !== rayCounts.totalPathSegments) {\n throw new Error(\n \"fixedSpp.totalPathSegments must match fixedSpp.rayCounts.totalPathSegments.\"\n );\n }\n if ((secondaryRays === null) !== (totalPathSegments === null)) {\n throw new Error(\n \"fixedSpp.secondaryRays and fixedSpp.totalPathSegments must both be measured or both be null.\"\n );\n }\n if (secondaryRays !== null && totalPathSegments !== primaryRays + secondaryRays) {\n throw new Error(\n \"fixedSpp.totalPathSegments must equal primaryRays plus secondaryRays when measured.\"\n );\n }\n if (\n rayCounts.expectedPrimaryRays !== null &&\n rayCounts.expectedPrimaryRays !== primaryRays\n ) {\n throw new Error(\n \"fixedSpp.primaryRays must match fixedSpp.rayCounts.expectedPrimaryRays.\"\n );\n }\n if (\n rayCounts.status === \"available\" &&\n rayCounts.observedPrimaryRays !== primaryRays\n ) {\n throw new Error(\n \"available fixedSpp.rayCounts observedPrimaryRays must match primaryRays.\"\n );\n }\n\n return Object.freeze({\n owner: assertIdentifier(\"fixedSpp.owner\", sample.owner),\n queueClass: assertEnumValue(\n \"fixedSpp.queueClass\",\n sample.queueClass,\n gpuDebugQueueClasses\n ),\n frameId:\n sample.frameId === undefined\n ? undefined\n : assertIdentifier(\"fixedSpp.frameId\", sample.frameId),\n samplesPerPixel,\n renderedSamplesPerPixel,\n primaryRays,\n secondaryRays,\n totalPathSegments,\n rayCounts,\n timings,\n telemetryMemoryBytes,\n });\n}\n\nexport function estimateDispatchInvocations(sample: GpuDispatchSample): number {\n const normalized = normalizeDispatchSample(sample);\n return (\n normalized.workgroups.x *\n normalized.workgroups.y *\n normalized.workgroups.z *\n normalized.workgroupSize.x *\n normalized.workgroupSize.y *\n normalized.workgroupSize.z\n );\n}\n\nexport function createGpuDebugSession(\n options: GpuDebugSessionOptions = {}\n): GpuDebugSession {\n const settings = {\n enabled: options.enabled ?? DEFAULT_OPTIONS.enabled,\n maxRetainedDispatches: clampCount(\n options.maxRetainedDispatches,\n DEFAULT_OPTIONS.maxRetainedDispatches\n ),\n maxRetainedQueueSamples: clampCount(\n options.maxRetainedQueueSamples,\n DEFAULT_OPTIONS.maxRetainedQueueSamples\n ),\n maxRetainedReadyLaneSamples: clampCount(\n options.maxRetainedReadyLaneSamples,\n DEFAULT_OPTIONS.maxRetainedReadyLaneSamples\n ),\n maxRetainedDependencyUnlockSamples: clampCount(\n options.maxRetainedDependencyUnlockSamples,\n DEFAULT_OPTIONS.maxRetainedDependencyUnlockSamples\n ),\n maxRetainedPipelinePhaseSamples: clampCount(\n options.maxRetainedPipelinePhaseSamples,\n DEFAULT_OPTIONS.maxRetainedPipelinePhaseSamples\n ),\n maxRetainedWavefrontSamples: clampCount(\n options.maxRetainedWavefrontSamples,\n DEFAULT_OPTIONS.maxRetainedWavefrontSamples\n ),\n maxRetainedFixedSppSamples: clampCount(\n options.maxRetainedFixedSppSamples,\n DEFAULT_OPTIONS.maxRetainedFixedSppSamples\n ),\n maxRetainedFrameSamples: clampCount(\n options.maxRetainedFrameSamples,\n DEFAULT_OPTIONS.maxRetainedFrameSamples\n ),\n maxTrackedAllocations: clampCount(\n options.maxTrackedAllocations,\n DEFAULT_OPTIONS.maxTrackedAllocations\n ),\n };\n\n const adapter = normalizeAdapterInfo(options.adapter);\n let enabled = settings.enabled;\n const allocations = new Map<string, NormalizedAllocation>();\n const allocationOrder: string[] = [];\n const queueSamples: NormalizedQueueSample[] = [];\n const readyLaneSamples: NormalizedReadyLaneSample[] = [];\n const dispatchSamples: NormalizedDispatchSample[] = [];\n const dependencyUnlockSamples: NormalizedDependencyUnlockSample[] = [];\n const pipelinePhaseSamples: NormalizedPipelinePhaseSample[] = [];\n const wavefrontSamples: NormalizedWavefrontTelemetrySample[] = [];\n const fixedSppSamples: NormalizedFixedSppTelemetrySample[] = [];\n const frameSamples: NormalizedFrameSample[] = [];\n let peakTrackedBytes = 0;\n\n const totalTrackedBytes = (): number =>\n [...allocations.values()].reduce((total, allocation) => total + allocation.sizeBytes, 0);\n\n const updatePeakTrackedBytes = (): void => {\n peakTrackedBytes = Math.max(peakTrackedBytes, totalTrackedBytes());\n };\n\n const ensureAllocationCapacity = (): void => {\n while (allocationOrder.length > settings.maxTrackedAllocations) {\n const oldestId = allocationOrder.shift();\n if (oldestId !== undefined) {\n allocations.delete(oldestId);\n }\n }\n };\n\n const buildDispatchSnapshot = (): GpuDebugDispatchSnapshot => {\n const durations = dispatchSamples\n .map((sample) => sample.durationMs)\n .filter((value): value is number => value !== undefined);\n const bytesRead = dispatchSamples\n .map((sample) => sample.bytesRead)\n .filter((value): value is number => value !== undefined);\n const bytesWritten = dispatchSamples\n .map((sample) => sample.bytesWritten)\n .filter((value): value is number => value !== undefined);\n\n const byQueueClass = new Map<\n NormalizedDispatchSample[\"queueClass\"],\n {\n queueClass: NormalizedDispatchSample[\"queueClass\"];\n dispatches: number;\n totalDurationMs: number;\n estimatedInvocations: number;\n }\n >();\n\n let estimatedWorkgroups = 0;\n let estimatedInvocations = 0;\n\n for (const sample of dispatchSamples) {\n const workgroupCount =\n sample.workgroups.x * sample.workgroups.y * sample.workgroups.z;\n const invocationCount =\n workgroupCount *\n sample.workgroupSize.x *\n sample.workgroupSize.y *\n sample.workgroupSize.z;\n estimatedWorkgroups += workgroupCount;\n estimatedInvocations += invocationCount;\n\n const bucket = byQueueClass.get(sample.queueClass) ?? {\n queueClass: sample.queueClass,\n dispatches: 0,\n totalDurationMs: 0,\n estimatedInvocations: 0,\n };\n bucket.dispatches += 1;\n bucket.totalDurationMs += sample.durationMs ?? 0;\n bucket.estimatedInvocations += invocationCount;\n byQueueClass.set(sample.queueClass, bucket);\n }\n\n const frameTimes = frameSamples.map((sample) => sample.frameTimeMs);\n const totalFrameTimeMs = frameTimes.reduce((total, value) => total + value, 0);\n const totalDurationMs = durations.reduce((total, value) => total + value, 0);\n\n return {\n sampleCount: dispatchSamples.length,\n totalDurationMs,\n averageDurationMs: average(durations),\n estimatedWorkgroups,\n estimatedInvocations,\n averageBytesRead: average(bytesRead),\n averageBytesWritten: average(bytesWritten),\n busyRatio:\n totalFrameTimeMs > 0 ? Math.min(totalDurationMs / totalFrameTimeMs, 1) : undefined,\n byQueueClass: [...byQueueClass.values()].sort(\n (left, right) => right.totalDurationMs - left.totalDurationMs\n ),\n };\n };\n\n const buildQueueSnapshot = (): GpuDebugQueueSnapshot => {\n const depths = queueSamples.map((sample) => sample.depth);\n const hottestQueues = queueSamples\n .map((sample) => ({\n owner: sample.owner,\n queueClass: sample.queueClass,\n depth: sample.depth,\n capacity: sample.capacity,\n utilizationRatio:\n sample.capacity !== undefined ? sample.depth / sample.capacity : undefined,\n }))\n .sort((left, right) => {\n const leftScore = left.utilizationRatio ?? left.depth;\n const rightScore = right.utilizationRatio ?? right.depth;\n return rightScore - leftScore;\n })\n .slice(0, 5);\n\n const peakUtilizationRatio = queueSamples.reduce<number | undefined>(\n (peak, sample) => {\n if (sample.capacity === undefined) {\n return peak;\n }\n\n const nextRatio = sample.depth / sample.capacity;\n return peak === undefined ? nextRatio : Math.max(peak, nextRatio);\n },\n undefined\n );\n\n return {\n sampleCount: queueSamples.length,\n averageDepth: average(depths) ?? 0,\n peakDepth: depths.length === 0 ? 0 : Math.max(...depths),\n peakUtilizationRatio,\n hottestQueues,\n };\n };\n\n const buildDagSnapshot = (): GpuDebugDagSnapshot => {\n const laneDepths = readyLaneSamples.map((sample) => sample.depth);\n const hottestReadyLanes = readyLaneSamples\n .map((sample) => ({\n owner: sample.owner,\n queueClass: sample.queueClass,\n laneId: sample.laneId,\n priority: sample.priority,\n depth: sample.depth,\n capacity: sample.capacity,\n utilizationRatio:\n sample.capacity !== undefined ? sample.depth / sample.capacity : undefined,\n }))\n .sort((left, right) => {\n const leftScore = left.utilizationRatio ?? left.depth;\n const rightScore = right.utilizationRatio ?? right.depth;\n return rightScore - leftScore;\n })\n .slice(0, 5);\n\n const peakReadyLaneUtilizationRatio = readyLaneSamples.reduce<number | undefined>(\n (peak, sample) => {\n if (sample.capacity === undefined) {\n return peak;\n }\n\n const nextRatio = sample.depth / sample.capacity;\n return peak === undefined ? nextRatio : Math.max(peak, nextRatio);\n },\n undefined\n );\n\n const bySourceJobType = new Map<\n string,\n {\n owner: string;\n queueClass: NormalizedDependencyUnlockSample[\"queueClass\"];\n sourceJobType: string;\n unlockCount: number;\n }\n >();\n const byUnlockedJobType = new Map<\n string,\n {\n owner: string;\n queueClass: NormalizedDependencyUnlockSample[\"queueClass\"];\n unlockedJobType: string;\n priority?: number;\n unlockCount: number;\n }\n >();\n\n let totalUnlockCount = 0;\n\n for (const sample of dependencyUnlockSamples) {\n totalUnlockCount += sample.unlockCount;\n\n const sourceKey = `${sample.owner}:${sample.queueClass}:${sample.sourceJobType}`;\n const unlockedKey =\n `${sample.owner}:${sample.queueClass}:` +\n `${sample.unlockedJobType}:${sample.priority ?? \"none\"}`;\n\n const sourceBucket = bySourceJobType.get(sourceKey) ?? {\n owner: sample.owner,\n queueClass: sample.queueClass,\n sourceJobType: sample.sourceJobType,\n unlockCount: 0,\n };\n sourceBucket.unlockCount += sample.unlockCount;\n bySourceJobType.set(sourceKey, sourceBucket);\n\n const unlockedBucket = byUnlockedJobType.get(unlockedKey) ?? {\n owner: sample.owner,\n queueClass: sample.queueClass,\n unlockedJobType: sample.unlockedJobType,\n priority: sample.priority,\n unlockCount: 0,\n };\n unlockedBucket.unlockCount += sample.unlockCount;\n byUnlockedJobType.set(unlockedKey, unlockedBucket);\n }\n\n return {\n readyLaneSampleCount: readyLaneSamples.length,\n averageReadyLaneDepth: average(laneDepths) ?? 0,\n peakReadyLaneDepth: laneDepths.length === 0 ? 0 : Math.max(...laneDepths),\n peakReadyLaneUtilizationRatio,\n hottestReadyLanes,\n dependencyUnlockSampleCount: dependencyUnlockSamples.length,\n totalUnlockCount,\n bySourceJobType: [...bySourceJobType.values()].sort(\n (left, right) => right.unlockCount - left.unlockCount\n ),\n byUnlockedJobType: [...byUnlockedJobType.values()].sort(\n (left, right) => right.unlockCount - left.unlockCount\n ),\n };\n };\n\n const buildPipelineSnapshot = (): GpuDebugPipelineSnapshot => {\n const durations = pipelinePhaseSamples\n .map((sample) => sample.durationMs)\n .filter((value): value is number => value !== undefined);\n const snapshotAgeMsValues = pipelinePhaseSamples\n .map((sample) => sample.snapshotAgeMs)\n .filter((value): value is number => value !== undefined);\n const snapshotAgeFrameValues = pipelinePhaseSamples\n .map((sample) => sample.snapshotAgeFrames)\n .filter((value): value is number => value !== undefined);\n\n const byPipeline = new Map<\n NormalizedPipelinePhaseSample[\"pipeline\"],\n {\n pipeline: NormalizedPipelinePhaseSample[\"pipeline\"];\n sampleCount: number;\n totalDurationMs: number;\n durationValues: number[];\n snapshotAgeMsValues: number[];\n snapshotAgeFramesValues: number[];\n }\n >();\n\n for (const sample of pipelinePhaseSamples) {\n const bucket = byPipeline.get(sample.pipeline) ?? {\n pipeline: sample.pipeline,\n sampleCount: 0,\n totalDurationMs: 0,\n durationValues: [],\n snapshotAgeMsValues: [],\n snapshotAgeFramesValues: [],\n };\n bucket.sampleCount += 1;\n bucket.totalDurationMs += sample.durationMs ?? 0;\n if (sample.durationMs !== undefined) {\n bucket.durationValues.push(sample.durationMs);\n }\n if (sample.snapshotAgeMs !== undefined) {\n bucket.snapshotAgeMsValues.push(sample.snapshotAgeMs);\n }\n if (sample.snapshotAgeFrames !== undefined) {\n bucket.snapshotAgeFramesValues.push(sample.snapshotAgeFrames);\n }\n byPipeline.set(sample.pipeline, bucket);\n }\n\n const hottestStages = pipelinePhaseSamples\n .map((sample) => ({\n owner: sample.owner,\n pipeline: sample.pipeline,\n stage: sample.stage,\n frameId: sample.frameId,\n durationMs: sample.durationMs,\n snapshotFrameId: sample.snapshotFrameId,\n snapshotAgeFrames: sample.snapshotAgeFrames,\n snapshotAgeMs: sample.snapshotAgeMs,\n }))\n .sort((left, right) => {\n const leftScore =\n left.durationMs ??\n left.snapshotAgeMs ??\n left.snapshotAgeFrames ??\n 0;\n const rightScore =\n right.durationMs ??\n right.snapshotAgeMs ??\n right.snapshotAgeFrames ??\n 0;\n return rightScore - leftScore;\n })\n .slice(0, 5);\n\n return {\n sampleCount: pipelinePhaseSamples.length,\n totalDurationMs: durations.reduce((total, value) => total + value, 0),\n averageDurationMs: average(durations),\n averageSnapshotAgeMs: average(snapshotAgeMsValues),\n maxSnapshotAgeMs:\n snapshotAgeMsValues.length > 0 ? Math.max(...snapshotAgeMsValues) : undefined,\n maxSnapshotAgeFrames:\n snapshotAgeFrameValues.length > 0\n ? Math.max(...snapshotAgeFrameValues)\n : undefined,\n byPipeline: [...byPipeline.values()]\n .map((bucket) => ({\n pipeline: bucket.pipeline,\n sampleCount: bucket.sampleCount,\n totalDurationMs: bucket.totalDurationMs,\n averageDurationMs: average(bucket.durationValues),\n averageSnapshotAgeMs: average(bucket.snapshotAgeMsValues),\n maxSnapshotAgeMs:\n bucket.snapshotAgeMsValues.length > 0\n ? Math.max(...bucket.snapshotAgeMsValues)\n : undefined,\n maxSnapshotAgeFrames:\n bucket.snapshotAgeFramesValues.length > 0\n ? Math.max(...bucket.snapshotAgeFramesValues)\n : undefined,\n }))\n .sort((left, right) => right.totalDurationMs - left.totalDurationMs),\n hottestStages,\n };\n };\n\n const buildWavefrontSnapshot = (): GpuDebugWavefrontSnapshot => {\n const activeRayCounts = wavefrontSamples.map((sample) => sample.activeRayCount);\n const hitBufferCounts = wavefrontSamples\n .map((sample) => sample.hitBufferCount)\n .filter((value): value is number => value !== undefined);\n\n const byBounceDepth = new Map<\n number,\n {\n bounceDepth: number;\n sampleCount: number;\n activeRayCounts: number[];\n hitBufferCounts: number[];\n totalOverflowCount: number;\n }\n >();\n const byTerminationReason = new Map<string, number>();\n const byHitKind = new Map<string, number>();\n\n const peakQueueUtilizationRatio = wavefrontSamples.reduce<number | undefined>(\n (peak, sample) => {\n if (sample.queueCapacity === undefined) {\n return peak;\n }\n const ratio = sample.activeRayCount / sample.queueCapacity;\n return peak === undefined ? ratio : Math.max(peak, ratio);\n },\n undefined\n );\n\n let totalOverflowCount = 0;\n let peakOverflowCount = 0;\n let maxBounceDepth: number | undefined;\n\n for (const sample of wavefrontSamples) {\n totalOverflowCount += sample.overflowCount;\n peakOverflowCount = Math.max(peakOverflowCount, sample.overflowCount);\n maxBounceDepth =\n maxBounceDepth === undefined\n ? sample.bounceDepth\n : Math.max(maxBounceDepth, sample.bounceDepth);\n\n const bucket = byBounceDepth.get(sample.bounceDepth) ?? {\n bounceDepth: sample.bounceDepth,\n sampleCount: 0,\n activeRayCounts: [],\n hitBufferCounts: [],\n totalOverflowCount: 0,\n };\n bucket.sampleCount += 1;\n bucket.activeRayCounts.push(sample.activeRayCount);\n if (sample.hitBufferCount !== undefined) {\n bucket.hitBufferCounts.push(sample.hitBufferCount);\n }\n bucket.totalOverflowCount += sample.overflowCount;\n byBounceDepth.set(sample.bounceDepth, bucket);\n\n for (const reason of sample.terminationReasons) {\n pushAggregate(byTerminationReason, reason.reason, reason.count);\n }\n for (const kind of sample.hitKinds) {\n pushAggregate(byHitKind, kind.kind, kind.count);\n }\n }\n\n return {\n sampleCount: wavefrontSamples.length,\n averageActiveRayCount: average(activeRayCounts) ?? 0,\n peakActiveRayCount:\n activeRayCounts.length > 0 ? Math.max(...activeRayCounts) : 0,\n peakQueueUtilizationRatio,\n maxBounceDepth,\n totalOverflowCount,\n peakOverflowCount,\n averageHitBufferCount: average(hitBufferCounts),\n peakHitBufferCount:\n hitBufferCounts.length > 0 ? Math.max(...hitBufferCounts) : undefined,\n byBounceDepth: [...byBounceDepth.values()]\n .map((bucket) => ({\n bounceDepth: bucket.bounceDepth,\n sampleCount: bucket.sampleCount,\n averageActiveRayCount: average(bucket.activeRayCounts) ?? 0,\n peakActiveRayCount: Math.max(...bucket.activeRayCounts),\n averageHitBufferCount: average(bucket.hitBufferCounts),\n peakHitBufferCount:\n bucket.hitBufferCounts.length > 0\n ? Math.max(...bucket.hitBufferCounts)\n : undefined,\n totalOverflowCount: bucket.totalOverflowCount,\n }))\n .sort((left, right) => left.bounceDepth - right.bounceDepth),\n byTerminationReason: [...byTerminationReason.entries()]\n .map(([reason, count]) => ({ reason, count }))\n .sort((left, right) => right.count - left.count),\n byHitKind: [...byHitKind.entries()]\n .map(([kind, count]) => ({ kind, count }))\n .sort((left, right) => right.count - left.count),\n };\n };\n\n const buildFixedSppSnapshot = (): GpuDebugFixedSppSnapshot => {\n const primaryRays = fixedSppSamples.map((sample) => sample.primaryRays);\n const measuredSecondaryRays = fixedSppSamples\n .map((sample) => sample.secondaryRays)\n .filter((value): value is number => value !== null);\n const measuredPathSegments = fixedSppSamples\n .map((sample) => sample.totalPathSegments)\n .filter((value): value is number => value !== null);\n const gpuTimes = fixedSppSamples\n .map((sample) => sample.timings.totalGpuTimeMs)\n .filter((value): value is number => value !== null);\n const renderJobTimes = fixedSppSamples.map(\n (sample) => sample.timings.totalRenderJobTimeMs\n );\n const classificationTimes = fixedSppSamples\n .map((sample) => sample.timings.classificationTimeMs)\n .filter((value): value is number => value !== null);\n const compactionTimes = fixedSppSamples\n .map((sample) => sample.timings.compactionTimeMs)\n .filter((value): value is number => value !== null);\n const samplingTimes = fixedSppSamples\n .map((sample) => sample.timings.samplingTimeMs)\n .filter((value): value is number => value !== null);\n const telemetryMemory = fixedSppSamples.map(\n (sample) => sample.telemetryMemoryBytes\n );\n const byRayCountStatus = new Map<\n NormalizedFixedSppTelemetrySample[\"rayCounts\"][\"status\"],\n number\n >();\n const byTimingStatus = new Map<\n NormalizedFixedSppTelemetrySample[\"timings\"][\"status\"],\n number\n >();\n const byTimestampQueryStatus = new Map<\n NormalizedFixedSppTelemetrySample[\"timings\"][\"timestampQueryStatus\"],\n number\n >();\n\n for (const sample of fixedSppSamples) {\n pushAggregate(byRayCountStatus, sample.rayCounts.status, 1);\n pushAggregate(byTimingStatus, sample.timings.status, 1);\n pushAggregate(\n byTimestampQueryStatus,\n sample.timings.timestampQueryStatus,\n 1\n );\n }\n\n return {\n sampleCount: fixedSppSamples.length,\n measuredRayCountSampleCount: measuredPathSegments.length,\n measuredGpuTimeSampleCount: gpuTimes.length,\n totalPrimaryRays: primaryRays.reduce((total, value) => total + value, 0),\n totalMeasuredSecondaryRays: measuredSecondaryRays.reduce(\n (total, value) => total + value,\n 0\n ),\n totalMeasuredPathSegments: measuredPathSegments.reduce(\n (total, value) => total + value,\n 0\n ),\n averagePrimaryRays: average(primaryRays),\n averageMeasuredSecondaryRays: average(measuredSecondaryRays),\n averageMeasuredPathSegments: average(measuredPathSegments),\n averageGpuTimeMs: average(gpuTimes),\n averageRenderJobTimeMs: average(renderJobTimes),\n averageClassificationTimeMs: average(classificationTimes),\n averageCompactionTimeMs: average(compactionTimes),\n averageSamplingTimeMs: average(samplingTimes),\n peakTelemetryMemoryBytes:\n telemetryMemory.length > 0 ? Math.max(...telemetryMemory) : 0,\n byRayCountStatus: [...byRayCountStatus.entries()].map(\n ([status, count]) => ({ status, count })\n ),\n byTimingStatus: [...byTimingStatus.entries()].map(([status, count]) => ({\n status,\n count,\n })),\n byTimestampQueryStatus: [...byTimestampQueryStatus.entries()].map(\n ([status, count]) => ({ status, count })\n ),\n latest: fixedSppSamples[fixedSppSamples.length - 1],\n };\n };\n\n return {\n isEnabled() {\n return enabled;\n },\n setEnabled(nextEnabled) {\n enabled = Boolean(nextEnabled);\n },\n trackAllocation(allocation) {\n if (!enabled || allocation.signal?.aborted === true) {\n return () => {};\n }\n\n const normalized = normalizeAllocation(allocation);\n if (!allocations.has(normalized.id)) {\n allocationOrder.push(normalized.id);\n }\n allocations.set(normalized.id, normalized);\n ensureAllocationCapacity();\n updatePeakTrackedBytes();\n\n return () => {\n this.releaseAllocation(normalized.id);\n };\n },\n releaseAllocation(id) {\n const normalizedId = assertIdentifier(\"allocation.id\", id);\n const deleted = allocations.delete(normalizedId);\n if (!deleted) {\n return false;\n }\n\n const index = allocationOrder.indexOf(normalizedId);\n if (index >= 0) {\n allocationOrder.splice(index, 1);\n }\n\n return true;\n },\n recordQueue(sample) {\n if (!enabled || sample.signal?.aborted === true) {\n return false;\n }\n\n queueSamples.push(normalizeQueueSample(sample));\n trimHistory(queueSamples, settings.maxRetainedQueueSamples);\n return true;\n },\n recordReadyLane(sample) {\n if (!enabled || sample.signal?.aborted === true) {\n return false;\n }\n\n readyLaneSamples.push(normalizeReadyLaneSample(sample));\n trimHistory(readyLaneSamples, settings.maxRetainedReadyLaneSamples);\n return true;\n },\n recordDispatch(sample) {\n if (!enabled || sample.signal?.aborted === true) {\n return false;\n }\n\n dispatchSamples.push(normalizeDispatchSample(sample));\n trimHistory(dispatchSamples, settings.maxRetainedDispatches);\n return true;\n },\n recordDependencyUnlock(sample) {\n if (!enabled || sample.signal?.aborted === true) {\n return false;\n }\n\n dependencyUnlockSamples.push(normalizeDependencyUnlockSample(sample));\n trimHistory(\n dependencyUnlockSamples,\n settings.maxRetainedDependencyUnlockSamples\n );\n return true;\n },\n recordPipelinePhase(sample) {\n if (!enabled || sample.signal?.aborted === true) {\n return false;\n }\n\n pipelinePhaseSamples.push(normalizePipelinePhaseSample(sample));\n trimHistory(\n pipelinePhaseSamples,\n settings.maxRetainedPipelinePhaseSamples\n );\n return true;\n },\n recordWavefrontTelemetry(sample) {\n if (!enabled || sample.signal?.aborted === true) {\n return false;\n }\n\n wavefrontSamples.push(normalizeWavefrontTelemetrySample(sample));\n trimHistory(wavefrontSamples, settings.maxRetainedWavefrontSamples);\n return true;\n },\n recordFixedSppTelemetry(sample) {\n if (!enabled || sample.signal?.aborted === true) {\n return false;\n }\n\n fixedSppSamples.push(normalizeFixedSppTelemetrySample(sample));\n trimHistory(fixedSppSamples, settings.maxRetainedFixedSppSamples);\n return true;\n },\n recordFrame(sample) {\n if (!enabled || sample.signal?.aborted === true) {\n return false;\n }\n\n frameSamples.push(normalizeFrameSample(sample));\n trimHistory(frameSamples, settings.maxRetainedFrameSamples);\n return true;\n },\n getSnapshot() {\n const memoryByOwner = new Map<string, number>();\n const memoryByCategory = new Map<GpuResourceCategory, number>();\n for (const allocation of allocations.values()) {\n pushAggregate(memoryByOwner, allocation.owner, allocation.sizeBytes);\n pushAggregate(memoryByCategory, allocation.category, allocation.sizeBytes);\n }\n\n const totalBytes = totalTrackedBytes();\n const frameTimes = frameSamples.map((sample) => sample.frameTimeMs);\n const targetFrameTimes = frameSamples\n .map((sample) => sample.targetFrameTimeMs)\n .filter((value): value is number => value !== undefined);\n const gpuBusyTimes = frameSamples\n .map((sample) => sample.gpuBusyMs)\n .filter((value): value is number => value !== undefined);\n\n const snapshot: GpuDebugSnapshot = {\n enabled,\n adapter,\n memory: {\n totalTrackedBytes: totalBytes,\n peakTrackedBytes,\n allocationCount: allocations.size,\n trackedUsageRatio:\n adapter.memoryCapacityHintBytes !== undefined\n ? totalBytes / adapter.memoryCapacityHintBytes\n : undefined,\n byOwner: [...memoryByOwner.entries()]\n .map(([owner, bytes]) => ({ owner, bytes }))\n .sort((left, right) => right.bytes - left.bytes),\n byCategory: [...memoryByCategory.entries()]\n .map(([category, bytes]) => ({ category, bytes }))\n .sort((left, right) => right.bytes - left.bytes),\n },\n dispatch: buildDispatchSnapshot(),\n queues: buildQueueSnapshot(),\n frames: {\n sampleCount: frameSamples.length,\n latestFrameTimeMs: frameSamples[frameSamples.length - 1]?.frameTimeMs,\n averageFrameTimeMs: average(frameTimes),\n averageTargetFrameTimeMs: average(targetFrameTimes),\n droppedFrameRatio:\n frameSamples.length > 0\n ? frameSamples.filter((sample) => sample.dropped === true).length /\n frameSamples.length\n : undefined,\n averageGpuBusyMs: average(gpuBusyTimes),\n },\n dag: buildDagSnapshot(),\n pipeline: buildPipelineSnapshot(),\n wavefront: buildWavefrontSnapshot(),\n fixedSpp: buildFixedSppSnapshot(),\n limitations: LIMITATIONS,\n };\n\n return snapshot;\n },\n reset() {\n allocations.clear();\n allocationOrder.splice(0, allocationOrder.length);\n queueSamples.splice(0, queueSamples.length);\n readyLaneSamples.splice(0, readyLaneSamples.length);\n dispatchSamples.splice(0, dispatchSamples.length);\n dependencyUnlockSamples.splice(0, dependencyUnlockSamples.length);\n pipelinePhaseSamples.splice(0, pipelinePhaseSamples.length);\n wavefrontSamples.splice(0, wavefrontSamples.length);\n fixedSppSamples.splice(0, fixedSppSamples.length);\n frameSamples.splice(0, frameSamples.length);\n peakTrackedBytes = 0;\n },\n };\n}\n\nexport function summarizeWavefrontTelemetry(\n snapshot: GpuDebugWavefrontSnapshot | undefined\n): readonly string[] {\n if (!snapshot || snapshot.sampleCount === 0) {\n return Object.freeze([\"Wavefront telemetry: no samples recorded.\"]);\n }\n\n const lines = [\n `Wavefront telemetry: ${snapshot.sampleCount} samples, peak ${snapshot.peakActiveRayCount} active rays, overflow ${snapshot.totalOverflowCount}, max bounce ${snapshot.maxBounceDepth ?? 0}.`,\n ];\n\n if (snapshot.byTerminationReason.length > 0) {\n lines.push(\n `Termination reasons: ${snapshot.byTerminationReason\n .slice(0, 3)\n .map((entry) => `${entry.reason}=${entry.count}`)\n .join(\", \")}.`\n );\n } else {\n lines.push(\"Termination reasons: none recorded.\");\n }\n\n if (snapshot.byHitKind.length > 0) {\n lines.push(\n `Hit kinds: ${snapshot.byHitKind\n .slice(0, 3)\n .map((entry) => `${entry.kind}=${entry.count}`)\n .join(\", \")}.`\n );\n } else {\n lines.push(\"Hit kinds: none recorded.\");\n }\n\n lines.push(\n `Bounce depth: ${snapshot.byBounceDepth\n .map(\n (entry) =>\n `b${entry.bounceDepth} avg=${entry.averageActiveRayCount.toFixed(1)} peak=${entry.peakActiveRayCount}`\n )\n .join(\"; \")}.`\n );\n\n return Object.freeze(lines);\n}\n\nfunction summarizeStatusCounts(\n entries: readonly { status: string; count: number }[]\n): string {\n return entries.length === 0\n ? \"none\"\n : entries.map((entry) => `${entry.status}=${entry.count}`).join(\", \");\n}\n\nfunction sampleLabel(count: number): string {\n return count === 1 ? \"sample\" : \"samples\";\n}\n\n/** Formats bounded fixed-SPP ray, timing, and telemetry-memory evidence. */\nexport function summarizeFixedSppTelemetry(\n snapshot: GpuDebugFixedSppSnapshot | undefined\n): readonly string[] {\n if (!snapshot || snapshot.sampleCount === 0) {\n return Object.freeze([\"Fixed-SPP telemetry: no samples recorded.\"]);\n }\n\n const gpuTiming =\n snapshot.averageGpuTimeMs === undefined\n ? \"GPU unavailable from 0 samples\"\n : `GPU avg ${snapshot.averageGpuTimeMs.toFixed(2)} ms from ${snapshot.measuredGpuTimeSampleCount} ${sampleLabel(snapshot.measuredGpuTimeSampleCount)}`;\n const renderJobTiming =\n snapshot.averageRenderJobTimeMs === undefined\n ? \"render-job unavailable from 0 samples\"\n : `render-job avg ${snapshot.averageRenderJobTimeMs.toFixed(2)} ms from ${snapshot.sampleCount} ${sampleLabel(snapshot.sampleCount)}`;\n\n return Object.freeze([\n `Fixed-SPP telemetry: ${snapshot.sampleCount} ${sampleLabel(snapshot.sampleCount)}, ${snapshot.totalPrimaryRays} primary rays, ${snapshot.totalMeasuredSecondaryRays} measured secondary rays, ${snapshot.totalMeasuredPathSegments} measured path segments.`,\n `Timing: ${gpuTiming}; ${renderJobTiming}.`,\n `Evidence: ray counts ${summarizeStatusCounts(snapshot.byRayCountStatus)}; timestamp queries ${summarizeStatusCounts(snapshot.byTimestampQueryStatus)}; peak telemetry memory ${snapshot.peakTelemetryMem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AAe;AAAA,IACxC,wBAAwB,sBAAsB,SAAS,gBAAgB,CAAC,uBAAuB,sBAAsB,SAAS,sBAAsB,CAAC,2BAA2B,SAAS,wBAAwB;AAAA,EACnN,CAAC;AACH;","names":[]}
package/dist/index.d.cts CHANGED
@@ -28,6 +28,7 @@ interface GpuDebugSessionOptions {
28
28
  maxRetainedDependencyUnlockSamples?: number;
29
29
  maxRetainedPipelinePhaseSamples?: number;
30
30
  maxRetainedWavefrontSamples?: number;
31
+ maxRetainedFixedSppSamples?: number;
31
32
  maxRetainedFrameSamples?: number;
32
33
  maxTrackedAllocations?: number;
33
34
  }
@@ -120,6 +121,55 @@ interface GpuWavefrontTelemetrySample {
120
121
  terminationReasons?: readonly GpuWavefrontTerminationSample[];
121
122
  signal?: AbortSignal;
122
123
  }
124
+ /** Availability state reported by the renderer for exact per-bounce ray counts. */
125
+ type GpuFixedSppRayCountStatus = "not-requested" | "available" | "unavailable" | "failed";
126
+ /** Timing evidence state reported by the renderer for one fixed-SPP frame. */
127
+ type GpuFixedSppTimingStatus = "not-requested" | "available" | "fallback" | "unavailable" | "failed";
128
+ /** Timestamp-query availability reported by the renderer. */
129
+ type GpuFixedSppTimestampQueryStatus = "not-recorded" | "available" | "unsupported" | "failed";
130
+ /** Exact, structurally compatible ray-count evidence from a renderer frame. */
131
+ interface GpuFixedSppRayCountTelemetry {
132
+ readonly status: GpuFixedSppRayCountStatus;
133
+ readonly source: "gpu-active-queue-readback" | null;
134
+ readonly expectedPrimaryRays: number | null;
135
+ readonly observedPrimaryRays: number | null;
136
+ readonly secondaryRays: number | null;
137
+ readonly totalPathSegments: number | null;
138
+ readonly bounceHistogram: readonly number[];
139
+ readonly capturedRayCounts: number;
140
+ readonly expectedRayCounts: number;
141
+ readonly reason: string | null;
142
+ }
143
+ /** Timing evidence from a fixed-SPP renderer frame. */
144
+ interface GpuFixedSppFrameTimingTelemetry {
145
+ readonly status: GpuFixedSppTimingStatus;
146
+ readonly source: "timestamp-query" | "queue-completion" | "cpu-submit" | null;
147
+ readonly timestampQueryStatus: GpuFixedSppTimestampQueryStatus;
148
+ readonly totalGpuTimeMs: number | null;
149
+ readonly totalRenderJobTimeMs: number;
150
+ readonly classificationTimeMs: number | null;
151
+ readonly compactionTimeMs: number | null;
152
+ readonly samplingTimeMs: number | null;
153
+ readonly reason: string | null;
154
+ }
155
+ /**
156
+ * Caller-reported fixed-SPP frame evidence. Recording this sample never starts a
157
+ * readback; callers pass an already-resolved renderer statistics snapshot.
158
+ */
159
+ interface GpuFixedSppTelemetrySample {
160
+ owner: string;
161
+ queueClass: GpuDebugQueueClass;
162
+ frameId?: string;
163
+ samplesPerPixel: number;
164
+ renderedSamplesPerPixel: number;
165
+ primaryRays: number;
166
+ secondaryRays: number | null;
167
+ totalPathSegments: number | null;
168
+ rayCounts: GpuFixedSppRayCountTelemetry;
169
+ timings: GpuFixedSppFrameTimingTelemetry;
170
+ telemetryMemoryBytes: number;
171
+ signal?: AbortSignal;
172
+ }
123
173
  interface GpuDebugMemorySnapshot {
124
174
  totalTrackedBytes: number;
125
175
  peakTrackedBytes: number;
@@ -256,6 +306,37 @@ interface GpuDebugWavefrontSnapshot {
256
306
  count: number;
257
307
  }[];
258
308
  }
309
+ /** Aggregated fixed-SPP evidence from the session's bounded local history. */
310
+ interface GpuDebugFixedSppSnapshot {
311
+ sampleCount: number;
312
+ measuredRayCountSampleCount: number;
313
+ measuredGpuTimeSampleCount: number;
314
+ totalPrimaryRays: number;
315
+ totalMeasuredSecondaryRays: number;
316
+ totalMeasuredPathSegments: number;
317
+ averagePrimaryRays?: number;
318
+ averageMeasuredSecondaryRays?: number;
319
+ averageMeasuredPathSegments?: number;
320
+ averageGpuTimeMs?: number;
321
+ averageRenderJobTimeMs?: number;
322
+ averageClassificationTimeMs?: number;
323
+ averageCompactionTimeMs?: number;
324
+ averageSamplingTimeMs?: number;
325
+ peakTelemetryMemoryBytes: number;
326
+ byRayCountStatus: readonly {
327
+ status: GpuFixedSppRayCountStatus;
328
+ count: number;
329
+ }[];
330
+ byTimingStatus: readonly {
331
+ status: GpuFixedSppTimingStatus;
332
+ count: number;
333
+ }[];
334
+ byTimestampQueryStatus: readonly {
335
+ status: GpuFixedSppTimestampQueryStatus;
336
+ count: number;
337
+ }[];
338
+ latest?: Readonly<Omit<GpuFixedSppTelemetrySample, "signal">>;
339
+ }
259
340
  interface GpuDebugSnapshot {
260
341
  enabled: boolean;
261
342
  adapter: Readonly<GpuDebugAdapterInfo>;
@@ -266,6 +347,7 @@ interface GpuDebugSnapshot {
266
347
  dag: GpuDebugDagSnapshot;
267
348
  pipeline: GpuDebugPipelineSnapshot;
268
349
  wavefront: GpuDebugWavefrontSnapshot;
350
+ fixedSpp: GpuDebugFixedSppSnapshot;
269
351
  limitations: readonly string[];
270
352
  }
271
353
  interface GpuDebugSession {
@@ -279,6 +361,7 @@ interface GpuDebugSession {
279
361
  recordDependencyUnlock(sample: GpuDependencyUnlockSample): boolean;
280
362
  recordPipelinePhase(sample: GpuPipelinePhaseSample): boolean;
281
363
  recordWavefrontTelemetry(sample: GpuWavefrontTelemetrySample): boolean;
364
+ recordFixedSppTelemetry(sample: GpuFixedSppTelemetrySample): boolean;
282
365
  recordFrame(sample: GpuFrameSample): boolean;
283
366
  getSnapshot(): GpuDebugSnapshot;
284
367
  reset(): void;
@@ -287,9 +370,11 @@ interface GpuDebugSession {
287
370
  declare function estimateDispatchInvocations(sample: GpuDispatchSample): number;
288
371
  declare function createGpuDebugSession(options?: GpuDebugSessionOptions): GpuDebugSession;
289
372
  declare function summarizeWavefrontTelemetry(snapshot: GpuDebugWavefrontSnapshot | undefined): readonly string[];
373
+ /** Formats bounded fixed-SPP ray, timing, and telemetry-memory evidence. */
374
+ declare function summarizeFixedSppTelemetry(snapshot: GpuDebugFixedSppSnapshot | undefined): readonly string[];
290
375
 
291
376
  declare const gpuDebugQueueClasses: readonly ("render" | "simulation" | "lighting" | "post-processing" | "voxel" | "transfer" | "custom")[];
292
377
  declare const gpuResourceCategories: readonly ("custom" | "buffer" | "texture" | "bind-group" | "pipeline")[];
293
378
  declare const gpuPipelinePhases: readonly ("render" | "simulation" | "secondary-simulation" | "scene-preparation")[];
294
379
 
295
- export { type GpuDebugAdapterInfo, type GpuDebugDagSnapshot, type GpuDebugDispatchSnapshot, type GpuDebugFrameSnapshot, type GpuDebugMemorySnapshot, type GpuDebugPipelineSnapshot, type GpuDebugQueueClass, type GpuDebugQueueSnapshot, type GpuDebugSession, type GpuDebugSessionOptions, type GpuDebugSnapshot, type GpuDebugWavefrontSnapshot, type GpuDependencyUnlockSample, type GpuDispatchSample, type GpuFrameSample, type GpuPipelinePhase, type GpuPipelinePhaseSample, type GpuQueueSample, type GpuReadyLaneSample, type GpuResourceCategory, type GpuVector3, type GpuWavefrontHitKindSample, type GpuWavefrontTelemetrySample, type GpuWavefrontTerminationSample, type TrackedGpuAllocation, createGpuDebugSession, estimateDispatchInvocations, gpuDebugQueueClasses, gpuPipelinePhases, gpuResourceCategories, summarizeWavefrontTelemetry };
380
+ export { type GpuDebugAdapterInfo, type GpuDebugDagSnapshot, type GpuDebugDispatchSnapshot, type GpuDebugFixedSppSnapshot, type GpuDebugFrameSnapshot, type GpuDebugMemorySnapshot, type GpuDebugPipelineSnapshot, type GpuDebugQueueClass, type GpuDebugQueueSnapshot, type GpuDebugSession, type GpuDebugSessionOptions, type GpuDebugSnapshot, type GpuDebugWavefrontSnapshot, type GpuDependencyUnlockSample, type GpuDispatchSample, type GpuFixedSppFrameTimingTelemetry, type GpuFixedSppRayCountStatus, type GpuFixedSppRayCountTelemetry, type GpuFixedSppTelemetrySample, type GpuFixedSppTimestampQueryStatus, type GpuFixedSppTimingStatus, type GpuFrameSample, type GpuPipelinePhase, type GpuPipelinePhaseSample, type GpuQueueSample, type GpuReadyLaneSample, type GpuResourceCategory, type GpuVector3, type GpuWavefrontHitKindSample, type GpuWavefrontTelemetrySample, type GpuWavefrontTerminationSample, type TrackedGpuAllocation, createGpuDebugSession, estimateDispatchInvocations, gpuDebugQueueClasses, gpuPipelinePhases, gpuResourceCategories, summarizeFixedSppTelemetry, summarizeWavefrontTelemetry };