ultra-text 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. package/README.md +168 -85
  2. package/THIRD_PARTY_NOTICES.md +3 -0
  3. package/dist/assets/{cpuSdf.worker-Du9o8q4p.js → cpuSdf.worker-xS57yQbP.js} +13 -11
  4. package/dist/assets/cpuSdf.worker-xS57yQbP.js.map +1 -0
  5. package/dist/atlas/appendAtlas.js +2 -1
  6. package/dist/atlas/appendAtlas.js.map +1 -1
  7. package/dist/atlas/buildAtlas.js +3 -14
  8. package/dist/atlas/buildAtlas.js.map +1 -1
  9. package/dist/atlas/cpuSdf.js +12 -10
  10. package/dist/atlas/cpuSdf.js.map +1 -1
  11. package/dist/atlas/cpuWorker.js +1 -1
  12. package/dist/atlas/cpuWorker.js.map +1 -1
  13. package/dist/atlas/gpuAtlas.d.ts +7 -6
  14. package/dist/atlas/gpuAtlas.js +280 -145
  15. package/dist/atlas/gpuAtlas.js.map +1 -1
  16. package/dist/atlas/jfaWgsl.js +201 -73
  17. package/dist/atlas/jfaWgsl.js.map +1 -1
  18. package/dist/atlas/rasterize.d.ts +2 -0
  19. package/dist/atlas/rasterize.js +2 -87
  20. package/dist/atlas/rasterize.js.map +1 -1
  21. package/dist/dom/DomSdf.js +66 -15
  22. package/dist/dom/DomSdf.js.map +1 -1
  23. package/dist/dom/DomSlug.d.ts +26 -0
  24. package/dist/dom/DomSlug.js +640 -0
  25. package/dist/dom/DomSlug.js.map +1 -0
  26. package/dist/dom/SlugText.d.ts +18 -0
  27. package/dist/dom/SlugText.js +94 -0
  28. package/dist/dom/SlugText.js.map +1 -0
  29. package/dist/dom/Text.js +4 -67
  30. package/dist/dom/Text.js.map +1 -1
  31. package/dist/dom/fontCanvas.d.ts +2 -0
  32. package/dist/dom/fontCanvas.js +101 -0
  33. package/dist/dom/fontCanvas.js.map +1 -0
  34. package/dist/dom/layoutSignature.js +29 -2
  35. package/dist/dom/layoutSignature.js.map +1 -1
  36. package/dist/dom/snapshot.js +251 -96
  37. package/dist/dom/snapshot.js.map +1 -1
  38. package/dist/dom/textHost.d.ts +11 -0
  39. package/dist/dom/textHost.js +68 -0
  40. package/dist/dom/textHost.js.map +1 -0
  41. package/dist/slug/SlugMaterial.d.ts +3 -2
  42. package/dist/slug/SlugMaterial.js +28 -2
  43. package/dist/slug/SlugMaterial.js.map +1 -1
  44. package/dist/slug/coverage.d.ts +1 -1
  45. package/dist/slug/coverage.js +1 -1
  46. package/dist/slug/coverage.js.map +1 -1
  47. package/dist/slug/preprocessCore.d.ts +1 -2
  48. package/dist/slug/preprocessCore.js +39 -16
  49. package/dist/slug/preprocessCore.js.map +1 -1
  50. package/dist/slug/runtime.js +6 -4
  51. package/dist/slug/runtime.js.map +1 -1
  52. package/dist/slug/standaloneRuntime.d.ts +39 -0
  53. package/dist/slug/standaloneRuntime.js +140 -0
  54. package/dist/slug/standaloneRuntime.js.map +1 -0
  55. package/dist/slug/truetype.d.ts +22 -0
  56. package/dist/slug/truetype.js +494 -0
  57. package/dist/slug/truetype.js.map +1 -0
  58. package/dist/slug-vanilla.d.ts +364 -0
  59. package/dist/slug-vanilla.js +1461 -0
  60. package/dist/slug-vanilla.js.map +1 -0
  61. package/dist/slug.d.ts +21 -0
  62. package/dist/slug.js +19 -0
  63. package/dist/text/GlyphTextMaterial.d.ts +11 -11
  64. package/dist/text/GlyphTextMaterial.js +98 -29
  65. package/dist/text/GlyphTextMaterial.js.map +1 -1
  66. package/dist/text/SdfTextMaterial.d.ts +5 -4
  67. package/dist/text/SdfTextMaterial.js +22 -4
  68. package/dist/text/SdfTextMaterial.js.map +1 -1
  69. package/dist/types.d.ts +63 -14
  70. package/dist/vanilla.d.ts +3 -0
  71. package/dist/vanilla.js +132 -59
  72. package/dist/vanilla.js.map +1 -1
  73. package/dist/windfoil/WindfoilMaterial.d.ts +2 -1
  74. package/dist/windfoil/WindfoilMaterial.js +8 -1
  75. package/dist/windfoil/WindfoilMaterial.js.map +1 -1
  76. package/dist/windfoil/abortable.d.ts +2 -0
  77. package/dist/windfoil/abortable.js +26 -0
  78. package/dist/windfoil/abortable.js.map +1 -0
  79. package/dist/windfoil/color.js +2 -1
  80. package/dist/windfoil/color.js.map +1 -1
  81. package/dist/windfoil/coverage.d.ts +3 -20
  82. package/dist/windfoil/coverage.js +7 -20
  83. package/dist/windfoil/coverage.js.map +1 -1
  84. package/dist/windfoil/emoji.js +1 -1
  85. package/dist/windfoil/emoji.js.map +1 -1
  86. package/dist/windfoil/emojiMetrics.js +1 -1
  87. package/dist/windfoil/emojiMetrics.js.map +1 -1
  88. package/dist/windfoil/geometry.js +100 -33
  89. package/dist/windfoil/geometry.js.map +1 -1
  90. package/dist/windfoil/layerGrid.js +14 -10
  91. package/dist/windfoil/layerGrid.js.map +1 -1
  92. package/dist/windfoil/layerNormalization.d.ts +1 -1
  93. package/dist/windfoil/layerNormalization.js +1 -1
  94. package/dist/windfoil/layerNormalization.js.map +1 -1
  95. package/dist/windfoil/outlineValidation.d.ts +86 -0
  96. package/dist/windfoil/outlineValidation.js +65 -0
  97. package/dist/windfoil/outlineValidation.js.map +1 -0
  98. package/dist/windfoil/preprocess.js +3 -2
  99. package/dist/windfoil/preprocess.js.map +1 -1
  100. package/dist/windfoil/preprocessCore.d.ts +4 -85
  101. package/dist/windfoil/preprocessCore.js +210 -206
  102. package/dist/windfoil/preprocessCore.js.map +1 -1
  103. package/dist/windfoil/requests.js +1 -1
  104. package/dist/windfoil/requests.js.map +1 -1
  105. package/dist/windfoil/runtime.d.ts +2 -1
  106. package/dist/windfoil/runtime.js +3 -2
  107. package/dist/windfoil/runtime.js.map +1 -1
  108. package/dist/windfoil/shapeResources.js +2 -1
  109. package/dist/windfoil/shapeResources.js.map +1 -1
  110. package/dist/windfoil/shapes.js +1 -1
  111. package/dist/windfoil/skirt.d.ts +22 -0
  112. package/dist/windfoil/skirt.js +20 -0
  113. package/dist/windfoil/skirt.js.map +1 -0
  114. package/dist/windfoil/storage.d.ts +2 -2
  115. package/dist/windfoil/storage.js +1 -22
  116. package/dist/windfoil/storage.js.map +1 -1
  117. package/dist/windfoil/trace/contours.d.ts +0 -5
  118. package/dist/windfoil/trace/contours.js +81 -114
  119. package/dist/windfoil/trace/contours.js.map +1 -1
  120. package/dist/windfoil/trace/fit.d.ts +0 -6
  121. package/dist/windfoil/trace/fit.js +304 -308
  122. package/dist/windfoil/trace/fit.js.map +1 -1
  123. package/dist/windfoil/trace/outline.js +10 -10
  124. package/dist/windfoil/trace/outline.js.map +1 -1
  125. package/dist/windfoil/trace/types.d.ts +5 -3
  126. package/dist/windfoil/tracedOutlines.d.ts +37 -1
  127. package/dist/windfoil/tracedOutlines.js +172 -33
  128. package/dist/windfoil/tracedOutlines.js.map +1 -1
  129. package/package.json +57 -8
  130. package/skills/ultra-text/SKILL.md +114 -0
  131. package/skills/ultra-text/references/frameworks.md +43 -0
  132. package/skills/ultra-text/references/three-tsl.md +78 -0
  133. package/skills/ultra-text/references/vanilla-webgpu.md +95 -0
  134. package/dist/assets/cpuSdf.worker-Du9o8q4p.js.map +0 -1
package/dist/vanilla.js CHANGED
@@ -1,5 +1,6 @@
1
- import { JFA_WGSL, MIP_WGSL } from "./atlas/jfaWgsl.js";
2
- import { isColorCandidate, rasterizeGlyphAtlas } from "./atlas/rasterize.js";
1
+ import { MIP_WGSL, buildJfaWgsl } from "./atlas/jfaWgsl.js";
2
+ import { isColorCandidate } from "./dom/fontCanvas.js";
3
+ import { rasterizeGlyphAtlas } from "./atlas/rasterize.js";
3
4
  import { backdropCurve, resolveDomTextTone, resolveTextTone, srgbEncode, toneCoverage, toneLightness } from "./dom/tone.js";
4
5
  import { reflowSnapshot, snapGlyph } from "./text/reflow.js";
5
6
  import { collectDomSnapshot } from "./dom/snapshot.js";
@@ -28,26 +29,43 @@ function jfaSteps(pxRange) {
28
29
  }
29
30
  return steps;
30
31
  }
31
- var COMPUTE_WORKGROUP_DIMENSION = 8;
32
+ var MIN_WORKGROUP_DIMENSION = 8;
33
+ var CORE_WORKGROUP_DIMENSION = 16;
34
+ var SEED_BYTES_PER_TEXEL = 4;
32
35
  var ERROR_FILTERS = [
33
36
  "validation",
34
37
  "out-of-memory",
35
38
  "internal"
36
39
  ];
37
- function checkVanillaAtlasLimits(limits, width, height) {
40
+ function selectVanillaWorkgroupDimension(limits) {
41
+ const inv = limits?.maxComputeInvocationsPerWorkgroup ?? 256;
42
+ const wx = limits?.maxComputeWorkgroupSizeX ?? 256;
43
+ const wy = limits?.maxComputeWorkgroupSizeY ?? 256;
44
+ return inv >= CORE_WORKGROUP_DIMENSION ** 2 && wx >= CORE_WORKGROUP_DIMENSION && wy >= CORE_WORKGROUP_DIMENSION ? CORE_WORKGROUP_DIMENSION : MIN_WORKGROUP_DIMENSION;
45
+ }
46
+ function supportsVanillaDirectStore(device) {
47
+ const textures = texUsageOf();
48
+ return typeof textures.STORAGE_BINDING === "number" && textures.STORAGE_BINDING > 0 && Boolean(device.features?.has("texture-formats-tier1"));
49
+ }
50
+ function checkVanillaAtlasLimits(limits, width, height, maxStep, directStore) {
51
+ if (maxStep > 64) throw new RangeError("buildVanillaGpuSdfAtlas: pxRange exceeds fixed-point jump range");
52
+ if (!limits) return;
38
53
  for (const [name, need] of [
39
- ["maxComputeInvocationsPerWorkgroup", COMPUTE_WORKGROUP_DIMENSION ** 2],
40
- ["maxComputeWorkgroupSizeX", COMPUTE_WORKGROUP_DIMENSION],
41
- ["maxComputeWorkgroupSizeY", COMPUTE_WORKGROUP_DIMENSION],
42
- ["maxStorageBuffersPerShaderStage", 2],
43
- ["maxStorageBuffersInFragmentStage", 1]
54
+ ["maxComputeInvocationsPerWorkgroup", MIN_WORKGROUP_DIMENSION ** 2],
55
+ ["maxComputeWorkgroupSizeX", MIN_WORKGROUP_DIMENSION],
56
+ ["maxComputeWorkgroupSizeY", MIN_WORKGROUP_DIMENSION],
57
+ ["maxStorageBuffersPerShaderStage", 2]
44
58
  ]) {
45
59
  const value = limits[name];
46
60
  if (typeof value === "number" && value < need) throw new RangeError(`buildVanillaGpuSdfAtlas: ${name}=${value}, needs ${need}`);
47
61
  }
62
+ if (!directStore) {
63
+ const fragBuffers = limits.maxStorageBuffersInFragmentStage;
64
+ if (typeof fragBuffers === "number" && fragBuffers < 1) throw new RangeError(`buildVanillaGpuSdfAtlas: maxStorageBuffersInFragmentStage=${fragBuffers}, needs 1`);
65
+ }
48
66
  const largest = limits.maxTextureDimension2D;
49
67
  if (typeof largest === "number" && Math.max(width, height) > largest) throw new RangeError(`buildVanillaGpuSdfAtlas: ${width}×${height} exceeds maxTextureDimension2D=${largest}`);
50
- const bytes = Math.max(width * height * 8, rasterRowBytes(width) * height);
68
+ const bytes = Math.max(width * height * SEED_BYTES_PER_TEXEL, rasterRowBytes(width) * height);
51
69
  if (bytes > limits.maxStorageBufferBindingSize || bytes > limits.maxBufferSize) throw new RangeError(`buildVanillaGpuSdfAtlas: ${width}×${height} exceeds storage-buffer limits`);
52
70
  }
53
71
  function openVanillaErrorScopes(device) {
@@ -63,9 +81,11 @@ function openVanillaErrorScopes(device) {
63
81
  }
64
82
  var devicePipelines = /* @__PURE__ */ new WeakMap();
65
83
  function getDevicePipelines(device) {
66
- let cached = devicePipelines.get(device);
67
- if (cached) return cached;
68
- const module = device.createShaderModule({ code: JFA_WGSL + MIP_WGSL });
84
+ const directStore = supportsVanillaDirectStore(device);
85
+ const workgroupDim = selectVanillaWorkgroupDimension(device.limits);
86
+ const cached = devicePipelines.get(device);
87
+ if (cached?.directStore === directStore && cached.workgroupDim === workgroupDim) return cached;
88
+ const module = device.createShaderModule({ code: buildJfaWgsl(workgroupDim, directStore) + MIP_WGSL });
69
89
  const compute = (entryPoint) => device.createComputePipeline({
70
90
  layout: "auto",
71
91
  compute: {
@@ -85,19 +105,22 @@ function getDevicePipelines(device) {
85
105
  targets: [{ format }]
86
106
  }
87
107
  });
88
- cached = [
89
- compute("seedMain"),
90
- compute("jumpMain"),
91
- render("fullscreenVert", "resolveFrag", "r8unorm"),
92
- render("mipVert", "mipFrag", "r8unorm"),
93
- render("mipVert", "mipFrag", "rgba8unorm-srgb"),
94
- device.createSampler({
108
+ const next = {
109
+ workgroupDim,
110
+ directStore,
111
+ seed: compute("seedMain"),
112
+ jump: compute("jumpMain"),
113
+ jumpStore: directStore ? compute("jumpStoreMain") : null,
114
+ resolve: directStore ? null : render("fullscreenVert", "resolveFrag", "r8unorm"),
115
+ mipR8: render("mipVert", "mipFrag", "r8unorm"),
116
+ mipRgba: render("mipVert", "mipFrag", "rgba8unorm-srgb"),
117
+ sampler: device.createSampler({
95
118
  minFilter: "linear",
96
119
  magFilter: "linear"
97
120
  })
98
- ];
99
- devicePipelines.set(device, cached);
100
- return cached;
121
+ };
122
+ devicePipelines.set(device, next);
123
+ return next;
101
124
  }
102
125
  function encodeMipmapChain(device, encoder, texture, mipLevelCount, pipeline, sampler) {
103
126
  const view = (baseMipLevel) => texture.createView({
@@ -135,6 +158,7 @@ var DEFAULT_TEX_USAGE = {
135
158
  COPY_SRC: 1,
136
159
  COPY_DST: 2,
137
160
  TEXTURE_BINDING: 4,
161
+ STORAGE_BINDING: 8,
138
162
  RENDER_ATTACHMENT: 16
139
163
  };
140
164
  var texUsageOf = () => globalThis.GPUTextureUsage ?? DEFAULT_TEX_USAGE;
@@ -160,7 +184,7 @@ function createGpuColorLayer(device, width, band, mipmaps) {
160
184
  if (mipLevelCount > 1) {
161
185
  const pipelines = getDevicePipelines(device);
162
186
  const encoder = device.createCommandEncoder();
163
- encodeMipmapChain(device, encoder, gpuTexture, mipLevelCount, pipelines[4], pipelines[5]);
187
+ encodeMipmapChain(device, encoder, gpuTexture, mipLevelCount, pipelines.mipRgba, pipelines.sampler);
164
188
  device.queue.submit([encoder.finish()]);
165
189
  }
166
190
  return {
@@ -174,12 +198,13 @@ function createGpuColorLayer(device, width, band, mipmaps) {
174
198
  async function buildVanillaGpuSdfAtlas(device, raster, options = {}) {
175
199
  options.signal?.throwIfAborted();
176
200
  const { width, height } = raster;
177
- if (device.limits) checkVanillaAtlasLimits(device.limits, width, height);
201
+ const steps = jfaSteps(raster.pxRange);
202
+ const directStore = supportsVanillaDirectStore(device);
203
+ checkVanillaAtlasLimits(device.limits, width, height, steps[0], directStore);
178
204
  const bufUsage = bufUsageOf();
179
205
  const texUsage = texUsageOf();
180
206
  const scopes = openVanillaErrorScopes(device);
181
207
  const bytesPerRow = rasterRowBytes(width);
182
- const steps = jfaSteps(raster.pxRange);
183
208
  const mipmaps = options.mipmaps === true;
184
209
  const mipLevelCount = mipCount(width, height, mipmaps);
185
210
  let rasterTexture;
@@ -202,22 +227,27 @@ async function buildVanillaGpuSdfAtlas(device, raster, options = {}) {
202
227
  usage: texUsage.COPY_SRC | texUsage.COPY_DST | texUsage.RENDER_ATTACHMENT
203
228
  });
204
229
  const rasterBuffer = makeBuf(bytesPerRow * height, bufUsage.STORAGE | bufUsage.COPY_DST);
205
- const seedBytes = width * height * 8;
230
+ const seedBytes = width * height * SEED_BYTES_PER_TEXEL;
206
231
  const seedA = makeBuf(seedBytes, bufUsage.STORAGE);
207
232
  const seedB = makeBuf(seedBytes, bufUsage.STORAGE);
208
233
  const paramsBuffer = makeBuf(steps.length * 256 + 16, bufUsage.UNIFORM | bufUsage.COPY_DST);
209
234
  const paramsInts = new Int32Array(steps.length * 64 + 4);
235
+ const invPxRange = 1 / raster.pxRange;
210
236
  paramsInts.set([
211
237
  width,
212
238
  height,
213
239
  bytesPerRow / 4
214
240
  ]);
215
- new Float32Array(paramsInts.buffer, 12, 1)[0] = 1 / raster.pxRange;
216
- steps.forEach((step, i) => paramsInts.set([
217
- width,
218
- height,
219
- step
220
- ], (i + 1) * 64));
241
+ new Float32Array(paramsInts.buffer, 12, 1)[0] = invPxRange;
242
+ steps.forEach((step, i) => {
243
+ const base = (i + 1) * 64;
244
+ paramsInts.set([
245
+ width,
246
+ height,
247
+ step
248
+ ], base);
249
+ new Float32Array(paramsInts.buffer, base * 4 + 12, 1)[0] = invPxRange;
250
+ });
221
251
  device.queue.writeBuffer(paramsBuffer, 0, paramsInts);
222
252
  device.queue.copyExternalImageToTexture({
223
253
  source: raster.canvas,
@@ -230,7 +260,7 @@ async function buildVanillaGpuSdfAtlas(device, raster, options = {}) {
230
260
  size: [width, height],
231
261
  mipLevelCount,
232
262
  format: "r8unorm",
233
- usage: texUsage.RENDER_ATTACHMENT | texUsage.TEXTURE_BINDING | texUsage.COPY_SRC
263
+ usage: texUsage.RENDER_ATTACHMENT | texUsage.TEXTURE_BINDING | texUsage.COPY_SRC | (pipelines.directStore ? texUsage.STORAGE_BINDING ?? 0 : 0)
234
264
  });
235
265
  const encoder = device.createCommandEncoder();
236
266
  encoder.copyTextureToBuffer({ texture: rasterTexture }, {
@@ -238,8 +268,8 @@ async function buildVanillaGpuSdfAtlas(device, raster, options = {}) {
238
268
  bytesPerRow,
239
269
  rowsPerImage: height
240
270
  }, [width, height]);
241
- const groupsX = Math.ceil(width / COMPUTE_WORKGROUP_DIMENSION);
242
- const groupsY = Math.ceil(height / COMPUTE_WORKGROUP_DIMENSION);
271
+ const groupsX = Math.ceil(width / pipelines.workgroupDim);
272
+ const groupsY = Math.ceil(height / pipelines.workgroupDim);
243
273
  const bind = (pipeline, offset, ...bufs) => device.createBindGroup({
244
274
  layout: pipeline.getBindGroupLayout(0),
245
275
  entries: [{
@@ -255,33 +285,75 @@ async function buildVanillaGpuSdfAtlas(device, raster, options = {}) {
255
285
  }))]
256
286
  });
257
287
  const computePass = encoder.beginComputePass();
258
- computePass.setPipeline(pipelines[0]);
259
- computePass.setBindGroup(0, bind(pipelines[0], 0, rasterBuffer, seedA));
288
+ computePass.setPipeline(pipelines.seed);
289
+ computePass.setBindGroup(0, bind(pipelines.seed, 0, rasterBuffer, seedA));
260
290
  computePass.dispatchWorkgroups(groupsX, groupsY);
261
291
  let currentIn = seedA;
262
292
  let currentOut = seedB;
263
- computePass.setPipeline(pipelines[1]);
264
- for (let i = 0; i < steps.length; i++) {
265
- computePass.setBindGroup(0, bind(pipelines[1], (i + 1) * 256, currentIn, currentOut));
266
- computePass.dispatchWorkgroups(groupsX, groupsY);
267
- const prev = currentIn;
268
- currentIn = currentOut;
269
- currentOut = prev;
270
- }
271
- computePass.end();
272
- const resolvePass = encoder.beginRenderPass({ colorAttachments: [{
273
- view: outputTexture.createView({
293
+ if (pipelines.directStore && pipelines.jumpStore) {
294
+ const midSteps = steps.length - 1;
295
+ if (midSteps > 0) {
296
+ computePass.setPipeline(pipelines.jump);
297
+ for (let i = 0; i < midSteps; i++) {
298
+ computePass.setBindGroup(0, bind(pipelines.jump, (i + 1) * 256, currentIn, currentOut));
299
+ computePass.dispatchWorkgroups(groupsX, groupsY);
300
+ const prev = currentIn;
301
+ currentIn = currentOut;
302
+ currentOut = prev;
303
+ }
304
+ }
305
+ const level0View = outputTexture.createView({
274
306
  baseMipLevel: 0,
275
307
  mipLevelCount: 1
276
- }),
277
- loadOp: "clear",
278
- storeOp: "store"
279
- }] });
280
- resolvePass.setPipeline(pipelines[2]);
281
- resolvePass.setBindGroup(0, bind(pipelines[2], 0, currentIn));
282
- resolvePass.draw(3);
283
- resolvePass.end();
284
- if (mipLevelCount > 1) encodeMipmapChain(device, encoder, outputTexture, mipLevelCount, pipelines[3], pipelines[5]);
308
+ });
309
+ computePass.setPipeline(pipelines.jumpStore);
310
+ computePass.setBindGroup(0, device.createBindGroup({
311
+ layout: pipelines.jumpStore.getBindGroupLayout(0),
312
+ entries: [
313
+ {
314
+ binding: 0,
315
+ resource: {
316
+ buffer: paramsBuffer,
317
+ offset: steps.length * 256,
318
+ size: 16
319
+ }
320
+ },
321
+ {
322
+ binding: 1,
323
+ resource: { buffer: currentIn }
324
+ },
325
+ {
326
+ binding: 2,
327
+ resource: level0View
328
+ }
329
+ ]
330
+ }));
331
+ computePass.dispatchWorkgroups(groupsX, groupsY);
332
+ computePass.end();
333
+ } else {
334
+ computePass.setPipeline(pipelines.jump);
335
+ for (let i = 0; i < steps.length; i++) {
336
+ computePass.setBindGroup(0, bind(pipelines.jump, (i + 1) * 256, currentIn, currentOut));
337
+ computePass.dispatchWorkgroups(groupsX, groupsY);
338
+ const prev = currentIn;
339
+ currentIn = currentOut;
340
+ currentOut = prev;
341
+ }
342
+ computePass.end();
343
+ const resolvePass = encoder.beginRenderPass({ colorAttachments: [{
344
+ view: outputTexture.createView({
345
+ baseMipLevel: 0,
346
+ mipLevelCount: 1
347
+ }),
348
+ loadOp: "clear",
349
+ storeOp: "store"
350
+ }] });
351
+ resolvePass.setPipeline(pipelines.resolve);
352
+ resolvePass.setBindGroup(0, bind(pipelines.resolve, 0, currentIn));
353
+ resolvePass.draw(3);
354
+ resolvePass.end();
355
+ }
356
+ if (mipLevelCount > 1) encodeMipmapChain(device, encoder, outputTexture, mipLevelCount, pipelines.mipR8, pipelines.sampler);
285
357
  device.queue.submit([encoder.finish()]);
286
358
  } catch (error) {
287
359
  scopes.close();
@@ -294,6 +366,7 @@ async function buildVanillaGpuSdfAtlas(device, raster, options = {}) {
294
366
  const rejection = await scopes.close();
295
367
  for (const b of transient) b.destroy();
296
368
  if (rejection !== null) {
369
+ devicePipelines.delete(device);
297
370
  outputTexture.destroy();
298
371
  throw new Error(`buildVanillaGpuSdfAtlas: the device rejected the atlas passes: ${rejection}`);
299
372
  }
@@ -369,7 +442,7 @@ async function buildVanillaCpuSdfAtlas(raster, options = {}) {
369
442
  if (mipLevelCount > 1) {
370
443
  const pipelines = getDevicePipelines(device);
371
444
  const encoder = device.createCommandEncoder();
372
- encodeMipmapChain(device, encoder, gpuTexture, mipLevelCount, pipelines[3], pipelines[5]);
445
+ encodeMipmapChain(device, encoder, gpuTexture, mipLevelCount, pipelines.mipR8, pipelines.sampler);
373
446
  device.queue.submit([encoder.finish()]);
374
447
  }
375
448
  if (raster.colorBand) colorLayer = createGpuColorLayer(device, raster.width, raster.colorBand, mipmaps);