ultra-text 1.0.2 → 1.0.3
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.
- package/README.md +193 -115
- package/dist/assets/{cpuSdf.worker--X1Qpmdp.js → cpuSdf.worker-Dy4P5_TI.js} +98 -43
- package/dist/assets/cpuSdf.worker-Dy4P5_TI.js.map +1 -0
- package/dist/assets/traceOutline.worker-B5uVKmR4.js +1725 -0
- package/dist/assets/traceOutline.worker-B5uVKmR4.js.map +1 -0
- package/dist/atlas/appendAtlas.js +35 -11
- package/dist/atlas/appendAtlas.js.map +1 -1
- package/dist/atlas/buildAtlas.js +1 -1
- package/dist/atlas/buildAtlas.js.map +1 -1
- package/dist/atlas/colorGlyphs.d.ts +0 -10
- package/dist/atlas/colorGlyphs.js +97 -155
- package/dist/atlas/colorGlyphs.js.map +1 -1
- package/dist/atlas/colorTexture.d.ts +1 -0
- package/dist/atlas/colorTexture.js +64 -0
- package/dist/atlas/colorTexture.js.map +1 -0
- package/dist/atlas/cpuAtlas.js +8 -3
- package/dist/atlas/cpuAtlas.js.map +1 -1
- package/dist/atlas/cpuSdf.d.ts +1 -1
- package/dist/atlas/cpuSdf.js +97 -42
- package/dist/atlas/cpuSdf.js.map +1 -1
- package/dist/atlas/cpuWorker.d.ts +10 -4
- package/dist/atlas/cpuWorker.js +99 -49
- package/dist/atlas/cpuWorker.js.map +1 -1
- package/dist/atlas/gpuAtlas.js +133 -56
- package/dist/atlas/gpuAtlas.js.map +1 -1
- package/dist/atlas/gpuCommon.d.ts +140 -18
- package/dist/atlas/gpuCommon.js +726 -104
- package/dist/atlas/gpuCommon.js.map +1 -1
- package/dist/atlas/jfaWgsl.d.ts +1 -1
- package/dist/atlas/jfaWgsl.js +232 -61
- package/dist/atlas/jfaWgsl.js.map +1 -1
- package/dist/atlas/rasterize.d.ts +22 -0
- package/dist/atlas/rasterize.js +237 -111
- package/dist/atlas/rasterize.js.map +1 -1
- package/dist/atlas/vanillaCore.js +156 -103
- package/dist/atlas/vanillaCore.js.map +1 -1
- package/dist/atlas/vanillaCpuAtlas.js +37 -52
- package/dist/atlas/vanillaCpuAtlas.js.map +1 -1
- package/dist/atlas/vanillaExtras.js +91 -90
- package/dist/atlas/vanillaExtras.js.map +1 -1
- package/dist/atlas/vanillaGpuHelpers.d.ts +70 -7
- package/dist/atlas/vanillaGpuHelpers.js +262 -27
- package/dist/atlas/vanillaGpuHelpers.js.map +1 -1
- package/dist/dom/DomSdf.js +85 -79
- package/dist/dom/DomSdf.js.map +1 -1
- package/dist/dom/DomSlug.js +23 -18
- package/dist/dom/DomSlug.js.map +1 -1
- package/dist/dom/Text.d.ts +4 -1
- package/dist/dom/Text.js +5 -1
- package/dist/dom/Text.js.map +1 -1
- package/dist/dom/browserShaping.js +31 -14
- package/dist/dom/browserShaping.js.map +1 -1
- package/dist/dom/clusters.js +13 -2
- package/dist/dom/clusters.js.map +1 -1
- package/dist/dom/cssEffects.d.ts +4 -0
- package/dist/dom/cssEffects.js +72 -0
- package/dist/dom/cssEffects.js.map +1 -0
- package/dist/dom/domAnalytic.d.ts +1 -2
- package/dist/dom/domAnalytic.js +1 -1
- package/dist/dom/domAnalytic.js.map +1 -1
- package/dist/dom/fontCanvas.d.ts +16 -0
- package/dist/dom/fontCanvas.js +4 -4
- package/dist/dom/fontCanvas.js.map +1 -1
- package/dist/dom/layoutSignature.js +28 -12
- package/dist/dom/layoutSignature.js.map +1 -1
- package/dist/dom/markup.d.ts +10 -0
- package/dist/dom/markup.js +16 -1
- package/dist/dom/markup.js.map +1 -1
- package/dist/dom/pretextLayout.js +27 -19
- package/dist/dom/pretextLayout.js.map +1 -1
- package/dist/dom/snapshot.d.ts +4 -0
- package/dist/dom/snapshot.js +747 -505
- package/dist/dom/snapshot.js.map +1 -1
- package/dist/dom/snapshotsEqual.d.ts +7 -0
- package/dist/dom/snapshotsEqual.js +68 -0
- package/dist/dom/snapshotsEqual.js.map +1 -0
- package/dist/dom/svgCapture.js +30 -27
- package/dist/dom/svgCapture.js.map +1 -1
- package/dist/dom/textTransform.d.ts +13 -1
- package/dist/dom/textTransform.js +31 -13
- package/dist/dom/textTransform.js.map +1 -1
- package/dist/dom/tone.js +15 -8
- package/dist/dom/tone.js.map +1 -1
- package/dist/slug/SlugMaterial.d.ts +6 -0
- package/dist/slug/SlugMaterial.js +48 -20
- package/dist/slug/SlugMaterial.js.map +1 -1
- package/dist/slug/cff.d.ts +5 -0
- package/dist/slug/cff.js +780 -0
- package/dist/slug/cff.js.map +1 -0
- package/dist/slug/coverage.d.ts +3 -3
- package/dist/slug/coverage.js +283 -101
- package/dist/slug/coverage.js.map +1 -1
- package/dist/slug/preprocessCore.d.ts +1 -1
- package/dist/slug/preprocessCore.js +100 -80
- package/dist/slug/preprocessCore.js.map +1 -1
- package/dist/slug/runtime.js +32 -39
- package/dist/slug/runtime.js.map +1 -1
- package/dist/slug/standaloneRuntime.js +47 -37
- package/dist/slug/standaloneRuntime.js.map +1 -1
- package/dist/slug/truetype.d.ts +14 -6
- package/dist/slug/truetype.js +190 -62
- package/dist/slug/truetype.js.map +1 -1
- package/dist/slug/vanillaCore.d.ts +74 -4
- package/dist/slug/vanillaCore.js +226 -217
- package/dist/slug/vanillaCore.js.map +1 -1
- package/dist/slug-vanilla.d.ts +1 -1
- package/dist/slug-vanilla.js +5 -4
- package/dist/slug.d.ts +1 -1
- package/dist/slug.js +3 -3
- package/dist/text/GlyphTextMaterial.d.ts +5 -0
- package/dist/text/GlyphTextMaterial.js +11 -7
- package/dist/text/GlyphTextMaterial.js.map +1 -1
- package/dist/text/RectMaterial.js +6 -10
- package/dist/text/RectMaterial.js.map +1 -1
- package/dist/text/SdfTextMaterial.d.ts +9 -3
- package/dist/text/SdfTextMaterial.js +122 -37
- package/dist/text/SdfTextMaterial.js.map +1 -1
- package/dist/text/decorations.d.ts +7 -2
- package/dist/text/decorations.js +187 -96
- package/dist/text/decorations.js.map +1 -1
- package/dist/text/geometryUtils.d.ts +5 -0
- package/dist/text/geometryUtils.js +63 -9
- package/dist/text/geometryUtils.js.map +1 -1
- package/dist/text/glyphGeometry.d.ts +1 -1
- package/dist/text/glyphGeometry.js +281 -200
- package/dist/text/glyphGeometry.js.map +1 -1
- package/dist/text/rectGeometry.js +46 -42
- package/dist/text/rectGeometry.js.map +1 -1
- package/dist/text/reflow.d.ts +5 -0
- package/dist/text/reflow.js +127 -68
- package/dist/text/reflow.js.map +1 -1
- package/dist/text/snap.d.ts +15 -1
- package/dist/text/snap.js +1 -1
- package/dist/text/snap.js.map +1 -1
- package/dist/text/tone.js +2 -2
- package/dist/text/tone.js.map +1 -1
- package/dist/types.d.ts +23 -7
- package/dist/vanilla.js +1 -1
- package/dist/windfoil/WindfoilCompositeMaterial.d.ts +1 -1
- package/dist/windfoil/WindfoilCompositeMaterial.js +10 -3
- package/dist/windfoil/WindfoilCompositeMaterial.js.map +1 -1
- package/dist/windfoil/WindfoilMaterial.d.ts +12 -5
- package/dist/windfoil/WindfoilMaterial.js +71 -8
- package/dist/windfoil/WindfoilMaterial.js.map +1 -1
- package/dist/windfoil/compositeGeometry.js +12 -5
- package/dist/windfoil/compositeGeometry.js.map +1 -1
- package/dist/windfoil/coverage.d.ts +10 -2
- package/dist/windfoil/coverage.js +147 -59
- package/dist/windfoil/coverage.js.map +1 -1
- package/dist/windfoil/geometry.d.ts +15 -0
- package/dist/windfoil/geometry.js +154 -64
- package/dist/windfoil/geometry.js.map +1 -1
- package/dist/windfoil/layerGrid.js +8 -8
- package/dist/windfoil/layerGrid.js.map +1 -1
- package/dist/windfoil/mixed.js +13 -4
- package/dist/windfoil/mixed.js.map +1 -1
- package/dist/windfoil/preprocess.js +2 -2
- package/dist/windfoil/preprocessCore.d.ts +1 -0
- package/dist/windfoil/preprocessCore.js +63 -36
- package/dist/windfoil/preprocessCore.js.map +1 -1
- package/dist/windfoil/requests.d.ts +1 -1
- package/dist/windfoil/requests.js +11 -4
- package/dist/windfoil/requests.js.map +1 -1
- package/dist/windfoil/resolveOutline.d.ts +9 -0
- package/dist/windfoil/resolveOutline.js +20 -0
- package/dist/windfoil/resolveOutline.js.map +1 -0
- package/dist/windfoil/runtime.d.ts +1 -0
- package/dist/windfoil/runtime.js +8 -24
- package/dist/windfoil/runtime.js.map +1 -1
- package/dist/windfoil/shapeGeometry.js +80 -34
- package/dist/windfoil/shapeGeometry.js.map +1 -1
- package/dist/windfoil/sizeSwitch.d.ts +1 -1
- package/dist/windfoil/sizeSwitch.js +13 -8
- package/dist/windfoil/sizeSwitch.js.map +1 -1
- package/dist/windfoil/storage.d.ts +23 -9
- package/dist/windfoil/storage.js +49 -30
- package/dist/windfoil/storage.js.map +1 -1
- package/dist/windfoil/svg/curves.d.ts +20 -0
- package/dist/windfoil/svg/curves.js +145 -42
- package/dist/windfoil/svg/curves.js.map +1 -1
- package/dist/windfoil/svg/document.js +10 -1
- package/dist/windfoil/svg/document.js.map +1 -1
- package/dist/windfoil/svg/pathConverter.js +66 -50
- package/dist/windfoil/svg/pathConverter.js.map +1 -1
- package/dist/windfoil/svg/pathData.d.ts +9 -0
- package/dist/windfoil/svg/pathData.js +142 -109
- package/dist/windfoil/svg/pathData.js.map +1 -1
- package/dist/windfoil/svg/winding.js +34 -10
- package/dist/windfoil/svg/winding.js.map +1 -1
- package/dist/windfoil/trace/contours.js +120 -50
- package/dist/windfoil/trace/contours.js.map +1 -1
- package/dist/windfoil/trace/fit.js +578 -224
- package/dist/windfoil/trace/fit.js.map +1 -1
- package/dist/windfoil/trace/traceOutline.worker.d.ts +24 -0
- package/dist/windfoil/trace/traceWorker.d.ts +13 -0
- package/dist/windfoil/trace/traceWorker.js +192 -0
- package/dist/windfoil/trace/traceWorker.js.map +1 -0
- package/dist/windfoil/tracedOutlines.d.ts +2 -0
- package/dist/windfoil/tracedOutlines.js +335 -70
- package/dist/windfoil/tracedOutlines.js.map +1 -1
- package/package.json +48 -29
- package/skills/ultra-text/SKILL.md +9 -10
- package/skills/ultra-text/references/frameworks.md +46 -2
- package/skills/ultra-text/references/three-tsl.md +26 -24
- package/skills/ultra-text/references/vanilla-webgpu.md +3 -1
- package/dist/assets/cpuSdf.worker--X1Qpmdp.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gpuAtlas.js","names":["hasDirectStoreFeature"],"sources":["../../src/atlas/gpuAtlas.ts"],"sourcesContent":["import {\n ExternalTexture,\n LinearFilter,\n LinearMipmapLinearFilter,\n NoColorSpace,\n RedFormat,\n WebGPUBackend,\n type Texture,\n type WebGPURenderer,\n} from 'three/webgpu'\n\nimport type { BuildSdfAtlasOptions, RasterAtlas, SdfAtlas } from '../types.js'\nimport {\n checkCommonAtlasLimits,\n encodeJfaWork,\n jfaSteps,\n openErrorScopes,\n prefersTiledJfa,\n selectWorkgroupDimension,\n supportsDirectStore as hasDirectStoreFeature,\n type AtlasDeviceLimitsLike,\n type AtlasErrorFilter,\n type CommonJfaPipelines,\n type UsageGlobals,\n} from './gpuCommon.js'\nimport { buildJfaWgsl } from './jfaWgsl.js'\nimport type { ShapeRows } from './rasterize.js'\n\ntype AtlasDeviceLimits = AtlasDeviceLimitsLike & {\n readonly maxStorageBufferBindingSize: number\n readonly maxBufferSize: number\n}\n\n/** @internal The WebGPU texture calls the atlas makes (no `@webgpu/types` needed). */\nexport interface AtlasGpuTexture {\n readonly mipLevelCount: number\n createView(descriptor?: { baseMipLevel?: number; mipLevelCount?: number }): unknown\n destroy(): void\n}\n\ninterface AtlasGpuBuffer {\n destroy(): void\n}\n\ninterface AtlasPipeline {\n getBindGroupLayout(index: number): unknown\n}\n\ninterface AtlasPass {\n setPipeline(pipeline: AtlasPipeline): void\n setBindGroup(index: number, bindGroup: unknown): void\n end(): void\n}\n\n/** @internal One command encoder of the atlas passes, which a patch adds its copies to. */\nexport interface AtlasEncoder {\n copyTextureToBuffer(\n source: { texture: AtlasGpuTexture },\n destination: { buffer: AtlasGpuBuffer; bytesPerRow: number; rowsPerImage: number },\n size: [number, number],\n ): void\n copyTextureToTexture(\n source: { texture: AtlasGpuTexture; origin: [number, number] },\n destination: { texture: AtlasGpuTexture; origin: [number, number] },\n size: [number, number],\n ): void\n beginComputePass(): AtlasPass & { dispatchWorkgroups(x: number, y: number): void }\n beginRenderPass(descriptor: {\n colorAttachments: { view: unknown; loadOp: 'clear'; storeOp: 'store' }[]\n }): AtlasPass & { draw(vertexCount: number): void }\n finish(): unknown\n}\n\n/** @internal The device calls of the atlas passes, called with the device as `this`. */\nexport interface AtlasDevice {\n readonly features?: { has(name: string): boolean }\n readonly limits?: AtlasDeviceLimits\n createTexture(descriptor: {\n size: [number, number]\n mipLevelCount?: number\n format: string\n usage: number\n }): AtlasGpuTexture\n createBuffer(descriptor: { size: number; usage: number }): AtlasGpuBuffer\n createShaderModule(descriptor: { label: string; code: string }): unknown\n createComputePipeline(descriptor: {\n layout: 'auto'\n compute: { module: unknown; entryPoint: string }\n }): AtlasPipeline\n readonly createComputePipelineAsync?: (descriptor: {\n layout: 'auto'\n compute: { module: unknown; entryPoint: string }\n }) => Promise<AtlasPipeline>\n createRenderPipeline(descriptor: {\n layout: 'auto'\n vertex: { module: unknown; entryPoint: string }\n fragment: { module: unknown; entryPoint: string; targets: { format: string }[] }\n }): AtlasPipeline\n readonly createRenderPipelineAsync?: (descriptor: {\n layout: 'auto'\n vertex: { module: unknown; entryPoint: string }\n fragment: { module: unknown; entryPoint: string; targets: { format: string }[] }\n }) => Promise<AtlasPipeline>\n createBindGroup(descriptor: {\n layout: unknown\n entries: { binding: number; resource: unknown }[]\n }): unknown\n createCommandEncoder(): AtlasEncoder\n readonly queue: {\n copyExternalImageToTexture(\n source: { source: HTMLCanvasElement; flipY: boolean },\n destination: { texture: AtlasGpuTexture; premultipliedAlpha: boolean },\n size: [number, number],\n ): void\n writeBuffer(buffer: AtlasGpuBuffer, offset: number, data: Int32Array): void\n submit(commandBuffers: unknown[]): void\n }\n readonly pushErrorScope?: (filter: AtlasErrorFilter) => void\n readonly popErrorScope?: () => Promise<{ readonly message?: string } | null>\n}\n\ntype AtlasPipelines = CommonJfaPipelines<AtlasPipeline, AtlasPipeline>\n\ninterface MultiPassPipelines {\n readonly seed: AtlasPipeline\n readonly jump: AtlasPipeline\n readonly jumpStore: AtlasPipeline | null\n readonly resolve: AtlasPipeline | null\n}\n\ninterface DevicePipelineCache {\n readonly workgroupDim: 8 | 16\n readonly directStore: boolean\n readonly module: unknown\n tiledStore?: AtlasPipeline\n tiledPromise?: Promise<AtlasPipelines> | undefined\n multi?: MultiPassPipelines\n multiPromise?: Promise<AtlasPipelines> | undefined\n}\n\nconst devicePipelines = new WeakMap<AtlasDevice, DevicePipelineCache>()\n\nfunction asAtlasPipelines(\n workgroupDim: 8 | 16,\n directStore: boolean,\n tiledStore: AtlasPipeline | null,\n multi?: MultiPassPipelines,\n): AtlasPipelines {\n return {\n workgroupDim,\n directStore,\n seed: multi?.seed ?? null,\n jump: multi?.jump ?? null,\n jumpStore: multi?.jumpStore ?? null,\n tiledStore,\n resolve: multi?.resolve ?? null,\n }\n}\n\nfunction getDeviceCache(\n device: AtlasDevice,\n workgroupDim: 8 | 16,\n directStore: boolean,\n): DevicePipelineCache {\n const existing = devicePipelines.get(device)\n if (existing?.workgroupDim === workgroupDim && existing.directStore === directStore) {\n return existing\n }\n const cache: DevicePipelineCache = {\n workgroupDim,\n directStore,\n module: device.createShaderModule({\n label: 'ultra-text atlas',\n code: buildJfaWgsl(workgroupDim, directStore),\n }),\n }\n devicePipelines.set(device, cache)\n return cache\n}\n\nfunction cachedAtlasPipelines(\n device: AtlasDevice,\n workgroupDim: 8 | 16,\n directStore: boolean,\n tiledOnly: boolean,\n): AtlasPipelines | undefined {\n const cache = devicePipelines.get(device)\n if (cache?.workgroupDim !== workgroupDim || cache.directStore !== directStore) return undefined\n if (tiledOnly) {\n return cache.tiledStore\n ? asAtlasPipelines(workgroupDim, directStore, cache.tiledStore)\n : undefined\n }\n return cache.multi ? asAtlasPipelines(workgroupDim, directStore, null, cache.multi) : undefined\n}\n\nfunction supportsAsyncAtlasPipelines(device: AtlasDevice, directStore: boolean): boolean {\n return (\n typeof device.createComputePipelineAsync === 'function' &&\n (directStore || typeof device.createRenderPipelineAsync === 'function')\n )\n}\n\nfunction buildAtlasPipelines(\n device: AtlasDevice,\n workgroupDim: 8 | 16,\n directStore: boolean,\n tiledOnly: boolean,\n async: true,\n): Promise<AtlasPipelines>\nfunction buildAtlasPipelines(\n device: AtlasDevice,\n workgroupDim: 8 | 16,\n directStore: boolean,\n tiledOnly: boolean,\n async: false,\n): AtlasPipelines\nfunction buildAtlasPipelines(\n device: AtlasDevice,\n workgroupDim: 8 | 16,\n directStore: boolean,\n tiledOnly: boolean,\n async: boolean,\n): AtlasPipelines | Promise<AtlasPipelines> {\n const cached = cachedAtlasPipelines(device, workgroupDim, directStore, tiledOnly)\n if (cached) return async ? Promise.resolve(cached) : cached\n\n const existing = devicePipelines.get(device)\n const sameConfig = existing?.workgroupDim === workgroupDim && existing.directStore === directStore\n if (async && sameConfig) {\n const inFlight = tiledOnly ? existing.tiledPromise : existing.multiPromise\n if (inFlight) return inFlight\n }\n\n const cache = getDeviceCache(device, workgroupDim, directStore)\n const module = cache.module\n const computeSync = (entryPoint: string) =>\n device.createComputePipeline({ layout: 'auto', compute: { module, entryPoint } })\n const computeAsync = (entryPoint: string) =>\n device.createComputePipelineAsync!({ layout: 'auto', compute: { module, entryPoint } })\n\n if (tiledOnly) {\n const store = (tiledStore: AtlasPipeline): AtlasPipelines => {\n cache.tiledStore = tiledStore\n return asAtlasPipelines(workgroupDim, directStore, tiledStore)\n }\n if (!async) return store(computeSync('tiledStoreMain'))\n const promise = computeAsync('tiledStoreMain').then(\n (tiledStore) => store(tiledStore),\n (error: unknown) => {\n if (cache.tiledPromise === promise) cache.tiledPromise = undefined\n throw error\n },\n )\n cache.tiledPromise = promise\n return promise\n }\n\n const resolveDesc = {\n layout: 'auto' as const,\n vertex: { module, entryPoint: 'fullscreenVert' },\n fragment: { module, entryPoint: 'resolveFrag', targets: [{ format: 'r8unorm' }] },\n }\n const store = (\n seed: AtlasPipeline,\n jump: AtlasPipeline,\n jumpStore: AtlasPipeline | null,\n resolve: AtlasPipeline | null,\n ): AtlasPipelines => {\n const multi: MultiPassPipelines = { seed, jump, jumpStore, resolve }\n cache.multi = multi\n return asAtlasPipelines(workgroupDim, directStore, null, multi)\n }\n\n if (!async) {\n return store(\n computeSync('seedMain'),\n computeSync('jumpMain'),\n directStore ? computeSync('jumpStoreMain') : null,\n directStore ? null : device.createRenderPipeline(resolveDesc),\n )\n }\n\n const promise = Promise.all([\n computeAsync('seedMain'),\n computeAsync('jumpMain'),\n directStore ? computeAsync('jumpStoreMain') : Promise.resolve(null),\n directStore ? Promise.resolve(null) : device.createRenderPipelineAsync!(resolveDesc),\n ]).then(\n ([seed, jump, jumpStore, resolve]) => store(seed, jump, jumpStore, resolve),\n (error: unknown) => {\n if (cache.multiPromise === promise) cache.multiPromise = undefined\n throw error\n },\n )\n cache.multiPromise = promise\n return promise\n}\n\n/**\n * @internal Starts the native compile of the device's atlas passes ahead of its first atlas,\n * while the caller reads the DOM.\n */\nexport function prepareAtlasPasses(renderer: WebGPURenderer, pxRange?: number): void {\n const device = atlasDevice(renderer)\n if (!device?.createShaderModule) return\n const directStore = hasDirectStoreFeature(device.features)\n const workgroupDim = selectWorkgroupDimension(device.limits)\n const tiledOnly = prefersTiledJfa(directStore, pxRange)\n const cached = devicePipelines.get(device)\n const matches = cached?.workgroupDim === workgroupDim && cached.directStore === directStore\n if (\n matches &&\n (tiledOnly ? cached.tiledStore || cached.tiledPromise : cached.multi || cached.multiPromise)\n ) {\n return\n }\n if (supportsAsyncAtlasPipelines(device, directStore)) {\n void buildAtlasPipelines(device, workgroupDim, directStore, tiledOnly, true).catch(\n () => undefined,\n )\n } else {\n buildAtlasPipelines(device, workgroupDim, directStore, tiledOnly, false)\n }\n device.queue.submit([])\n}\n\n/**\n * @internal Regenerates the mips of an atlas texture from its level 0 with three's own mip\n * pass, as three does for a render target, after the submissions that wrote it.\n */\nexport async function generateAtlasMips(renderer: WebGPURenderer, texture: Texture): Promise<void> {\n const scopes = openErrorScopes(atlasDevice(renderer)!)\n let reported: Promise<string | null>\n try {\n renderer.initTexture(texture)\n ;(renderer.backend as unknown as { generateMipmaps(texture: Texture): void }).generateMipmaps(\n texture,\n )\n } finally {\n reported = scopes.close()\n }\n const rejection = await reported\n if (rejection !== null) throw new Error(`buildGpuSdfAtlas: mip generation failed: ${rejection}`)\n}\n\n/** @internal The device behind a WebGPU-backend renderer, or `undefined`. */\nexport function atlasDevice(renderer: WebGPURenderer): AtlasDevice | undefined {\n return (renderer.backend as unknown as { device?: AtlasDevice }).device\n}\n\n/**\n * @internal Runs the atlas passes over `raster` into level 0 of a new r8unorm texture of\n * `mipLevelCount` levels, all in one command buffer.\n */\nexport async function encodeGpuSdf(\n device: AtlasDevice | undefined,\n raster: Pick<RasterAtlas, 'canvas' | 'width' | 'height' | 'pxRange'>,\n mipLevelCount: number,\n finish?: (encoder: AtlasEncoder, texture: AtlasGpuTexture) => void,\n onSubmitted?: (texture: AtlasGpuTexture) => void,\n): Promise<AtlasGpuTexture> {\n const { width, height, pxRange, canvas } = raster\n const { GPUBufferUsage: buffers, GPUTextureUsage: textures } = globalThis as UsageGlobals\n if (!device?.createCommandEncoder || !buffers || !textures)\n throw new Error('buildGpuSdfAtlas: device cannot run the atlas passes')\n const steps = jfaSteps(pxRange)\n const directStore = hasDirectStoreFeature(device.features)\n checkCommonAtlasLimits(\n 'buildGpuSdfAtlas',\n device.limits,\n width,\n height,\n steps[0]!,\n directStore,\n '; use atlasMode \"cpu\"',\n )\n const workgroupDim = selectWorkgroupDimension(device.limits)\n const tiledOnly = directStore && steps[0] === 4\n let prebuilt = cachedAtlasPipelines(device, workgroupDim, directStore, tiledOnly)\n if (!prebuilt && supportsAsyncAtlasPipelines(device, directStore)) {\n try {\n prebuilt = await buildAtlasPipelines(device, workgroupDim, directStore, tiledOnly, true)\n } catch (error: unknown) {\n throw new Error(\n `buildGpuSdfAtlas: the device rejected the atlas passes: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n )\n }\n }\n const transient: { destroy(): void }[] = []\n let output: AtlasGpuTexture | undefined\n try {\n const scopes = openErrorScopes(device)\n let reported: Promise<string | null>\n try {\n const pipelines =\n prebuilt ?? buildAtlasPipelines(device, workgroupDim, directStore, tiledOnly, false)\n output = device.createTexture({\n size: [width, height],\n mipLevelCount,\n format: 'r8unorm',\n usage:\n textures.RENDER_ATTACHMENT |\n textures.TEXTURE_BINDING |\n textures.COPY_SRC |\n textures.COPY_DST |\n (pipelines.directStore ? (textures.STORAGE_BINDING ?? 0) : 0),\n })\n const encoder = device.createCommandEncoder()\n encodeJfaWork(\n device,\n encoder,\n pipelines,\n canvas,\n width,\n height,\n pxRange,\n steps,\n output,\n transient,\n buffers,\n textures,\n )\n finish?.(encoder, output)\n device.queue.submit([encoder.finish()])\n } finally {\n reported = scopes.close()\n }\n onSubmitted?.(output)\n const rejection = await reported\n if (rejection !== null) {\n devicePipelines.delete(device)\n throw new Error(`buildGpuSdfAtlas: the device rejected the atlas passes: ${rejection}`)\n }\n const retained = output\n output = undefined\n return retained\n } finally {\n for (const resource of transient) resource.destroy()\n output?.destroy()\n }\n}\n\n/**\n * Generates a compact R8 runtime SDF on the renderer's WebGPU device: boundary seeding and\n * 4-byte relative fixed-point jump flooding in compute passes, writing directly into `r8unorm`\n * when `'texture-formats-tier1'` is active on the device or resolving via a fullscreen render\n * pass on Core WebGPU 1.0 devices.\n */\nexport async function buildGpuSdfAtlas(\n renderer: WebGPURenderer,\n raster: RasterAtlas,\n options: Pick<BuildSdfAtlasOptions, 'mipmaps' | 'anisotropy'> = {},\n /** @internal */\n onProvisional?: (atlas: SdfAtlas) => void,\n): Promise<SdfAtlas> {\n await renderer.init()\n if (!(renderer.backend instanceof WebGPUBackend)) {\n throw new Error('buildGpuSdfAtlas: requires the WebGPU backend; use mode \"cpu\"')\n }\n const { width, height } = raster\n const mipmaps = options.mipmaps === true\n const levels = mipmaps ? Math.floor(Math.log2(Math.max(width, height))) + 1 : 1\n const { shapeTop } = raster as RasterAtlas & ShapeRows\n const maxAnisotropy = mipmaps ? renderer.getMaxAnisotropy() : 1\n const wrapAtlas = (gpuTexture: AtlasGpuTexture) => {\n const texture = new ExternalTexture(gpuTexture)\n let disposed = false\n let gpuDestroyed = false\n const dispose = (): void => {\n if (disposed) return\n disposed = true\n try {\n texture.dispose()\n } finally {\n if (!gpuDestroyed) {\n gpuDestroyed = true\n gpuTexture.destroy()\n }\n }\n }\n try {\n ;(texture as { image: unknown }).image = { width, height }\n texture.name = 'ultra-text SDF atlas'\n texture.format = RedFormat\n texture.colorSpace = NoColorSpace\n texture.generateMipmaps = mipmaps\n texture.minFilter = mipmaps ? LinearMipmapLinearFilter : LinearFilter\n texture.magFilter = LinearFilter\n texture.anisotropy = mipmaps\n ? Math.min(Math.max(1, options.anisotropy ?? 1), maxAnisotropy)\n : 1\n if (shapeTop !== undefined) texture.userData['ultraShapeTop'] = shapeTop\n } catch (error) {\n dispose()\n throw error\n }\n const atlas: SdfAtlas = {\n ...(shapeTop === undefined ? {} : { shapeTop }),\n texture,\n width,\n height,\n pxRange: raster.pxRange,\n bakeSize: raster.bakeSize,\n glyphs: raster.glyphs,\n mode: 'gpu',\n dispose,\n }\n return {\n atlas,\n markGpuDestroyed: () => {\n gpuDestroyed = true\n },\n }\n }\n\n if (onProvisional && !mipmaps) {\n let wrapped: ReturnType<typeof wrapAtlas> | undefined\n try {\n const gpuTexture = await encodeGpuSdf(\n atlasDevice(renderer),\n raster,\n levels,\n undefined,\n (candidate) => {\n wrapped = wrapAtlas(candidate)\n onProvisional(wrapped.atlas)\n },\n )\n return wrapped ? wrapped.atlas : wrapAtlas(gpuTexture).atlas\n } catch (error) {\n if (wrapped) {\n wrapped.markGpuDestroyed()\n wrapped.atlas.dispose()\n }\n throw error\n }\n }\n\n const gpuTexture = await encodeGpuSdf(atlasDevice(renderer), raster, levels)\n const { atlas } = wrapAtlas(gpuTexture)\n try {\n if (mipmaps) await generateAtlasMips(renderer, atlas.texture)\n } catch (error) {\n atlas.dispose()\n throw error\n }\n return atlas\n}\n"],"mappings":";;;;AA4IA,IAAM,kCAAkB,IAAI,QAA0C;AAEtE,SAAS,iBACP,cACA,aACA,YACA,OACgB;CAChB,OAAO;EACL;EACA;EACA,MAAM,OAAO,QAAQ;EACrB,MAAM,OAAO,QAAQ;EACrB,WAAW,OAAO,aAAa;EAC/B;EACA,SAAS,OAAO,WAAW;CAC7B;AACF;AAEA,SAAS,eACP,QACA,cACA,aACqB;CACrB,MAAM,WAAW,gBAAgB,IAAI,MAAM;CAC3C,IAAI,UAAU,iBAAiB,gBAAgB,SAAS,gBAAgB,aACtE,OAAO;CAET,MAAM,QAA6B;EACjC;EACA;EACA,QAAQ,OAAO,mBAAmB;GAChC,OAAO;GACP,MAAM,aAAa,cAAc,WAAW;EAC9C,CAAC;CACH;CACA,gBAAgB,IAAI,QAAQ,KAAK;CACjC,OAAO;AACT;AAEA,SAAS,qBACP,QACA,cACA,aACA,WAC4B;CAC5B,MAAM,QAAQ,gBAAgB,IAAI,MAAM;CACxC,IAAI,OAAO,iBAAiB,gBAAgB,MAAM,gBAAgB,aAAa,OAAO,KAAA;CACtF,IAAI,WACF,OAAO,MAAM,aACT,iBAAiB,cAAc,aAAa,MAAM,UAAU,IAC5D,KAAA;CAEN,OAAO,MAAM,QAAQ,iBAAiB,cAAc,aAAa,MAAM,MAAM,KAAK,IAAI,KAAA;AACxF;AAEA,SAAS,4BAA4B,QAAqB,aAA+B;CACvF,OACE,OAAO,OAAO,+BAA+B,eAC5C,eAAe,OAAO,OAAO,8BAA8B;AAEhE;AAgBA,SAAS,oBACP,QACA,cACA,aACA,WACA,OAC0C;CAC1C,MAAM,SAAS,qBAAqB,QAAQ,cAAc,aAAa,SAAS;CAChF,IAAI,QAAQ,OAAO,QAAQ,QAAQ,QAAQ,MAAM,IAAI;CAErD,MAAM,WAAW,gBAAgB,IAAI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QAAQ,YAAY;GACpB,QAAQ,aAAa,UACjB,KAAK,IAAI,KAAK,IAAI,GAAG,QAAQ,cAAc,CAAC,GAAG,aAAa,IAC5D;GACJ,IAAI,aAAa,KAAA,GAAW,QAAQ,SAAS,mBAAmB;EAClE,SAAS,OAAO;GACd,QAAQ;GACR,MAAM;EACR;EAYA,OAAO;GACL,OAAA;IAXA,GAAI,aAAa,KAAA,IAAY,CAAC,IAAI,EAAE,SAAS;IAC7C;IACA;IACA;IACA,SAAS,OAAO;IAChB,UAAU,OAAO;IACjB,QAAQ,OAAO;IACf,MAAM;IACN;GAGA;GACA,wBAAwB;IACtB,eAAe;GACjB;EACF;CACF;CAEA,IAAI,iBAAiB,CAAC,SAAS;EAC7B,IAAI;EACJ,IAAI;GACF,MAAM,aAAa,MAAM,aACvB,YAAY,QAAQ,GACpB,QACA,QACA,KAAA,IACC,cAAc;IACb,UAAU,UAAU,SAAS;IAC7B,cAAc,QAAQ,KAAK;GAC7B,CACF;GACA,OAAO,UAAU,QAAQ,QAAQ,UAAU,UAAU,CAAC,CAAC;EACzD,SAAS,OAAO;GACd,IAAI,SAAS;IACX,QAAQ,iBAAiB;IACzB,QAAQ,MAAM,QAAQ;GACxB;GACA,MAAM;EACR;CACF;CAGA,MAAM,EAAE,UAAU,UAAU,MADH,aAAa,YAAY,QAAQ,GAAG,QAAQ,MAAM,CACrC;CACtC,IAAI;EACF,IAAI,SAAS,MAAM,kBAAkB,UAAU,MAAM,OAAO;CAC9D,SAAS,OAAO;EACd,MAAM,QAAQ;EACd,MAAM;CACR;CACA,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"gpuAtlas.js","names":["hasDirectStoreFeature"],"sources":["../../src/atlas/gpuAtlas.ts"],"sourcesContent":["import {\n ExternalTexture,\n LinearFilter,\n LinearMipmapLinearFilter,\n NoColorSpace,\n RedFormat,\n WebGPUBackend,\n type Texture,\n type WebGPURenderer,\n} from 'three/webgpu'\n\nimport type { BuildSdfAtlasOptions, RasterAtlas, SdfAtlas } from '../types.js'\nimport {\n checkCommonAtlasLimits,\n edtRadius,\n encodeGpuColorBleed,\n encodeJfaWork,\n getDeviceGpuPool,\n getJfaLayouts,\n openErrorScopes,\n peekDeferredColorBleed,\n putReadyGpuColorTexture,\n selectAtlasMode,\n selectWorkgroupDimension,\n storageBufferFits,\n supportsDirectStore as hasDirectStoreFeature,\n takeDeferredColorBleed,\n takeReadyGpuColorTexture,\n type AtlasDeviceLimitsLike,\n type AtlasErrorFilter,\n type AtlasModeKind,\n type ColorBleedDeviceLike,\n type CommonJfaPipelines,\n type CommonTextureLike,\n type DeferredColorBleed,\n type JfaPipelineLayouts,\n type UsageGlobals,\n} from './gpuCommon.js'\nimport { buildJfaWgsl } from './jfaWgsl.js'\nimport type { ShapeRows } from './rasterize.js'\nimport {\n encodeMipmapChain,\n getDeviceMipPipeline,\n mipCount,\n type VanillaGpuDevice,\n} from './vanillaGpuHelpers.js'\n\ntype AtlasDeviceLimits = AtlasDeviceLimitsLike & {\n readonly maxStorageBufferBindingSize: number\n readonly maxBufferSize: number\n}\n\n/** @internal The WebGPU texture calls the atlas makes (no `@webgpu/types` needed). */\nexport interface AtlasGpuTexture {\n readonly mipLevelCount: number\n createView(descriptor?: { baseMipLevel?: number; mipLevelCount?: number }): unknown\n destroy(): void\n}\n\ninterface AtlasGpuBuffer {\n destroy(): void\n}\n\ninterface AtlasPipeline {\n getBindGroupLayout(index: number): unknown\n}\n\ninterface AtlasPass {\n setPipeline(pipeline: AtlasPipeline): void\n setBindGroup(index: number, bindGroup: unknown): void\n end(): void\n}\n\n/** @internal One command encoder of the atlas passes, which a patch adds its copies to. */\nexport interface AtlasEncoder {\n copyTextureToBuffer(\n source: { texture: AtlasGpuTexture },\n destination: { buffer: AtlasGpuBuffer; bytesPerRow: number; rowsPerImage: number },\n size: [number, number],\n ): void\n copyTextureToTexture(\n source: { texture: AtlasGpuTexture; origin: [number, number] },\n destination: { texture: AtlasGpuTexture; origin: [number, number] },\n size: [number, number],\n ): void\n beginComputePass(): AtlasPass & { dispatchWorkgroups(x: number, y: number): void }\n beginRenderPass(descriptor: {\n colorAttachments: { view: unknown; loadOp: 'clear'; storeOp: 'store' }[]\n }): AtlasPass & { draw(vertexCount: number): void }\n finish(): unknown\n}\n\n/** @internal The device calls of the atlas passes, called with the device as `this`. */\nexport interface AtlasDevice {\n readonly features?: { has(name: string): boolean }\n readonly limits?: AtlasDeviceLimits\n createTexture(descriptor: {\n size: [number, number]\n mipLevelCount?: number\n format: string\n usage: number\n }): AtlasGpuTexture\n createBuffer(descriptor: { size: number; usage: number }): AtlasGpuBuffer\n createShaderModule(descriptor: { label: string; code: string }): unknown\n createBindGroupLayout?(descriptor: object): unknown\n createPipelineLayout?(descriptor: { bindGroupLayouts: unknown[] }): unknown\n createComputePipeline(descriptor: {\n layout: unknown\n compute: { module: unknown; entryPoint: string }\n }): AtlasPipeline\n readonly createComputePipelineAsync?: (descriptor: {\n layout: unknown\n compute: { module: unknown; entryPoint: string }\n }) => Promise<AtlasPipeline>\n createRenderPipeline(descriptor: {\n layout: unknown\n vertex: { module: unknown; entryPoint: string }\n fragment: { module: unknown; entryPoint: string; targets: { format: string }[] }\n }): AtlasPipeline\n readonly createRenderPipelineAsync?: (descriptor: {\n layout: unknown\n vertex: { module: unknown; entryPoint: string }\n fragment: { module: unknown; entryPoint: string; targets: { format: string }[] }\n }) => Promise<AtlasPipeline>\n createBindGroup(descriptor: {\n layout: unknown\n entries: { binding: number; resource: unknown }[]\n }): unknown\n createCommandEncoder(): AtlasEncoder\n readonly queue: {\n copyExternalImageToTexture(\n source: { source: HTMLCanvasElement; flipY: boolean },\n destination: { texture: AtlasGpuTexture; premultipliedAlpha: boolean },\n size: [number, number],\n ): void\n writeBuffer(buffer: AtlasGpuBuffer, offset: number, data: BufferSource | ArrayBufferView): void\n submit(commandBuffers: unknown[]): void\n }\n readonly pushErrorScope?: (filter: AtlasErrorFilter) => void\n readonly popErrorScope?: () => Promise<{ readonly message?: string } | null>\n}\n\ntype AtlasPipelines = CommonJfaPipelines<AtlasPipeline, AtlasPipeline>\n\ninterface MultiPassPipelines {\n readonly sepHoriz: AtlasPipeline\n readonly sepVertStore: AtlasPipeline | null\n readonly resolve: AtlasPipeline | null\n}\n\ninterface Sep12Pipelines {\n readonly sepHorizPx12: AtlasPipeline\n readonly sepVertPx12: AtlasPipeline\n}\n\ninterface DevicePipelineCache {\n readonly workgroupDim: 8 | 16\n readonly directStore: boolean\n readonly includeWideTiled: boolean\n readonly layouts: JfaPipelineLayouts | null\n readonly module: unknown\n sep12?: Sep12Pipelines\n sep12Promise?: Promise<AtlasPipelines> | undefined\n tiledStore?: AtlasPipeline\n tiledPromise?: Promise<AtlasPipelines> | undefined\n tiledWide?: AtlasPipeline\n tiledWidePromise?: Promise<AtlasPipelines> | undefined\n multi?: MultiPassPipelines\n multiPromise?: Promise<AtlasPipelines> | undefined\n}\n\nconst devicePipelines = new WeakMap<AtlasDevice, DevicePipelineCache>()\n\nfunction asAtlasPipelines(\n workgroupDim: 8 | 16,\n directStore: boolean,\n layouts: JfaPipelineLayouts | null,\n tiledStore: AtlasPipeline | null,\n tiledStoreWide: AtlasPipeline | null,\n multi?: MultiPassPipelines,\n sep12?: Sep12Pipelines,\n): AtlasPipelines {\n return {\n workgroupDim,\n directStore,\n layouts,\n sepHoriz: multi?.sepHoriz ?? null,\n sepVertStore: multi?.sepVertStore ?? null,\n sepHorizPx12: sep12?.sepHorizPx12 ?? null,\n sepVertPx12: sep12?.sepVertPx12 ?? null,\n tiledStore,\n tiledStoreWide,\n resolve: multi?.resolve ?? null,\n }\n}\n\nfunction atlasModeFor(\n directStore: boolean,\n pxRange?: number,\n limits?: AtlasDeviceLimits,\n width = 0,\n height = 0,\n): AtlasModeKind {\n return selectAtlasMode(directStore, pxRange, limits, width, height)\n}\n\nfunction getDeviceCache(\n device: AtlasDevice,\n workgroupDim: 8 | 16,\n directStore: boolean,\n needWideTiled = false,\n): DevicePipelineCache {\n const existing = devicePipelines.get(device)\n if (\n existing?.workgroupDim === workgroupDim &&\n existing.directStore === directStore &&\n (!needWideTiled || existing.includeWideTiled)\n ) {\n return existing\n }\n const includeWideTiled = needWideTiled || !storageBufferFits(device.limits, 4096, 4096)\n const cache: DevicePipelineCache = {\n workgroupDim,\n directStore,\n includeWideTiled,\n layouts: getJfaLayouts(device),\n module: device.createShaderModule({\n label: 'ultra-text atlas',\n code: buildJfaWgsl(workgroupDim, directStore, true, includeWideTiled),\n }),\n }\n devicePipelines.set(device, cache)\n return cache\n}\n\nfunction cachedAtlasPipelines(\n device: AtlasDevice,\n workgroupDim: 8 | 16,\n directStore: boolean,\n mode: AtlasModeKind,\n): AtlasPipelines | undefined {\n const cache = devicePipelines.get(device)\n if (cache?.workgroupDim !== workgroupDim || cache.directStore !== directStore) return undefined\n if (mode === 'sep12') {\n return cache.sep12\n ? asAtlasPipelines(\n workgroupDim,\n directStore,\n cache.layouts,\n null,\n null,\n undefined,\n cache.sep12,\n )\n : undefined\n }\n if (mode === 'tiled12') {\n return cache.tiledStore\n ? asAtlasPipelines(workgroupDim, directStore, cache.layouts, cache.tiledStore, null)\n : undefined\n }\n if (mode === 'tiled32') {\n return cache.tiledWide\n ? asAtlasPipelines(workgroupDim, directStore, cache.layouts, null, cache.tiledWide)\n : undefined\n }\n return cache.multi\n ? asAtlasPipelines(workgroupDim, directStore, cache.layouts, null, null, cache.multi)\n : undefined\n}\n\nfunction supportsAsyncAtlasPipelines(device: AtlasDevice, directStore: boolean): boolean {\n return (\n typeof device.createComputePipelineAsync === 'function' &&\n (directStore || typeof device.createRenderPipelineAsync === 'function')\n )\n}\n\nfunction buildAtlasPipelines(\n device: AtlasDevice,\n workgroupDim: 8 | 16,\n directStore: boolean,\n mode: AtlasModeKind,\n async: true,\n): Promise<AtlasPipelines>\nfunction buildAtlasPipelines(\n device: AtlasDevice,\n workgroupDim: 8 | 16,\n directStore: boolean,\n mode: AtlasModeKind,\n async: false,\n): AtlasPipelines\nfunction buildAtlasPipelines(\n device: AtlasDevice,\n workgroupDim: 8 | 16,\n directStore: boolean,\n mode: AtlasModeKind,\n async: boolean,\n): AtlasPipelines | Promise<AtlasPipelines> {\n const cached = cachedAtlasPipelines(device, workgroupDim, directStore, mode)\n if (cached) return async ? Promise.resolve(cached) : cached\n\n const existing = devicePipelines.get(device)\n const sameConfig = existing?.workgroupDim === workgroupDim && existing.directStore === directStore\n if (async && sameConfig) {\n const inFlight =\n mode === 'sep12'\n ? existing.sep12Promise\n : mode === 'tiled12'\n ? existing.tiledPromise\n : mode === 'tiled32'\n ? existing.tiledWidePromise\n : existing.multiPromise\n if (inFlight) return inFlight\n }\n\n const cache = getDeviceCache(device, workgroupDim, directStore, mode === 'tiled32')\n const { module, layouts } = cache\n const computeSync = (entryPoint: string, layout: unknown) =>\n device.createComputePipeline({ layout, compute: { module, entryPoint } })\n const computeAsync = (entryPoint: string, layout: unknown) =>\n device.createComputePipelineAsync!({ layout, compute: { module, entryPoint } })\n\n if (mode === 'sep12') {\n const hLayout = layouts ? layouts.sepHorizPipeline : 'auto'\n const vLayout = layouts ? layouts.sepVertStorePipeline : 'auto'\n const storeSep12 = (\n sepHorizPx12: AtlasPipeline,\n sepVertPx12: AtlasPipeline,\n ): AtlasPipelines => {\n const sep12: Sep12Pipelines = { sepHorizPx12, sepVertPx12 }\n cache.sep12 = sep12\n return asAtlasPipelines(workgroupDim, directStore, layouts, null, null, undefined, sep12)\n }\n if (!async) {\n return storeSep12(computeSync('sepHorizPx12', hLayout), computeSync('sepVertPx12', vLayout))\n }\n const promise = Promise.all([\n computeAsync('sepHorizPx12', hLayout),\n computeAsync('sepVertPx12', vLayout),\n ]).then(\n ([h, v]) => storeSep12(h, v),\n (error: unknown) => {\n if (cache.sep12Promise === promise) cache.sep12Promise = undefined\n throw error\n },\n )\n cache.sep12Promise = promise\n return promise\n }\n\n if (mode === 'tiled12' || mode === 'tiled32') {\n const isWide = mode === 'tiled32'\n const entryPoint = isWide ? 'tiledStoreWideMain' : 'tiledStoreMain'\n const layout = layouts ? layouts.tiledPipeline : 'auto'\n const store = (pipeline: AtlasPipeline): AtlasPipelines => {\n if (isWide) cache.tiledWide = pipeline\n else cache.tiledStore = pipeline\n return asAtlasPipelines(\n workgroupDim,\n directStore,\n layouts,\n isWide ? null : pipeline,\n isWide ? pipeline : null,\n )\n }\n if (!async) return store(computeSync(entryPoint, layout))\n const promise = computeAsync(entryPoint, layout).then(\n (pipeline) => store(pipeline),\n (error: unknown) => {\n if (isWide) {\n if (cache.tiledWidePromise === promise) cache.tiledWidePromise = undefined\n } else if (cache.tiledPromise === promise) {\n cache.tiledPromise = undefined\n }\n throw error\n },\n )\n if (isWide) cache.tiledWidePromise = promise\n else cache.tiledPromise = promise\n return promise\n }\n\n const resolveDesc = {\n layout: layouts ? layouts.resolvePipeline : ('auto' as const),\n vertex: { module, entryPoint: 'fullscreenVert' },\n fragment: { module, entryPoint: 'resolveFrag', targets: [{ format: 'r8unorm' }] },\n }\n const store = (\n sepHoriz: AtlasPipeline,\n sepVertStore: AtlasPipeline | null,\n resolve: AtlasPipeline | null,\n ): AtlasPipelines => {\n const multi: MultiPassPipelines = { sepHoriz, sepVertStore, resolve }\n cache.multi = multi\n return asAtlasPipelines(workgroupDim, directStore, layouts, null, null, multi)\n }\n\n const horizLayout = layouts ? layouts.sepHorizPipeline : 'auto'\n const vertLayout = directStore && layouts ? layouts.sepVertStorePipeline : 'auto'\n if (!async) {\n return store(\n computeSync('sepHorizMain', horizLayout),\n directStore ? computeSync('sepVertStoreMain', vertLayout) : null,\n directStore ? null : device.createRenderPipeline(resolveDesc),\n )\n }\n\n const promise = Promise.all([\n computeAsync('sepHorizMain', horizLayout),\n directStore ? computeAsync('sepVertStoreMain', vertLayout) : Promise.resolve(null),\n directStore ? Promise.resolve(null) : device.createRenderPipelineAsync!(resolveDesc),\n ]).then(\n ([sepHoriz, sepVertStore, resolve]) => store(sepHoriz, sepVertStore, resolve),\n (error: unknown) => {\n if (cache.multiPromise === promise) cache.multiPromise = undefined\n throw error\n },\n )\n cache.multiPromise = promise\n return promise\n}\n\n/**\n * @internal Starts the native compile of the device's atlas passes ahead of its first atlas,\n * while the caller reads the DOM.\n */\nexport function prepareAtlasPasses(renderer: WebGPURenderer, pxRange?: number): void {\n const device = atlasDevice(renderer)\n if (!device?.createShaderModule) return\n const directStore = hasDirectStoreFeature(device.features)\n const workgroupDim = selectWorkgroupDimension(device.limits)\n const mode = atlasModeFor(directStore, pxRange)\n const cached = devicePipelines.get(device)\n const matches = cached?.workgroupDim === workgroupDim && cached.directStore === directStore\n if (\n matches &&\n (mode === 'sep12'\n ? cached.sep12 || cached.sep12Promise\n : mode === 'tiled12'\n ? cached.tiledStore || cached.tiledPromise\n : mode === 'tiled32'\n ? cached.tiledWide || cached.tiledWidePromise\n : cached.multi || cached.multiPromise)\n ) {\n return\n }\n if (supportsAsyncAtlasPipelines(device, directStore)) {\n void buildAtlasPipelines(device, workgroupDim, directStore, mode, true).catch(() => undefined)\n } else {\n buildAtlasPipelines(device, workgroupDim, directStore, mode, false)\n }\n device.queue.submit([])\n}\n\n/**\n * @internal Regenerates the mips of an atlas texture from its level 0 with three's own mip\n * pass, as three does for a render target, after the submissions that wrote it.\n */\nexport async function generateAtlasMips(renderer: WebGPURenderer, texture: Texture): Promise<void> {\n const scopes = openErrorScopes(atlasDevice(renderer)!)\n let reported: Promise<string | null>\n try {\n renderer.initTexture(texture)\n ;(renderer.backend as unknown as { generateMipmaps(texture: Texture): void }).generateMipmaps(\n texture,\n )\n } finally {\n reported = scopes.close()\n }\n const rejection = await reported\n if (rejection !== null) throw new Error(`buildGpuSdfAtlas: mip generation failed: ${rejection}`)\n}\n\n/** @internal The device behind a WebGPU-backend renderer, or `undefined`. */\nexport function atlasDevice(renderer: WebGPURenderer): AtlasDevice | undefined {\n return (renderer.backend as unknown as { device?: AtlasDevice }).device\n}\n\n/**\n * @internal Runs the atlas passes over `raster` into level 0 of a new r8unorm texture of\n * `mipLevelCount` levels, all in one command buffer.\n */\nexport async function encodeGpuSdf(\n device: AtlasDevice | undefined,\n raster: Pick<RasterAtlas, 'canvas' | 'width' | 'height' | 'pxRange'>,\n mipLevelCount: number,\n finish?: (encoder: AtlasEncoder, texture: AtlasGpuTexture) => void,\n onSubmitted?: (texture: AtlasGpuTexture) => void,\n extraTransient?: { destroy(): void }[],\n): Promise<AtlasGpuTexture> {\n const { width, height, pxRange, canvas } = raster\n const { GPUBufferUsage: buffers, GPUTextureUsage: textures } = globalThis as UsageGlobals\n if (!device?.createCommandEncoder || !buffers || !textures)\n throw new Error('buildGpuSdfAtlas: device cannot run the atlas passes')\n const radius = edtRadius(pxRange)\n const directStore = hasDirectStoreFeature(device.features)\n const mode = atlasModeFor(directStore, pxRange, device.limits, width, height)\n checkCommonAtlasLimits(\n 'buildGpuSdfAtlas',\n device.limits,\n width,\n height,\n radius,\n directStore,\n '; use atlasMode \"cpu\"',\n mode,\n )\n const workgroupDim = selectWorkgroupDimension(device.limits)\n let prebuilt = cachedAtlasPipelines(device, workgroupDim, directStore, mode)\n const cachedEntry = devicePipelines.get(device)\n const inFlight =\n !prebuilt &&\n cachedEntry?.workgroupDim === workgroupDim &&\n cachedEntry.directStore === directStore\n ? mode === 'sep12'\n ? cachedEntry.sep12Promise\n : mode === 'tiled12'\n ? cachedEntry.tiledPromise\n : mode === 'tiled32'\n ? cachedEntry.tiledWidePromise\n : cachedEntry.multiPromise\n : undefined\n if (inFlight) {\n try {\n prebuilt = await inFlight\n } catch (error: unknown) {\n throw new Error(\n `buildGpuSdfAtlas: the device rejected the atlas passes: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n )\n }\n }\n const pool = getDeviceGpuPool(device)\n const retainPool = pool.beginBuild()\n const transient: { destroy(): void }[] = []\n let output: AtlasGpuTexture | undefined\n let resolvedOk = false\n let buildEnded = false\n try {\n const scopes = openErrorScopes(device)\n let reported: Promise<string | null>\n try {\n const pipelines =\n prebuilt ?? buildAtlasPipelines(device, workgroupDim, directStore, mode, false)\n output = device.createTexture({\n size: [width, height],\n mipLevelCount,\n format: 'r8unorm',\n usage:\n textures.RENDER_ATTACHMENT |\n textures.TEXTURE_BINDING |\n textures.COPY_SRC |\n textures.COPY_DST |\n (pipelines.directStore ? (textures.STORAGE_BINDING ?? 0) : 0),\n })\n const encoder = device.createCommandEncoder()\n encodeJfaWork(\n device,\n encoder,\n pipelines,\n canvas,\n width,\n height,\n pxRange,\n radius,\n output,\n transient,\n buffers,\n textures,\n pool,\n )\n finish?.(encoder, output)\n if (extraTransient?.length) transient.push(...extraTransient)\n device.queue.submit([encoder.finish()])\n pool.resetRing()\n } finally {\n reported = scopes.close()\n }\n onSubmitted?.(output)\n const rejection = await reported\n if (rejection !== null) {\n devicePipelines.delete(device)\n throw new Error(`buildGpuSdfAtlas: the device rejected the atlas passes: ${rejection}`)\n }\n resolvedOk = true\n buildEnded = true\n pool.endBuild(transient, retainPool, false)\n transient.length = 0\n const retained = output\n output = undefined\n return retained\n } finally {\n if (!resolvedOk && !buildEnded) {\n pool.endBuild(transient, false, true)\n }\n output?.destroy()\n }\n}\n\n/**\n * Generates a compact R8 runtime SDF on the renderer's WebGPU device: boundary seeding and\n * 4-byte relative fixed-point jump flooding in compute passes, writing directly into `r8unorm`\n * when `'texture-formats-tier1'` is active on the device or resolving via a fullscreen render\n * pass on Core WebGPU 1.0 devices.\n */\nexport async function buildGpuSdfAtlas(\n renderer: WebGPURenderer,\n raster: RasterAtlas,\n options: Pick<BuildSdfAtlasOptions, 'mipmaps' | 'anisotropy'> = {},\n /** @internal */\n onProvisional?: (atlas: SdfAtlas) => void,\n): Promise<SdfAtlas> {\n await renderer.init()\n if (!(renderer.backend instanceof WebGPUBackend)) {\n throw new Error('buildGpuSdfAtlas: requires the WebGPU backend; use mode \"cpu\"')\n }\n const { width, height } = raster\n const mipmaps = options.mipmaps === true\n const levels = mipmaps ? Math.floor(Math.log2(Math.max(width, height))) + 1 : 1\n const { shapeTop } = raster as RasterAtlas & ShapeRows\n const maxAnisotropy = mipmaps ? renderer.getMaxAnisotropy() : 1\n const wrapAtlas = (gpuTexture: AtlasGpuTexture) => {\n const texture = new ExternalTexture(gpuTexture)\n let disposed = false\n let gpuDestroyed = false\n const dispose = (): void => {\n if (disposed) return\n disposed = true\n try {\n texture.dispose()\n } finally {\n if (!gpuDestroyed) {\n gpuDestroyed = true\n gpuTexture.destroy()\n }\n }\n }\n try {\n ;(texture as { image: unknown }).image = { width, height }\n texture.name = 'ultra-text SDF atlas'\n texture.format = RedFormat\n texture.colorSpace = NoColorSpace\n texture.generateMipmaps = mipmaps\n texture.minFilter = mipmaps ? LinearMipmapLinearFilter : LinearFilter\n texture.magFilter = LinearFilter\n texture.anisotropy = mipmaps\n ? Math.min(Math.max(1, options.anisotropy ?? 1), maxAnisotropy)\n : 1\n if (shapeTop !== undefined) texture.userData['ultraShapeTop'] = shapeTop\n } catch (error) {\n dispose()\n throw error\n }\n const atlas: SdfAtlas = {\n ...(shapeTop === undefined ? {} : { shapeTop }),\n texture,\n width,\n height,\n pxRange: raster.pxRange,\n bakeSize: raster.bakeSize,\n glyphs: raster.glyphs,\n mode: 'gpu',\n dispose,\n }\n return {\n atlas,\n markGpuDestroyed: () => {\n gpuDestroyed = true\n },\n }\n }\n\n const device = atlasDevice(renderer)\n const bleed: DeferredColorBleed | undefined =\n raster.colorBand && device ? peekDeferredColorBleed(raster.colorBand.data) : undefined\n\n if (onProvisional && !mipmaps && !bleed) {\n let wrapped: ReturnType<typeof wrapAtlas> | undefined\n try {\n const gpuTexture = await encodeGpuSdf(device, raster, levels, undefined, (candidate) => {\n wrapped = wrapAtlas(candidate)\n onProvisional(wrapped.atlas)\n })\n return wrapped ? wrapped.atlas : wrapAtlas(gpuTexture).atlas\n } catch (error) {\n if (wrapped) {\n wrapped.markGpuDestroyed()\n wrapped.atlas.dispose()\n }\n throw error\n }\n }\n\n const extraTransient: { destroy(): void }[] = []\n let colorGpuTex: CommonTextureLike | undefined\n const encodeBleed = (encoder: AtlasEncoder) => {\n if (!bleed || !device) return\n const colorMips = mipCount(width, bleed.height, mipmaps)\n const res = encodeGpuColorBleed(\n device as unknown as ColorBleedDeviceLike,\n encoder,\n bleed,\n colorMips,\n getDeviceGpuPool(device),\n )\n colorGpuTex = res.texture\n extraTransient.push(...res.transient)\n if (colorMips > 1) {\n const mip = getDeviceMipPipeline(device as unknown as VanillaGpuDevice, 'rgba8unorm-srgb')\n encodeMipmapChain(\n device as unknown as VanillaGpuDevice,\n encoder,\n colorGpuTex,\n colorMips,\n mip.pipeline,\n mip.sampler,\n mip.layout,\n )\n }\n }\n let gpuTexture: AtlasGpuTexture\n try {\n gpuTexture = await encodeGpuSdf(\n device,\n raster,\n levels,\n bleed ? encodeBleed : undefined,\n undefined,\n extraTransient,\n )\n } catch (error) {\n colorGpuTex?.destroy()\n throw error\n }\n if (colorGpuTex && raster.colorBand) {\n takeDeferredColorBleed(raster.colorBand.data)\n putReadyGpuColorTexture(raster.colorBand.data, colorGpuTex)\n }\n const { atlas } = wrapAtlas(gpuTexture)\n try {\n if (mipmaps) await generateAtlasMips(renderer, atlas.texture)\n } catch (error) {\n if (raster.colorBand) takeReadyGpuColorTexture(raster.colorBand.data)?.destroy()\n atlas.dispose()\n throw error\n }\n return atlas\n}\n"],"mappings":";;;;;AA2KA,IAAM,kCAAkB,IAAI,QAA0C;AAEtE,SAAS,iBACP,cACA,aACA,SACA,YACA,gBACA,OACA,OACgB;CAChB,OAAO;EACL;EACA;EACA;EACA,UAAU,OAAO,YAAY;EAC7B,cAAc,OAAO,gBAAgB;EACrC,cAAc,OAAO,gBAAgB;EACrC,aAAa,OAAO,eAAe;EACnC;EACA;EACA,SAAS,OAAO,WAAW;CAC7B;AACF;AAEA,SAAS,aACP,aACA,SACA,QACA,QAAQ,GACR,SAAS,GACM;CACf,OAAO,gBAAgB,aAAa,SAAS,QAAQ,OAAO,MAAM;AACpE;AAEA,SAAS,eACP,QACA,cACA,aACA,gBAAgB,OACK;CACrB,MAAM,WAAW,gBAAgB,IAA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CACF;CAEA,MAAM,iBAAwC,CAAC;CAC/C,IAAI;CACJ,MAAM,eAAe,YAA0B;EAC7C,IAAI,CAAC,SAAS,CAAC,QAAQ;EACvB,MAAM,YAAY,SAAS,OAAO,MAAM,QAAQ,OAAO;EACvD,MAAM,MAAM,oBACV,QACA,SACA,OACA,WACA,iBAAiB,MAAM,CACzB;EACA,cAAc,IAAI;EAClB,eAAe,KAAK,GAAG,IAAI,SAAS;EACpC,IAAI,YAAY,GAAG;GACjB,MAAM,MAAM,qBAAqB,QAAuC,iBAAiB;GACzF,kBACE,QACA,SACA,aACA,WACA,IAAI,UACJ,IAAI,SACJ,IAAI,MACN;EACF;CACF;CACA,IAAI;CACJ,IAAI;EACF,aAAa,MAAM,aACjB,QACA,QACA,QACA,QAAQ,cAAc,KAAA,GACtB,KAAA,GACA,cACF;CACF,SAAS,OAAO;EACd,aAAa,QAAQ;EACrB,MAAM;CACR;CACA,IAAI,eAAe,OAAO,WAAW;EACnC,uBAAuB,OAAO,UAAU,IAAI;EAC5C,wBAAwB,OAAO,UAAU,MAAM,WAAW;CAC5D;CACA,MAAM,EAAE,UAAU,UAAU,UAAU;CACtC,IAAI;EACF,IAAI,SAAS,MAAM,kBAAkB,UAAU,MAAM,OAAO;CAC9D,SAAS,OAAO;EACd,IAAI,OAAO,WAAW,yBAAyB,OAAO,UAAU,IAAI,CAAC,EAAE,QAAQ;EAC/E,MAAM,QAAQ;EACd,MAAM;CACR;CACA,OAAO;AACT"}
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
export declare const MIN_WORKGROUP_DIMENSION = 8;
|
|
2
2
|
export declare const CORE_WORKGROUP_DIMENSION = 16;
|
|
3
3
|
export declare const SEED_BYTES_PER_TEXEL = 4;
|
|
4
|
-
export declare const COMPUTE_STORAGE_BUFFERS =
|
|
4
|
+
export declare const COMPUTE_STORAGE_BUFFERS = 1;
|
|
5
5
|
export declare const FRAGMENT_STORAGE_BUFFERS = 1;
|
|
6
|
+
export declare const TILED_DEFAULT_PX_RANGE = 12;
|
|
7
|
+
export declare const TILED_MAX_PX_RANGE = 32;
|
|
8
|
+
export declare const TILED_MAX_TEXELS = 450000;
|
|
9
|
+
export declare const GLOBAL_MAX_EDT_RADIUS = 65;
|
|
10
|
+
export type AtlasModeKind = 'sep12' | 'tiled12' | 'tiled32' | 'multi';
|
|
6
11
|
export type AtlasErrorFilter = 'validation' | 'out-of-memory' | 'internal';
|
|
7
12
|
export interface AtlasDeviceLimitsLike {
|
|
8
13
|
readonly maxStorageBufferBindingSize?: number;
|
|
@@ -12,7 +17,9 @@ export interface AtlasDeviceLimitsLike {
|
|
|
12
17
|
readonly maxComputeWorkgroupSizeY?: number;
|
|
13
18
|
readonly maxStorageBuffersPerShaderStage?: number;
|
|
14
19
|
readonly maxStorageBuffersInFragmentStage?: number;
|
|
20
|
+
readonly maxStorageTexturesPerShaderStage?: number;
|
|
15
21
|
readonly maxTextureDimension2D?: number;
|
|
22
|
+
readonly minUniformBufferOffsetAlignment?: number;
|
|
16
23
|
}
|
|
17
24
|
export interface UsageGlobals {
|
|
18
25
|
GPUBufferUsage?: {
|
|
@@ -42,13 +49,6 @@ export interface CommonTextureLike {
|
|
|
42
49
|
destroy(): void;
|
|
43
50
|
}
|
|
44
51
|
export interface CommonCommandEncoderLike {
|
|
45
|
-
copyTextureToBuffer(source: {
|
|
46
|
-
texture: CommonTextureLike;
|
|
47
|
-
}, destination: {
|
|
48
|
-
buffer: CommonBufferLike;
|
|
49
|
-
bytesPerRow: number;
|
|
50
|
-
rowsPerImage: number;
|
|
51
|
-
}, size: [number, number]): void;
|
|
52
52
|
beginComputePass(): {
|
|
53
53
|
setPipeline(pipeline: CommonPipelineLike): void;
|
|
54
54
|
setBindGroup(index: number, bindGroup: unknown): void;
|
|
@@ -69,6 +69,7 @@ export interface CommonCommandEncoderLike {
|
|
|
69
69
|
};
|
|
70
70
|
}
|
|
71
71
|
export interface CommonJfaDeviceLike {
|
|
72
|
+
readonly limits?: AtlasDeviceLimitsLike;
|
|
72
73
|
createBuffer(descriptor: {
|
|
73
74
|
size: number;
|
|
74
75
|
usage: number;
|
|
@@ -79,6 +80,10 @@ export interface CommonJfaDeviceLike {
|
|
|
79
80
|
format: string;
|
|
80
81
|
usage: number;
|
|
81
82
|
}): CommonTextureLike;
|
|
83
|
+
createBindGroupLayout?(descriptor: object): unknown;
|
|
84
|
+
createPipelineLayout?(descriptor: {
|
|
85
|
+
bindGroupLayouts: unknown[];
|
|
86
|
+
}): unknown;
|
|
82
87
|
createBindGroup(descriptor: {
|
|
83
88
|
layout: unknown;
|
|
84
89
|
entries: {
|
|
@@ -87,7 +92,7 @@ export interface CommonJfaDeviceLike {
|
|
|
87
92
|
}[];
|
|
88
93
|
}): unknown;
|
|
89
94
|
readonly queue: {
|
|
90
|
-
writeBuffer(buffer: CommonBufferLike, offset: number, data:
|
|
95
|
+
writeBuffer(buffer: CommonBufferLike, offset: number, data: BufferSource | ArrayBufferView): void;
|
|
91
96
|
copyExternalImageToTexture(source: {
|
|
92
97
|
source: HTMLCanvasElement;
|
|
93
98
|
flipY: boolean;
|
|
@@ -97,23 +102,37 @@ export interface CommonJfaDeviceLike {
|
|
|
97
102
|
}, size: [number, number]): void;
|
|
98
103
|
};
|
|
99
104
|
}
|
|
105
|
+
export interface JfaPipelineLayouts {
|
|
106
|
+
readonly tiledGroup: unknown;
|
|
107
|
+
readonly tiledPipeline: unknown;
|
|
108
|
+
readonly sepHorizGroup: unknown;
|
|
109
|
+
readonly sepHorizPipeline: unknown;
|
|
110
|
+
readonly sepVertStoreGroup: unknown;
|
|
111
|
+
readonly sepVertStorePipeline: unknown;
|
|
112
|
+
readonly resolveGroup: unknown;
|
|
113
|
+
readonly resolvePipeline: unknown;
|
|
114
|
+
}
|
|
100
115
|
export interface CommonJfaPipelines<P extends CommonPipelineLike = CommonPipelineLike, R extends CommonPipelineLike = CommonPipelineLike> {
|
|
101
116
|
readonly workgroupDim: 8 | 16;
|
|
102
117
|
readonly directStore: boolean;
|
|
103
|
-
readonly
|
|
104
|
-
readonly
|
|
105
|
-
readonly
|
|
118
|
+
readonly layouts?: JfaPipelineLayouts | null;
|
|
119
|
+
readonly sepHoriz: P | null;
|
|
120
|
+
readonly sepVertStore: P | null;
|
|
121
|
+
readonly sepHorizPx12?: P | null;
|
|
122
|
+
readonly sepVertPx12?: P | null;
|
|
106
123
|
readonly tiledStore: P | null;
|
|
124
|
+
readonly tiledStoreWide: P | null;
|
|
107
125
|
readonly resolve: R | null;
|
|
108
126
|
}
|
|
127
|
+
export declare function storageBufferFits(limits: AtlasDeviceLimitsLike | undefined, width: number, height: number): boolean;
|
|
109
128
|
export declare function prefersTiledJfa(directStore: boolean, pxRange?: number): boolean;
|
|
129
|
+
export declare function selectAtlasMode(directStore: boolean, pxRange: number | undefined, limits?: AtlasDeviceLimitsLike, width?: number, height?: number): AtlasModeKind;
|
|
110
130
|
export declare function selectWorkgroupDimension(limits?: AtlasDeviceLimitsLike): 8 | 16;
|
|
111
131
|
export declare function supportsDirectStore(features?: {
|
|
112
132
|
has(name: string): boolean;
|
|
113
133
|
}): boolean;
|
|
114
|
-
export declare function
|
|
115
|
-
export declare function
|
|
116
|
-
export declare function checkCommonAtlasLimits(caller: string, limits: AtlasDeviceLimitsLike | undefined, width: number, height: number, maxStep: number, directStore: boolean, cpuHint?: string): void;
|
|
134
|
+
export declare function edtRadius(pxRange: number): number;
|
|
135
|
+
export declare function checkCommonAtlasLimits(caller: string, limits: AtlasDeviceLimitsLike | undefined, width: number, height: number, radius: number, directStore: boolean, cpuHint?: string, mode?: AtlasModeKind): void;
|
|
117
136
|
export declare function openErrorScopes(device: {
|
|
118
137
|
readonly pushErrorScope?: (filter: AtlasErrorFilter) => void;
|
|
119
138
|
readonly popErrorScope?: () => Promise<{
|
|
@@ -122,14 +141,117 @@ export declare function openErrorScopes(device: {
|
|
|
122
141
|
}): {
|
|
123
142
|
close(): Promise<string | null>;
|
|
124
143
|
};
|
|
125
|
-
export declare
|
|
144
|
+
export declare const POOL_IDLE_TRIM_MS = 5000;
|
|
145
|
+
export declare const POOL_RING_BYTES: number;
|
|
146
|
+
export declare const POOL_STAGING_ROUND = 64;
|
|
147
|
+
export declare function poolSizeClass(size: number, maxBufferSize?: number): number;
|
|
148
|
+
export interface AtlasGpuPoolStats {
|
|
149
|
+
readonly liveBuffers: number;
|
|
150
|
+
readonly liveTextures: number;
|
|
151
|
+
readonly liveBytes: number;
|
|
152
|
+
readonly idleBytes: number;
|
|
153
|
+
readonly createdBuffers: number;
|
|
154
|
+
readonly createdTextures: number;
|
|
155
|
+
readonly reused: number;
|
|
156
|
+
readonly idle: number;
|
|
157
|
+
readonly live: number;
|
|
158
|
+
}
|
|
159
|
+
export interface AtlasGpuPool {
|
|
160
|
+
beginBuild(): boolean;
|
|
161
|
+
endBuild(transient: readonly {
|
|
162
|
+
destroy(): void;
|
|
163
|
+
}[], retain: boolean, failed?: boolean): void;
|
|
164
|
+
buffer(size: number, usage: number): CommonBufferLike;
|
|
165
|
+
uploadTexture(width: number, height: number, format: string, usage: number): CommonTextureLike;
|
|
166
|
+
ringAlloc(bytes: number, usage: number): {
|
|
167
|
+
buffer: CommonBufferLike;
|
|
168
|
+
offset: number;
|
|
169
|
+
};
|
|
170
|
+
resetRing(): void;
|
|
171
|
+
discardRing(): void;
|
|
172
|
+
give(resource: CommonBufferLike | CommonTextureLike | null | undefined): void;
|
|
173
|
+
discard(resource: CommonBufferLike | CommonTextureLike | null | undefined): void;
|
|
174
|
+
trim(all?: boolean): void;
|
|
175
|
+
stats(): AtlasGpuPoolStats;
|
|
176
|
+
destroy(): void;
|
|
177
|
+
}
|
|
178
|
+
export declare function createGpuPool(device: CommonJfaDeviceLike, options?: {
|
|
179
|
+
readonly now?: () => number;
|
|
180
|
+
readonly setTimer?: (fn: () => void, ms: number) => unknown;
|
|
181
|
+
readonly clearTimer?: (id: unknown) => void;
|
|
182
|
+
}): AtlasGpuPool;
|
|
183
|
+
export declare function getDeviceGpuPool(device: CommonJfaDeviceLike): AtlasGpuPool;
|
|
184
|
+
export declare function getJfaLayouts(device: CommonJfaDeviceLike): JfaPipelineLayouts | null;
|
|
185
|
+
export declare function encodeJfaWork(device: CommonJfaDeviceLike, encoder: CommonCommandEncoderLike, pipelines: CommonJfaPipelines, canvas: HTMLCanvasElement, width: number, height: number, pxRange: number, radius: number, output: CommonTextureLike, transient: {
|
|
126
186
|
destroy(): void;
|
|
127
187
|
}[], buffers: {
|
|
128
188
|
COPY_DST: number;
|
|
129
189
|
UNIFORM: number;
|
|
130
190
|
STORAGE: number;
|
|
131
191
|
}, textures: {
|
|
132
|
-
COPY_SRC: number;
|
|
133
192
|
COPY_DST: number;
|
|
193
|
+
TEXTURE_BINDING: number;
|
|
134
194
|
RENDER_ATTACHMENT: number;
|
|
135
|
-
}): CommonTextureLike;
|
|
195
|
+
}, pool?: AtlasGpuPool): CommonTextureLike;
|
|
196
|
+
/** Deferred CPU dilation payload when GPU color-band bleed will run on the GPU device. */
|
|
197
|
+
export interface DeferredColorBleed {
|
|
198
|
+
readonly white: Uint8ClampedArray;
|
|
199
|
+
readonly black: Uint8ClampedArray;
|
|
200
|
+
readonly width: number;
|
|
201
|
+
readonly height: number;
|
|
202
|
+
readonly pxRange: number;
|
|
203
|
+
readonly applyCpu: () => void;
|
|
204
|
+
}
|
|
205
|
+
export declare function registerDeferredColorBleed(data: Uint8Array, entry: DeferredColorBleed): void;
|
|
206
|
+
export declare function peekDeferredColorBleed(data: Uint8Array): DeferredColorBleed | undefined;
|
|
207
|
+
export declare function takeDeferredColorBleed(data: Uint8Array): DeferredColorBleed | undefined;
|
|
208
|
+
export declare function flushDeferredColorBleed(data: Uint8Array): void;
|
|
209
|
+
export declare function putReadyGpuColorTexture(data: Uint8Array, texture: CommonTextureLike): void;
|
|
210
|
+
export declare function takeReadyGpuColorTexture(data: Uint8Array): CommonTextureLike | undefined;
|
|
211
|
+
export interface ColorBleedDeviceLike extends CommonJfaDeviceLike {
|
|
212
|
+
createShaderModule(descriptor: {
|
|
213
|
+
label?: string;
|
|
214
|
+
code: string;
|
|
215
|
+
}): unknown;
|
|
216
|
+
createComputePipeline(descriptor: {
|
|
217
|
+
layout: unknown;
|
|
218
|
+
compute: {
|
|
219
|
+
module: unknown;
|
|
220
|
+
entryPoint: string;
|
|
221
|
+
};
|
|
222
|
+
}): CommonPipelineLike;
|
|
223
|
+
createRenderPipeline(descriptor: {
|
|
224
|
+
layout: unknown;
|
|
225
|
+
vertex: {
|
|
226
|
+
module: unknown;
|
|
227
|
+
entryPoint: string;
|
|
228
|
+
};
|
|
229
|
+
fragment: {
|
|
230
|
+
module: unknown;
|
|
231
|
+
entryPoint: string;
|
|
232
|
+
targets: {
|
|
233
|
+
format: string;
|
|
234
|
+
}[];
|
|
235
|
+
};
|
|
236
|
+
}): CommonPipelineLike;
|
|
237
|
+
createCommandEncoder(): CommonCommandEncoderLike & {
|
|
238
|
+
finish(): unknown;
|
|
239
|
+
};
|
|
240
|
+
readonly queue: CommonJfaDeviceLike['queue'] & {
|
|
241
|
+
writeTexture(destination: {
|
|
242
|
+
texture: CommonTextureLike;
|
|
243
|
+
mipLevel?: number;
|
|
244
|
+
}, data: BufferSource | ArrayBufferView, dataLayout: {
|
|
245
|
+
offset?: number;
|
|
246
|
+
bytesPerRow: number;
|
|
247
|
+
rowsPerImage?: number;
|
|
248
|
+
}, size: [number, number]): void;
|
|
249
|
+
submit(commandBuffers: unknown[]): void;
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
export declare function encodeGpuColorBleed(device: ColorBleedDeviceLike, encoder: CommonCommandEncoderLike, bleed: DeferredColorBleed, mipLevelCount: number, pool?: AtlasGpuPool): {
|
|
253
|
+
texture: CommonTextureLike;
|
|
254
|
+
transient: {
|
|
255
|
+
destroy(): void;
|
|
256
|
+
}[];
|
|
257
|
+
};
|