ultra-text 1.0.1 → 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 +339 -1039
- package/dist/assets/cpuSdf.worker-Dy4P5_TI.js +466 -0
- 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 +97 -31
- package/dist/atlas/appendAtlas.js.map +1 -1
- package/dist/atlas/buildAtlas.js +4 -3
- 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.d.ts +4 -1
- package/dist/atlas/cpuAtlas.js +14 -7
- package/dist/atlas/cpuAtlas.js.map +1 -1
- package/dist/atlas/cpuSdf.d.ts +1 -1
- package/dist/atlas/cpuSdf.js +235 -68
- package/dist/atlas/cpuSdf.js.map +1 -1
- package/dist/atlas/cpuWorker.d.ts +11 -3
- package/dist/atlas/cpuWorker.js +179 -22
- package/dist/atlas/cpuWorker.js.map +1 -1
- package/dist/atlas/gpuAtlas.js +188 -287
- package/dist/atlas/gpuAtlas.js.map +1 -1
- package/dist/atlas/gpuCommon.d.ts +257 -0
- package/dist/atlas/gpuCommon.js +845 -0
- package/dist/atlas/gpuCommon.js.map +1 -0
- package/dist/atlas/jfaWgsl.d.ts +1 -1
- package/dist/atlas/jfaWgsl.js +226 -249
- package/dist/atlas/jfaWgsl.js.map +1 -1
- package/dist/atlas/rasterize.d.ts +22 -0
- package/dist/atlas/rasterize.js +329 -158
- package/dist/atlas/rasterize.js.map +1 -1
- package/dist/atlas/shapeRaster.js +2 -1
- package/dist/atlas/shapeRaster.js.map +1 -1
- package/dist/atlas/vanillaBounds.d.ts +64 -0
- package/dist/atlas/vanillaBounds.js +42 -0
- package/dist/atlas/vanillaBounds.js.map +1 -0
- package/dist/atlas/vanillaCore.d.ts +100 -0
- package/dist/atlas/vanillaCore.js +1065 -0
- package/dist/atlas/vanillaCore.js.map +1 -0
- package/dist/atlas/vanillaCpuAtlas.d.ts +9 -0
- package/dist/atlas/vanillaCpuAtlas.js +72 -0
- package/dist/atlas/vanillaCpuAtlas.js.map +1 -0
- package/dist/atlas/vanillaExtras.d.ts +8 -0
- package/dist/atlas/vanillaExtras.js +167 -0
- package/dist/atlas/vanillaExtras.js.map +1 -0
- package/dist/atlas/vanillaGpuHelpers.d.ts +295 -0
- package/dist/atlas/vanillaGpuHelpers.js +354 -0
- package/dist/atlas/vanillaGpuHelpers.js.map +1 -0
- package/dist/dom/DomSdf.js +243 -297
- package/dist/dom/DomSdf.js.map +1 -1
- package/dist/dom/DomSlug.js +94 -165
- 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 +53 -0
- package/dist/dom/domAnalytic.js +282 -0
- package/dist/dom/domAnalytic.js.map +1 -0
- package/dist/dom/domExtras.d.ts +27 -0
- package/dist/dom/domExtras.js +137 -0
- package/dist/dom/domExtras.js.map +1 -0
- package/dist/dom/fontCanvas.d.ts +16 -0
- package/dist/dom/fontCanvas.js +31 -13
- package/dist/dom/fontCanvas.js.map +1 -1
- package/dist/dom/layoutSignature.js +175 -57
- 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 +78 -28
- package/dist/dom/pretextLayout.js.map +1 -1
- package/dist/dom/snapshot.d.ts +4 -0
- package/dist/dom/snapshot.js +891 -484
- 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.d.ts +8 -1
- package/dist/dom/svgCapture.js +105 -28
- 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 +91 -44
- package/dist/dom/tone.js.map +1 -1
- package/dist/index.js +4 -3
- package/dist/slug/SlugMaterial.d.ts +17 -3
- package/dist/slug/SlugMaterial.js +98 -26
- 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 +19 -15
- package/dist/slug/coverage.js +380 -225
- package/dist/slug/coverage.js.map +1 -1
- package/dist/slug/preprocessCore.d.ts +6 -2
- package/dist/slug/preprocessCore.js +199 -148
- package/dist/slug/preprocessCore.js.map +1 -1
- package/dist/slug/runtime.d.ts +1 -0
- package/dist/slug/runtime.js +113 -74
- package/dist/slug/runtime.js.map +1 -1
- package/dist/slug/standaloneRuntime.d.ts +3 -2
- package/dist/slug/standaloneRuntime.js +112 -67
- package/dist/slug/standaloneRuntime.js.map +1 -1
- package/dist/slug/truetype.d.ts +14 -6
- package/dist/slug/truetype.js +356 -255
- package/dist/slug/truetype.js.map +1 -1
- package/dist/slug/vanillaCore.d.ts +410 -0
- package/dist/slug/vanillaCore.js +1630 -0
- package/dist/slug/vanillaCore.js.map +1 -0
- package/dist/slug-vanilla.d.ts +13 -364
- package/dist/slug-vanilla.js +7 -1454
- package/dist/slug.d.ts +2 -2
- package/dist/slug.js +7 -7
- package/dist/text/GlyphTextMaterial.d.ts +6 -1
- package/dist/text/GlyphTextMaterial.js +16 -12
- 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 +125 -38
- package/dist/text/SdfTextMaterial.js.map +1 -1
- package/dist/text/decorations.d.ts +7 -2
- package/dist/text/decorations.js +187 -79
- package/dist/text/decorations.js.map +1 -1
- package/dist/text/geometry.d.ts +3 -22
- package/dist/text/geometryUtils.d.ts +16 -1
- package/dist/text/geometryUtils.js +83 -8
- package/dist/text/geometryUtils.js.map +1 -1
- package/dist/text/glyphGeometry.d.ts +9 -0
- package/dist/text/glyphGeometry.js +434 -0
- package/dist/text/glyphGeometry.js.map +1 -0
- package/dist/text/index.d.ts +2 -1
- package/dist/text/rectGeometry.d.ts +13 -0
- package/dist/text/rectGeometry.js +101 -0
- package/dist/text/rectGeometry.js.map +1 -0
- package/dist/text/reflow.d.ts +23 -1
- package/dist/text/reflow.js +223 -94
- package/dist/text/reflow.js.map +1 -1
- package/dist/text/snap.d.ts +15 -0
- package/dist/text/snap.js +26 -0
- package/dist/text/snap.js.map +1 -0
- 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.d.ts +13 -363
- package/dist/vanilla.js +7 -1474
- 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 +17 -2
- package/dist/windfoil/geometry.js +220 -57
- 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.d.ts +1 -0
- package/dist/windfoil/mixed.js +57 -29
- package/dist/windfoil/mixed.js.map +1 -1
- package/dist/windfoil/preprocess.js +2 -2
- package/dist/windfoil/preprocessCore.d.ts +2 -0
- package/dist/windfoil/preprocessCore.js +69 -37
- 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 +4 -1
- package/dist/windfoil/runtime.js +69 -63
- 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 +78 -6
- package/dist/windfoil/storage.js +166 -11
- 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.d.ts +5 -0
- package/dist/windfoil/trace/contours.js +256 -62
- package/dist/windfoil/trace/contours.js.map +1 -1
- package/dist/windfoil/trace/fit.d.ts +3 -1
- package/dist/windfoil/trace/fit.js +915 -265
- package/dist/windfoil/trace/fit.js.map +1 -1
- package/dist/windfoil/trace/outline.js +55 -30
- package/dist/windfoil/trace/outline.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/trace/types.d.ts +10 -0
- package/dist/windfoil/tracedOutlines.d.ts +2 -0
- package/dist/windfoil/tracedOutlines.js +393 -103
- 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 +27 -25
- package/skills/ultra-text/references/vanilla-webgpu.md +5 -2
- package/dist/assets/cpuSdf.worker-xS57yQbP.js +0 -322
- package/dist/assets/cpuSdf.worker-xS57yQbP.js.map +0 -1
- package/dist/slug-vanilla.js.map +0 -1
- package/dist/text/geometry.js +0 -348
- package/dist/text/geometry.js.map +0 -1
- package/dist/vanilla.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gpuAtlas.js","names":[],"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 { buildJfaWgsl } from './jfaWgsl.js'\nimport type { ShapeRows } from './rasterize.js'\n\n// Compatibility mode guarantees 128 invocations (8×8 = 64); core WebGPU devices provide >= 256\n// (16×16 = 256). Both visit neighbours in identical order and produce identical SDF bytes.\nconst MIN_WORKGROUP_DIMENSION = 8\nconst CORE_WORKGROUP_DIMENSION = 16\nconst SEED_BYTES_PER_TEXEL = 4\nconst COMPUTE_STORAGE_BUFFERS = 2\nconst FRAGMENT_STORAGE_BUFFERS = 1\n\ninterface AtlasDeviceLimits {\n readonly maxStorageBufferBindingSize: number\n readonly maxBufferSize: number\n readonly maxComputeInvocationsPerWorkgroup?: number\n readonly maxComputeWorkgroupSizeX?: number\n readonly maxComputeWorkgroupSizeY?: number\n readonly maxStorageBuffersPerShaderStage?: number\n readonly maxStorageBuffersInFragmentStage?: number\n readonly maxTextureDimension2D?: number\n}\n\ntype AtlasErrorFilter = 'validation' | 'out-of-memory' | 'internal'\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\ninterface UsageFlags {\n GPUBufferUsage?: { STORAGE: number; UNIFORM: number; COPY_DST: number }\n GPUTextureUsage?: {\n COPY_SRC: number\n COPY_DST: number\n TEXTURE_BINDING: number\n STORAGE_BINDING?: number\n RENDER_ATTACHMENT: number\n }\n}\n\nconst KERNEL_NEEDS = [\n ['maxComputeInvocationsPerWorkgroup', MIN_WORKGROUP_DIMENSION ** 2],\n ['maxComputeWorkgroupSizeX', MIN_WORKGROUP_DIMENSION],\n ['maxComputeWorkgroupSizeY', MIN_WORKGROUP_DIMENSION],\n ['maxStorageBuffersPerShaderStage', COMPUTE_STORAGE_BUFFERS],\n] as const satisfies readonly (readonly [keyof AtlasDeviceLimits, number])[]\n\nfunction selectWorkgroupDimension(limits?: AtlasDeviceLimits): 8 | 16 {\n const inv = limits?.maxComputeInvocationsPerWorkgroup ?? 256\n const wx = limits?.maxComputeWorkgroupSizeX ?? 256\n const wy = limits?.maxComputeWorkgroupSizeY ?? 256\n return inv >= CORE_WORKGROUP_DIMENSION ** 2 &&\n wx >= CORE_WORKGROUP_DIMENSION &&\n wy >= CORE_WORKGROUP_DIMENSION\n ? CORE_WORKGROUP_DIMENSION\n : MIN_WORKGROUP_DIMENSION\n}\n\nfunction supportsDirectStore(device: AtlasDevice): boolean {\n const textures = (globalThis as UsageFlags).GPUTextureUsage\n return (\n typeof textures?.STORAGE_BINDING === 'number' &&\n textures.STORAGE_BINDING > 0 &&\n Boolean(device.features?.has('texture-formats-tier1'))\n )\n}\n\n/** A texture-to-buffer copy aligns each row to 256 bytes; the raster keeps 4 bytes a texel. */\nfunction rasterRowBytes(width: number): number {\n return Math.ceil(width / 64) * 256\n}\n\n/**\n * Past a device limit the passes are invalid, which WebGPU reports only asynchronously:\n * checking first lets `auto` fall back without GPU work and `gpu` fail with a reason.\n */\nfunction checkAtlasLimits(\n limits: AtlasDeviceLimits | undefined,\n width: number,\n height: number,\n maxStep: number,\n directStore: boolean,\n): void {\n if (maxStep > 64) {\n throw new RangeError(\n 'buildGpuSdfAtlas: pxRange exceeds fixed-point jump range; use atlasMode \"cpu\"',\n )\n }\n if (!limits) return\n for (const [name, need] of KERNEL_NEEDS) {\n const value = limits[name]\n if (value !== undefined && value < need) {\n throw new RangeError(`buildGpuSdfAtlas: ${name}=${value}, needs ${need}; use atlasMode \"cpu\"`)\n }\n }\n if (!directStore) {\n const fragBuffers = limits.maxStorageBuffersInFragmentStage\n if (fragBuffers !== undefined && fragBuffers < FRAGMENT_STORAGE_BUFFERS) {\n throw new RangeError(\n `buildGpuSdfAtlas: maxStorageBuffersInFragmentStage=${fragBuffers}, needs ${FRAGMENT_STORAGE_BUFFERS}; use atlasMode \"cpu\"`,\n )\n }\n }\n const largest = limits.maxTextureDimension2D\n if (largest !== undefined && Math.max(width, height) > largest) {\n throw new RangeError(\n `buildGpuSdfAtlas: ${width}×${height} exceeds maxTextureDimension2D=${largest}; lower maxAtlasSize`,\n )\n }\n // Each ping-pong seed buffer holds one packed u32 fixed-point relative seed (4 bytes) per texel.\n const bytes = Math.max(width * height * SEED_BYTES_PER_TEXEL, rasterRowBytes(width) * height)\n if (bytes > limits.maxStorageBufferBindingSize || bytes > limits.maxBufferSize) {\n throw new RangeError(\n `buildGpuSdfAtlas: ${width}×${height} exceeds storage-buffer limits; use atlasMode \"cpu\" or lower maxAtlasSize`,\n )\n }\n}\n\nconst ERROR_FILTERS: readonly AtlasErrorFilter[] = ['validation', 'out-of-memory', 'internal']\n\nfunction openErrorScopes(device: AtlasDevice): { close(): Promise<string | null> } {\n const push = device.pushErrorScope\n const pop = device.popErrorScope\n if (!push || !pop) {\n return { close: () => Promise.resolve(null) }\n }\n for (const filter of ERROR_FILTERS) push.call(device, filter)\n return {\n close() {\n return Promise.all(ERROR_FILTERS.map(() => pop.call(device))).then(\n (errors) => {\n const error = errors.find(Boolean)\n return error ? (error.message ?? 'unknown GPU error') : null\n },\n (error: unknown) => String(error),\n )\n },\n }\n}\n\nfunction jfaSteps(pxRange: number): number[] {\n const radius = Math.ceil(pxRange * 0.5) + 1\n let step = 1\n while (step * 2 - 1 < radius) step <<= 1\n const steps: number[] = []\n for (; step >= 1; step >>= 1) steps.push(step)\n return steps\n}\n\ninterface AtlasPipelines {\n readonly workgroupDim: 8 | 16\n readonly directStore: boolean\n readonly seed: AtlasPipeline\n readonly jump: AtlasPipeline\n readonly jumpStore: AtlasPipeline | null\n readonly resolve: AtlasPipeline | null\n}\n\nconst devicePipelines = new WeakMap<AtlasDevice, AtlasPipelines>()\nconst devicePipelinePromises = new WeakMap<\n AtlasDevice,\n {\n readonly workgroupDim: 8 | 16\n readonly directStore: boolean\n readonly promise: Promise<AtlasPipelines>\n }\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 atlasPipelinesSync(\n device: AtlasDevice,\n workgroupDim: 8 | 16,\n directStore: boolean,\n): AtlasPipelines {\n const cached = devicePipelines.get(device)\n if (cached?.directStore === directStore && cached.workgroupDim === workgroupDim) {\n return cached\n }\n const module = device.createShaderModule({\n label: 'ultra-text atlas',\n code: buildJfaWgsl(workgroupDim, directStore),\n })\n const compute = (entryPoint: string): AtlasPipeline =>\n device.createComputePipeline({ layout: 'auto', compute: { module, entryPoint } })\n const pipelines: AtlasPipelines = {\n workgroupDim,\n directStore,\n seed: compute('seedMain'),\n jump: compute('jumpMain'),\n jumpStore: directStore ? compute('jumpStoreMain') : null,\n resolve: directStore\n ? null\n : device.createRenderPipeline({\n layout: 'auto',\n vertex: { module, entryPoint: 'fullscreenVert' },\n fragment: { module, entryPoint: 'resolveFrag', targets: [{ format: 'r8unorm' }] },\n }),\n }\n devicePipelines.set(device, pipelines)\n return pipelines\n}\n\nfunction atlasPipelinesAsync(\n device: AtlasDevice,\n workgroupDim: 8 | 16,\n directStore: boolean,\n): Promise<AtlasPipelines> {\n const cached = devicePipelines.get(device)\n if (cached?.directStore === directStore && cached.workgroupDim === workgroupDim) {\n return Promise.resolve(cached)\n }\n const inFlight = devicePipelinePromises.get(device)\n if (inFlight?.directStore === directStore && inFlight.workgroupDim === workgroupDim) {\n return inFlight.promise\n }\n const module = device.createShaderModule({\n label: 'ultra-text atlas',\n code: buildJfaWgsl(workgroupDim, directStore),\n })\n const computeAsync = (entryPoint: string): Promise<AtlasPipeline> =>\n device.createComputePipelineAsync!({ layout: 'auto', compute: { module, entryPoint } })\n const promise = Promise.all([\n computeAsync('seedMain'),\n computeAsync('jumpMain'),\n directStore ? computeAsync('jumpStoreMain') : Promise.resolve(null),\n directStore\n ? Promise.resolve(null)\n : device.createRenderPipelineAsync!({\n layout: 'auto',\n vertex: { module, entryPoint: 'fullscreenVert' },\n fragment: { module, entryPoint: 'resolveFrag', targets: [{ format: 'r8unorm' }] },\n }),\n ]).then(\n ([seed, jump, jumpStore, resolve]) => {\n const pipelines: AtlasPipelines = {\n workgroupDim,\n directStore,\n seed,\n jump,\n jumpStore,\n resolve,\n }\n devicePipelines.set(device, pipelines)\n return pipelines\n },\n (error: unknown) => {\n devicePipelinePromises.delete(device)\n throw error\n },\n )\n devicePipelinePromises.set(device, { workgroupDim, directStore, 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): void {\n const device = atlasDevice(renderer)\n if (\n device?.createShaderModule &&\n !devicePipelines.has(device) &&\n !devicePipelinePromises.has(device)\n ) {\n const directStore = supportsDirectStore(device)\n const workgroupDim = selectWorkgroupDimension(device.limits)\n if (supportsAsyncAtlasPipelines(device, directStore)) {\n void atlasPipelinesAsync(device, workgroupDim, directStore).catch(() => undefined)\n } else {\n atlasPipelinesSync(device, workgroupDim, directStore)\n }\n device.queue.submit([])\n }\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 } = raster\n const { GPUBufferUsage: buffers, GPUTextureUsage: textures } = globalThis as UsageFlags\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 = supportsDirectStore(device)\n checkAtlasLimits(device.limits, width, height, steps[0]!, directStore)\n const workgroupDim = selectWorkgroupDimension(device.limits)\n let prebuilt: AtlasPipelines | undefined = devicePipelines.get(device)\n if (\n !(prebuilt?.directStore === directStore && prebuilt.workgroupDim === workgroupDim) &&\n supportsAsyncAtlasPipelines(device, directStore)\n ) {\n try {\n prebuilt = await atlasPipelinesAsync(device, workgroupDim, directStore)\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 } else if (!(prebuilt?.directStore === directStore && prebuilt.workgroupDim === workgroupDim)) {\n prebuilt = undefined\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 = prebuilt ?? atlasPipelinesSync(device, workgroupDim, directStore)\n const rowBytes = rasterRowBytes(width)\n const buffer = (size: number, usage: number): AtlasGpuBuffer => {\n const created = device.createBuffer({ size, usage })\n transient.push(created)\n return created\n }\n const upload = device.createTexture({\n size: [width, height],\n format: 'rgba8unorm',\n usage: textures.COPY_SRC | textures.COPY_DST | textures.RENDER_ATTACHMENT,\n })\n transient.push(upload)\n const words = buffer(rowBytes * height, buffers.STORAGE | buffers.COPY_DST)\n const seedBytes = width * height * SEED_BYTES_PER_TEXEL\n const seeds = [buffer(seedBytes, buffers.STORAGE), buffer(seedBytes, buffers.STORAGE)]\n // Uniform slots 256 bytes apart: seed/resolve parameters at 0, then one per jump step.\n const params = buffer(steps.length * 256 + 16, buffers.UNIFORM | buffers.COPY_DST)\n const values = new Int32Array(steps.length * 64 + 4)\n const invPxRange = 1 / pxRange\n values.set([width, height, rowBytes / 4])\n new Float32Array(values.buffer, 12, 1)[0] = invPxRange\n steps.forEach((step, index) => {\n const base = (index + 1) * 64\n values.set([width, height, step], base)\n new Float32Array(values.buffer, base * 4 + 12, 1)[0] = invPxRange\n })\n device.queue.writeBuffer(params, 0, values)\n device.queue.copyExternalImageToTexture(\n { source: raster.canvas, flipY: false },\n { texture: upload, premultipliedAlpha: false },\n [width, height],\n )\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 bind = (\n pipeline: AtlasPipeline,\n offset: number,\n ...storageBuffers: AtlasGpuBuffer[]\n ): unknown =>\n device.createBindGroup({\n layout: pipeline.getBindGroupLayout(0),\n entries: [\n { binding: 0, resource: { buffer: params, offset, size: 16 } },\n ...storageBuffers.map((resource, index) => ({\n binding: index + 1,\n resource: { buffer: resource },\n })),\n ],\n })\n const encoder = device.createCommandEncoder()\n encoder.copyTextureToBuffer(\n { texture: upload },\n { buffer: words, bytesPerRow: rowBytes, rowsPerImage: height },\n [width, height],\n )\n const groupsX = Math.ceil(width / pipelines.workgroupDim)\n const groupsY = Math.ceil(height / pipelines.workgroupDim)\n const flood = encoder.beginComputePass()\n flood.setPipeline(pipelines.seed)\n flood.setBindGroup(0, bind(pipelines.seed, 0, words, seeds[0]!))\n flood.dispatchWorkgroups(groupsX, groupsY)\n if (pipelines.directStore && pipelines.jumpStore) {\n const midSteps = steps.length - 1\n if (midSteps > 0) {\n flood.setPipeline(pipelines.jump)\n for (let index = 0; index < midSteps; index++) {\n const into = seeds[(index + 1) % 2]!\n flood.setBindGroup(0, bind(pipelines.jump, (index + 1) * 256, seeds[index % 2]!, into))\n flood.dispatchWorkgroups(groupsX, groupsY)\n }\n }\n const finalView = output.createView({ mipLevelCount: 1 })\n flood.setPipeline(pipelines.jumpStore)\n flood.setBindGroup(\n 0,\n device.createBindGroup({\n layout: pipelines.jumpStore.getBindGroupLayout(0),\n entries: [\n { binding: 0, resource: { buffer: params, offset: steps.length * 256, size: 16 } },\n { binding: 1, resource: { buffer: seeds[midSteps % 2]! } },\n { binding: 2, resource: finalView },\n ],\n }),\n )\n flood.dispatchWorkgroups(groupsX, groupsY)\n flood.end()\n } else {\n flood.setPipeline(pipelines.jump)\n steps.forEach((_, index) => {\n const into = seeds[(index + 1) % 2]!\n flood.setBindGroup(0, bind(pipelines.jump, (index + 1) * 256, seeds[index % 2]!, into))\n flood.dispatchWorkgroups(groupsX, groupsY)\n })\n flood.end()\n const resolve = encoder.beginRenderPass({\n colorAttachments: [\n { view: output.createView({ mipLevelCount: 1 }), loadOp: 'clear', storeOp: 'store' },\n ],\n })\n resolve.setPipeline(pipelines.resolve!)\n resolve.setBindGroup(0, bind(pipelines.resolve!, 0, seeds[steps.length % 2]!))\n resolve.draw(3)\n resolve.end()\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 devicePipelinePromises.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":";;;AAiBA,IAAM,0BAA0B;AAChC,IAAM,2BAA2B;AACjC,IAAM,uBAAuB;AAC7B,IAAM,0BAA0B;AAChC,IAAM,2BAA2B;AAkHjC,IAAM,eAAe;CACnB,CAAC,qCAAqC,2BAA2B,CAAC;CAClE,CAAC,4BAA4B,uBAAuB;CACpD,CAAC,4BAA4B,uBAAuB;CACpD,CAAC,mCAAmC,uBAAuB;AAC7D;AAEA,SAAS,yBAAyB,QAAoC;CACpE,MAAM,MAAM,QAAQ,qCAAqC;CACzD,MAAM,KAAK,QAAQ,4BAA4B;CAC/C,MAAM,KAAK,QAAQ,4BAA4B;CAC/C,OAAO,OA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as.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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C7B,CAAC;GACD,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;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"}
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
export declare const MIN_WORKGROUP_DIMENSION = 8;
|
|
2
|
+
export declare const CORE_WORKGROUP_DIMENSION = 16;
|
|
3
|
+
export declare const SEED_BYTES_PER_TEXEL = 4;
|
|
4
|
+
export declare const COMPUTE_STORAGE_BUFFERS = 1;
|
|
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';
|
|
11
|
+
export type AtlasErrorFilter = 'validation' | 'out-of-memory' | 'internal';
|
|
12
|
+
export interface AtlasDeviceLimitsLike {
|
|
13
|
+
readonly maxStorageBufferBindingSize?: number;
|
|
14
|
+
readonly maxBufferSize?: number;
|
|
15
|
+
readonly maxComputeInvocationsPerWorkgroup?: number;
|
|
16
|
+
readonly maxComputeWorkgroupSizeX?: number;
|
|
17
|
+
readonly maxComputeWorkgroupSizeY?: number;
|
|
18
|
+
readonly maxStorageBuffersPerShaderStage?: number;
|
|
19
|
+
readonly maxStorageBuffersInFragmentStage?: number;
|
|
20
|
+
readonly maxStorageTexturesPerShaderStage?: number;
|
|
21
|
+
readonly maxTextureDimension2D?: number;
|
|
22
|
+
readonly minUniformBufferOffsetAlignment?: number;
|
|
23
|
+
}
|
|
24
|
+
export interface UsageGlobals {
|
|
25
|
+
GPUBufferUsage?: {
|
|
26
|
+
COPY_DST: number;
|
|
27
|
+
UNIFORM: number;
|
|
28
|
+
STORAGE: number;
|
|
29
|
+
};
|
|
30
|
+
GPUTextureUsage?: {
|
|
31
|
+
COPY_SRC: number;
|
|
32
|
+
COPY_DST: number;
|
|
33
|
+
TEXTURE_BINDING: number;
|
|
34
|
+
STORAGE_BINDING?: number;
|
|
35
|
+
RENDER_ATTACHMENT: number;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export interface CommonPipelineLike {
|
|
39
|
+
getBindGroupLayout(index: number): unknown;
|
|
40
|
+
}
|
|
41
|
+
export interface CommonBufferLike {
|
|
42
|
+
destroy(): void;
|
|
43
|
+
}
|
|
44
|
+
export interface CommonTextureLike {
|
|
45
|
+
createView(descriptor?: {
|
|
46
|
+
baseMipLevel?: number;
|
|
47
|
+
mipLevelCount?: number;
|
|
48
|
+
}): unknown;
|
|
49
|
+
destroy(): void;
|
|
50
|
+
}
|
|
51
|
+
export interface CommonCommandEncoderLike {
|
|
52
|
+
beginComputePass(): {
|
|
53
|
+
setPipeline(pipeline: CommonPipelineLike): void;
|
|
54
|
+
setBindGroup(index: number, bindGroup: unknown): void;
|
|
55
|
+
dispatchWorkgroups(x: number, y: number): void;
|
|
56
|
+
end(): void;
|
|
57
|
+
};
|
|
58
|
+
beginRenderPass(descriptor: {
|
|
59
|
+
colorAttachments: {
|
|
60
|
+
view: unknown;
|
|
61
|
+
loadOp: 'clear';
|
|
62
|
+
storeOp: 'store';
|
|
63
|
+
}[];
|
|
64
|
+
}): {
|
|
65
|
+
setPipeline(pipeline: CommonPipelineLike): void;
|
|
66
|
+
setBindGroup(index: number, bindGroup: unknown): void;
|
|
67
|
+
draw(vertexCount: number): void;
|
|
68
|
+
end(): void;
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
export interface CommonJfaDeviceLike {
|
|
72
|
+
readonly limits?: AtlasDeviceLimitsLike;
|
|
73
|
+
createBuffer(descriptor: {
|
|
74
|
+
size: number;
|
|
75
|
+
usage: number;
|
|
76
|
+
}): CommonBufferLike;
|
|
77
|
+
createTexture(descriptor: {
|
|
78
|
+
size: [number, number];
|
|
79
|
+
mipLevelCount?: number;
|
|
80
|
+
format: string;
|
|
81
|
+
usage: number;
|
|
82
|
+
}): CommonTextureLike;
|
|
83
|
+
createBindGroupLayout?(descriptor: object): unknown;
|
|
84
|
+
createPipelineLayout?(descriptor: {
|
|
85
|
+
bindGroupLayouts: unknown[];
|
|
86
|
+
}): unknown;
|
|
87
|
+
createBindGroup(descriptor: {
|
|
88
|
+
layout: unknown;
|
|
89
|
+
entries: {
|
|
90
|
+
binding: number;
|
|
91
|
+
resource: unknown;
|
|
92
|
+
}[];
|
|
93
|
+
}): unknown;
|
|
94
|
+
readonly queue: {
|
|
95
|
+
writeBuffer(buffer: CommonBufferLike, offset: number, data: BufferSource | ArrayBufferView): void;
|
|
96
|
+
copyExternalImageToTexture(source: {
|
|
97
|
+
source: HTMLCanvasElement;
|
|
98
|
+
flipY: boolean;
|
|
99
|
+
}, destination: {
|
|
100
|
+
texture: CommonTextureLike;
|
|
101
|
+
premultipliedAlpha: boolean;
|
|
102
|
+
}, size: [number, number]): void;
|
|
103
|
+
};
|
|
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
|
+
}
|
|
115
|
+
export interface CommonJfaPipelines<P extends CommonPipelineLike = CommonPipelineLike, R extends CommonPipelineLike = CommonPipelineLike> {
|
|
116
|
+
readonly workgroupDim: 8 | 16;
|
|
117
|
+
readonly directStore: boolean;
|
|
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;
|
|
123
|
+
readonly tiledStore: P | null;
|
|
124
|
+
readonly tiledStoreWide: P | null;
|
|
125
|
+
readonly resolve: R | null;
|
|
126
|
+
}
|
|
127
|
+
export declare function storageBufferFits(limits: AtlasDeviceLimitsLike | undefined, width: number, height: number): boolean;
|
|
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;
|
|
130
|
+
export declare function selectWorkgroupDimension(limits?: AtlasDeviceLimitsLike): 8 | 16;
|
|
131
|
+
export declare function supportsDirectStore(features?: {
|
|
132
|
+
has(name: string): boolean;
|
|
133
|
+
}): boolean;
|
|
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;
|
|
136
|
+
export declare function openErrorScopes(device: {
|
|
137
|
+
readonly pushErrorScope?: (filter: AtlasErrorFilter) => void;
|
|
138
|
+
readonly popErrorScope?: () => Promise<{
|
|
139
|
+
readonly message?: string;
|
|
140
|
+
} | null>;
|
|
141
|
+
}): {
|
|
142
|
+
close(): Promise<string | null>;
|
|
143
|
+
};
|
|
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: {
|
|
186
|
+
destroy(): void;
|
|
187
|
+
}[], buffers: {
|
|
188
|
+
COPY_DST: number;
|
|
189
|
+
UNIFORM: number;
|
|
190
|
+
STORAGE: number;
|
|
191
|
+
}, textures: {
|
|
192
|
+
COPY_DST: number;
|
|
193
|
+
TEXTURE_BINDING: number;
|
|
194
|
+
RENDER_ATTACHMENT: number;
|
|
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
|
+
};
|