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
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
import type { GlyphSlot, RasterColorBand, SdfAtlasMode } from '../types.js';
|
|
2
|
+
import { type AtlasGpuPool, type DeferredColorBleed } from './gpuCommon.js';
|
|
3
|
+
/** Structural WebGPU texture handle returned by GPU atlas builds. */
|
|
4
|
+
export interface VanillaGpuTexture {
|
|
5
|
+
readonly label?: string;
|
|
6
|
+
readonly width?: number;
|
|
7
|
+
readonly height?: number;
|
|
8
|
+
readonly format?: string;
|
|
9
|
+
readonly mipLevelCount?: number;
|
|
10
|
+
createView(descriptor?: {
|
|
11
|
+
baseMipLevel?: number;
|
|
12
|
+
mipLevelCount?: number;
|
|
13
|
+
}): unknown;
|
|
14
|
+
destroy(): void;
|
|
15
|
+
}
|
|
16
|
+
/** Structural WebGPU device interface so callers need neither Three.js nor `@webgpu/types`. */
|
|
17
|
+
export interface VanillaGpuDevice {
|
|
18
|
+
readonly features?: {
|
|
19
|
+
has(name: string): boolean;
|
|
20
|
+
};
|
|
21
|
+
readonly limits?: {
|
|
22
|
+
readonly maxStorageBufferBindingSize: number;
|
|
23
|
+
readonly maxBufferSize: number;
|
|
24
|
+
readonly maxComputeInvocationsPerWorkgroup?: number;
|
|
25
|
+
readonly maxComputeWorkgroupSizeX?: number;
|
|
26
|
+
readonly maxComputeWorkgroupSizeY?: number;
|
|
27
|
+
readonly maxStorageBuffersPerShaderStage?: number;
|
|
28
|
+
readonly maxStorageBuffersInFragmentStage?: number;
|
|
29
|
+
readonly maxStorageTexturesPerShaderStage?: number;
|
|
30
|
+
readonly maxTextureDimension2D?: number;
|
|
31
|
+
readonly minUniformBufferOffsetAlignment?: number;
|
|
32
|
+
};
|
|
33
|
+
createTexture(descriptor: {
|
|
34
|
+
label?: string;
|
|
35
|
+
size: readonly [number, number] | [number, number];
|
|
36
|
+
mipLevelCount?: number;
|
|
37
|
+
format: string;
|
|
38
|
+
usage: number;
|
|
39
|
+
}): VanillaGpuTexture;
|
|
40
|
+
createBuffer(descriptor: {
|
|
41
|
+
label?: string;
|
|
42
|
+
size: number;
|
|
43
|
+
usage: number;
|
|
44
|
+
mappedAtCreation?: boolean;
|
|
45
|
+
}): {
|
|
46
|
+
destroy(): void;
|
|
47
|
+
};
|
|
48
|
+
createSampler(descriptor?: {
|
|
49
|
+
label?: string;
|
|
50
|
+
minFilter?: 'nearest' | 'linear';
|
|
51
|
+
magFilter?: 'nearest' | 'linear';
|
|
52
|
+
}): unknown;
|
|
53
|
+
createShaderModule(descriptor: {
|
|
54
|
+
label?: string;
|
|
55
|
+
code: string;
|
|
56
|
+
}): unknown;
|
|
57
|
+
createBindGroupLayout?(descriptor: object): unknown;
|
|
58
|
+
createPipelineLayout?(descriptor: {
|
|
59
|
+
bindGroupLayouts: unknown[];
|
|
60
|
+
}): unknown;
|
|
61
|
+
createComputePipeline(descriptor: {
|
|
62
|
+
label?: string;
|
|
63
|
+
layout: unknown;
|
|
64
|
+
compute: {
|
|
65
|
+
module: unknown;
|
|
66
|
+
entryPoint: string;
|
|
67
|
+
};
|
|
68
|
+
}): {
|
|
69
|
+
getBindGroupLayout(index: number): unknown;
|
|
70
|
+
};
|
|
71
|
+
readonly createComputePipelineAsync?: (descriptor: {
|
|
72
|
+
label?: string;
|
|
73
|
+
layout: unknown;
|
|
74
|
+
compute: {
|
|
75
|
+
module: unknown;
|
|
76
|
+
entryPoint: string;
|
|
77
|
+
};
|
|
78
|
+
}) => Promise<{
|
|
79
|
+
getBindGroupLayout(index: number): unknown;
|
|
80
|
+
}>;
|
|
81
|
+
createRenderPipeline(descriptor: {
|
|
82
|
+
label?: string;
|
|
83
|
+
layout: unknown;
|
|
84
|
+
vertex: {
|
|
85
|
+
module: unknown;
|
|
86
|
+
entryPoint: string;
|
|
87
|
+
};
|
|
88
|
+
fragment: {
|
|
89
|
+
module: unknown;
|
|
90
|
+
entryPoint: string;
|
|
91
|
+
targets: readonly {
|
|
92
|
+
format: string;
|
|
93
|
+
}[];
|
|
94
|
+
};
|
|
95
|
+
primitive?: {
|
|
96
|
+
topology?: string;
|
|
97
|
+
};
|
|
98
|
+
}): {
|
|
99
|
+
getBindGroupLayout(index: number): unknown;
|
|
100
|
+
};
|
|
101
|
+
readonly createRenderPipelineAsync?: (descriptor: {
|
|
102
|
+
label?: string;
|
|
103
|
+
layout: unknown;
|
|
104
|
+
vertex: {
|
|
105
|
+
module: unknown;
|
|
106
|
+
entryPoint: string;
|
|
107
|
+
};
|
|
108
|
+
fragment: {
|
|
109
|
+
module: unknown;
|
|
110
|
+
entryPoint: string;
|
|
111
|
+
targets: readonly {
|
|
112
|
+
format: string;
|
|
113
|
+
}[];
|
|
114
|
+
};
|
|
115
|
+
primitive?: {
|
|
116
|
+
topology?: string;
|
|
117
|
+
};
|
|
118
|
+
}) => Promise<{
|
|
119
|
+
getBindGroupLayout(index: number): unknown;
|
|
120
|
+
}>;
|
|
121
|
+
createBindGroup(descriptor: {
|
|
122
|
+
layout: unknown;
|
|
123
|
+
entries: readonly {
|
|
124
|
+
binding: number;
|
|
125
|
+
resource: unknown;
|
|
126
|
+
}[];
|
|
127
|
+
}): unknown;
|
|
128
|
+
createCommandEncoder(descriptor?: {
|
|
129
|
+
label?: string;
|
|
130
|
+
}): {
|
|
131
|
+
copyTextureToBuffer(source: {
|
|
132
|
+
texture: VanillaGpuTexture;
|
|
133
|
+
}, destination: {
|
|
134
|
+
buffer: {
|
|
135
|
+
destroy(): void;
|
|
136
|
+
};
|
|
137
|
+
bytesPerRow: number;
|
|
138
|
+
rowsPerImage: number;
|
|
139
|
+
}, size: readonly [number, number] | [number, number]): void;
|
|
140
|
+
beginComputePass(descriptor?: {
|
|
141
|
+
label?: string;
|
|
142
|
+
}): {
|
|
143
|
+
setPipeline(pipeline: unknown): void;
|
|
144
|
+
setBindGroup(index: number, bindGroup: unknown): void;
|
|
145
|
+
dispatchWorkgroups(x: number, y?: number, z?: number): void;
|
|
146
|
+
end(): void;
|
|
147
|
+
};
|
|
148
|
+
beginRenderPass(descriptor: {
|
|
149
|
+
label?: string;
|
|
150
|
+
colorAttachments: readonly {
|
|
151
|
+
view: unknown;
|
|
152
|
+
loadOp: 'clear' | 'load';
|
|
153
|
+
storeOp: 'store' | 'discard';
|
|
154
|
+
clearValue?: {
|
|
155
|
+
r: number;
|
|
156
|
+
g: number;
|
|
157
|
+
b: number;
|
|
158
|
+
a: number;
|
|
159
|
+
};
|
|
160
|
+
}[];
|
|
161
|
+
}): {
|
|
162
|
+
setPipeline(pipeline: unknown): void;
|
|
163
|
+
setBindGroup(index: number, bindGroup: unknown): void;
|
|
164
|
+
draw(vertexCount: number): void;
|
|
165
|
+
end(): void;
|
|
166
|
+
};
|
|
167
|
+
finish(): unknown;
|
|
168
|
+
};
|
|
169
|
+
readonly queue: {
|
|
170
|
+
copyExternalImageToTexture(source: {
|
|
171
|
+
source: HTMLCanvasElement;
|
|
172
|
+
flipY?: boolean;
|
|
173
|
+
}, destination: {
|
|
174
|
+
texture: VanillaGpuTexture;
|
|
175
|
+
premultipliedAlpha?: boolean;
|
|
176
|
+
}, size: readonly [number, number] | [number, number]): void;
|
|
177
|
+
writeBuffer(buffer: {
|
|
178
|
+
destroy(): void;
|
|
179
|
+
}, bufferOffset: number, data: BufferSource | ArrayBufferView, dataOffset?: number, size?: number): void;
|
|
180
|
+
writeTexture(destination: {
|
|
181
|
+
texture: VanillaGpuTexture;
|
|
182
|
+
mipLevel?: number;
|
|
183
|
+
}, data: ArrayBufferView, dataLayout: {
|
|
184
|
+
offset?: number;
|
|
185
|
+
bytesPerRow: number;
|
|
186
|
+
rowsPerImage?: number;
|
|
187
|
+
}, size: readonly [number, number] | [number, number]): void;
|
|
188
|
+
submit(commandBuffers: readonly unknown[]): void;
|
|
189
|
+
};
|
|
190
|
+
pushErrorScope?(filter: 'validation' | 'out-of-memory' | 'internal'): void;
|
|
191
|
+
popErrorScope?(): Promise<{
|
|
192
|
+
readonly message?: string;
|
|
193
|
+
} | null>;
|
|
194
|
+
}
|
|
195
|
+
/** A WebGPU `GPUDevice`, an engine renderer holding `{ device }`, or `null`/`undefined` for CPU mode. */
|
|
196
|
+
export type VanillaGpuDeviceSource = VanillaGpuDevice | {
|
|
197
|
+
readonly device?: VanillaGpuDevice | null | undefined;
|
|
198
|
+
} | null | undefined;
|
|
199
|
+
/** Companion colour layer owned and disposed by its `VanillaSdfAtlas`. */
|
|
200
|
+
export interface VanillaSdfColorLayer {
|
|
201
|
+
readonly data: Uint8Array;
|
|
202
|
+
readonly gpuTexture?: VanillaGpuTexture | undefined;
|
|
203
|
+
readonly width: number;
|
|
204
|
+
readonly top: number;
|
|
205
|
+
readonly height: number;
|
|
206
|
+
}
|
|
207
|
+
/** Engine-agnostic SDF atlas with CPU bytes and/or an adopted WebGPU `GPUTexture`. */
|
|
208
|
+
export interface VanillaSdfAtlas {
|
|
209
|
+
/** Single-channel SDF bytes (`width * height`), present when built on CPU. */
|
|
210
|
+
readonly data?: Uint8Array | undefined;
|
|
211
|
+
/** WebGPU `r8unorm` texture (`TEXTURE_BINDING | COPY_SRC`), present when built on GPU. */
|
|
212
|
+
readonly gpuTexture?: VanillaGpuTexture | undefined;
|
|
213
|
+
readonly colorLayer?: VanillaSdfColorLayer | undefined;
|
|
214
|
+
readonly shapeTop?: number | undefined;
|
|
215
|
+
readonly width: number;
|
|
216
|
+
readonly height: number;
|
|
217
|
+
readonly pxRange: number;
|
|
218
|
+
readonly bakeSize: number;
|
|
219
|
+
readonly glyphs: ReadonlyMap<string, GlyphSlot>;
|
|
220
|
+
readonly mode: Exclude<SdfAtlasMode, 'auto'>;
|
|
221
|
+
/** Requested mipmap flag. */
|
|
222
|
+
readonly mipmaps: boolean;
|
|
223
|
+
/** Requested anisotropy level. */
|
|
224
|
+
readonly anisotropy: number;
|
|
225
|
+
dispose(): void;
|
|
226
|
+
}
|
|
227
|
+
export declare function resolveGpuDevice(source: VanillaGpuDeviceSource): VanillaGpuDevice | null;
|
|
228
|
+
export declare const DEFAULT_BUF_USAGE: {
|
|
229
|
+
COPY_SRC: number;
|
|
230
|
+
COPY_DST: number;
|
|
231
|
+
UNIFORM: number;
|
|
232
|
+
STORAGE: number;
|
|
233
|
+
};
|
|
234
|
+
export declare const DEFAULT_TEX_USAGE: {
|
|
235
|
+
COPY_SRC: number;
|
|
236
|
+
COPY_DST: number;
|
|
237
|
+
TEXTURE_BINDING: number;
|
|
238
|
+
STORAGE_BINDING?: number;
|
|
239
|
+
RENDER_ATTACHMENT: number;
|
|
240
|
+
};
|
|
241
|
+
export declare const texUsageOf: () => {
|
|
242
|
+
COPY_SRC: number;
|
|
243
|
+
COPY_DST: number;
|
|
244
|
+
TEXTURE_BINDING: number;
|
|
245
|
+
STORAGE_BINDING?: number;
|
|
246
|
+
RENDER_ATTACHMENT: number;
|
|
247
|
+
};
|
|
248
|
+
export declare const bufUsageOf: () => {
|
|
249
|
+
COPY_SRC: number;
|
|
250
|
+
COPY_DST: number;
|
|
251
|
+
UNIFORM: number;
|
|
252
|
+
STORAGE: number;
|
|
253
|
+
};
|
|
254
|
+
export declare const mipCount: (w: number, h: number, mipmaps: boolean) => number;
|
|
255
|
+
interface CachedMipPipelines {
|
|
256
|
+
readonly module: unknown;
|
|
257
|
+
readonly sampler: unknown;
|
|
258
|
+
readonly groupLayout: unknown;
|
|
259
|
+
readonly pipelineLayout: unknown;
|
|
260
|
+
r8?: ReturnType<VanillaGpuDevice['createRenderPipeline']>;
|
|
261
|
+
rgba?: ReturnType<VanillaGpuDevice['createRenderPipeline']>;
|
|
262
|
+
}
|
|
263
|
+
export declare const vanillaMipPipelines: WeakMap<VanillaGpuDevice, CachedMipPipelines>;
|
|
264
|
+
export declare function getDeviceMipPipeline(device: VanillaGpuDevice, format: 'r8unorm' | 'rgba8unorm-srgb'): {
|
|
265
|
+
readonly pipeline: ReturnType<VanillaGpuDevice['createRenderPipeline']>;
|
|
266
|
+
readonly sampler: unknown;
|
|
267
|
+
readonly layout: unknown;
|
|
268
|
+
};
|
|
269
|
+
export declare function encodeMipmapChain(device: VanillaGpuDevice, encoder: ReturnType<VanillaGpuDevice['createCommandEncoder']>, texture: VanillaGpuTexture, mipLevelCount: number, pipeline: ReturnType<VanillaGpuDevice['createRenderPipeline']>, sampler: unknown, layout?: unknown): void;
|
|
270
|
+
interface CachedSpdMipPipeline {
|
|
271
|
+
readonly pipeline?: ReturnType<VanillaGpuDevice['createComputePipeline']>;
|
|
272
|
+
readonly promise?: Promise<CachedSpdMipPipeline>;
|
|
273
|
+
readonly groupLayout: unknown;
|
|
274
|
+
readonly dummyViews: readonly unknown[];
|
|
275
|
+
readonly dummyTexture: VanillaGpuTexture;
|
|
276
|
+
}
|
|
277
|
+
export declare const vanillaSpdPipelines: WeakMap<VanillaGpuDevice, CachedSpdMipPipeline>;
|
|
278
|
+
export declare function canUseSpdMips(device: VanillaGpuDevice, directStore: boolean, workgroupDim: 8 | 16): boolean;
|
|
279
|
+
export declare function getDeviceSpdMipPipeline(device: VanillaGpuDevice): Promise<{
|
|
280
|
+
readonly pipeline: ReturnType<VanillaGpuDevice['createComputePipeline']>;
|
|
281
|
+
readonly layout: unknown;
|
|
282
|
+
readonly dummyViews: readonly unknown[];
|
|
283
|
+
}>;
|
|
284
|
+
export declare function encodeSpdMipmapChain(device: VanillaGpuDevice, encoder: ReturnType<VanillaGpuDevice['createCommandEncoder']>, texture: VanillaGpuTexture, width: number, height: number, mipLevelCount: number, spd: {
|
|
285
|
+
readonly pipeline: ReturnType<VanillaGpuDevice['createComputePipeline']>;
|
|
286
|
+
readonly layout: unknown;
|
|
287
|
+
readonly dummyViews: readonly unknown[];
|
|
288
|
+
}, pool: AtlasGpuPool): void;
|
|
289
|
+
/** Upload a complete atlas texture, transferring ownership only after its mip chain is submitted. */
|
|
290
|
+
export declare function uploadAtlasTexture(device: VanillaGpuDevice, width: number, height: number, data: Uint8Array, format: 'r8unorm' | 'rgba8unorm-srgb', mipmaps: boolean): VanillaGpuTexture;
|
|
291
|
+
export declare function createGpuColorLayer(device: VanillaGpuDevice, width: number, { data, height, top }: RasterColorBand, mipmaps: boolean): VanillaSdfColorLayer;
|
|
292
|
+
export declare function encodeVanillaGpuColorLayer(device: VanillaGpuDevice, encoder: ReturnType<VanillaGpuDevice['createCommandEncoder']>, width: number, band: RasterColorBand, bleed: DeferredColorBleed, mipmaps: boolean, pool: AtlasGpuPool, transient: {
|
|
293
|
+
destroy(): void;
|
|
294
|
+
}[]): VanillaSdfColorLayer;
|
|
295
|
+
export {};
|
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
import { MIP_SPD_WGSL, MIP_WGSL } from "./jfaWgsl.js";
|
|
2
|
+
import { encodeGpuColorBleed } from "./gpuCommon.js";
|
|
3
|
+
// src/atlas/vanillaGpuHelpers.ts
|
|
4
|
+
function resolveGpuDevice(source) {
|
|
5
|
+
if (!source || typeof source !== "object") return null;
|
|
6
|
+
if ("createTexture" in source && typeof source.createTexture === "function") return source;
|
|
7
|
+
if ("device" in source && source.device && typeof source.device.createTexture === "function") return source.device;
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
var DEFAULT_BUF_USAGE = {
|
|
11
|
+
COPY_SRC: 4,
|
|
12
|
+
COPY_DST: 8,
|
|
13
|
+
UNIFORM: 64,
|
|
14
|
+
STORAGE: 128
|
|
15
|
+
};
|
|
16
|
+
var DEFAULT_TEX_USAGE = {
|
|
17
|
+
COPY_SRC: 1,
|
|
18
|
+
COPY_DST: 2,
|
|
19
|
+
TEXTURE_BINDING: 4,
|
|
20
|
+
STORAGE_BINDING: 8,
|
|
21
|
+
RENDER_ATTACHMENT: 16
|
|
22
|
+
};
|
|
23
|
+
var texUsageOf = () => globalThis.GPUTextureUsage ?? DEFAULT_TEX_USAGE;
|
|
24
|
+
var bufUsageOf = () => globalThis.GPUBufferUsage ?? DEFAULT_BUF_USAGE;
|
|
25
|
+
var mipCount = (w, h, mipmaps) => mipmaps ? Math.floor(Math.log2(Math.max(w, h))) + 1 : 1;
|
|
26
|
+
var vanillaMipPipelines = /* @__PURE__ */ new WeakMap();
|
|
27
|
+
function getDeviceMipPipeline(device, format) {
|
|
28
|
+
let cached = vanillaMipPipelines.get(device);
|
|
29
|
+
if (!cached) {
|
|
30
|
+
let groupLayout = null;
|
|
31
|
+
let pipelineLayout = "auto";
|
|
32
|
+
if (typeof device.createBindGroupLayout === "function" && typeof device.createPipelineLayout === "function") {
|
|
33
|
+
groupLayout = device.createBindGroupLayout({ entries: [{
|
|
34
|
+
binding: 0,
|
|
35
|
+
visibility: 2,
|
|
36
|
+
texture: {
|
|
37
|
+
sampleType: "float",
|
|
38
|
+
viewDimension: "2d"
|
|
39
|
+
}
|
|
40
|
+
}, {
|
|
41
|
+
binding: 1,
|
|
42
|
+
visibility: 2,
|
|
43
|
+
sampler: { type: "filtering" }
|
|
44
|
+
}] });
|
|
45
|
+
pipelineLayout = device.createPipelineLayout({ bindGroupLayouts: [groupLayout] });
|
|
46
|
+
}
|
|
47
|
+
cached = {
|
|
48
|
+
module: device.createShaderModule({ code: MIP_WGSL }),
|
|
49
|
+
sampler: device.createSampler({
|
|
50
|
+
minFilter: "linear",
|
|
51
|
+
magFilter: "linear"
|
|
52
|
+
}),
|
|
53
|
+
groupLayout,
|
|
54
|
+
pipelineLayout
|
|
55
|
+
};
|
|
56
|
+
vanillaMipPipelines.set(device, cached);
|
|
57
|
+
}
|
|
58
|
+
const key = format === "r8unorm" ? "r8" : "rgba";
|
|
59
|
+
let pipeline = cached[key];
|
|
60
|
+
if (!pipeline) {
|
|
61
|
+
pipeline = device.createRenderPipeline({
|
|
62
|
+
layout: cached.pipelineLayout,
|
|
63
|
+
vertex: {
|
|
64
|
+
module: cached.module,
|
|
65
|
+
entryPoint: "mipVert"
|
|
66
|
+
},
|
|
67
|
+
fragment: {
|
|
68
|
+
module: cached.module,
|
|
69
|
+
entryPoint: "mipFrag",
|
|
70
|
+
targets: [{ format }]
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
cached[key] = pipeline;
|
|
74
|
+
}
|
|
75
|
+
return {
|
|
76
|
+
pipeline,
|
|
77
|
+
sampler: cached.sampler,
|
|
78
|
+
layout: cached.groupLayout ?? pipeline.getBindGroupLayout(0)
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
function encodeMipmapChain(device, encoder, texture, mipLevelCount, pipeline, sampler, layout = pipeline.getBindGroupLayout(0)) {
|
|
82
|
+
if (mipLevelCount <= 1) return;
|
|
83
|
+
const view = (baseMipLevel) => texture.createView({
|
|
84
|
+
baseMipLevel,
|
|
85
|
+
mipLevelCount: 1
|
|
86
|
+
});
|
|
87
|
+
let source = view(0);
|
|
88
|
+
for (let level = 1; level < mipLevelCount; level++) {
|
|
89
|
+
const target = view(level);
|
|
90
|
+
const pass = encoder.beginRenderPass({ colorAttachments: [{
|
|
91
|
+
view: target,
|
|
92
|
+
loadOp: "clear",
|
|
93
|
+
storeOp: "store"
|
|
94
|
+
}] });
|
|
95
|
+
pass.setPipeline(pipeline);
|
|
96
|
+
pass.setBindGroup(0, device.createBindGroup({
|
|
97
|
+
layout,
|
|
98
|
+
entries: [{
|
|
99
|
+
binding: 0,
|
|
100
|
+
resource: source
|
|
101
|
+
}, {
|
|
102
|
+
binding: 1,
|
|
103
|
+
resource: sampler
|
|
104
|
+
}]
|
|
105
|
+
}));
|
|
106
|
+
pass.draw(3);
|
|
107
|
+
pass.end();
|
|
108
|
+
source = target;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
var vanillaSpdPipelines = /* @__PURE__ */ new WeakMap();
|
|
112
|
+
function canUseSpdMips(device, directStore, workgroupDim) {
|
|
113
|
+
const texUsage = texUsageOf();
|
|
114
|
+
return directStore && workgroupDim === 16 && typeof texUsage.STORAGE_BINDING === "number" && texUsage.STORAGE_BINDING > 0 && (device.limits?.maxStorageTexturesPerShaderStage ?? 4) >= 4;
|
|
115
|
+
}
|
|
116
|
+
function buildSpdDummy(device) {
|
|
117
|
+
const texUsage = texUsageOf();
|
|
118
|
+
const dummyTexture = device.createTexture({
|
|
119
|
+
label: "ultra-text spd-scratch",
|
|
120
|
+
size: [8, 8],
|
|
121
|
+
mipLevelCount: 4,
|
|
122
|
+
format: "r8unorm",
|
|
123
|
+
usage: texUsage.TEXTURE_BINDING | (texUsage.STORAGE_BINDING ?? 0)
|
|
124
|
+
});
|
|
125
|
+
return {
|
|
126
|
+
dummyTexture,
|
|
127
|
+
dummyViews: [
|
|
128
|
+
0,
|
|
129
|
+
1,
|
|
130
|
+
2,
|
|
131
|
+
3
|
|
132
|
+
].map((baseMipLevel) => dummyTexture.createView({
|
|
133
|
+
baseMipLevel,
|
|
134
|
+
mipLevelCount: 1
|
|
135
|
+
}))
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
async function getDeviceSpdMipPipeline(device) {
|
|
139
|
+
const existing = vanillaSpdPipelines.get(device);
|
|
140
|
+
if (existing?.pipeline) return {
|
|
141
|
+
pipeline: existing.pipeline,
|
|
142
|
+
layout: existing.groupLayout ?? existing.pipeline.getBindGroupLayout(0),
|
|
143
|
+
dummyViews: existing.dummyViews
|
|
144
|
+
};
|
|
145
|
+
if (existing?.promise) {
|
|
146
|
+
const resolved = await existing.promise;
|
|
147
|
+
return {
|
|
148
|
+
pipeline: resolved.pipeline,
|
|
149
|
+
layout: resolved.groupLayout ?? resolved.pipeline.getBindGroupLayout(0),
|
|
150
|
+
dummyViews: resolved.dummyViews
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
let groupLayout = null;
|
|
154
|
+
let pipelineLayout = "auto";
|
|
155
|
+
if (typeof device.createBindGroupLayout === "function" && typeof device.createPipelineLayout === "function") {
|
|
156
|
+
const storageEntry = (binding) => ({
|
|
157
|
+
binding,
|
|
158
|
+
visibility: 4,
|
|
159
|
+
storageTexture: {
|
|
160
|
+
format: "r8unorm",
|
|
161
|
+
access: "write-only",
|
|
162
|
+
viewDimension: "2d"
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
groupLayout = device.createBindGroupLayout({ entries: [
|
|
166
|
+
{
|
|
167
|
+
binding: 0,
|
|
168
|
+
visibility: 4,
|
|
169
|
+
buffer: {
|
|
170
|
+
type: "uniform",
|
|
171
|
+
minBindingSize: 16
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
binding: 1,
|
|
176
|
+
visibility: 4,
|
|
177
|
+
texture: {
|
|
178
|
+
sampleType: "unfilterable-float",
|
|
179
|
+
viewDimension: "2d"
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
storageEntry(2),
|
|
183
|
+
storageEntry(3),
|
|
184
|
+
storageEntry(4),
|
|
185
|
+
storageEntry(5)
|
|
186
|
+
] });
|
|
187
|
+
pipelineLayout = device.createPipelineLayout({ bindGroupLayouts: [groupLayout] });
|
|
188
|
+
}
|
|
189
|
+
const module = device.createShaderModule({ code: MIP_SPD_WGSL });
|
|
190
|
+
const { dummyTexture, dummyViews } = buildSpdDummy(device);
|
|
191
|
+
const desc = {
|
|
192
|
+
label: "ultra-text spd-mips",
|
|
193
|
+
layout: pipelineLayout,
|
|
194
|
+
compute: {
|
|
195
|
+
module,
|
|
196
|
+
entryPoint: "mipSpdMain"
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
const pipeline = device.createComputePipeline(desc);
|
|
200
|
+
vanillaSpdPipelines.set(device, {
|
|
201
|
+
pipeline,
|
|
202
|
+
groupLayout,
|
|
203
|
+
dummyViews,
|
|
204
|
+
dummyTexture
|
|
205
|
+
});
|
|
206
|
+
return Promise.resolve({
|
|
207
|
+
pipeline,
|
|
208
|
+
layout: groupLayout ?? pipeline.getBindGroupLayout(0),
|
|
209
|
+
dummyViews
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
function encodeSpdMipmapChain(device, encoder, texture, width, height, mipLevelCount, spd, pool) {
|
|
213
|
+
if (mipLevelCount < 2) return;
|
|
214
|
+
const bufUsage = bufUsageOf();
|
|
215
|
+
const view = (baseMipLevel) => texture.createView({
|
|
216
|
+
baseMipLevel,
|
|
217
|
+
mipLevelCount: 1
|
|
218
|
+
});
|
|
219
|
+
const pass = encoder.beginComputePass();
|
|
220
|
+
pass.setPipeline(spd.pipeline);
|
|
221
|
+
const uniform = /* @__PURE__ */ new Uint32Array(4);
|
|
222
|
+
let srcW = width;
|
|
223
|
+
let srcH = height;
|
|
224
|
+
let k = 1;
|
|
225
|
+
while (k < mipLevelCount) {
|
|
226
|
+
let count = 0;
|
|
227
|
+
if (srcW >= 2 && srcH >= 2 && ((srcW | srcH) & 1) === 0) {
|
|
228
|
+
count = 1;
|
|
229
|
+
let pw = srcW >> 1;
|
|
230
|
+
let ph = srcH >> 1;
|
|
231
|
+
while (count < 4 && k + count < mipLevelCount && pw >= 2 && ph >= 2 && ((pw | ph) & 1) === 0) {
|
|
232
|
+
count++;
|
|
233
|
+
pw >>= 1;
|
|
234
|
+
ph >>= 1;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
const dstW = Math.max(1, srcW >> 1);
|
|
238
|
+
const dstH = Math.max(1, srcH >> 1);
|
|
239
|
+
uniform[0] = srcW;
|
|
240
|
+
uniform[1] = srcH;
|
|
241
|
+
uniform[2] = count;
|
|
242
|
+
uniform[3] = 0;
|
|
243
|
+
const slot = pool.ringAlloc(16, bufUsage.UNIFORM | bufUsage.COPY_DST);
|
|
244
|
+
device.queue.writeBuffer(slot.buffer, slot.offset, uniform);
|
|
245
|
+
const dstCount = count === 0 ? 1 : count;
|
|
246
|
+
const dstViews = [
|
|
247
|
+
0,
|
|
248
|
+
1,
|
|
249
|
+
2,
|
|
250
|
+
3
|
|
251
|
+
].map((i) => i < dstCount ? view(k + i) : spd.dummyViews[i]);
|
|
252
|
+
pass.setBindGroup(0, device.createBindGroup({
|
|
253
|
+
layout: spd.layout,
|
|
254
|
+
entries: [
|
|
255
|
+
{
|
|
256
|
+
binding: 0,
|
|
257
|
+
resource: {
|
|
258
|
+
buffer: slot.buffer,
|
|
259
|
+
offset: slot.offset,
|
|
260
|
+
size: 16
|
|
261
|
+
}
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
binding: 1,
|
|
265
|
+
resource: view(k - 1)
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
binding: 2,
|
|
269
|
+
resource: dstViews[0]
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
binding: 3,
|
|
273
|
+
resource: dstViews[1]
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
binding: 4,
|
|
277
|
+
resource: dstViews[2]
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
binding: 5,
|
|
281
|
+
resource: dstViews[3]
|
|
282
|
+
}
|
|
283
|
+
]
|
|
284
|
+
}));
|
|
285
|
+
pass.dispatchWorkgroups(Math.ceil(dstW / 16), Math.ceil(dstH / 16));
|
|
286
|
+
const steps = count === 0 ? 1 : count;
|
|
287
|
+
for (let s = 0; s < steps; s++) {
|
|
288
|
+
srcW = Math.max(1, srcW >> 1);
|
|
289
|
+
srcH = Math.max(1, srcH >> 1);
|
|
290
|
+
}
|
|
291
|
+
k += steps;
|
|
292
|
+
}
|
|
293
|
+
pass.end();
|
|
294
|
+
}
|
|
295
|
+
/** Upload a complete atlas texture, transferring ownership only after its mip chain is submitted. */
|
|
296
|
+
function uploadAtlasTexture(device, width, height, data, format, mipmaps) {
|
|
297
|
+
const usage = texUsageOf();
|
|
298
|
+
const mipLevelCount = mipCount(width, height, mipmaps);
|
|
299
|
+
const texture = device.createTexture({
|
|
300
|
+
size: [width, height],
|
|
301
|
+
mipLevelCount,
|
|
302
|
+
format,
|
|
303
|
+
usage: usage.TEXTURE_BINDING | usage.COPY_DST | usage.COPY_SRC | (mipLevelCount > 1 ? usage.RENDER_ATTACHMENT : 0)
|
|
304
|
+
});
|
|
305
|
+
try {
|
|
306
|
+
device.queue.writeTexture({
|
|
307
|
+
texture,
|
|
308
|
+
mipLevel: 0
|
|
309
|
+
}, data, {
|
|
310
|
+
offset: 0,
|
|
311
|
+
bytesPerRow: format === "r8unorm" ? width : width * 4,
|
|
312
|
+
rowsPerImage: height
|
|
313
|
+
}, [width, height]);
|
|
314
|
+
if (mipLevelCount > 1) {
|
|
315
|
+
const mip = getDeviceMipPipeline(device, format);
|
|
316
|
+
const encoder = device.createCommandEncoder();
|
|
317
|
+
encodeMipmapChain(device, encoder, texture, mipLevelCount, mip.pipeline, mip.sampler, mip.layout);
|
|
318
|
+
device.queue.submit([encoder.finish()]);
|
|
319
|
+
}
|
|
320
|
+
return texture;
|
|
321
|
+
} catch (error) {
|
|
322
|
+
texture.destroy();
|
|
323
|
+
throw error;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
function createGpuColorLayer(device, width, { data, height, top }, mipmaps) {
|
|
327
|
+
return {
|
|
328
|
+
data,
|
|
329
|
+
width,
|
|
330
|
+
height,
|
|
331
|
+
top,
|
|
332
|
+
gpuTexture: uploadAtlasTexture(device, width, height, data, "rgba8unorm-srgb", mipmaps)
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
function encodeVanillaGpuColorLayer(device, encoder, width, band, bleed, mipmaps, pool, transient) {
|
|
336
|
+
const mipLevelCount = mipCount(width, band.height, mipmaps);
|
|
337
|
+
const { texture, transient: bleedTransient } = encodeGpuColorBleed(device, encoder, bleed, mipLevelCount, pool);
|
|
338
|
+
transient.push(...bleedTransient);
|
|
339
|
+
const gpuTexture = texture;
|
|
340
|
+
if (mipLevelCount > 1) {
|
|
341
|
+
const mip = getDeviceMipPipeline(device, "rgba8unorm-srgb");
|
|
342
|
+
encodeMipmapChain(device, encoder, gpuTexture, mipLevelCount, mip.pipeline, mip.sampler, mip.layout);
|
|
343
|
+
}
|
|
344
|
+
return {
|
|
345
|
+
data: band.data,
|
|
346
|
+
gpuTexture,
|
|
347
|
+
width,
|
|
348
|
+
top: band.top,
|
|
349
|
+
height: band.height
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
export { DEFAULT_BUF_USAGE, DEFAULT_TEX_USAGE, bufUsageOf, canUseSpdMips, createGpuColorLayer, encodeMipmapChain, encodeSpdMipmapChain, encodeVanillaGpuColorLayer, getDeviceMipPipeline, getDeviceSpdMipPipeline, mipCount, resolveGpuDevice, texUsageOf, uploadAtlasTexture, vanillaMipPipelines, vanillaSpdPipelines };
|
|
353
|
+
|
|
354
|
+
//# sourceMappingURL=vanillaGpuHelpers.js.map
|