@motion-core/motion-gpu 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/dist/core/compute-bindgroup-cache.d.ts +13 -0
  2. package/dist/core/compute-bindgroup-cache.d.ts.map +1 -0
  3. package/dist/core/compute-bindgroup-cache.js +45 -0
  4. package/dist/core/compute-bindgroup-cache.js.map +1 -0
  5. package/dist/core/compute-shader.d.ts +48 -0
  6. package/dist/core/compute-shader.d.ts.map +1 -1
  7. package/dist/core/compute-shader.js +34 -1
  8. package/dist/core/compute-shader.js.map +1 -1
  9. package/dist/core/error-diagnostics.d.ts +8 -1
  10. package/dist/core/error-diagnostics.d.ts.map +1 -1
  11. package/dist/core/error-diagnostics.js +7 -3
  12. package/dist/core/error-diagnostics.js.map +1 -1
  13. package/dist/core/error-report.d.ts.map +1 -1
  14. package/dist/core/error-report.js +19 -1
  15. package/dist/core/error-report.js.map +1 -1
  16. package/dist/core/material.d.ts.map +1 -1
  17. package/dist/core/material.js +2 -1
  18. package/dist/core/material.js.map +1 -1
  19. package/dist/core/renderer.d.ts.map +1 -1
  20. package/dist/core/renderer.js +150 -85
  21. package/dist/core/renderer.js.map +1 -1
  22. package/dist/core/runtime-loop.d.ts.map +1 -1
  23. package/dist/core/runtime-loop.js +26 -14
  24. package/dist/core/runtime-loop.js.map +1 -1
  25. package/dist/core/shader.d.ts +7 -2
  26. package/dist/core/shader.d.ts.map +1 -1
  27. package/dist/core/shader.js +1 -0
  28. package/dist/core/shader.js.map +1 -1
  29. package/dist/core/textures.d.ts +4 -0
  30. package/dist/core/textures.d.ts.map +1 -1
  31. package/dist/core/textures.js +2 -1
  32. package/dist/core/textures.js.map +1 -1
  33. package/dist/core/types.d.ts +1 -1
  34. package/dist/core/types.d.ts.map +1 -1
  35. package/package.json +1 -1
  36. package/src/lib/core/compute-bindgroup-cache.ts +73 -0
  37. package/src/lib/core/compute-shader.ts +86 -0
  38. package/src/lib/core/error-diagnostics.ts +29 -4
  39. package/src/lib/core/error-report.ts +26 -1
  40. package/src/lib/core/material.ts +2 -1
  41. package/src/lib/core/renderer.ts +198 -92
  42. package/src/lib/core/runtime-loop.ts +37 -16
  43. package/src/lib/core/shader.ts +13 -2
  44. package/src/lib/core/textures.ts +6 -1
  45. package/src/lib/core/types.ts +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"runtime-loop.js","names":[],"sources":["../../src/lib/core/runtime-loop.ts"],"sourcesContent":["import type { CurrentReadable, CurrentWritable } from './current-value.js';\nimport { resolveMaterial, type FragMaterial, type ResolvedMaterial } from './material.js';\nimport {\n\ttoMotionGPUErrorReport,\n\ttype MotionGPUErrorPhase,\n\ttype MotionGPUErrorReport\n} from './error-report.js';\nimport { createRenderer } from './renderer.js';\nimport { buildRendererPipelineSignature } from './recompile-policy.js';\nimport { assertUniformValueForType } from './uniforms.js';\nimport type { FrameRegistry } from './frame-registry.js';\nimport type {\n\tAnyPass,\n\tFrameInvalidationToken,\n\tOutputColorSpace,\n\tPendingStorageWrite,\n\tRenderer,\n\tRenderTargetDefinitionMap,\n\tStorageBufferDefinitionMap,\n\tTextureMap,\n\tTextureValue,\n\tUniformType,\n\tUniformValue\n} from './types.js';\n\nexport interface MotionGPURuntimeLoopOptions {\n\tcanvas: HTMLCanvasElement;\n\tregistry: FrameRegistry;\n\tsize: CurrentWritable<{ width: number; height: number }>;\n\tdpr: CurrentReadable<number>;\n\tmaxDelta: CurrentReadable<number>;\n\tgetMaterial: () => FragMaterial;\n\tgetRenderTargets: () => RenderTargetDefinitionMap;\n\tgetPasses: () => AnyPass[];\n\tgetClearColor: () => [number, number, number, number];\n\tgetOutputColorSpace: () => OutputColorSpace;\n\tgetAdapterOptions: () => GPURequestAdapterOptions | undefined;\n\tgetDeviceDescriptor: () => GPUDeviceDescriptor | undefined;\n\tgetOnError: () => ((report: MotionGPUErrorReport) => void) | undefined;\n\treportError: (report: MotionGPUErrorReport | null) => void;\n\tgetErrorHistoryLimit?: () => number | undefined;\n\tgetOnErrorHistory?: () => ((history: MotionGPUErrorReport[]) => void) | undefined;\n\treportErrorHistory?: (history: MotionGPUErrorReport[]) => void;\n}\n\nexport interface MotionGPURuntimeLoop {\n\trequestFrame: () => void;\n\tinvalidate: (token?: FrameInvalidationToken) => void;\n\tadvance: () => void;\n\tdestroy: () => void;\n}\n\nfunction getRendererRetryDelayMs(attempt: number): number {\n\treturn Math.min(8000, 250 * 2 ** Math.max(0, attempt - 1));\n}\n\nexport function createMotionGPURuntimeLoop(\n\toptions: MotionGPURuntimeLoopOptions\n): MotionGPURuntimeLoop {\n\tconst { canvas: canvasElement, registry, size } = options;\n\tlet frameId: number | null = null;\n\tlet renderer: Renderer | null = null;\n\tlet isDisposed = false;\n\tlet previousTime = performance.now() / 1000;\n\tlet activeRendererSignature = '';\n\tlet failedRendererSignature: string | null = null;\n\tlet failedRendererAttempts = 0;\n\tlet nextRendererRetryAt = 0;\n\tlet rendererRebuildPromise: Promise<void> | null = null;\n\n\tconst runtimeUniforms: Record<string, UniformValue> = {};\n\tconst runtimeTextures: TextureMap = {};\n\tlet activeUniforms: Record<string, UniformValue> = {};\n\tlet activeTextures: Record<string, { source?: TextureValue }> = {};\n\tlet uniformKeys: string[] = [];\n\tlet uniformKeySet = new Set<string>();\n\tlet uniformTypes = new Map<string, UniformType>();\n\tlet textureKeys: string[] = [];\n\tlet textureKeySet = new Set<string>();\n\tlet activeMaterialSignature = '';\n\tlet currentCssWidth = -1;\n\tlet currentCssHeight = -1;\n\tconst renderUniforms: Record<string, UniformValue> = {};\n\tconst renderTextures: TextureMap = {};\n\tconst canvasSize = { width: 0, height: 0 };\n\tlet storageBufferKeys: string[] = [];\n\tlet storageBufferKeySet = new Set<string>();\n\tlet storageBufferDefinitions: StorageBufferDefinitionMap = {};\n\tconst pendingStorageWrites: PendingStorageWrite[] = [];\n\tlet shouldContinueAfterFrame = false;\n\tlet activeErrorKey: string | null = null;\n\tlet errorHistory: MotionGPUErrorReport[] = [];\n\n\tconst getHistoryLimit = (): number => {\n\t\tconst value = options.getErrorHistoryLimit?.() ?? 0;\n\t\tif (!Number.isFinite(value) || value <= 0) {\n\t\t\treturn 0;\n\t\t}\n\n\t\treturn Math.floor(value);\n\t};\n\n\tconst publishErrorHistory = (): void => {\n\t\toptions.reportErrorHistory?.(errorHistory);\n\t\tconst onErrorHistory = options.getOnErrorHistory?.();\n\t\tif (!onErrorHistory) {\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tonErrorHistory(errorHistory);\n\t\t} catch {\n\t\t\t// User-provided error history handlers must not break runtime error recovery.\n\t\t}\n\t};\n\n\tconst syncErrorHistory = (): void => {\n\t\tconst limit = getHistoryLimit();\n\t\tif (limit <= 0) {\n\t\t\tif (errorHistory.length === 0) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\terrorHistory = [];\n\t\t\tpublishErrorHistory();\n\t\t\treturn;\n\t\t}\n\n\t\tif (errorHistory.length <= limit) {\n\t\t\treturn;\n\t\t}\n\n\t\terrorHistory = errorHistory.slice(errorHistory.length - limit);\n\t\tpublishErrorHistory();\n\t};\n\n\tconst setError = (error: unknown, phase: MotionGPUErrorPhase): void => {\n\t\tconst report = toMotionGPUErrorReport(error, phase);\n\t\tconst reportKey = JSON.stringify({\n\t\t\tphase: report.phase,\n\t\t\ttitle: report.title,\n\t\t\tmessage: report.message,\n\t\t\trawMessage: report.rawMessage\n\t\t});\n\t\tif (activeErrorKey === reportKey) {\n\t\t\treturn;\n\t\t}\n\t\tactiveErrorKey = reportKey;\n\t\tconst historyLimit = getHistoryLimit();\n\t\tif (historyLimit > 0) {\n\t\t\terrorHistory = [...errorHistory, report];\n\t\t\tif (errorHistory.length > historyLimit) {\n\t\t\t\terrorHistory = errorHistory.slice(errorHistory.length - historyLimit);\n\t\t\t}\n\t\t\tpublishErrorHistory();\n\t\t}\n\t\toptions.reportError(report);\n\t\tconst onError = options.getOnError();\n\t\tif (!onError) {\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tonError(report);\n\t\t} catch {\n\t\t\t// User-provided error handlers must not break runtime error recovery.\n\t\t}\n\t};\n\n\tconst clearError = (): void => {\n\t\tif (activeErrorKey === null) {\n\t\t\treturn;\n\t\t}\n\n\t\tactiveErrorKey = null;\n\t\toptions.reportError(null);\n\t};\n\n\tconst scheduleFrame = (): void => {\n\t\tif (isDisposed || frameId !== null) {\n\t\t\treturn;\n\t\t}\n\n\t\tframeId = requestAnimationFrame(renderFrame);\n\t};\n\n\tconst requestFrame = (): void => {\n\t\tscheduleFrame();\n\t};\n\n\tconst invalidate = (token?: FrameInvalidationToken): void => {\n\t\tregistry.invalidate(token);\n\t\trequestFrame();\n\t};\n\n\tconst advance = (): void => {\n\t\tregistry.advance();\n\t\trequestFrame();\n\t};\n\n\tconst resetRuntimeMaps = (): void => {\n\t\tfor (const key of Object.keys(runtimeUniforms)) {\n\t\t\tif (!uniformKeySet.has(key)) {\n\t\t\t\tReflect.deleteProperty(runtimeUniforms, key);\n\t\t\t}\n\t\t}\n\n\t\tfor (const key of Object.keys(runtimeTextures)) {\n\t\t\tif (!textureKeySet.has(key)) {\n\t\t\t\tReflect.deleteProperty(runtimeTextures, key);\n\t\t\t}\n\t\t}\n\t};\n\n\tconst resetRenderPayloadMaps = (): void => {\n\t\tfor (const key of Object.keys(renderUniforms)) {\n\t\t\tif (!uniformKeySet.has(key)) {\n\t\t\t\tReflect.deleteProperty(renderUniforms, key);\n\t\t\t}\n\t\t}\n\n\t\tfor (const key of Object.keys(renderTextures)) {\n\t\t\tif (!textureKeySet.has(key)) {\n\t\t\t\tReflect.deleteProperty(renderTextures, key);\n\t\t\t}\n\t\t}\n\t};\n\n\tconst syncMaterialRuntimeState = (materialState: ResolvedMaterial): void => {\n\t\tconst signatureChanged = activeMaterialSignature !== materialState.signature;\n\t\tconst defaultsChanged =\n\t\t\tactiveUniforms !== materialState.uniforms || activeTextures !== materialState.textures;\n\n\t\tif (!signatureChanged && !defaultsChanged) {\n\t\t\treturn;\n\t\t}\n\n\t\tactiveUniforms = materialState.uniforms;\n\t\tactiveTextures = materialState.textures;\n\t\tif (!signatureChanged) {\n\t\t\treturn;\n\t\t}\n\n\t\tuniformKeys = materialState.uniformLayout.entries.map((entry) => entry.name);\n\t\tuniformTypes = new Map(\n\t\t\tmaterialState.uniformLayout.entries.map((entry) => [entry.name, entry.type])\n\t\t);\n\t\ttextureKeys = materialState.textureKeys;\n\t\tuniformKeySet = new Set(uniformKeys);\n\t\ttextureKeySet = new Set(textureKeys);\n\t\tstorageBufferKeys = materialState.storageBufferKeys;\n\t\tstorageBufferKeySet = new Set(storageBufferKeys);\n\t\tstorageBufferDefinitions = (options.getMaterial().storageBuffers ??\n\t\t\t{}) as StorageBufferDefinitionMap;\n\t\tresetRuntimeMaps();\n\t\tresetRenderPayloadMaps();\n\t\tactiveMaterialSignature = materialState.signature;\n\t};\n\n\tconst resolveActiveMaterial = (): ResolvedMaterial => {\n\t\treturn resolveMaterial(options.getMaterial());\n\t};\n\n\tconst setUniform = (name: string, value: UniformValue): void => {\n\t\tif (!uniformKeySet.has(name)) {\n\t\t\tthrow new Error(`Unknown uniform \"${name}\". Declare it in material.uniforms first.`);\n\t\t}\n\t\tconst expectedType = uniformTypes.get(name);\n\t\tif (!expectedType) {\n\t\t\tthrow new Error(`Unknown uniform type for \"${name}\"`);\n\t\t}\n\t\tassertUniformValueForType(expectedType, value);\n\t\truntimeUniforms[name] = value;\n\t};\n\n\tconst setTexture = (name: string, value: TextureValue): void => {\n\t\tif (!textureKeySet.has(name)) {\n\t\t\tthrow new Error(`Unknown texture \"${name}\". Declare it in material.textures first.`);\n\t\t}\n\t\truntimeTextures[name] = value;\n\t};\n\n\tconst writeStorageBuffer = (\n\t\tname: string,\n\t\tdata: ArrayBufferView,\n\t\twriteOptions?: { offset?: number }\n\t): void => {\n\t\tif (!storageBufferKeySet.has(name)) {\n\t\t\tthrow new Error(\n\t\t\t\t`Unknown storage buffer \"${name}\". Declare it in material.storageBuffers first.`\n\t\t\t);\n\t\t}\n\t\tconst definition = storageBufferDefinitions[name];\n\t\tif (!definition) {\n\t\t\tthrow new Error(`Missing definition for storage buffer \"${name}\".`);\n\t\t}\n\t\tconst offset = writeOptions?.offset ?? 0;\n\t\tif (offset < 0 || offset + data.byteLength > definition.size) {\n\t\t\tthrow new Error(\n\t\t\t\t`Storage buffer \"${name}\" write out of bounds: offset=${offset}, dataSize=${data.byteLength}, bufferSize=${definition.size}.`\n\t\t\t);\n\t\t}\n\t\tpendingStorageWrites.push({ name, data, offset });\n\t};\n\n\tconst readStorageBuffer = (name: string): Promise<ArrayBuffer> => {\n\t\tif (!storageBufferKeySet.has(name)) {\n\t\t\tthrow new Error(\n\t\t\t\t`Unknown storage buffer \"${name}\". Declare it in material.storageBuffers first.`\n\t\t\t);\n\t\t}\n\t\tif (!renderer) {\n\t\t\treturn Promise.reject(\n\t\t\t\tnew Error(`Cannot read storage buffer \"${name}\": renderer not initialized.`)\n\t\t\t);\n\t\t}\n\t\tconst gpuBuffer = renderer.getStorageBuffer?.(name);\n\t\tif (!gpuBuffer) {\n\t\t\treturn Promise.reject(new Error(`Storage buffer \"${name}\" not allocated on GPU.`));\n\t\t}\n\t\tconst device = renderer.getDevice?.();\n\t\tif (!device) {\n\t\t\treturn Promise.reject(new Error('Cannot read storage buffer: GPU device unavailable.'));\n\t\t}\n\t\tconst definition = storageBufferDefinitions[name];\n\t\tif (!definition) {\n\t\t\treturn Promise.reject(new Error(`Missing definition for storage buffer \"${name}\".`));\n\t\t}\n\t\tconst stagingBuffer = device.createBuffer({\n\t\t\tsize: definition.size,\n\t\t\tusage: GPUBufferUsage.MAP_READ | GPUBufferUsage.COPY_DST\n\t\t});\n\t\tconst commandEncoder = device.createCommandEncoder();\n\t\tcommandEncoder.copyBufferToBuffer(gpuBuffer, 0, stagingBuffer, 0, definition.size);\n\t\tdevice.queue.submit([commandEncoder.finish()]);\n\t\treturn stagingBuffer.mapAsync(GPUMapMode.READ).then(() => {\n\t\t\tconst result = stagingBuffer.getMappedRange().slice(0);\n\t\t\tstagingBuffer.unmap();\n\t\t\tstagingBuffer.destroy();\n\t\t\treturn result;\n\t\t});\n\t};\n\n\tconst renderFrame = (timestamp: number): void => {\n\t\tframeId = null;\n\t\tif (isDisposed) {\n\t\t\treturn;\n\t\t}\n\t\tsyncErrorHistory();\n\n\t\tlet materialState: ResolvedMaterial;\n\t\ttry {\n\t\t\tmaterialState = resolveActiveMaterial();\n\t\t} catch (error) {\n\t\t\tsetError(error, 'initialization');\n\t\t\tscheduleFrame();\n\t\t\treturn;\n\t\t}\n\n\t\tshouldContinueAfterFrame = false;\n\n\t\tconst outputColorSpace = options.getOutputColorSpace();\n\t\tconst rendererSignature = buildRendererPipelineSignature({\n\t\t\tmaterialSignature: materialState.signature,\n\t\t\toutputColorSpace\n\t\t});\n\t\tsyncMaterialRuntimeState(materialState);\n\n\t\tif (failedRendererSignature && failedRendererSignature !== rendererSignature) {\n\t\t\tfailedRendererSignature = null;\n\t\t\tfailedRendererAttempts = 0;\n\t\t\tnextRendererRetryAt = 0;\n\t\t}\n\n\t\tif (!renderer || activeRendererSignature !== rendererSignature) {\n\t\t\tif (\n\t\t\t\tfailedRendererSignature === rendererSignature &&\n\t\t\t\tperformance.now() < nextRendererRetryAt\n\t\t\t) {\n\t\t\t\tscheduleFrame();\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (!rendererRebuildPromise) {\n\t\t\t\trendererRebuildPromise = (async () => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst nextRenderer = await createRenderer({\n\t\t\t\t\t\t\tcanvas: canvasElement,\n\t\t\t\t\t\t\tfragmentWgsl: materialState.fragmentWgsl,\n\t\t\t\t\t\t\tfragmentLineMap: materialState.fragmentLineMap,\n\t\t\t\t\t\t\tfragmentSource: materialState.fragmentSource,\n\t\t\t\t\t\t\tincludeSources: materialState.includeSources,\n\t\t\t\t\t\t\tdefineBlockSource: materialState.defineBlockSource,\n\t\t\t\t\t\t\tmaterialSource: materialState.source,\n\t\t\t\t\t\t\tmaterialSignature: materialState.signature,\n\t\t\t\t\t\t\tuniformLayout: materialState.uniformLayout,\n\t\t\t\t\t\t\ttextureKeys: materialState.textureKeys,\n\t\t\t\t\t\t\ttextureDefinitions: materialState.textures,\n\t\t\t\t\t\t\tstorageBufferKeys: materialState.storageBufferKeys,\n\t\t\t\t\t\t\tstorageBufferDefinitions,\n\t\t\t\t\t\t\tstorageTextureKeys: materialState.storageTextureKeys,\n\t\t\t\t\t\t\tgetRenderTargets: options.getRenderTargets,\n\t\t\t\t\t\t\tgetPasses: options.getPasses,\n\t\t\t\t\t\t\toutputColorSpace,\n\t\t\t\t\t\t\tgetClearColor: options.getClearColor,\n\t\t\t\t\t\t\tgetDpr: () => options.dpr.current,\n\t\t\t\t\t\t\tadapterOptions: options.getAdapterOptions(),\n\t\t\t\t\t\t\tdeviceDescriptor: options.getDeviceDescriptor()\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tif (isDisposed) {\n\t\t\t\t\t\t\tnextRenderer.destroy();\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\trenderer?.destroy();\n\t\t\t\t\t\trenderer = nextRenderer;\n\t\t\t\t\t\tactiveRendererSignature = rendererSignature;\n\t\t\t\t\t\tfailedRendererSignature = null;\n\t\t\t\t\t\tfailedRendererAttempts = 0;\n\t\t\t\t\t\tnextRendererRetryAt = 0;\n\t\t\t\t\t\tclearError();\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tfailedRendererSignature = rendererSignature;\n\t\t\t\t\t\tfailedRendererAttempts += 1;\n\t\t\t\t\t\tconst retryDelayMs = getRendererRetryDelayMs(failedRendererAttempts);\n\t\t\t\t\t\tnextRendererRetryAt = performance.now() + retryDelayMs;\n\t\t\t\t\t\tsetError(error, 'initialization');\n\t\t\t\t\t} finally {\n\t\t\t\t\t\trendererRebuildPromise = null;\n\t\t\t\t\t\tscheduleFrame();\n\t\t\t\t\t}\n\t\t\t\t})();\n\t\t\t}\n\n\t\t\treturn;\n\t\t}\n\n\t\tconst time = timestamp / 1000;\n\t\tconst rawDelta = Math.max(0, time - previousTime);\n\t\tconst delta = Math.min(rawDelta, options.maxDelta.current);\n\t\tpreviousTime = time;\n\t\tconst rect = canvasElement.getBoundingClientRect();\n\t\tconst width = Math.max(0, Math.floor(rect.width));\n\t\tconst height = Math.max(0, Math.floor(rect.height));\n\t\tif (width !== currentCssWidth || height !== currentCssHeight) {\n\t\t\tcurrentCssWidth = width;\n\t\t\tcurrentCssHeight = height;\n\t\t\tsize.set({ width, height });\n\t\t}\n\n\t\ttry {\n\t\t\tregistry.run({\n\t\t\t\ttime,\n\t\t\t\tdelta,\n\t\t\t\tsetUniform,\n\t\t\t\tsetTexture,\n\t\t\t\twriteStorageBuffer,\n\t\t\t\treadStorageBuffer,\n\t\t\t\tinvalidate,\n\t\t\t\tadvance,\n\t\t\t\trenderMode: registry.getRenderMode(),\n\t\t\t\tautoRender: registry.getAutoRender(),\n\t\t\t\tcanvas: canvasElement\n\t\t\t});\n\n\t\t\tconst shouldRenderFrame = registry.shouldRender();\n\t\t\tshouldContinueAfterFrame =\n\t\t\t\tregistry.getRenderMode() === 'always' ||\n\t\t\t\t(registry.getRenderMode() === 'on-demand' && shouldRenderFrame);\n\n\t\t\tif (shouldRenderFrame) {\n\t\t\t\tfor (const key of uniformKeys) {\n\t\t\t\t\tconst runtimeValue = runtimeUniforms[key];\n\t\t\t\t\trenderUniforms[key] =\n\t\t\t\t\t\truntimeValue === undefined ? (activeUniforms[key] as UniformValue) : runtimeValue;\n\t\t\t\t}\n\n\t\t\t\tfor (const key of textureKeys) {\n\t\t\t\t\tconst runtimeValue = runtimeTextures[key];\n\t\t\t\t\trenderTextures[key] =\n\t\t\t\t\t\truntimeValue === undefined ? (activeTextures[key]?.source ?? null) : runtimeValue;\n\t\t\t\t}\n\n\t\t\t\tcanvasSize.width = width;\n\t\t\t\tcanvasSize.height = height;\n\t\t\t\trenderer.render({\n\t\t\t\t\ttime,\n\t\t\t\t\tdelta,\n\t\t\t\t\trenderMode: registry.getRenderMode(),\n\t\t\t\t\tuniforms: renderUniforms,\n\t\t\t\t\ttextures: renderTextures,\n\t\t\t\t\tcanvasSize,\n\t\t\t\t\t...(pendingStorageWrites.length > 0\n\t\t\t\t\t\t? { pendingStorageWrites: pendingStorageWrites.splice(0) }\n\t\t\t\t\t\t: {})\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tclearError();\n\t\t} catch (error) {\n\t\t\tsetError(error, 'render');\n\t\t} finally {\n\t\t\tregistry.endFrame();\n\t\t}\n\n\t\tif (shouldContinueAfterFrame) {\n\t\t\tscheduleFrame();\n\t\t}\n\t};\n\n\t(async () => {\n\t\ttry {\n\t\t\tconst initialMaterial = resolveActiveMaterial();\n\t\t\tsyncMaterialRuntimeState(initialMaterial);\n\t\t\tactiveRendererSignature = '';\n\t\t\tscheduleFrame();\n\t\t} catch (error) {\n\t\t\tsetError(error, 'initialization');\n\t\t\tscheduleFrame();\n\t\t}\n\t})();\n\n\treturn {\n\t\trequestFrame,\n\t\tinvalidate,\n\t\tadvance,\n\t\tdestroy: () => {\n\t\t\tisDisposed = true;\n\t\t\tif (frameId !== null) {\n\t\t\t\tcancelAnimationFrame(frameId);\n\t\t\t\tframeId = null;\n\t\t\t}\n\t\t\trenderer?.destroy();\n\t\t\tregistry.clear();\n\t\t}\n\t};\n}\n"],"mappings":";;;;;;AAoDA,SAAS,wBAAwB,SAAyB;AACzD,QAAO,KAAK,IAAI,KAAM,MAAM,KAAK,KAAK,IAAI,GAAG,UAAU,EAAE,CAAC;;AAG3D,SAAgB,2BACf,SACuB;CACvB,MAAM,EAAE,QAAQ,eAAe,UAAU,SAAS;CAClD,IAAI,UAAyB;CAC7B,IAAI,WAA4B;CAChC,IAAI,aAAa;CACjB,IAAI,eAAe,YAAY,KAAK,GAAG;CACvC,IAAI,0BAA0B;CAC9B,IAAI,0BAAyC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GAAI,qBAAqB,SAAS,IAC/B,EAAE,sBAAsB,qBAAqB,OAAO,EAAE,EAAE,GACxD,EAAE;KACL,CAAC;;AAGH,eAAY;WACJ,OAAO;AACf,YAAS,OAAO,SAAS;YAChB;AACT,YAAS,UAAU;;AAGpB,MAAI,yBACH,gBAAe;;AAIjB,EAAC,YAAY;AACZ,MAAI;AAEH,4BADwB,uBAAuB,CACN;AACzC,6BAA0B;AAC1B,kBAAe;WACP,OAAO;AACf,YAAS,OAAO,iBAAiB;AACjC,kBAAe;;KAEb;AAEJ,QAAO;EACN;EACA;EACA;EACA,eAAe;AACd,gBAAa;AACb,OAAI,YAAY,MAAM;AACrB,yBAAqB,QAAQ;AAC7B,cAAU;;AAEX,aAAU,SAAS;AACnB,YAAS,OAAO;;EAEjB"}
1
+ {"version":3,"file":"runtime-loop.js","names":[],"sources":["../../src/lib/core/runtime-loop.ts"],"sourcesContent":["import type { CurrentReadable, CurrentWritable } from './current-value.js';\nimport { resolveMaterial, type FragMaterial, type ResolvedMaterial } from './material.js';\nimport {\n\ttoMotionGPUErrorReport,\n\ttype MotionGPUErrorPhase,\n\ttype MotionGPUErrorReport\n} from './error-report.js';\nimport { createRenderer } from './renderer.js';\nimport { buildRendererPipelineSignature } from './recompile-policy.js';\nimport { assertUniformValueForType } from './uniforms.js';\nimport type { FrameRegistry } from './frame-registry.js';\nimport type {\n\tAnyPass,\n\tFrameInvalidationToken,\n\tOutputColorSpace,\n\tPendingStorageWrite,\n\tRenderer,\n\tRenderTargetDefinitionMap,\n\tStorageBufferDefinitionMap,\n\tTextureMap,\n\tTextureValue,\n\tUniformType,\n\tUniformValue\n} from './types.js';\n\nexport interface MotionGPURuntimeLoopOptions {\n\tcanvas: HTMLCanvasElement;\n\tregistry: FrameRegistry;\n\tsize: CurrentWritable<{ width: number; height: number }>;\n\tdpr: CurrentReadable<number>;\n\tmaxDelta: CurrentReadable<number>;\n\tgetMaterial: () => FragMaterial;\n\tgetRenderTargets: () => RenderTargetDefinitionMap;\n\tgetPasses: () => AnyPass[];\n\tgetClearColor: () => [number, number, number, number];\n\tgetOutputColorSpace: () => OutputColorSpace;\n\tgetAdapterOptions: () => GPURequestAdapterOptions | undefined;\n\tgetDeviceDescriptor: () => GPUDeviceDescriptor | undefined;\n\tgetOnError: () => ((report: MotionGPUErrorReport) => void) | undefined;\n\treportError: (report: MotionGPUErrorReport | null) => void;\n\tgetErrorHistoryLimit?: () => number | undefined;\n\tgetOnErrorHistory?: () => ((history: MotionGPUErrorReport[]) => void) | undefined;\n\treportErrorHistory?: (history: MotionGPUErrorReport[]) => void;\n}\n\nexport interface MotionGPURuntimeLoop {\n\trequestFrame: () => void;\n\tinvalidate: (token?: FrameInvalidationToken) => void;\n\tadvance: () => void;\n\tdestroy: () => void;\n}\n\nfunction getRendererRetryDelayMs(attempt: number): number {\n\treturn Math.min(8000, 250 * 2 ** Math.max(0, attempt - 1));\n}\n\nconst ERROR_CLEAR_GRACE_MS = 750;\n\nexport function createMotionGPURuntimeLoop(\n\toptions: MotionGPURuntimeLoopOptions\n): MotionGPURuntimeLoop {\n\tconst { canvas: canvasElement, registry, size } = options;\n\tlet frameId: number | null = null;\n\tlet renderer: Renderer | null = null;\n\tlet isDisposed = false;\n\tlet previousTime = performance.now() / 1000;\n\tlet activeRendererSignature = '';\n\tlet failedRendererSignature: string | null = null;\n\tlet failedRendererAttempts = 0;\n\tlet nextRendererRetryAt = 0;\n\tlet rendererRebuildPromise: Promise<void> | null = null;\n\n\tconst runtimeUniforms: Record<string, UniformValue> = {};\n\tconst runtimeTextures: TextureMap = {};\n\tlet activeUniforms: Record<string, UniformValue> = {};\n\tlet activeTextures: Record<string, { source?: TextureValue }> = {};\n\tlet uniformKeys: string[] = [];\n\tlet uniformKeySet = new Set<string>();\n\tlet uniformTypes = new Map<string, UniformType>();\n\tlet textureKeys: string[] = [];\n\tlet textureKeySet = new Set<string>();\n\tlet activeMaterialSignature = '';\n\tlet currentCssWidth = -1;\n\tlet currentCssHeight = -1;\n\tconst renderUniforms: Record<string, UniformValue> = {};\n\tconst renderTextures: TextureMap = {};\n\tconst canvasSize = { width: 0, height: 0 };\n\tlet storageBufferKeys: string[] = [];\n\tlet storageBufferKeySet = new Set<string>();\n\tlet storageBufferDefinitions: StorageBufferDefinitionMap = {};\n\tconst pendingStorageWrites: PendingStorageWrite[] = [];\n\tlet shouldContinueAfterFrame = false;\n\tlet activeErrorKey: string | null = null;\n\tlet errorHistory: MotionGPUErrorReport[] = [];\n\tlet errorClearReadyAtMs = 0;\n\tlet lastFrameTimestampMs = performance.now();\n\n\tconst resolveNowMs = (nowMs?: number): number => {\n\t\tif (typeof nowMs === 'number' && Number.isFinite(nowMs)) {\n\t\t\treturn nowMs;\n\t\t}\n\n\t\treturn lastFrameTimestampMs;\n\t};\n\n\tconst getHistoryLimit = (): number => {\n\t\tconst value = options.getErrorHistoryLimit?.() ?? 0;\n\t\tif (!Number.isFinite(value) || value <= 0) {\n\t\t\treturn 0;\n\t\t}\n\n\t\treturn Math.floor(value);\n\t};\n\n\tconst publishErrorHistory = (): void => {\n\t\toptions.reportErrorHistory?.(errorHistory);\n\t\tconst onErrorHistory = options.getOnErrorHistory?.();\n\t\tif (!onErrorHistory) {\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tonErrorHistory(errorHistory);\n\t\t} catch {\n\t\t\t// User-provided error history handlers must not break runtime error recovery.\n\t\t}\n\t};\n\n\tconst syncErrorHistory = (): void => {\n\t\tconst limit = getHistoryLimit();\n\t\tif (limit <= 0) {\n\t\t\tif (errorHistory.length === 0) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\terrorHistory = [];\n\t\t\tpublishErrorHistory();\n\t\t\treturn;\n\t\t}\n\n\t\tif (errorHistory.length <= limit) {\n\t\t\treturn;\n\t\t}\n\n\t\terrorHistory.splice(0, errorHistory.length - limit);\n\t\tpublishErrorHistory();\n\t};\n\n\tconst setError = (error: unknown, phase: MotionGPUErrorPhase, nowMs?: number): void => {\n\t\tconst report = toMotionGPUErrorReport(error, phase);\n\t\terrorClearReadyAtMs = resolveNowMs(nowMs) + ERROR_CLEAR_GRACE_MS;\n\t\tconst reportKey = JSON.stringify({\n\t\t\tphase: report.phase,\n\t\t\ttitle: report.title,\n\t\t\tmessage: report.message,\n\t\t\trawMessage: report.rawMessage\n\t\t});\n\t\tif (activeErrorKey === reportKey) {\n\t\t\treturn;\n\t\t}\n\t\tactiveErrorKey = reportKey;\n\t\tconst historyLimit = getHistoryLimit();\n\t\tif (historyLimit > 0) {\n\t\t\terrorHistory.push(report);\n\t\t\tif (errorHistory.length > historyLimit) {\n\t\t\t\terrorHistory.splice(0, errorHistory.length - historyLimit);\n\t\t\t}\n\t\t\tpublishErrorHistory();\n\t\t}\n\t\toptions.reportError(report);\n\t\tconst onError = options.getOnError();\n\t\tif (!onError) {\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tonError(report);\n\t\t} catch {\n\t\t\t// User-provided error handlers must not break runtime error recovery.\n\t\t}\n\t};\n\n\tconst maybeClearError = (nowMs?: number): void => {\n\t\tif (activeErrorKey === null) {\n\t\t\treturn;\n\t\t}\n\t\tif (resolveNowMs(nowMs) < errorClearReadyAtMs) {\n\t\t\treturn;\n\t\t}\n\n\t\tactiveErrorKey = null;\n\t\terrorClearReadyAtMs = 0;\n\t\toptions.reportError(null);\n\t};\n\n\tconst scheduleFrame = (): void => {\n\t\tif (isDisposed || frameId !== null) {\n\t\t\treturn;\n\t\t}\n\n\t\tframeId = requestAnimationFrame(renderFrame);\n\t};\n\n\tconst requestFrame = (): void => {\n\t\tscheduleFrame();\n\t};\n\n\tconst invalidate = (token?: FrameInvalidationToken): void => {\n\t\tregistry.invalidate(token);\n\t\trequestFrame();\n\t};\n\n\tconst advance = (): void => {\n\t\tregistry.advance();\n\t\trequestFrame();\n\t};\n\n\tconst resetRuntimeMaps = (): void => {\n\t\tfor (const key of Object.keys(runtimeUniforms)) {\n\t\t\tif (!uniformKeySet.has(key)) {\n\t\t\t\tdelete runtimeUniforms[key];\n\t\t\t}\n\t\t}\n\n\t\tfor (const key of Object.keys(runtimeTextures)) {\n\t\t\tif (!textureKeySet.has(key)) {\n\t\t\t\tdelete runtimeTextures[key];\n\t\t\t}\n\t\t}\n\t};\n\n\tconst resetRenderPayloadMaps = (): void => {\n\t\tfor (const key of Object.keys(renderUniforms)) {\n\t\t\tif (!uniformKeySet.has(key)) {\n\t\t\t\tdelete renderUniforms[key];\n\t\t\t}\n\t\t}\n\n\t\tfor (const key of Object.keys(renderTextures)) {\n\t\t\tif (!textureKeySet.has(key)) {\n\t\t\t\tdelete renderTextures[key];\n\t\t\t}\n\t\t}\n\t};\n\n\tconst syncMaterialRuntimeState = (materialState: ResolvedMaterial): void => {\n\t\tconst signatureChanged = activeMaterialSignature !== materialState.signature;\n\t\tconst defaultsChanged =\n\t\t\tactiveUniforms !== materialState.uniforms || activeTextures !== materialState.textures;\n\n\t\tif (!signatureChanged && !defaultsChanged) {\n\t\t\treturn;\n\t\t}\n\n\t\tactiveUniforms = materialState.uniforms;\n\t\tactiveTextures = materialState.textures;\n\t\tif (!signatureChanged) {\n\t\t\treturn;\n\t\t}\n\n\t\tuniformKeys = materialState.uniformLayout.entries.map((entry) => entry.name);\n\t\tuniformTypes = new Map(\n\t\t\tmaterialState.uniformLayout.entries.map((entry) => [entry.name, entry.type])\n\t\t);\n\t\ttextureKeys = materialState.textureKeys;\n\t\tuniformKeySet = new Set(uniformKeys);\n\t\ttextureKeySet = new Set(textureKeys);\n\t\tstorageBufferKeys = materialState.storageBufferKeys;\n\t\tstorageBufferKeySet = new Set(storageBufferKeys);\n\t\tstorageBufferDefinitions = (options.getMaterial().storageBuffers ??\n\t\t\t{}) as StorageBufferDefinitionMap;\n\t\tresetRuntimeMaps();\n\t\tresetRenderPayloadMaps();\n\t\tactiveMaterialSignature = materialState.signature;\n\t};\n\n\tconst resolveActiveMaterial = (): ResolvedMaterial => {\n\t\treturn resolveMaterial(options.getMaterial());\n\t};\n\n\tconst setUniform = (name: string, value: UniformValue): void => {\n\t\tif (!uniformKeySet.has(name)) {\n\t\t\tthrow new Error(`Unknown uniform \"${name}\". Declare it in material.uniforms first.`);\n\t\t}\n\t\tconst expectedType = uniformTypes.get(name);\n\t\tif (!expectedType) {\n\t\t\tthrow new Error(`Unknown uniform type for \"${name}\"`);\n\t\t}\n\t\tassertUniformValueForType(expectedType, value);\n\t\truntimeUniforms[name] = value;\n\t};\n\n\tconst setTexture = (name: string, value: TextureValue): void => {\n\t\tif (!textureKeySet.has(name)) {\n\t\t\tthrow new Error(`Unknown texture \"${name}\". Declare it in material.textures first.`);\n\t\t}\n\t\truntimeTextures[name] = value;\n\t};\n\n\tconst writeStorageBuffer = (\n\t\tname: string,\n\t\tdata: ArrayBufferView,\n\t\twriteOptions?: { offset?: number }\n\t): void => {\n\t\tif (!storageBufferKeySet.has(name)) {\n\t\t\tthrow new Error(\n\t\t\t\t`Unknown storage buffer \"${name}\". Declare it in material.storageBuffers first.`\n\t\t\t);\n\t\t}\n\t\tconst definition = storageBufferDefinitions[name];\n\t\tif (!definition) {\n\t\t\tthrow new Error(`Missing definition for storage buffer \"${name}\".`);\n\t\t}\n\t\tconst offset = writeOptions?.offset ?? 0;\n\t\tif (offset < 0 || offset + data.byteLength > definition.size) {\n\t\t\tthrow new Error(\n\t\t\t\t`Storage buffer \"${name}\" write out of bounds: offset=${offset}, dataSize=${data.byteLength}, bufferSize=${definition.size}.`\n\t\t\t);\n\t\t}\n\t\tpendingStorageWrites.push({ name, data, offset });\n\t};\n\n\tconst readStorageBuffer = (name: string): Promise<ArrayBuffer> => {\n\t\tif (!storageBufferKeySet.has(name)) {\n\t\t\tthrow new Error(\n\t\t\t\t`Unknown storage buffer \"${name}\". Declare it in material.storageBuffers first.`\n\t\t\t);\n\t\t}\n\t\tif (!renderer) {\n\t\t\treturn Promise.reject(\n\t\t\t\tnew Error(`Cannot read storage buffer \"${name}\": renderer not initialized.`)\n\t\t\t);\n\t\t}\n\t\tconst gpuBuffer = renderer.getStorageBuffer?.(name);\n\t\tif (!gpuBuffer) {\n\t\t\treturn Promise.reject(new Error(`Storage buffer \"${name}\" not allocated on GPU.`));\n\t\t}\n\t\tconst device = renderer.getDevice?.();\n\t\tif (!device) {\n\t\t\treturn Promise.reject(new Error('Cannot read storage buffer: GPU device unavailable.'));\n\t\t}\n\t\tconst definition = storageBufferDefinitions[name];\n\t\tif (!definition) {\n\t\t\treturn Promise.reject(new Error(`Missing definition for storage buffer \"${name}\".`));\n\t\t}\n\t\tconst stagingBuffer = device.createBuffer({\n\t\t\tsize: definition.size,\n\t\t\tusage: GPUBufferUsage.MAP_READ | GPUBufferUsage.COPY_DST\n\t\t});\n\t\tconst commandEncoder = device.createCommandEncoder();\n\t\tcommandEncoder.copyBufferToBuffer(gpuBuffer, 0, stagingBuffer, 0, definition.size);\n\t\tdevice.queue.submit([commandEncoder.finish()]);\n\t\treturn stagingBuffer.mapAsync(GPUMapMode.READ).then(() => {\n\t\t\tconst result = stagingBuffer.getMappedRange().slice(0);\n\t\t\tstagingBuffer.unmap();\n\t\t\tstagingBuffer.destroy();\n\t\t\treturn result;\n\t\t});\n\t};\n\n\tconst renderFrame = (timestamp: number): void => {\n\t\tframeId = null;\n\t\tif (isDisposed) {\n\t\t\treturn;\n\t\t}\n\t\tlastFrameTimestampMs = timestamp;\n\t\tsyncErrorHistory();\n\n\t\tlet materialState: ResolvedMaterial;\n\t\ttry {\n\t\t\tmaterialState = resolveActiveMaterial();\n\t\t} catch (error) {\n\t\t\tsetError(error, 'initialization', timestamp);\n\t\t\tscheduleFrame();\n\t\t\treturn;\n\t\t}\n\n\t\tshouldContinueAfterFrame = false;\n\n\t\tconst outputColorSpace = options.getOutputColorSpace();\n\t\tconst rendererSignature = buildRendererPipelineSignature({\n\t\t\tmaterialSignature: materialState.signature,\n\t\t\toutputColorSpace\n\t\t});\n\t\tsyncMaterialRuntimeState(materialState);\n\n\t\tif (failedRendererSignature && failedRendererSignature !== rendererSignature) {\n\t\t\tfailedRendererSignature = null;\n\t\t\tfailedRendererAttempts = 0;\n\t\t\tnextRendererRetryAt = 0;\n\t\t}\n\n\t\tif (!renderer || activeRendererSignature !== rendererSignature) {\n\t\t\tif (\n\t\t\t\tfailedRendererSignature === rendererSignature &&\n\t\t\t\tperformance.now() < nextRendererRetryAt\n\t\t\t) {\n\t\t\t\tscheduleFrame();\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (!rendererRebuildPromise) {\n\t\t\t\trendererRebuildPromise = (async () => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst nextRenderer = await createRenderer({\n\t\t\t\t\t\t\tcanvas: canvasElement,\n\t\t\t\t\t\t\tfragmentWgsl: materialState.fragmentWgsl,\n\t\t\t\t\t\t\tfragmentLineMap: materialState.fragmentLineMap,\n\t\t\t\t\t\t\tfragmentSource: materialState.fragmentSource,\n\t\t\t\t\t\t\tincludeSources: materialState.includeSources,\n\t\t\t\t\t\t\tdefineBlockSource: materialState.defineBlockSource,\n\t\t\t\t\t\t\tmaterialSource: materialState.source,\n\t\t\t\t\t\t\tmaterialSignature: materialState.signature,\n\t\t\t\t\t\t\tuniformLayout: materialState.uniformLayout,\n\t\t\t\t\t\t\ttextureKeys: materialState.textureKeys,\n\t\t\t\t\t\t\ttextureDefinitions: materialState.textures,\n\t\t\t\t\t\t\tstorageBufferKeys: materialState.storageBufferKeys,\n\t\t\t\t\t\t\tstorageBufferDefinitions,\n\t\t\t\t\t\t\tstorageTextureKeys: materialState.storageTextureKeys,\n\t\t\t\t\t\t\tgetRenderTargets: options.getRenderTargets,\n\t\t\t\t\t\t\tgetPasses: options.getPasses,\n\t\t\t\t\t\t\toutputColorSpace,\n\t\t\t\t\t\t\tgetClearColor: options.getClearColor,\n\t\t\t\t\t\t\tgetDpr: () => options.dpr.current,\n\t\t\t\t\t\t\tadapterOptions: options.getAdapterOptions(),\n\t\t\t\t\t\t\tdeviceDescriptor: options.getDeviceDescriptor()\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tif (isDisposed) {\n\t\t\t\t\t\t\tnextRenderer.destroy();\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\trenderer?.destroy();\n\t\t\t\t\t\trenderer = nextRenderer;\n\t\t\t\t\t\tactiveRendererSignature = rendererSignature;\n\t\t\t\t\t\tfailedRendererSignature = null;\n\t\t\t\t\t\tfailedRendererAttempts = 0;\n\t\t\t\t\t\tnextRendererRetryAt = 0;\n\t\t\t\t\t\tmaybeClearError(performance.now());\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tfailedRendererSignature = rendererSignature;\n\t\t\t\t\t\tfailedRendererAttempts += 1;\n\t\t\t\t\t\tconst retryDelayMs = getRendererRetryDelayMs(failedRendererAttempts);\n\t\t\t\t\t\tnextRendererRetryAt = performance.now() + retryDelayMs;\n\t\t\t\t\t\tsetError(error, 'initialization');\n\t\t\t\t\t} finally {\n\t\t\t\t\t\trendererRebuildPromise = null;\n\t\t\t\t\t\tscheduleFrame();\n\t\t\t\t\t}\n\t\t\t\t})();\n\t\t\t}\n\n\t\t\treturn;\n\t\t}\n\n\t\tconst time = timestamp / 1000;\n\t\tconst rawDelta = Math.max(0, time - previousTime);\n\t\tconst delta = Math.min(rawDelta, options.maxDelta.current);\n\t\tpreviousTime = time;\n\t\tconst rect = canvasElement.getBoundingClientRect();\n\t\tconst width = Math.max(0, Math.floor(rect.width));\n\t\tconst height = Math.max(0, Math.floor(rect.height));\n\t\tif (width !== currentCssWidth || height !== currentCssHeight) {\n\t\t\tcurrentCssWidth = width;\n\t\t\tcurrentCssHeight = height;\n\t\t\tsize.set({ width, height });\n\t\t}\n\n\t\ttry {\n\t\t\tregistry.run({\n\t\t\t\ttime,\n\t\t\t\tdelta,\n\t\t\t\tsetUniform,\n\t\t\t\tsetTexture,\n\t\t\t\twriteStorageBuffer,\n\t\t\t\treadStorageBuffer,\n\t\t\t\tinvalidate,\n\t\t\t\tadvance,\n\t\t\t\trenderMode: registry.getRenderMode(),\n\t\t\t\tautoRender: registry.getAutoRender(),\n\t\t\t\tcanvas: canvasElement\n\t\t\t});\n\n\t\t\tconst shouldRenderFrame = registry.shouldRender();\n\t\t\tshouldContinueAfterFrame =\n\t\t\t\tregistry.getRenderMode() === 'always' ||\n\t\t\t\t(registry.getRenderMode() === 'on-demand' && shouldRenderFrame);\n\n\t\t\tif (shouldRenderFrame) {\n\t\t\t\tfor (const key of uniformKeys) {\n\t\t\t\t\tconst runtimeValue = runtimeUniforms[key];\n\t\t\t\t\trenderUniforms[key] =\n\t\t\t\t\t\truntimeValue === undefined ? (activeUniforms[key] as UniformValue) : runtimeValue;\n\t\t\t\t}\n\n\t\t\t\tfor (const key of textureKeys) {\n\t\t\t\t\tconst runtimeValue = runtimeTextures[key];\n\t\t\t\t\trenderTextures[key] =\n\t\t\t\t\t\truntimeValue === undefined ? (activeTextures[key]?.source ?? null) : runtimeValue;\n\t\t\t\t}\n\n\t\t\t\tcanvasSize.width = width;\n\t\t\t\tcanvasSize.height = height;\n\t\t\t\trenderer.render({\n\t\t\t\t\ttime,\n\t\t\t\t\tdelta,\n\t\t\t\t\trenderMode: registry.getRenderMode(),\n\t\t\t\t\tuniforms: renderUniforms,\n\t\t\t\t\ttextures: renderTextures,\n\t\t\t\t\tcanvasSize,\n\t\t\t\t\tpendingStorageWrites: pendingStorageWrites.length > 0 ? pendingStorageWrites : undefined\n\t\t\t\t});\n\t\t\t\t// Clear in-place after synchronous render() completes — avoids\n\t\t\t\t// the splice(0) copy and eliminates the conditional spread object.\n\t\t\t\tif (pendingStorageWrites.length > 0) {\n\t\t\t\t\tpendingStorageWrites.length = 0;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tmaybeClearError(timestamp);\n\t\t} catch (error) {\n\t\t\tsetError(error, 'render', timestamp);\n\t\t} finally {\n\t\t\tregistry.endFrame();\n\t\t}\n\n\t\tif (shouldContinueAfterFrame) {\n\t\t\tscheduleFrame();\n\t\t}\n\t};\n\n\t(async () => {\n\t\ttry {\n\t\t\tconst initialMaterial = resolveActiveMaterial();\n\t\t\tsyncMaterialRuntimeState(initialMaterial);\n\t\t\tactiveRendererSignature = '';\n\t\t\tscheduleFrame();\n\t\t} catch (error) {\n\t\t\tsetError(error, 'initialization');\n\t\t\tscheduleFrame();\n\t\t}\n\t})();\n\n\treturn {\n\t\trequestFrame,\n\t\tinvalidate,\n\t\tadvance,\n\t\tdestroy: () => {\n\t\t\tisDisposed = true;\n\t\t\tif (frameId !== null) {\n\t\t\t\tcancelAnimationFrame(frameId);\n\t\t\t\tframeId = null;\n\t\t\t}\n\t\t\trenderer?.destroy();\n\t\t\tregistry.clear();\n\t\t}\n\t};\n}\n"],"mappings":";;;;;;AAoDA,SAAS,wBAAwB,SAAyB;AACzD,QAAO,KAAK,IAAI,KAAM,MAAM,KAAK,KAAK,IAAI,GAAG,UAAU,EAAE,CAAC;;AAG3D,IAAM,uBAAuB;AAE7B,SAAgB,2BACf,SACuB;CACvB,MAAM,EAAE,QAAQ,eAAe,UAAU,SAAS;CAClD,IAAI,UAAyB;CAC7B,IAAI,WAA4B;CAChC,IAAI,aAAa;CACjB,IAAI,eAAe,YAAY,KAAK,GAAG;CACvC,IAAI,0BAA0B;CAC9B,IAAI,0BAAyC;CAC7C,IAAI,yBAAyB;CAC7B,IAAI,sBAAsB;CAC1B,IAAI,yBAA+C;CAEnD,MAAM,kBAAgD,EAAE;CACxD,MAAM,kBAA8B,EAAE;CACtC,IAAI,iBAA+C,EAAE;CACrD,IAAI,iBAA4D,EAAE;CAClE,IAAI,cAAwB,EAAE;CAC9B,IAAI,gCAAgB,IAAI,KAAa;CACrC,IAAI,+BAAe,IAAI,KAA0B;CACjD,IAAI,cAAwB,EAAE;CAC9B,IAAI,gCAAgB,IAAI,KAAa;CACrC,IAAI,0BAA0B;CAC9B,IAAI,kBAAkB;CACtB,IAAI,mBAAmB;CACvB,MAAM,iBAA+C,EAAE;CACvD,MAAM,iBAA6B,EAAE;CACrC,MAAM,aAA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;AACZ,MAAI;AAEH,4BADwB,uBAAuB,CACN;AACzC,6BAA0B;AAC1B,kBAAe;WACP,OAAO;AACf,YAAS,OAAO,iBAAiB;AACjC,kBAAe;;KAEb;AAEJ,QAAO;EACN;EACA;EACA;EACA,eAAe;AACd,gBAAa;AACb,OAAI,YAAY,MAAM;AACrB,yBAAqB,QAAQ;AAC7B,cAAU;;AAEX,aAAU,SAAS;AACnB,YAAS,OAAO;;EAEjB"}
@@ -1,9 +1,13 @@
1
1
  import type { MaterialLineMap, MaterialSourceLocation } from './material-preprocess.js';
2
2
  import type { StorageBufferType, UniformLayout } from './types.js';
3
+ type ComputeShaderSourceLocation = {
4
+ kind: 'compute';
5
+ line: number;
6
+ };
3
7
  /**
4
8
  * 1-based map from generated WGSL lines to original material source lines.
5
9
  */
6
- export type ShaderLineMap = Array<MaterialSourceLocation | null>;
10
+ export type ShaderLineMap = Array<(MaterialSourceLocation | ComputeShaderSourceLocation) | null>;
7
11
  /**
8
12
  * Result of shader source generation with line mapping metadata.
9
13
  */
@@ -47,5 +51,6 @@ export declare function buildShaderSourceWithMap(fragmentWgsl: string, uniformLa
47
51
  /**
48
52
  * Converts source location metadata to user-facing diagnostics label.
49
53
  */
50
- export declare function formatShaderSourceLocation(location: MaterialSourceLocation | null): string | null;
54
+ export declare function formatShaderSourceLocation(location: (MaterialSourceLocation | ComputeShaderSourceLocation) | null): string | null;
55
+ export {};
51
56
  //# sourceMappingURL=shader.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"shader.d.ts","sourceRoot":"","sources":["../../src/lib/core/shader.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AACxF,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AA+InE;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,KAAK,CAAC,sBAAsB,GAAG,IAAI,CAAC,CAAC;AAEjE;;GAE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kind === "fragment") return `fragment line ${location.line}`;
184
184
  if (location.kind === "include") return `include <${location.include}> line ${location.line}`;
185
+ if (location.kind === "compute") return `compute line ${location.line}`;
185
186
  return `define "${location.define}" line ${location.line}`;
186
187
  }
187
188
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"shader.js","names":[],"sources":["../../src/lib/core/shader.ts"],"sourcesContent":["import { assertUniformName } from './uniforms.js';\nimport type { MaterialLineMap, MaterialSourceLocation } from './material-preprocess.js';\nimport type { StorageBufferType, UniformLayout } from './types.js';\n\n/**\n * Fallback uniform field used when no custom uniforms are provided.\n */\nconst DEFAULT_UNIFORM_FIELD = 'motiongpu_unused: vec4f,';\n\n/**\n * Builds WGSL struct fields for user uniforms.\n */\nfunction buildUniformStruct(layout: UniformLayout): string {\n\tif (layout.entries.length === 0) {\n\t\treturn DEFAULT_UNIFORM_FIELD;\n\t}\n\n\treturn layout.entries\n\t\t.map((entry) => {\n\t\t\tassertUniformName(entry.name);\n\t\t\treturn `${entry.name}: ${entry.type},`;\n\t\t})\n\t\t.join('\\n\\t');\n}\n\n/**\n * Builds a numeric expression that references one uniform value to keep bindings alive.\n */\nfunction getKeepAliveExpression(layout: UniformLayout): string {\n\tif (layout.entries.length === 0) {\n\t\treturn 'motiongpuUniforms.motiongpu_unused.x';\n\t}\n\n\tconst [firstEntry] = layout.entries;\n\tif (!firstEntry) {\n\t\treturn 'motiongpuUniforms.motiongpu_unused.x';\n\t}\n\n\tif (firstEntry.type === 'f32') {\n\t\treturn `motiongpuUniforms.${firstEntry.name}`;\n\t}\n\n\tif (firstEntry.type === 'mat4x4f') {\n\t\treturn `motiongpuUniforms.${firstEntry.name}[0].x`;\n\t}\n\n\treturn `motiongpuUniforms.${firstEntry.name}.x`;\n}\n\n/**\n * Builds texture sampler/texture binding declarations.\n */\nfunction buildTextureBindings(textureKeys: string[]): string {\n\tif (textureKeys.length === 0) {\n\t\treturn '';\n\t}\n\n\tconst declarations: string[] = [];\n\n\tfor (let index = 0; index < textureKeys.length; index += 1) {\n\t\tconst key = textureKeys[index];\n\t\tif (key === undefined) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tassertUniformName(key);\n\t\tconst binding = 2 + index * 2;\n\t\tdeclarations.push(`@group(0) @binding(${binding}) var ${key}Sampler: sampler;`);\n\t\tdeclarations.push(`@group(0) @binding(${binding + 1}) var ${key}: texture_2d<f32>;`);\n\t}\n\n\treturn declarations.join('\\n');\n}\n\n/**\n * Builds read-only storage buffer bindings for fragment shader.\n */\nfunction buildFragmentStorageBufferBindings(\n\tstorageBufferKeys: string[],\n\tdefinitions: Record<string, { type: StorageBufferType }>\n): string {\n\tif (storageBufferKeys.length === 0) {\n\t\treturn '';\n\t}\n\n\tconst declarations: string[] = [];\n\n\tfor (let index = 0; index < storageBufferKeys.length; index += 1) {\n\t\tconst key = storageBufferKeys[index];\n\t\tif (key === undefined) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst definition = definitions[key];\n\t\tif (!definition) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tdeclarations.push(\n\t\t\t`@group(1) @binding(${index}) var<storage, read> ${key}: ${definition.type};`\n\t\t);\n\t}\n\n\treturn declarations.join('\\n');\n}\n\n/**\n * Optionally returns helper WGSL for linear-to-sRGB conversion.\n */\nfunction buildColorTransformHelpers(enableSrgbTransform: boolean): string {\n\tif (!enableSrgbTransform) {\n\t\treturn '';\n\t}\n\n\treturn `\nfn motiongpuLinearToSrgb(linearColor: vec3f) -> vec3f {\n\tlet cutoff = vec3f(0.0031308);\n\tlet lower = linearColor * 12.92;\n\tlet higher = vec3f(1.055) * pow(linearColor, vec3f(1.0 / 2.4)) - vec3f(0.055);\n\treturn select(lower, higher, linearColor > cutoff);\n}\n`;\n}\n\n/**\n * Builds fragment output code with optional color-space conversion.\n */\nfunction buildFragmentOutput(keepAliveExpression: string, enableSrgbTransform: boolean): string {\n\tif (enableSrgbTransform) {\n\t\treturn `\n\tlet fragColor = frag(in.uv);\n\tlet motiongpuKeepAlive = ${keepAliveExpression};\n\tlet motiongpuLinear = vec4f(fragColor.rgb + motiongpuKeepAlive * 0.0, fragColor.a);\n\tlet motiongpuSrgb = motiongpuLinearToSrgb(max(motiongpuLinear.rgb, vec3f(0.0)));\n\treturn vec4f(motiongpuSrgb, motiongpuLinear.a);\n`;\n\t}\n\n\treturn `\n\tlet fragColor = frag(in.uv);\n\tlet motiongpuKeepAlive = ${keepAliveExpression};\n\treturn vec4f(fragColor.rgb + motiongpuKeepAlive * 0.0, fragColor.a);\n`;\n}\n\n/**\n * 1-based map from generated WGSL lines to original material source lines.\n */\nexport type ShaderLineMap = Array<MaterialSourceLocation | null>;\n\n/**\n * Result of shader source generation with line mapping metadata.\n */\nexport interface BuiltShaderSource {\n\t/**\n\t * Full WGSL source code.\n\t */\n\tcode: string;\n\t/**\n\t * 1-based generated-line map to material source locations.\n\t */\n\tlineMap: ShaderLineMap;\n}\n\n/**\n * Assembles complete WGSL shader source used by the fullscreen renderer pipeline.\n *\n * @param fragmentWgsl - User fragment shader code containing `frag(uv: vec2f) -> vec4f`.\n * @param uniformLayout - Resolved uniform layout.\n * @param textureKeys - Sorted texture keys.\n * @param options - Shader build options.\n * @returns Complete WGSL source for vertex + fragment stages.\n */\nexport function buildShaderSource(\n\tfragmentWgsl: string,\n\tuniformLayout: UniformLayout,\n\ttextureKeys: string[] = [],\n\toptions?: {\n\t\tconvertLinearToSrgb?: boolean;\n\t\tstorageBufferKeys?: string[];\n\t\tstorageBufferDefinitions?: Record<string, { type: StorageBufferType }>;\n\t}\n): string {\n\tconst uniformFields = buildUniformStruct(uniformLayout);\n\tconst keepAliveExpression = getKeepAliveExpression(uniformLayout);\n\tconst textureBindings = buildTextureBindings(textureKeys);\n\tconst enableSrgbTransform = options?.convertLinearToSrgb ?? false;\n\tconst colorTransformHelpers = buildColorTransformHelpers(enableSrgbTransform);\n\tconst fragmentOutput = buildFragmentOutput(keepAliveExpression, enableSrgbTransform);\n\tconst storageBufferBindings = buildFragmentStorageBufferBindings(\n\t\toptions?.storageBufferKeys ?? [],\n\t\toptions?.storageBufferDefinitions ?? {}\n\t);\n\n\treturn `\nstruct MotionGPUFrame {\n\ttime: f32,\n\tdelta: f32,\n\tresolution: vec2f,\n};\n\nstruct MotionGPUUniforms {\n\t${uniformFields}\n};\n\n@group(0) @binding(0) var<uniform> motiongpuFrame: MotionGPUFrame;\n@group(0) @binding(1) var<uniform> motiongpuUniforms: MotionGPUUniforms;\n${textureBindings}\n${storageBufferBindings ? '\\n' + storageBufferBindings : ''}\n${colorTransformHelpers}\n\nstruct MotionGPUVertexOut {\n\t@builtin(position) position: vec4f,\n\t@location(0) uv: vec2f,\n};\n\n@vertex\nfn motiongpuVertex(@builtin(vertex_index) index: u32) -> MotionGPUVertexOut {\n\tvar positions = array<vec2f, 3>(\n\t\tvec2f(-1.0, -3.0),\n\t\tvec2f(-1.0, 1.0),\n\t\tvec2f(3.0, 1.0)\n\t);\n\n\tlet position = positions[index];\n\tvar out: MotionGPUVertexOut;\n\tout.position = vec4f(position, 0.0, 1.0);\n\tout.uv = (position + vec2f(1.0, 1.0)) * 0.5;\n\treturn out;\n}\n\n${fragmentWgsl}\n\n@fragment\nfn motiongpuFragment(in: MotionGPUVertexOut) -> @location(0) vec4f {\n\t${fragmentOutput}\n}\n`;\n}\n\n/**\n * Assembles complete WGSL shader source with material-source line mapping metadata.\n */\nexport function buildShaderSourceWithMap(\n\tfragmentWgsl: string,\n\tuniformLayout: UniformLayout,\n\ttextureKeys: string[] = [],\n\toptions?: {\n\t\tconvertLinearToSrgb?: boolean;\n\t\tfragmentLineMap?: MaterialLineMap;\n\t\tstorageBufferKeys?: string[];\n\t\tstorageBufferDefinitions?: Record<string, { type: StorageBufferType }>;\n\t}\n): BuiltShaderSource {\n\tconst code = buildShaderSource(fragmentWgsl, uniformLayout, textureKeys, options);\n\tconst fragmentStartIndex = code.indexOf(fragmentWgsl);\n\tconst lineCount = code.split('\\n').length;\n\tconst lineMap: ShaderLineMap = new Array(lineCount + 1).fill(null);\n\n\tif (fragmentStartIndex === -1) {\n\t\treturn {\n\t\t\tcode,\n\t\t\tlineMap\n\t\t};\n\t}\n\n\tconst fragmentStartLine = code.slice(0, fragmentStartIndex).split('\\n').length;\n\tconst fragmentLineCount = fragmentWgsl.split('\\n').length;\n\n\tfor (let line = 0; line < fragmentLineCount; line += 1) {\n\t\tconst generatedLine = fragmentStartLine + line;\n\t\tlineMap[generatedLine] = options?.fragmentLineMap?.[line + 1] ?? {\n\t\t\tkind: 'fragment',\n\t\t\tline: line + 1\n\t\t};\n\t}\n\n\treturn {\n\t\tcode,\n\t\tlineMap\n\t};\n}\n\n/**\n * Converts source location metadata to user-facing diagnostics label.\n */\nexport function formatShaderSourceLocation(location: MaterialSourceLocation | null): string | null {\n\tif (!location) {\n\t\treturn null;\n\t}\n\n\tif (location.kind === 'fragment') {\n\t\treturn `fragment line ${location.line}`;\n\t}\n\n\tif (location.kind === 'include') {\n\t\treturn `include <${location.include}> line ${location.line}`;\n\t}\n\n\treturn `define \"${location.define}\" line ${location.line}`;\n}\n"],"mappings":";;;;;AAOA,IAAM,wBAAwB;;;;AAK9B,SAAS,mBAAmB,QAA+B;AAC1D,KAAI,OAAO,QAAQ,WAAW,EAC7B,QAAO;AAGR,QAAO,OAAO,QACZ,KAAK,UAAU;AACf,oBAAkB,MAAM,KAAK;AAC7B,SAAO,GAAG,MAAM,KAAK,IAAI,MAAM,KAAK;GACnC,CACD,KAAK,MAAO;;;;;AAMf,SAAS,uBAAuB,QAA+B;AAC9D,KAAI,OAAO,QAAQ,WAAW,EAC7B,QAAO;CAGR,MAAM,CAAC,cAAc,OAAO;AAC5B,KAAI,CAAC,WACJ,QAAO;AAGR,KAAI,WAAW,SAAS,MACvB,QAAO,qBAAqB,WAAW;AAGxC,KAAI,WAAW,SAAS,UACvB,QAAO,qBAAqB,WAAW,KAAK;AAG7C,QAAO,qBAAqB,WAAW,KAAK;;;;;AAM7C,SAAS,qBAAqB,aAA+B;AAC5D,KA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B,oBAAoB;CACpF,MAAM,wBAAwB,mCAC7B,SAAS,qBAAqB,EAAE,EAChC,SAAS,4BAA4B,EAAE,CACvC;AAED,QAAO;;;;;;;;GAQL,cAAc;;;;;EAKf,gBAAgB;EAChB,wBAAwB,OAAO,wBAAwB,GAAG;EAC1D,sBAAsB;;;;;;;;;;;;;;;;;;;;;;EAsBtB,aAAa;;;;GAIZ,eAAe;;;;;;;AAQlB,SAAgB,yBACf,cACA,eACA,cAAwB,EAAE,EAC1B,SAMoB;CACpB,MAAM,OAAO,kBAAkB,cAAc,eAAe,aAAa,QAAQ;CACjF,MAAM,qBAAqB,KAAK,QAAQ,aAAa;CACrD,MAAM,YAAY,KAAK,MAAM,KAAK,CAAC;CACnC,MAAM,UAAyB,IAAI,MAAM,YAAY,EAAE,CAAC,KAAK,KAAK;AAElE,KAAI,uBAAuB,GAC1B,QAAO;EACN;EACA;EACA;CAGF,MAAM,oBAAoB,KAAK,MAAM,GAAG,mBAAmB,CAAC,MAAM,KAAK,CAAC;CACxE,MAAM,oBAAoB,aAAa,MAAM,KAAK,CAAC;AAEnD,MAAK,IAAI,OAAO,GAAG,OAAO,mBAAmB,QAAQ,GAAG;EACvD,MAAM,gBAAgB,oBAAoB;AAC1C,UAAQ,iBAAiB,SAAS,kBAAkB,OAAO,MAAM;GAChE,MAAM;GACN,MAAM,OAAO;GACb;;AAGF,QAAO;EACN;EACA;EACA;;;;;AAMF,SAAgB,2BAA2B,UAAwD;AAClG,KAAI,CAAC,SACJ,QAAO;AAGR,KAAI,SAAS,SAAS,WACrB,QAAO,iBAAiB,SAAS;AAGlC,KAAI,SAAS,SAAS,UACrB,QAAO,YAAY,SAAS,QAAQ,SAAS,SAAS;AAGvD,QAAO,WAAW,SAAS,OAAO,SAAS,SAAS"}
1
+ {"version":3,"file":"shader.js","names":[],"sources":["../../src/lib/core/shader.ts"],"sourcesContent":["import { assertUniformName } from './uniforms.js';\nimport type { MaterialLineMap, MaterialSourceLocation } from './material-preprocess.js';\nimport type { StorageBufferType, UniformLayout } from './types.js';\n\ntype ComputeShaderSourceLocation = {\n\tkind: 'compute';\n\tline: number;\n};\n\n/**\n * Fallback uniform field used when no custom uniforms are provided.\n */\nconst DEFAULT_UNIFORM_FIELD = 'motiongpu_unused: vec4f,';\n\n/**\n * Builds WGSL struct fields for user uniforms.\n */\nfunction buildUniformStruct(layout: UniformLayout): string {\n\tif (layout.entries.length === 0) {\n\t\treturn DEFAULT_UNIFORM_FIELD;\n\t}\n\n\treturn layout.entries\n\t\t.map((entry) => {\n\t\t\tassertUniformName(entry.name);\n\t\t\treturn `${entry.name}: ${entry.type},`;\n\t\t})\n\t\t.join('\\n\\t');\n}\n\n/**\n * Builds a numeric expression that references one uniform value to keep bindings alive.\n */\nfunction getKeepAliveExpression(layout: UniformLayout): string {\n\tif (layout.entries.length === 0) {\n\t\treturn 'motiongpuUniforms.motiongpu_unused.x';\n\t}\n\n\tconst [firstEntry] = layout.entries;\n\tif (!firstEntry) {\n\t\treturn 'motiongpuUniforms.motiongpu_unused.x';\n\t}\n\n\tif (firstEntry.type === 'f32') {\n\t\treturn `motiongpuUniforms.${firstEntry.name}`;\n\t}\n\n\tif (firstEntry.type === 'mat4x4f') {\n\t\treturn `motiongpuUniforms.${firstEntry.name}[0].x`;\n\t}\n\n\treturn `motiongpuUniforms.${firstEntry.name}.x`;\n}\n\n/**\n * Builds texture sampler/texture binding declarations.\n */\nfunction buildTextureBindings(textureKeys: string[]): string {\n\tif (textureKeys.length === 0) {\n\t\treturn '';\n\t}\n\n\tconst declarations: string[] = [];\n\n\tfor (let index = 0; index < textureKeys.length; index += 1) {\n\t\tconst key = textureKeys[index];\n\t\tif (key === undefined) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tassertUniformName(key);\n\t\tconst binding = 2 + index * 2;\n\t\tdeclarations.push(`@group(0) @binding(${binding}) var ${key}Sampler: sampler;`);\n\t\tdeclarations.push(`@group(0) @binding(${binding + 1}) var ${key}: texture_2d<f32>;`);\n\t}\n\n\treturn declarations.join('\\n');\n}\n\n/**\n * Builds read-only storage buffer bindings for fragment shader.\n */\nfunction buildFragmentStorageBufferBindings(\n\tstorageBufferKeys: string[],\n\tdefinitions: Record<string, { type: StorageBufferType }>\n): string {\n\tif (storageBufferKeys.length === 0) {\n\t\treturn '';\n\t}\n\n\tconst declarations: string[] = [];\n\n\tfor (let index = 0; index < storageBufferKeys.length; index += 1) {\n\t\tconst key = storageBufferKeys[index];\n\t\tif (key === undefined) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst definition = definitions[key];\n\t\tif (!definition) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tdeclarations.push(\n\t\t\t`@group(1) @binding(${index}) var<storage, read> ${key}: ${definition.type};`\n\t\t);\n\t}\n\n\treturn declarations.join('\\n');\n}\n\n/**\n * Optionally returns helper WGSL for linear-to-sRGB conversion.\n */\nfunction buildColorTransformHelpers(enableSrgbTransform: boolean): string {\n\tif (!enableSrgbTransform) {\n\t\treturn '';\n\t}\n\n\treturn `\nfn motiongpuLinearToSrgb(linearColor: vec3f) -> vec3f {\n\tlet cutoff = vec3f(0.0031308);\n\tlet lower = linearColor * 12.92;\n\tlet higher = vec3f(1.055) * pow(linearColor, vec3f(1.0 / 2.4)) - vec3f(0.055);\n\treturn select(lower, higher, linearColor > cutoff);\n}\n`;\n}\n\n/**\n * Builds fragment output code with optional color-space conversion.\n */\nfunction buildFragmentOutput(keepAliveExpression: string, enableSrgbTransform: boolean): string {\n\tif (enableSrgbTransform) {\n\t\treturn `\n\tlet fragColor = frag(in.uv);\n\tlet motiongpuKeepAlive = ${keepAliveExpression};\n\tlet motiongpuLinear = vec4f(fragColor.rgb + motiongpuKeepAlive * 0.0, fragColor.a);\n\tlet motiongpuSrgb = motiongpuLinearToSrgb(max(motiongpuLinear.rgb, vec3f(0.0)));\n\treturn vec4f(motiongpuSrgb, motiongpuLinear.a);\n`;\n\t}\n\n\treturn `\n\tlet fragColor = frag(in.uv);\n\tlet motiongpuKeepAlive = ${keepAliveExpression};\n\treturn vec4f(fragColor.rgb + motiongpuKeepAlive * 0.0, fragColor.a);\n`;\n}\n\n/**\n * 1-based map from generated WGSL lines to original material source lines.\n */\nexport type ShaderLineMap = Array<(MaterialSourceLocation | ComputeShaderSourceLocation) | null>;\n\n/**\n * Result of shader source generation with line mapping metadata.\n */\nexport interface BuiltShaderSource {\n\t/**\n\t * Full WGSL source code.\n\t */\n\tcode: string;\n\t/**\n\t * 1-based generated-line map to material source locations.\n\t */\n\tlineMap: ShaderLineMap;\n}\n\n/**\n * Assembles complete WGSL shader source used by the fullscreen renderer pipeline.\n *\n * @param fragmentWgsl - User fragment shader code containing `frag(uv: vec2f) -> vec4f`.\n * @param uniformLayout - Resolved uniform layout.\n * @param textureKeys - Sorted texture keys.\n * @param options - Shader build options.\n * @returns Complete WGSL source for vertex + fragment stages.\n */\nexport function buildShaderSource(\n\tfragmentWgsl: string,\n\tuniformLayout: UniformLayout,\n\ttextureKeys: string[] = [],\n\toptions?: {\n\t\tconvertLinearToSrgb?: boolean;\n\t\tstorageBufferKeys?: string[];\n\t\tstorageBufferDefinitions?: Record<string, { type: StorageBufferType }>;\n\t}\n): string {\n\tconst uniformFields = buildUniformStruct(uniformLayout);\n\tconst keepAliveExpression = getKeepAliveExpression(uniformLayout);\n\tconst textureBindings = buildTextureBindings(textureKeys);\n\tconst enableSrgbTransform = options?.convertLinearToSrgb ?? false;\n\tconst colorTransformHelpers = buildColorTransformHelpers(enableSrgbTransform);\n\tconst fragmentOutput = buildFragmentOutput(keepAliveExpression, enableSrgbTransform);\n\tconst storageBufferBindings = buildFragmentStorageBufferBindings(\n\t\toptions?.storageBufferKeys ?? [],\n\t\toptions?.storageBufferDefinitions ?? {}\n\t);\n\n\treturn `\nstruct MotionGPUFrame {\n\ttime: f32,\n\tdelta: f32,\n\tresolution: vec2f,\n};\n\nstruct MotionGPUUniforms {\n\t${uniformFields}\n};\n\n@group(0) @binding(0) var<uniform> motiongpuFrame: MotionGPUFrame;\n@group(0) @binding(1) var<uniform> motiongpuUniforms: MotionGPUUniforms;\n${textureBindings}\n${storageBufferBindings ? '\\n' + storageBufferBindings : ''}\n${colorTransformHelpers}\n\nstruct MotionGPUVertexOut {\n\t@builtin(position) position: vec4f,\n\t@location(0) uv: vec2f,\n};\n\n@vertex\nfn motiongpuVertex(@builtin(vertex_index) index: u32) -> MotionGPUVertexOut {\n\tvar positions = array<vec2f, 3>(\n\t\tvec2f(-1.0, -3.0),\n\t\tvec2f(-1.0, 1.0),\n\t\tvec2f(3.0, 1.0)\n\t);\n\n\tlet position = positions[index];\n\tvar out: MotionGPUVertexOut;\n\tout.position = vec4f(position, 0.0, 1.0);\n\tout.uv = (position + vec2f(1.0, 1.0)) * 0.5;\n\treturn out;\n}\n\n${fragmentWgsl}\n\n@fragment\nfn motiongpuFragment(in: MotionGPUVertexOut) -> @location(0) vec4f {\n\t${fragmentOutput}\n}\n`;\n}\n\n/**\n * Assembles complete WGSL shader source with material-source line mapping metadata.\n */\nexport function buildShaderSourceWithMap(\n\tfragmentWgsl: string,\n\tuniformLayout: UniformLayout,\n\ttextureKeys: string[] = [],\n\toptions?: {\n\t\tconvertLinearToSrgb?: boolean;\n\t\tfragmentLineMap?: MaterialLineMap;\n\t\tstorageBufferKeys?: string[];\n\t\tstorageBufferDefinitions?: Record<string, { type: StorageBufferType }>;\n\t}\n): BuiltShaderSource {\n\tconst code = buildShaderSource(fragmentWgsl, uniformLayout, textureKeys, options);\n\tconst fragmentStartIndex = code.indexOf(fragmentWgsl);\n\tconst lineCount = code.split('\\n').length;\n\tconst lineMap: ShaderLineMap = new Array(lineCount + 1).fill(null);\n\n\tif (fragmentStartIndex === -1) {\n\t\treturn {\n\t\t\tcode,\n\t\t\tlineMap\n\t\t};\n\t}\n\n\tconst fragmentStartLine = code.slice(0, fragmentStartIndex).split('\\n').length;\n\tconst fragmentLineCount = fragmentWgsl.split('\\n').length;\n\n\tfor (let line = 0; line < fragmentLineCount; line += 1) {\n\t\tconst generatedLine = fragmentStartLine + line;\n\t\tlineMap[generatedLine] = options?.fragmentLineMap?.[line + 1] ?? {\n\t\t\tkind: 'fragment',\n\t\t\tline: line + 1\n\t\t};\n\t}\n\n\treturn {\n\t\tcode,\n\t\tlineMap\n\t};\n}\n\n/**\n * Converts source location metadata to user-facing diagnostics label.\n */\nexport function formatShaderSourceLocation(\n\tlocation: (MaterialSourceLocation | ComputeShaderSourceLocation) | null\n): string | null {\n\tif (!location) {\n\t\treturn null;\n\t}\n\n\tif (location.kind === 'fragment') {\n\t\treturn `fragment line ${location.line}`;\n\t}\n\n\tif (location.kind === 'include') {\n\t\treturn `include <${location.include}> line ${location.line}`;\n\t}\n\n\tif (location.kind === 'compute') {\n\t\treturn `compute line ${location.line}`;\n\t}\n\n\treturn `define \"${location.define}\" line ${location.line}`;\n}\n"],"mappings":";;;;;AAYA,IAAM,wBAAwB;;;;AAK9B,SAAS,mBAAmB,QAA+B;AAC1D,KAAI,OAAO,QAAQ,WAAW,EAC7B,QAAO;AAGR,QAAO,OAAO,QACZ,KAAK,UAAU;AACf,oBAAkB,MAAM,KAAK;AAC7B,SAAO,GAAG,MAAM,KAAK,IAAI,MAAM,KAAK;GACnC,CACD,KAAK,MAAO;;;;;AAMf,SAAS,uBAAuB,QAA+B;AAC9D,KAAI,OAAO,QAAQ,WAAW,EAC7B,QAAO;CAGR,MAAM,CAAC,cAAc,OAAO;AAC5B,KAAI,CAAC,WACJ,QAAO;AAGR,KAAI,WAAW,SAAS,MACvB,QAAO,qBAAqB,WAAW;AAGxC,KAAI,WAAW,SAAS,UACvB,QAAO,qBAAqB,WAAW,KAAK;AAG7C,QAAO,qBAAqB,WAAW,KAAK;;;;;AAM7C,SAAS,qBAAqB,aAA+B;AAC5D,KAAI,YAAY,WAAW,EAC1B,QAAO;CAGR,MAAM,eAAyB,EAAE;AAEjC,MAAK,IAAI,QAAQ,GAAG,QAAQ,YAAY,QAAQ,SAAS,GAAG;EAC3D,MAAM,MAAM,YAAY;AAC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B,wBAAwB,OAAO,wBAAwB,GAAG;EAC1D,sBAAsB;;;;;;;;;;;;;;;;;;;;;;EAsBtB,aAAa;;;;GAIZ,eAAe;;;;;;;AAQlB,SAAgB,yBACf,cACA,eACA,cAAwB,EAAE,EAC1B,SAMoB;CACpB,MAAM,OAAO,kBAAkB,cAAc,eAAe,aAAa,QAAQ;CACjF,MAAM,qBAAqB,KAAK,QAAQ,aAAa;CACrD,MAAM,YAAY,KAAK,MAAM,KAAK,CAAC;CACnC,MAAM,UAAyB,IAAI,MAAM,YAAY,EAAE,CAAC,KAAK,KAAK;AAElE,KAAI,uBAAuB,GAC1B,QAAO;EACN;EACA;EACA;CAGF,MAAM,oBAAoB,KAAK,MAAM,GAAG,mBAAmB,CAAC,MAAM,KAAK,CAAC;CACxE,MAAM,oBAAoB,aAAa,MAAM,KAAK,CAAC;AAEnD,MAAK,IAAI,OAAO,GAAG,OAAO,mBAAmB,QAAQ,GAAG;EACvD,MAAM,gBAAgB,oBAAoB;AAC1C,UAAQ,iBAAiB,SAAS,kBAAkB,OAAO,MAAM;GAChE,MAAM;GACN,MAAM,OAAO;GACb;;AAGF,QAAO;EACN;EACA;EACA;;;;;AAMF,SAAgB,2BACf,UACgB;AAChB,KAAI,CAAC,SACJ,QAAO;AAGR,KAAI,SAAS,SAAS,WACrB,QAAO,iBAAiB,SAAS;AAGlC,KAAI,SAAS,SAAS,UACrB,QAAO,YAAY,SAAS,QAAQ,SAAS,SAAS;AAGvD,KAAI,SAAS,SAAS,UACrB,QAAO,gBAAgB,SAAS;AAGjC,QAAO,WAAW,SAAS,OAAO,SAAS,SAAS"}
@@ -52,6 +52,10 @@ export interface NormalizedTextureDefinition {
52
52
  * Whether this texture is a storage texture (writable by compute).
53
53
  */
54
54
  storage: boolean;
55
+ /**
56
+ * Whether this texture should be exposed as a fragment-stage sampled binding.
57
+ */
58
+ fragmentVisible: boolean;
55
59
  /**
56
60
  * Explicit width for storage textures. Undefined when derived from source.
57
61
  */
@@ -1 +1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AM,CAAC;CACf,CAkBA;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAY7E;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,WAAW,CAAC,QAAQ,CAAC,GAAG,MAAM,IAAI,gBAAgB,CAE9F"}
@@ -39,7 +39,8 @@ function normalizeTextureDefinition(definition) {
39
39
  filter: definition?.filter ?? DEFAULT_TEXTURE_FILTER,
40
40
  addressModeU: definition?.addressModeU ?? DEFAULT_TEXTURE_ADDRESS_MODE,
41
41
  addressModeV: definition?.addressModeV ?? DEFAULT_TEXTURE_ADDRESS_MODE,
42
- storage: isStorage
42
+ storage: isStorage,
43
+ fragmentVisible: definition?.fragmentVisible ?? true
43
44
  };
44
45
  if (definition?.width !== void 0) normalized.width = definition.width;
45
46
  if (definition?.height !== void 0) normalized.height = definition.height;
@@ -1 +1 @@
1
- {"version":3,"file":"textures.js","names":[],"sources":["../../src/lib/core/textures.ts"],"sourcesContent":["import { assertUniformName } from './uniforms.js';\nimport type {\n\tTextureData,\n\tTextureDefinition,\n\tTextureDefinitionMap,\n\tTextureUpdateMode,\n\tTextureValue\n} from './types.js';\n\n/**\n * Texture definition with defaults and normalized numeric limits applied.\n */\nexport interface NormalizedTextureDefinition {\n\t/**\n\t * Normalized source value.\n\t */\n\tsource: TextureValue;\n\t/**\n\t * Effective color space.\n\t */\n\tcolorSpace: 'srgb' | 'linear';\n\t/**\n\t * Effective texture format.\n\t */\n\tformat: GPUTextureFormat;\n\t/**\n\t * Effective flip-y flag.\n\t */\n\tflipY: boolean;\n\t/**\n\t * Effective mipmap toggle.\n\t */\n\tgenerateMipmaps: boolean;\n\t/**\n\t * Effective premultiplied-alpha flag.\n\t */\n\tpremultipliedAlpha: boolean;\n\t/**\n\t * Effective dynamic update strategy.\n\t */\n\tupdate?: TextureUpdateMode;\n\t/**\n\t * Effective anisotropy level.\n\t */\n\tanisotropy: number;\n\t/**\n\t * Effective filter mode.\n\t */\n\tfilter: GPUFilterMode;\n\t/**\n\t * Effective U address mode.\n\t */\n\taddressModeU: GPUAddressMode;\n\t/**\n\t * Effective V address mode.\n\t */\n\taddressModeV: GPUAddressMode;\n\t/**\n\t * Whether this texture is a storage texture (writable by compute).\n\t */\n\tstorage: boolean;\n\t/**\n\t * Explicit width for storage textures. Undefined when derived from source.\n\t */\n\twidth?: number;\n\t/**\n\t * Explicit height for storage textures. Undefined when derived from source.\n\t */\n\theight?: number;\n}\n\n/**\n * Default sampling filter for textures when no explicit value is provided.\n */\nconst DEFAULT_TEXTURE_FILTER: GPUFilterMode = 'linear';\n\n/**\n * Default addressing mode for textures when no explicit value is provided.\n */\nconst DEFAULT_TEXTURE_ADDRESS_MODE: GPUAddressMode = 'clamp-to-edge';\n\n/**\n * Validates and returns sorted texture keys.\n *\n * @param textures - Texture definition map.\n * @returns Lexicographically sorted texture keys.\n */\nexport function resolveTextureKeys(textures: TextureDefinitionMap): string[] {\n\tconst keys = Object.keys(textures).sort();\n\tfor (const key of keys) {\n\t\tassertUniformName(key);\n\t}\n\treturn keys;\n}\n\n/**\n * Applies defaults and clamps to a single texture definition.\n *\n * @param definition - Optional texture definition.\n * @returns Normalized definition with deterministic defaults.\n */\nexport function normalizeTextureDefinition(\n\tdefinition: TextureDefinition | undefined\n): NormalizedTextureDefinition {\n\tconst isStorage = definition?.storage === true;\n\tconst defaultFormat = definition?.colorSpace === 'linear' ? 'rgba8unorm' : 'rgba8unorm-srgb';\n\tconst normalized: NormalizedTextureDefinition = {\n\t\tsource: definition?.source ?? null,\n\t\tcolorSpace: definition?.colorSpace ?? 'srgb',\n\t\tformat: definition?.format ?? defaultFormat,\n\t\tflipY: definition?.flipY ?? true,\n\t\tgenerateMipmaps: definition?.generateMipmaps ?? false,\n\t\tpremultipliedAlpha: definition?.premultipliedAlpha ?? false,\n\t\tanisotropy: Math.max(1, Math.min(16, Math.floor(definition?.anisotropy ?? 1))),\n\t\tfilter: definition?.filter ?? DEFAULT_TEXTURE_FILTER,\n\t\taddressModeU: definition?.addressModeU ?? DEFAULT_TEXTURE_ADDRESS_MODE,\n\t\taddressModeV: definition?.addressModeV ?? DEFAULT_TEXTURE_ADDRESS_MODE,\n\t\tstorage: isStorage\n\t};\n\n\tif (definition?.width !== undefined) {\n\t\tnormalized.width = definition.width;\n\t}\n\tif (definition?.height !== undefined) {\n\t\tnormalized.height = definition.height;\n\t}\n\n\tif (definition?.update !== undefined) {\n\t\tnormalized.update = definition.update;\n\t}\n\n\treturn normalized;\n}\n\n/**\n * Normalizes all texture definitions for already-resolved texture keys.\n *\n * @param textures - Source texture definitions.\n * @param textureKeys - Texture keys to normalize.\n * @returns Normalized map keyed by `textureKeys`.\n */\nexport function normalizeTextureDefinitions(\n\ttextures: TextureDefinitionMap,\n\ttextureKeys: string[]\n): Record<string, NormalizedTextureDefinition> {\n\tconst out: Record<string, NormalizedTextureDefinition> = {};\n\tfor (const key of textureKeys) {\n\t\tout[key] = normalizeTextureDefinition(textures[key]);\n\t}\n\treturn out;\n}\n\n/**\n * Checks whether a texture value is a structured `{ source, width?, height? }` object.\n */\nexport function isTextureData(value: TextureValue): value is TextureData {\n\treturn typeof value === 'object' && value !== null && 'source' in value;\n}\n\n/**\n * Converts supported texture input variants to normalized `TextureData`.\n *\n * @param value - Texture value input.\n * @returns Structured texture data or `null`.\n */\nexport function toTextureData(value: TextureValue): TextureData | null {\n\tif (value === null) {\n\t\treturn null;\n\t}\n\n\tif (isTextureData(value)) {\n\t\treturn value;\n\t}\n\n\treturn { source: value };\n}\n\n/**\n * Resolves effective runtime texture update strategy.\n */\nexport function resolveTextureUpdateMode(input: {\n\tsource: TextureData['source'];\n\toverride?: TextureUpdateMode;\n\tdefaultMode?: TextureUpdateMode;\n}): TextureUpdateMode {\n\tif (input.override) {\n\t\treturn input.override;\n\t}\n\n\tif (input.defaultMode) {\n\t\treturn input.defaultMode;\n\t}\n\n\tif (isVideoTextureSource(input.source)) {\n\t\treturn 'perFrame';\n\t}\n\n\treturn 'once';\n}\n\n/**\n * Resolves texture dimensions from explicit values or source metadata.\n *\n * @param data - Texture payload.\n * @returns Positive integer width/height.\n * @throws {Error} When dimensions cannot be resolved to positive values.\n */\nexport function resolveTextureSize(data: TextureData): {\n\twidth: number;\n\theight: number;\n} {\n\tconst source = data.source as {\n\t\twidth?: number;\n\t\theight?: number;\n\t\tnaturalWidth?: number;\n\t\tnaturalHeight?: number;\n\t\tvideoWidth?: number;\n\t\tvideoHeight?: number;\n\t};\n\n\tconst width = data.width ?? source.naturalWidth ?? source.videoWidth ?? source.width ?? 0;\n\tconst height = data.height ?? source.naturalHeight ?? source.videoHeight ?? source.height ?? 0;\n\n\tif (width <= 0 || height <= 0) {\n\t\tthrow new Error('Texture source must have positive width and height');\n\t}\n\n\treturn { width, height };\n}\n\n/**\n * Computes the number of mipmap levels for a base texture size.\n *\n * @param width - Base width.\n * @param height - Base height.\n * @returns Total mip level count (minimum `1`).\n */\nexport function getTextureMipLevelCount(width: number, height: number): number {\n\tlet levels = 1;\n\tlet currentWidth = Math.max(1, width);\n\tlet currentHeight = Math.max(1, height);\n\n\twhile (currentWidth > 1 || currentHeight > 1) {\n\t\tcurrentWidth = Math.max(1, Math.floor(currentWidth / 2));\n\t\tcurrentHeight = Math.max(1, Math.floor(currentHeight / 2));\n\t\tlevels += 1;\n\t}\n\n\treturn levels;\n}\n\n/**\n * Checks whether the source is an `HTMLVideoElement`.\n */\nexport function isVideoTextureSource(source: TextureData['source']): source is HTMLVideoElement {\n\treturn typeof HTMLVideoElement !== 'undefined' && source instanceof HTMLVideoElement;\n}\n"],"mappings":";;;;;AA0EA,IAAM,yBAAwC;;;;AAK9C,IAAM,+BAA+C;;;;;;;AAQrD,SAAgB,mBAAmB,UAA0C;CAC5E,MAAM,OAAO,OAAO,KAAK,SAAS,CAAC,MAAM;AACzC,MAAK,MAAM,OAAO,KACjB,mBAAkB,IAAI;AAEvB,QAAO;;;;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AQ,KAAK,SAAS,OAAO,gBAAgB,OAAO,cAAc,OAAO,SAAS;CACxF,MAAM,SAAS,KAAK,UAAU,OAAO,iBAAiB,OAAO,eAAe,OAAO,UAAU;AAE7F,KAAI,SAAS,KAAK,UAAU,EAC3B,OAAM,IAAI,MAAM,qDAAqD;AAGtE,QAAO;EAAE;EAAO;EAAQ;;;;;;;;;AAUzB,SAAgB,wBAAwB,OAAe,QAAwB;CAC9E,IAAI,SAAS;CACb,IAAI,eAAe,KAAK,IAAI,GAAG,MAAM;CACrC,IAAI,gBAAgB,KAAK,IAAI,GAAG,OAAO;AAEvC,QAAO,eAAe,KAAK,gBAAgB,GAAG;AAC7C,iBAAe,KAAK,IAAI,GAAG,KAAK,MAAM,eAAe,EAAE,CAAC;AACxD,kBAAgB,KAAK,IAAI,GAAG,KAAK,MAAM,gBAAgB,EAAE,CAAC;AAC1D,YAAU;;AAGX,QAAO;;;;;AAMR,SAAgB,qBAAqB,QAA2D;AAC/F,QAAO,OAAO,qBAAqB,eAAe,kBAAkB"}
1
+ {"version":3,"file":"textures.js","names":[],"sources":["../../src/lib/core/textures.ts"],"sourcesContent":["import { assertUniformName } from './uniforms.js';\nimport type {\n\tTextureData,\n\tTextureDefinition,\n\tTextureDefinitionMap,\n\tTextureUpdateMode,\n\tTextureValue\n} from './types.js';\n\n/**\n * Texture definition with defaults and normalized numeric limits applied.\n */\nexport interface NormalizedTextureDefinition {\n\t/**\n\t * Normalized source value.\n\t */\n\tsource: TextureValue;\n\t/**\n\t * Effective color space.\n\t */\n\tcolorSpace: 'srgb' | 'linear';\n\t/**\n\t * Effective texture format.\n\t */\n\tformat: GPUTextureFormat;\n\t/**\n\t * Effective flip-y flag.\n\t */\n\tflipY: boolean;\n\t/**\n\t * Effective mipmap toggle.\n\t */\n\tgenerateMipmaps: boolean;\n\t/**\n\t * Effective premultiplied-alpha flag.\n\t */\n\tpremultipliedAlpha: boolean;\n\t/**\n\t * Effective dynamic update strategy.\n\t */\n\tupdate?: TextureUpdateMode;\n\t/**\n\t * Effective anisotropy level.\n\t */\n\tanisotropy: number;\n\t/**\n\t * Effective filter mode.\n\t */\n\tfilter: GPUFilterMode;\n\t/**\n\t * Effective U address mode.\n\t */\n\taddressModeU: GPUAddressMode;\n\t/**\n\t * Effective V address mode.\n\t */\n\taddressModeV: GPUAddressMode;\n\t/**\n\t * Whether this texture is a storage texture (writable by compute).\n\t */\n\tstorage: boolean;\n\t/**\n\t * Whether this texture should be exposed as a fragment-stage sampled binding.\n\t */\n\tfragmentVisible: boolean;\n\t/**\n\t * Explicit width for storage textures. Undefined when derived from source.\n\t */\n\twidth?: number;\n\t/**\n\t * Explicit height for storage textures. Undefined when derived from source.\n\t */\n\theight?: number;\n}\n\n/**\n * Default sampling filter for textures when no explicit value is provided.\n */\nconst DEFAULT_TEXTURE_FILTER: GPUFilterMode = 'linear';\n\n/**\n * Default addressing mode for textures when no explicit value is provided.\n */\nconst DEFAULT_TEXTURE_ADDRESS_MODE: GPUAddressMode = 'clamp-to-edge';\n\n/**\n * Validates and returns sorted texture keys.\n *\n * @param textures - Texture definition map.\n * @returns Lexicographically sorted texture keys.\n */\nexport function resolveTextureKeys(textures: TextureDefinitionMap): string[] {\n\tconst keys = Object.keys(textures).sort();\n\tfor (const key of keys) {\n\t\tassertUniformName(key);\n\t}\n\treturn keys;\n}\n\n/**\n * Applies defaults and clamps to a single texture definition.\n *\n * @param definition - Optional texture definition.\n * @returns Normalized definition with deterministic defaults.\n */\nexport function normalizeTextureDefinition(\n\tdefinition: TextureDefinition | undefined\n): NormalizedTextureDefinition {\n\tconst isStorage = definition?.storage === true;\n\tconst defaultFormat = definition?.colorSpace === 'linear' ? 'rgba8unorm' : 'rgba8unorm-srgb';\n\tconst normalized: NormalizedTextureDefinition = {\n\t\tsource: definition?.source ?? null,\n\t\tcolorSpace: definition?.colorSpace ?? 'srgb',\n\t\tformat: definition?.format ?? defaultFormat,\n\t\tflipY: definition?.flipY ?? true,\n\t\tgenerateMipmaps: definition?.generateMipmaps ?? false,\n\t\tpremultipliedAlpha: definition?.premultipliedAlpha ?? false,\n\t\tanisotropy: Math.max(1, Math.min(16, Math.floor(definition?.anisotropy ?? 1))),\n\t\tfilter: definition?.filter ?? DEFAULT_TEXTURE_FILTER,\n\t\taddressModeU: definition?.addressModeU ?? DEFAULT_TEXTURE_ADDRESS_MODE,\n\t\taddressModeV: definition?.addressModeV ?? DEFAULT_TEXTURE_ADDRESS_MODE,\n\t\tstorage: isStorage,\n\t\tfragmentVisible: definition?.fragmentVisible ?? true\n\t};\n\n\tif (definition?.width !== undefined) {\n\t\tnormalized.width = definition.width;\n\t}\n\tif (definition?.height !== undefined) {\n\t\tnormalized.height = definition.height;\n\t}\n\n\tif (definition?.update !== undefined) {\n\t\tnormalized.update = definition.update;\n\t}\n\n\treturn normalized;\n}\n\n/**\n * Normalizes all texture definitions for already-resolved texture keys.\n *\n * @param textures - Source texture definitions.\n * @param textureKeys - Texture keys to normalize.\n * @returns Normalized map keyed by `textureKeys`.\n */\nexport function normalizeTextureDefinitions(\n\ttextures: TextureDefinitionMap,\n\ttextureKeys: string[]\n): Record<string, NormalizedTextureDefinition> {\n\tconst out: Record<string, NormalizedTextureDefinition> = {};\n\tfor (const key of textureKeys) {\n\t\tout[key] = normalizeTextureDefinition(textures[key]);\n\t}\n\treturn out;\n}\n\n/**\n * Checks whether a texture value is a structured `{ source, width?, height? }` object.\n */\nexport function isTextureData(value: TextureValue): value is TextureData {\n\treturn typeof value === 'object' && value !== null && 'source' in value;\n}\n\n/**\n * Converts supported texture input variants to normalized `TextureData`.\n *\n * @param value - Texture value input.\n * @returns Structured texture data or `null`.\n */\nexport function toTextureData(value: TextureValue): TextureData | null {\n\tif (value === null) {\n\t\treturn null;\n\t}\n\n\tif (isTextureData(value)) {\n\t\treturn value;\n\t}\n\n\treturn { source: value };\n}\n\n/**\n * Resolves effective runtime texture update strategy.\n */\nexport function resolveTextureUpdateMode(input: {\n\tsource: TextureData['source'];\n\toverride?: TextureUpdateMode;\n\tdefaultMode?: TextureUpdateMode;\n}): TextureUpdateMode {\n\tif (input.override) {\n\t\treturn input.override;\n\t}\n\n\tif (input.defaultMode) {\n\t\treturn input.defaultMode;\n\t}\n\n\tif (isVideoTextureSource(input.source)) {\n\t\treturn 'perFrame';\n\t}\n\n\treturn 'once';\n}\n\n/**\n * Resolves texture dimensions from explicit values or source metadata.\n *\n * @param data - Texture payload.\n * @returns Positive integer width/height.\n * @throws {Error} When dimensions cannot be resolved to positive values.\n */\nexport function resolveTextureSize(data: TextureData): {\n\twidth: number;\n\theight: number;\n} {\n\tconst source = data.source as {\n\t\twidth?: number;\n\t\theight?: number;\n\t\tnaturalWidth?: number;\n\t\tnaturalHeight?: number;\n\t\tvideoWidth?: number;\n\t\tvideoHeight?: number;\n\t};\n\n\tconst width = data.width ?? source.naturalWidth ?? source.videoWidth ?? source.width ?? 0;\n\tconst height = data.height ?? source.naturalHeight ?? source.videoHeight ?? source.height ?? 0;\n\n\tif (width <= 0 || height <= 0) {\n\t\tthrow new Error('Texture source must have positive width and height');\n\t}\n\n\treturn { width, height };\n}\n\n/**\n * Computes the number of mipmap levels for a base texture size.\n *\n * @param width - Base width.\n * @param height - Base height.\n * @returns Total mip level count (minimum `1`).\n */\nexport function getTextureMipLevelCount(width: number, height: number): number {\n\tlet levels = 1;\n\tlet currentWidth = Math.max(1, width);\n\tlet currentHeight = Math.max(1, height);\n\n\twhile (currentWidth > 1 || currentHeight > 1) {\n\t\tcurrentWidth = Math.max(1, Math.floor(currentWidth / 2));\n\t\tcurrentHeight = Math.max(1, Math.floor(currentHeight / 2));\n\t\tlevels += 1;\n\t}\n\n\treturn levels;\n}\n\n/**\n * Checks whether the source is an `HTMLVideoElement`.\n */\nexport function isVideoTextureSource(source: TextureData['source']): source is HTMLVideoElement {\n\treturn typeof HTMLVideoElement !== 'undefined' && source instanceof HTMLVideoElement;\n}\n"],"mappings":";;;;;AA8EA,IAAM,yBAAwC;;;;AAK9C,IAAM,+BAA+C;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AO,MAAM;AAGd,KAAI,MAAM,YACT,QAAO,MAAM;AAGd,KAAI,qBAAqB,MAAM,OAAO,CACrC,QAAO;AAGR,QAAO;;;;;;;;;AAUR,SAAgB,mBAAmB,MAGjC;CACD,MAAM,SAAS,KAAK;CASpB,MAAM,QAAQ,KAAK,SAAS,OAAO,gBAAgB,OAAO,cAAc,OAAO,SAAS;CACxF,MAAM,SAAS,KAAK,UAAU,OAAO,iBAAiB,OAAO,eAAe,OAAO,UAAU;AAE7F,KAAI,SAAS,KAAK,UAAU,EAC3B,OAAM,IAAI,MAAM,qDAAqD;AAGtE,QAAO;EAAE;EAAO;EAAQ;;;;;;;;;AAUzB,SAAgB,wBAAwB,OAAe,QAAwB;CAC9E,IAAI,SAAS;CACb,IAAI,eAAe,KAAK,IAAI,GAAG,MAAM;CACrC,IAAI,gBAAgB,KAAK,IAAI,GAAG,OAAO;AAEvC,QAAO,eAAe,KAAK,gBAAgB,GAAG;AAC7C,iBAAe,KAAK,IAAI,GAAG,KAAK,MAAM,eAAe,EAAE,CAAC;AACxD,kBAAgB,KAAK,IAAI,GAAG,KAAK,MAAM,gBAAgB,EAAE,CAAC;AAC1D,YAAU;;AAGX,QAAO;;;;;AAMR,SAAgB,qBAAqB,QAA2D;AAC/F,QAAO,OAAO,qBAAqB,eAAe,kBAAkB"}
@@ -663,7 +663,7 @@ export interface Renderer {
663
663
  width: number;
664
664
  height: number;
665
665
  };
666
- pendingStorageWrites?: PendingStorageWrite[];
666
+ pendingStorageWrites?: PendingStorageWrite[] | undefined;
667
667
  }) => void;
668
668
  /**
669
669
  * Returns the GPU buffer for a named storage buffer, if allocated.
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/core/types.ts"],"names":[],"mappings":";AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,KAAK,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,SAAS,CAAC;AAE1E;;;;;GAKG;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H,MAAM,WAAW,QAAQ;IACxB;;OAEG;IACH,MAAM,EAAE,CAAC,KAAK,EAAE;QACf,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;QACd,UAAU,EAAE,UAAU,CAAC;QACvB,QAAQ,EAAE,UAAU,CAAC;QACrB,QAAQ,EAAE,UAAU,CAAC;QACrB,UAAU,CAAC,EAAE;YACZ,KAAK,EAAE,MAAM,CAAC;YACd,MAAM,EAAE,MAAM,CAAC;SACf,CAAC;QACF,oBAAoB,CAAC,EAAE,mBAAmB,EAAE,GAAG,SAAS,CAAC;KACzD,KAAK,IAAI,CAAC;IACX;;OAEG;IACH,gBAAgB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,SAAS,GAAG,SAAS,CAAC;IAC3D;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,SAAS,CAAC;IAC5B;;OAEG;IACH,OAAO,EAAE,MAAM,IAAI,CAAC;CACpB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@motion-core/motion-gpu",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "Framework-agnostic WebGPU runtime for fullscreen WGSL shaders with explicit Svelte and React adapter entrypoints.",
5
5
  "keywords": [
6
6
  "svelte",
@@ -0,0 +1,73 @@
1
+ export interface ComputeStorageBindGroupCacheRequest {
2
+ topologyKey: string;
3
+ layoutEntries: GPUBindGroupLayoutEntry[];
4
+ bindGroupEntries: GPUBindGroupEntry[];
5
+ resourceRefs: readonly unknown[];
6
+ }
7
+
8
+ export interface ComputeStorageBindGroupCache {
9
+ getOrCreate: (request: ComputeStorageBindGroupCacheRequest) => GPUBindGroup | null;
10
+ reset: () => void;
11
+ }
12
+
13
+ function equalResourceRefs(previous: readonly unknown[], next: readonly unknown[]): boolean {
14
+ if (previous.length !== next.length) {
15
+ return false;
16
+ }
17
+
18
+ for (let index = 0; index < previous.length; index += 1) {
19
+ if (!Object.is(previous[index], next[index])) {
20
+ return false;
21
+ }
22
+ }
23
+
24
+ return true;
25
+ }
26
+
27
+ export function createComputeStorageBindGroupCache(
28
+ device: GPUDevice
29
+ ): ComputeStorageBindGroupCache {
30
+ let cachedTopologyKey: string | null = null;
31
+ let cachedLayout: GPUBindGroupLayout | null = null;
32
+ let cachedBindGroup: GPUBindGroup | null = null;
33
+ let cachedResourceRefs: readonly unknown[] = [];
34
+
35
+ const reset = (): void => {
36
+ cachedTopologyKey = null;
37
+ cachedLayout = null;
38
+ cachedBindGroup = null;
39
+ cachedResourceRefs = [];
40
+ };
41
+
42
+ return {
43
+ getOrCreate(request) {
44
+ if (request.layoutEntries.length === 0) {
45
+ reset();
46
+ return null;
47
+ }
48
+
49
+ if (cachedTopologyKey !== request.topologyKey) {
50
+ cachedTopologyKey = request.topologyKey;
51
+ cachedLayout = device.createBindGroupLayout({ entries: request.layoutEntries });
52
+ cachedBindGroup = null;
53
+ cachedResourceRefs = [];
54
+ }
55
+
56
+ if (!cachedLayout) {
57
+ throw new Error('Compute storage bind group cache is missing a layout.');
58
+ }
59
+
60
+ if (cachedBindGroup && equalResourceRefs(cachedResourceRefs, request.resourceRefs)) {
61
+ return cachedBindGroup;
62
+ }
63
+
64
+ cachedBindGroup = device.createBindGroup({
65
+ layout: cachedLayout,
66
+ entries: request.bindGroupEntries
67
+ });
68
+ cachedResourceRefs = [...request.resourceRefs];
69
+ return cachedBindGroup;
70
+ },
71
+ reset
72
+ };
73
+ }
@@ -277,6 +277,27 @@ ${options.compute}
277
277
  `;
278
278
  }
279
279
 
280
+ /**
281
+ * Source location for generated compute shader lines.
282
+ */
283
+ export interface ComputeShaderSourceLocation {
284
+ kind: 'compute';
285
+ line: number;
286
+ }
287
+
288
+ /**
289
+ * 1-based line map from generated compute WGSL to user compute source.
290
+ */
291
+ export type ComputeShaderLineMap = Array<ComputeShaderSourceLocation | null>;
292
+
293
+ /**
294
+ * Result of compute shader source generation with line mapping metadata.
295
+ */
296
+ export interface BuiltComputeShaderSource {
297
+ code: string;
298
+ lineMap: ComputeShaderLineMap;
299
+ }
300
+
280
301
  /**
281
302
  * Assembles full compute shader WGSL with preamble.
282
303
  *
@@ -324,3 +345,68 @@ ${storageTextureBindings ? '\n' + storageTextureBindings : ''}
324
345
  ${options.compute}
325
346
  `;
326
347
  }
348
+
349
+ function buildComputeLineMap(
350
+ generatedCode: string,
351
+ userComputeSource: string
352
+ ): ComputeShaderLineMap {
353
+ const lineCount = generatedCode.split('\n').length;
354
+ const lineMap: ComputeShaderLineMap = new Array(lineCount + 1).fill(null);
355
+ const computeStartIndex = generatedCode.indexOf(userComputeSource);
356
+ if (computeStartIndex === -1) {
357
+ return lineMap;
358
+ }
359
+
360
+ const computeStartLine = generatedCode.slice(0, computeStartIndex).split('\n').length;
361
+ const computeLineCount = userComputeSource.split('\n').length;
362
+ for (let line = 0; line < computeLineCount; line += 1) {
363
+ lineMap[computeStartLine + line] = {
364
+ kind: 'compute',
365
+ line: line + 1
366
+ };
367
+ }
368
+
369
+ return lineMap;
370
+ }
371
+
372
+ /**
373
+ * Assembles full compute shader WGSL with source line mapping metadata.
374
+ */
375
+ export function buildComputeShaderSourceWithMap(options: {
376
+ compute: string;
377
+ uniformLayout: UniformLayout;
378
+ storageBufferKeys: string[];
379
+ storageBufferDefinitions: Record<
380
+ string,
381
+ { type: StorageBufferType; access: StorageBufferAccess }
382
+ >;
383
+ storageTextureKeys: string[];
384
+ storageTextureDefinitions: Record<string, { format: GPUTextureFormat }>;
385
+ }): BuiltComputeShaderSource {
386
+ const code = buildComputeShaderSource(options);
387
+ return {
388
+ code,
389
+ lineMap: buildComputeLineMap(code, options.compute)
390
+ };
391
+ }
392
+
393
+ /**
394
+ * Assembles ping-pong compute shader WGSL with source line mapping metadata.
395
+ */
396
+ export function buildPingPongComputeShaderSourceWithMap(options: {
397
+ compute: string;
398
+ uniformLayout: UniformLayout;
399
+ storageBufferKeys: string[];
400
+ storageBufferDefinitions: Record<
401
+ string,
402
+ { type: StorageBufferType; access: StorageBufferAccess }
403
+ >;
404
+ target: string;
405
+ targetFormat: GPUTextureFormat;
406
+ }): BuiltComputeShaderSource {
407
+ const code = buildPingPongComputeShaderSource(options);
408
+ return {
409
+ code,
410
+ lineMap: buildComputeLineMap(code, options.compute)
411
+ };
412
+ }
@@ -11,6 +11,13 @@ export interface MaterialSourceMetadata {
11
11
  functionName?: string;
12
12
  }
13
13
 
14
+ export interface ComputeSourceLocation {
15
+ kind: 'compute';
16
+ line: number;
17
+ }
18
+
19
+ export type ShaderSourceLocation = MaterialSourceLocation | ComputeSourceLocation;
20
+
14
21
  /**
15
22
  * One WGSL compiler diagnostic enriched with source-location metadata.
16
23
  */
@@ -19,7 +26,7 @@ export interface ShaderCompilationDiagnostic {
19
26
  message: string;
20
27
  linePos?: number;
21
28
  lineLength?: number;
22
- sourceLocation: MaterialSourceLocation | null;
29
+ sourceLocation: ShaderSourceLocation | null;
23
30
  }
24
31
 
25
32
  /**
@@ -41,8 +48,10 @@ export interface ShaderCompilationRuntimeContext {
41
48
  */
42
49
  export interface ShaderCompilationDiagnosticsPayload {
43
50
  kind: 'shader-compilation';
51
+ shaderStage?: 'fragment' | 'compute';
44
52
  diagnostics: ShaderCompilationDiagnostic[];
45
53
  fragmentSource: string;
54
+ computeSource?: string;
46
55
  includeSources: Record<string, string>;
47
56
  defineBlockSource?: string;
48
57
  materialSource: MaterialSourceMetadata | null;
@@ -78,7 +87,7 @@ function isMaterialSourceMetadata(value: unknown): value is MaterialSourceMetada
78
87
  return true;
79
88
  }
80
89
 
81
- function isMaterialSourceLocation(value: unknown): value is MaterialSourceLocation | null {
90
+ function isShaderSourceLocation(value: unknown): value is ShaderSourceLocation | null {
82
91
  if (value === null) {
83
92
  return true;
84
93
  }
@@ -89,7 +98,7 @@ function isMaterialSourceLocation(value: unknown): value is MaterialSourceLocati
89
98
 
90
99
  const record = value as Record<string, unknown>;
91
100
  const kind = record.kind;
92
- if (kind !== 'fragment' && kind !== 'include' && kind !== 'define') {
101
+ if (kind !== 'fragment' && kind !== 'include' && kind !== 'define' && kind !== 'compute') {
93
102
  return false;
94
103
  }
95
104
 
@@ -114,7 +123,7 @@ function isShaderCompilationDiagnostic(value: unknown): value is ShaderCompilati
114
123
  if (record.lineLength !== undefined && typeof record.lineLength !== 'number') {
115
124
  return false;
116
125
  }
117
- if (!isMaterialSourceLocation(record.sourceLocation)) {
126
+ if (!isShaderSourceLocation(record.sourceLocation)) {
118
127
  return false;
119
128
  }
120
129
 
@@ -191,6 +200,13 @@ export function getShaderCompilationDiagnostics(
191
200
  if (record.kind !== 'shader-compilation') {
192
201
  return null;
193
202
  }
203
+ if (
204
+ record.shaderStage !== undefined &&
205
+ record.shaderStage !== 'fragment' &&
206
+ record.shaderStage !== 'compute'
207
+ ) {
208
+ return null;
209
+ }
194
210
  if (
195
211
  !Array.isArray(record.diagnostics) ||
196
212
  !record.diagnostics.every(isShaderCompilationDiagnostic)
@@ -200,6 +216,9 @@ export function getShaderCompilationDiagnostics(
200
216
  if (typeof record.fragmentSource !== 'string') {
201
217
  return null;
202
218
  }
219
+ if (record.computeSource !== undefined && typeof record.computeSource !== 'string') {
220
+ return null;
221
+ }
203
222
  if (record.defineBlockSource !== undefined && typeof record.defineBlockSource !== 'string') {
204
223
  return null;
205
224
  }
@@ -222,8 +241,14 @@ export function getShaderCompilationDiagnostics(
222
241
 
223
242
  return {
224
243
  kind: 'shader-compilation',
244
+ ...(record.shaderStage !== undefined
245
+ ? { shaderStage: record.shaderStage as 'fragment' | 'compute' }
246
+ : {}),
225
247
  diagnostics: record.diagnostics as ShaderCompilationDiagnostic[],
226
248
  fragmentSource: record.fragmentSource,
249
+ ...(record.computeSource !== undefined
250
+ ? { computeSource: record.computeSource as string }
251
+ : {}),
227
252
  includeSources: includeSources as Record<string, string>,
228
253
  ...(record.defineBlockSource !== undefined
229
254
  ? { defineBlockSource: record.defineBlockSource as string }