@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/validation.ts","../src/session.ts"],"sourcesContent":["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":";AAQA,IAAM,qBAAqB;AAEpB,IAAM,uBAAuB,OAAO,OAAO;AAAA,EAChD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAEM,IAAM,wBAAwB,OAAO,OAAO;AAAA,EACjD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAA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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,2 @@
1
+ type,github_handle,full_name,company,email,date,approver
2
+ corporate,Zephod111r,Phillip Hounslow,Plasius LTD,zephod@plasius.co.uk,2025-09-12,Phillip Hounslow (Maintainer)
package/legal/CLA.md ADDED
@@ -0,0 +1,22 @@
1
+ # Contributor License Agreements (CLA)
2
+
3
+ To protect the intellectual property of this project and ensure clarity of rights, all contributors must sign a Contributor License Agreement (CLA) before their first contribution.
4
+
5
+ ## Which CLA should I sign?
6
+
7
+ - **Individual CLA**: If you are contributing personally and not on behalf of an employer, sign the [Individual CLA](INDIVIDUAL_CLA.md).
8
+ - **Corporate CLA**: If you are contributing as part of your work for a company, the company should sign the [Corporate CLA](CORPORATE_CLA.md).
9
+
10
+ ## How to sign
11
+
12
+ 1. Download the appropriate CLA file (Individual or Corporate).
13
+ 2. Fill in the required details, sign, and date it.
14
+ 3. Email a PDF copy of the signed document to **[contributors@plasius.co.uk](mailto:contributors@plasius.co.uk)** with subject: `CLA – Individual` or `CLA – Corporate`.
15
+
16
+ ## Registry
17
+
18
+ All signed CLAs are logged internally in the CLA registry (`CLA-REGISTRY.csv`).
19
+
20
+ ## Questions?
21
+
22
+ If you have any questions about which CLA to sign or how the process works, please email **[contributors@plasius.co.uk](mailtocontributors@plasius.co.uk)**.
@@ -0,0 +1,57 @@
1
+ # Corporate Contributor License Agreement (CLA)
2
+
3
+ ## Purpose
4
+
5
+ This Corporate Contributor License Agreement ("Agreement") is intended to protect the intellectual property rights of the contributors and the project, ensure clear licensing terms for contributions, and maintain trust within the community. By signing this Agreement, the corporation agrees to the terms that facilitate the use, distribution, and modification of contributions under the project's licensing framework.
6
+
7
+ ## Agreement
8
+
9
+ 1. **Representation of Authority**
10
+ The undersigned individual represents and warrants that they have the full legal authority to enter into this Agreement on behalf of the corporation named below ("Corporation") and to grant the rights contained herein.
11
+
12
+ 2. **Grant of Copyright License**
13
+ The Corporation hereby grants to the project maintainers and users a perpetual, worldwide, non-exclusive, royalty-free, irrevocable copyright license to use, reproduce, prepare derivative works of, publicly display, publicly perform, sublicense, and distribute the contributions submitted to the project.
14
+
15
+ 3. **Grant of Patent License**
16
+ The Corporation hereby grants to the project maintainers and users a perpetual, worldwide, non-exclusive, royalty-free, irrevocable license under any patent claims that are necessarily infringed by the contributions to make, use, sell, offer for sale, import, and otherwise dispose of the contributions or derivative works thereof.
17
+
18
+ 4. **Warranties and Representations**
19
+ The Corporation represents and warrants that:
20
+
21
+ - The contributions are the original work of the Corporation or that the Corporation has sufficient rights to grant the licenses herein.
22
+ - The submission of the contributions does not violate any agreements or rights of third parties.
23
+
24
+ 5. **No Revocation**
25
+ This license is granted on a perpetual basis and cannot be revoked, provided that the terms of this Agreement are met.
26
+
27
+ 6. **Governing Law**
28
+ This Agreement shall be governed by and construed in accordance with the laws of the United Kingdom, without regard to its conflict of laws principles.
29
+
30
+ 7. **Execution**
31
+
32
+ This Agreement is effective upon signature by the authorized representative of the Corporation. Please sign and date this document, then email a scanned PDF copy to [contributors@plasius.co.uk](mailto:contributors@plasius.co.uk).
33
+
34
+ ---
35
+
36
+ ### **@plasius/gpu-debug**
37
+
38
+ **Corporation Legal Name:** \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
39
+
40
+ **Authorized Representative:** \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
41
+
42
+ **Title:** \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
43
+
44
+ **Email:** \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
45
+
46
+ **Date:** \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
47
+
48
+ **Signature:** \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
49
+
50
+ ---
51
+
52
+ ## How to Sign
53
+
54
+ - Download this file as a template.
55
+ - Fill in the Corporation’s legal name, authorized representative, title, email, date, and provide a signature.
56
+ - Sign and date the document.
57
+ - Send a scanned copy of the signed Agreement to [contributors@plasius.co.uk](mailto:contributors@plasius.co.uk).
@@ -0,0 +1,91 @@
1
+ # Individual Contributor License Agreement (CLA)
2
+
3
+ **Project:** @plasius/gpu-debug (Plasius LTD)
4
+ **Version:** 1.0 — 2025‑09‑12
5
+ **Contact:** [contributors@plasius.co.uk](mailto:contributors@plasius.co.uk)
6
+
7
+ ---
8
+
9
+ ## 1. Definitions
10
+
11
+ - **"You"** (or **"Contributor"**) means the individual signing this CLA and submitting Contributions to the Project.
12
+ - **"Contribution"** means any original work of authorship, including code, documentation, data, designs, or feedback that You submit to the Project in any form (e.g., pull request, issue comment, email, file upload).
13
+ - **"Project"** means the @plasius/gpu-debug repositories and related materials owned or managed by **Plasius LTD**.
14
+
15
+ ## 2. Copyright License Grant
16
+
17
+ You hereby grant to Plasius LTD a **perpetual, worldwide, non‑exclusive, transferable, sublicensable, royalty‑free, irrevocable** copyright license to:
18
+
19
+ - use, reproduce, publicly display, publicly perform, modify, create derivative works of, and
20
+ - distribute Contributions in source and object form,
21
+ - and to **sublicense** these rights under any terms Plasius LTD chooses, including proprietary or open‑source licenses.
22
+
23
+ ## 3. Patent License Grant
24
+
25
+ You hereby grant to Plasius LTD and its sublicensees a **perpetual, worldwide, non‑exclusive, transferable, royalty‑free, irrevocable** patent license to **make, have made, use, offer to sell, sell, import, and otherwise transfer** the Contribution and derivative works thereof, where such license applies only to patent claims that You **own or control** and that would be infringed by Your Contribution or its combination with the Project.
26
+
27
+ ## 4. Moral Rights & Attribution
28
+
29
+ To the maximum extent permitted by applicable law, You **waive** and agree not to assert any moral rights (e.g., rights of attribution or integrity) in or to the Contribution against Plasius LTD. Plasius LTD may, but is not required to, credit You.
30
+
31
+ ## 5. Representations & Warranties
32
+
33
+ You represent that:
34
+
35
+ 1. **Originality / Rights:** Each Contribution is Your original creation, or You have sufficient rights to submit it and grant the licenses above.
36
+ 2. **No Confidential Info:** Contributions **do not** include confidential information or trade secrets of any third party.
37
+ 3. **No Infringement:** To the best of Your knowledge, Contributions do not infringe any third‑party IP rights.
38
+ 4. **Employment / Contractor Status:** If Your employer or a third party might claim rights in Your Contribution, You have obtained **written permission** to make the Contribution and grant these licenses (attach or reference below), or Your Contribution is made **outside the scope** of your employment and without using your employer’s confidential information or resources.
39
+ 5. **Compliance:** You will follow the Project’s policies (e.g., Code of Conduct, Security Policy) and applicable laws.
40
+
41
+ ## 6. Third‑Party Code
42
+
43
+ If Your Contribution includes code, data, or other material from a third party, You will **identify the material and its license** in the pull request or submission, and ensure it is **compatible** with the Project’s licensing model. You will not submit material subject to terms that require the Project to disclose proprietary source code (e.g., certain copyleft obligations) unless the Project has **pre‑approved** such inclusion in writing.
44
+
45
+ ## 7. Scope & Duration
46
+
47
+ - This CLA covers **all past and future** Contributions You submit to the Project, unless and until You provide written notice to **revoke** it.
48
+ - Revocation is **not retroactive**: rights granted for prior Contributions remain in effect.
49
+
50
+ ## 8. Disclaimer
51
+
52
+ THE CONTRIBUTION IS PROVIDED “AS IS” WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON‑INFRINGEMENT.
53
+
54
+ ## 9. Governing Law & Jurisdiction
55
+
56
+ This CLA is governed by the **laws of England and Wales**, and the courts of England and Wales shall have **exclusive jurisdiction** over any dispute arising out of or relating to it.
57
+
58
+ ## 10. Entire Agreement
59
+
60
+ This CLA is the entire agreement between You and Plasius LTD regarding Contributions. It supersedes any prior discussions relating to Contributions. If any provision is held unenforceable, the remaining provisions remain in full force.
61
+
62
+ ---
63
+
64
+ ## 11. Contributor Information & Signature
65
+
66
+ By signing below, You agree to the terms of this CLA for Your Contributions to the Project.
67
+
68
+ **Full Name:** \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
69
+
70
+ **Email:** \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
71
+
72
+ **GitHub Handle:** \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
73
+
74
+ **Address (optional):** \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
75
+
76
+ **Employer (if applicable):** \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
77
+
78
+ **If employed:** ☐ I confirm Contributions are made outside the scope of employment **or** ☐ I have attached my employer’s written permission.
79
+
80
+ **Signature:** \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
81
+
82
+ **Date (YYYY‑MM‑DD):** \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
83
+
84
+ _Electronic signatures are accepted. You may type your name in the Signature field and email a PDF copy._
85
+
86
+ **Submission:** Please email the signed CLA to **[contributors@plasius.co.uk](mailto:contributors@plasius.co.uk)** with subject line: `CLA – Individual – <GitHubHandle>`.
87
+
88
+ **(Optional) Attachments / Notes:**
89
+
90
+ - Employer permission letter (if required)
91
+ - Third‑party license disclosures (if any)
package/package.json ADDED
@@ -0,0 +1,99 @@
1
+ {
2
+ "name": "@plasius/gpu-debug",
3
+ "version": "0.2.4",
4
+ "description": "Opt-in GPU debug instrumentation for tracked memory, dispatch, queue, and frame-budget metrics in Plasius WebGPU runtimes.",
5
+ "type": "module",
6
+ "sideEffects": false,
7
+ "main": "./dist/index.cjs",
8
+ "module": "./dist/index.js",
9
+ "types": "./dist/index.d.ts",
10
+ "files": [
11
+ "dist",
12
+ "README.md",
13
+ "CHANGELOG.md",
14
+ "LICENSE",
15
+ "legal"
16
+ ],
17
+ "exports": {
18
+ ".": {
19
+ "types": "./dist/index.d.ts",
20
+ "import": "./dist/index.js",
21
+ "require": "./dist/index.cjs"
22
+ },
23
+ "./package.json": "./package.json"
24
+ },
25
+ "scripts": {
26
+ "build": "tsup",
27
+ "clean": "rimraf dist coverage",
28
+ "demo": "python3 -m http.server --directory ..",
29
+ "demo:example": "tsx demo/example.ts",
30
+ "test": "vitest run",
31
+ "test:watch": "vitest",
32
+ "typecheck": "tsc --noEmit",
33
+ "audit:eslint": "eslint . --max-warnings=0",
34
+ "audit:deps": "npm ls --all --omit=optional --omit=peer > /dev/null 2>&1 || true",
35
+ "audit:npm": "npm audit --audit-level=high --omit=dev",
36
+ "audit:test": "vitest run --coverage",
37
+ "lint": "eslint . --max-warnings=0",
38
+ "prepare": "npm run build",
39
+ "test:coverage": "vitest run --coverage",
40
+ "pack:check": "node scripts/verify-public-package.cjs",
41
+ "prepublishOnly": "npm run build && npm run pack:check"
42
+ },
43
+ "keywords": [
44
+ "webgpu",
45
+ "gpu",
46
+ "debug",
47
+ "instrumentation",
48
+ "memory",
49
+ "profiling",
50
+ "typescript",
51
+ "plasius"
52
+ ],
53
+ "author": "Plasius LTD <development@plasius.co.uk>",
54
+ "license": "Apache-2.0",
55
+ "repository": {
56
+ "type": "git",
57
+ "url": "git+https://github.com/Plasius-LTD/gpu-debug.git"
58
+ },
59
+ "bugs": {
60
+ "url": "https://github.com/Plasius-LTD/gpu-debug/issues"
61
+ },
62
+ "homepage": "https://github.com/Plasius-LTD/gpu-debug#readme",
63
+ "dependencies": {
64
+ "@plasius/gpu-shared": "^1.0.1"
65
+ },
66
+ "devDependencies": {
67
+ "@eslint/js": "^10.0.1",
68
+ "@types/node": "^26.0.1",
69
+ "@typescript-eslint/eslint-plugin": "^8.59.3",
70
+ "@typescript-eslint/parser": "^8.59.3",
71
+ "@vitest/coverage-v8": "^4.1.6",
72
+ "eslint": "^10.6.0",
73
+ "globals": "^17.6.0",
74
+ "rimraf": "^6.1.3",
75
+ "tsup": "^8.5.1",
76
+ "tsx": "^4.21.0",
77
+ "typescript": "^6.0.3",
78
+ "vitest": "^4.1.6"
79
+ },
80
+ "publishConfig": {
81
+ "access": "public"
82
+ },
83
+ "funding": [
84
+ {
85
+ "type": "patreon",
86
+ "url": "https://www.patreon.com/c/plasiusltd/membership"
87
+ },
88
+ {
89
+ "type": "github",
90
+ "url": "https://github.com/sponsors/Plasius-LTD"
91
+ }
92
+ ],
93
+ "overrides": {
94
+ "minimatch": "^10.2.1"
95
+ },
96
+ "engines": {
97
+ "node": ">=24"
98
+ }
99
+ }