@plasius/gpu-debug 0.2.4

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.
@@ -0,0 +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;AAAA;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AAM;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":[]}
@@ -0,0 +1,295 @@
1
+ type GpuDebugQueueClass = "render" | "simulation" | "lighting" | "post-processing" | "voxel" | "transfer" | "custom";
2
+ type GpuResourceCategory = "buffer" | "texture" | "bind-group" | "pipeline" | "custom";
3
+ type GpuPipelinePhase = "simulation" | "secondary-simulation" | "scene-preparation" | "render";
4
+ interface GpuVector3 {
5
+ x: number;
6
+ y?: number;
7
+ z?: number;
8
+ }
9
+ interface GpuDebugAdapterInfo {
10
+ label?: string;
11
+ vendor?: string;
12
+ architecture?: string;
13
+ driver?: string;
14
+ maxBufferSizeBytes?: number;
15
+ maxStorageBufferBindingSizeBytes?: number;
16
+ maxComputeInvocationsPerWorkgroup?: number;
17
+ maxComputeWorkgroupsPerDimension?: number;
18
+ memoryCapacityHintBytes?: number;
19
+ coreCountHint?: number;
20
+ metadata?: Readonly<Record<string, unknown>>;
21
+ }
22
+ interface GpuDebugSessionOptions {
23
+ enabled?: boolean;
24
+ adapter?: GpuDebugAdapterInfo;
25
+ maxRetainedDispatches?: number;
26
+ maxRetainedQueueSamples?: number;
27
+ maxRetainedReadyLaneSamples?: number;
28
+ maxRetainedDependencyUnlockSamples?: number;
29
+ maxRetainedPipelinePhaseSamples?: number;
30
+ maxRetainedWavefrontSamples?: number;
31
+ maxRetainedFrameSamples?: number;
32
+ maxTrackedAllocations?: number;
33
+ }
34
+ interface TrackedGpuAllocation {
35
+ id: string;
36
+ owner: string;
37
+ category: GpuResourceCategory;
38
+ sizeBytes: number;
39
+ label?: string;
40
+ signal?: AbortSignal;
41
+ }
42
+ interface GpuQueueSample {
43
+ owner: string;
44
+ queueClass: GpuDebugQueueClass;
45
+ depth: number;
46
+ capacity?: number;
47
+ frameId?: string;
48
+ signal?: AbortSignal;
49
+ }
50
+ interface GpuReadyLaneSample {
51
+ owner: string;
52
+ queueClass: GpuDebugQueueClass;
53
+ laneId: string;
54
+ priority?: number;
55
+ depth: number;
56
+ capacity?: number;
57
+ frameId?: string;
58
+ signal?: AbortSignal;
59
+ }
60
+ interface GpuDispatchSample {
61
+ id?: string;
62
+ owner: string;
63
+ queueClass: GpuDebugQueueClass;
64
+ jobType: string;
65
+ frameId?: string;
66
+ durationMs?: number;
67
+ workgroups: GpuVector3;
68
+ workgroupSize?: GpuVector3;
69
+ bytesRead?: number;
70
+ bytesWritten?: number;
71
+ signal?: AbortSignal;
72
+ }
73
+ interface GpuFrameSample {
74
+ frameId?: string;
75
+ frameTimeMs: number;
76
+ targetFrameTimeMs?: number;
77
+ gpuBusyMs?: number;
78
+ dropped?: boolean;
79
+ signal?: AbortSignal;
80
+ }
81
+ interface GpuDependencyUnlockSample {
82
+ owner: string;
83
+ queueClass: GpuDebugQueueClass;
84
+ sourceJobType: string;
85
+ unlockedJobType: string;
86
+ priority?: number;
87
+ unlockCount?: number;
88
+ frameId?: string;
89
+ signal?: AbortSignal;
90
+ }
91
+ interface GpuPipelinePhaseSample {
92
+ owner: string;
93
+ pipeline: GpuPipelinePhase;
94
+ stage: string;
95
+ frameId?: string;
96
+ durationMs?: number;
97
+ snapshotFrameId?: string;
98
+ snapshotAgeFrames?: number;
99
+ snapshotAgeMs?: number;
100
+ signal?: AbortSignal;
101
+ }
102
+ interface GpuWavefrontHitKindSample {
103
+ kind: string;
104
+ count: number;
105
+ }
106
+ interface GpuWavefrontTerminationSample {
107
+ reason: string;
108
+ count: number;
109
+ }
110
+ interface GpuWavefrontTelemetrySample {
111
+ owner: string;
112
+ queueClass: GpuDebugQueueClass;
113
+ frameId?: string;
114
+ bounceDepth: number;
115
+ activeRayCount: number;
116
+ queueCapacity?: number;
117
+ overflowCount?: number;
118
+ hitBufferCount?: number;
119
+ hitKinds?: readonly GpuWavefrontHitKindSample[];
120
+ terminationReasons?: readonly GpuWavefrontTerminationSample[];
121
+ signal?: AbortSignal;
122
+ }
123
+ interface GpuDebugMemorySnapshot {
124
+ totalTrackedBytes: number;
125
+ peakTrackedBytes: number;
126
+ allocationCount: number;
127
+ trackedUsageRatio?: number;
128
+ byOwner: readonly {
129
+ owner: string;
130
+ bytes: number;
131
+ }[];
132
+ byCategory: readonly {
133
+ category: GpuResourceCategory;
134
+ bytes: number;
135
+ }[];
136
+ }
137
+ interface GpuDebugDispatchSnapshot {
138
+ sampleCount: number;
139
+ totalDurationMs: number;
140
+ averageDurationMs?: number;
141
+ estimatedWorkgroups: number;
142
+ estimatedInvocations: number;
143
+ averageBytesRead?: number;
144
+ averageBytesWritten?: number;
145
+ busyRatio?: number;
146
+ byQueueClass: readonly {
147
+ queueClass: GpuDebugQueueClass;
148
+ dispatches: number;
149
+ totalDurationMs: number;
150
+ estimatedInvocations: number;
151
+ }[];
152
+ }
153
+ interface GpuDebugQueueSnapshot {
154
+ sampleCount: number;
155
+ averageDepth: number;
156
+ peakDepth: number;
157
+ peakUtilizationRatio?: number;
158
+ hottestQueues: readonly {
159
+ owner: string;
160
+ queueClass: GpuDebugQueueClass;
161
+ depth: number;
162
+ capacity?: number;
163
+ utilizationRatio?: number;
164
+ }[];
165
+ }
166
+ interface GpuDebugFrameSnapshot {
167
+ sampleCount: number;
168
+ latestFrameTimeMs?: number;
169
+ averageFrameTimeMs?: number;
170
+ averageTargetFrameTimeMs?: number;
171
+ droppedFrameRatio?: number;
172
+ averageGpuBusyMs?: number;
173
+ }
174
+ interface GpuDebugDagSnapshot {
175
+ readyLaneSampleCount: number;
176
+ averageReadyLaneDepth: number;
177
+ peakReadyLaneDepth: number;
178
+ peakReadyLaneUtilizationRatio?: number;
179
+ hottestReadyLanes: readonly {
180
+ owner: string;
181
+ queueClass: GpuDebugQueueClass;
182
+ laneId: string;
183
+ priority?: number;
184
+ depth: number;
185
+ capacity?: number;
186
+ utilizationRatio?: number;
187
+ }[];
188
+ dependencyUnlockSampleCount: number;
189
+ totalUnlockCount: number;
190
+ bySourceJobType: readonly {
191
+ owner: string;
192
+ queueClass: GpuDebugQueueClass;
193
+ sourceJobType: string;
194
+ unlockCount: number;
195
+ }[];
196
+ byUnlockedJobType: readonly {
197
+ owner: string;
198
+ queueClass: GpuDebugQueueClass;
199
+ unlockedJobType: string;
200
+ priority?: number;
201
+ unlockCount: number;
202
+ }[];
203
+ }
204
+ interface GpuDebugPipelineSnapshot {
205
+ sampleCount: number;
206
+ totalDurationMs: number;
207
+ averageDurationMs?: number;
208
+ averageSnapshotAgeMs?: number;
209
+ maxSnapshotAgeMs?: number;
210
+ maxSnapshotAgeFrames?: number;
211
+ byPipeline: readonly {
212
+ pipeline: GpuPipelinePhase;
213
+ sampleCount: number;
214
+ totalDurationMs: number;
215
+ averageDurationMs?: number;
216
+ averageSnapshotAgeMs?: number;
217
+ maxSnapshotAgeMs?: number;
218
+ maxSnapshotAgeFrames?: number;
219
+ }[];
220
+ hottestStages: readonly {
221
+ owner: string;
222
+ pipeline: GpuPipelinePhase;
223
+ stage: string;
224
+ frameId?: string;
225
+ durationMs?: number;
226
+ snapshotFrameId?: string;
227
+ snapshotAgeFrames?: number;
228
+ snapshotAgeMs?: number;
229
+ }[];
230
+ }
231
+ interface GpuDebugWavefrontSnapshot {
232
+ sampleCount: number;
233
+ averageActiveRayCount: number;
234
+ peakActiveRayCount: number;
235
+ peakQueueUtilizationRatio?: number;
236
+ maxBounceDepth?: number;
237
+ totalOverflowCount: number;
238
+ peakOverflowCount: number;
239
+ averageHitBufferCount?: number;
240
+ peakHitBufferCount?: number;
241
+ byBounceDepth: readonly {
242
+ bounceDepth: number;
243
+ sampleCount: number;
244
+ averageActiveRayCount: number;
245
+ peakActiveRayCount: number;
246
+ averageHitBufferCount?: number;
247
+ peakHitBufferCount?: number;
248
+ totalOverflowCount: number;
249
+ }[];
250
+ byTerminationReason: readonly {
251
+ reason: string;
252
+ count: number;
253
+ }[];
254
+ byHitKind: readonly {
255
+ kind: string;
256
+ count: number;
257
+ }[];
258
+ }
259
+ interface GpuDebugSnapshot {
260
+ enabled: boolean;
261
+ adapter: Readonly<GpuDebugAdapterInfo>;
262
+ memory: GpuDebugMemorySnapshot;
263
+ dispatch: GpuDebugDispatchSnapshot;
264
+ queues: GpuDebugQueueSnapshot;
265
+ frames: GpuDebugFrameSnapshot;
266
+ dag: GpuDebugDagSnapshot;
267
+ pipeline: GpuDebugPipelineSnapshot;
268
+ wavefront: GpuDebugWavefrontSnapshot;
269
+ limitations: readonly string[];
270
+ }
271
+ interface GpuDebugSession {
272
+ isEnabled(): boolean;
273
+ setEnabled(enabled: boolean): void;
274
+ trackAllocation(allocation: TrackedGpuAllocation): () => void;
275
+ releaseAllocation(id: string): boolean;
276
+ recordQueue(sample: GpuQueueSample): boolean;
277
+ recordReadyLane(sample: GpuReadyLaneSample): boolean;
278
+ recordDispatch(sample: GpuDispatchSample): boolean;
279
+ recordDependencyUnlock(sample: GpuDependencyUnlockSample): boolean;
280
+ recordPipelinePhase(sample: GpuPipelinePhaseSample): boolean;
281
+ recordWavefrontTelemetry(sample: GpuWavefrontTelemetrySample): boolean;
282
+ recordFrame(sample: GpuFrameSample): boolean;
283
+ getSnapshot(): GpuDebugSnapshot;
284
+ reset(): void;
285
+ }
286
+
287
+ declare function estimateDispatchInvocations(sample: GpuDispatchSample): number;
288
+ declare function createGpuDebugSession(options?: GpuDebugSessionOptions): GpuDebugSession;
289
+ declare function summarizeWavefrontTelemetry(snapshot: GpuDebugWavefrontSnapshot | undefined): readonly string[];
290
+
291
+ declare const gpuDebugQueueClasses: readonly ("render" | "simulation" | "lighting" | "post-processing" | "voxel" | "transfer" | "custom")[];
292
+ declare const gpuResourceCategories: readonly ("custom" | "buffer" | "texture" | "bind-group" | "pipeline")[];
293
+ declare const gpuPipelinePhases: readonly ("render" | "simulation" | "secondary-simulation" | "scene-preparation")[];
294
+
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 };