@jbrowse/render-core 4.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/esm/OverlayCanvas.d.ts +29 -0
- package/esm/OverlayCanvas.js +43 -0
- package/esm/RenderCanvas.d.ts +76 -0
- package/esm/RenderCanvas.js +38 -0
- package/esm/RenderLifecycleMixin.d.ts +180 -0
- package/esm/RenderLifecycleMixin.js +279 -0
- package/esm/ScrollLockedOverlay.d.ts +28 -0
- package/esm/ScrollLockedOverlay.js +42 -0
- package/esm/blockClipUtils.d.ts +27 -0
- package/esm/blockClipUtils.js +101 -0
- package/esm/canvas2dUtils.d.ts +372 -0
- package/esm/canvas2dUtils.js +564 -0
- package/esm/canvasContext.d.ts +68 -0
- package/esm/canvasContext.js +74 -0
- package/esm/colorRampLut.d.ts +17 -0
- package/esm/colorRampLut.js +25 -0
- package/esm/coverageBand.d.ts +107 -0
- package/esm/coverageBand.js +109 -0
- package/esm/coverageBandBuffers.d.ts +30 -0
- package/esm/coverageBandBuffers.js +13 -0
- package/esm/createRenderingBackend.d.ts +52 -0
- package/esm/createRenderingBackend.js +58 -0
- package/esm/displayPhase.d.ts +155 -0
- package/esm/displayPhase.js +97 -0
- package/esm/globalRenderingBackend.d.ts +90 -0
- package/esm/globalRenderingBackend.js +53 -0
- package/esm/gpuDevice.d.ts +91 -0
- package/esm/gpuDevice.js +277 -0
- package/esm/graphicsCapabilities.d.ts +98 -0
- package/esm/graphicsCapabilities.js +165 -0
- package/esm/hal/createHal.d.ts +22 -0
- package/esm/hal/createHal.js +91 -0
- package/esm/hal/deviceGpuCache.d.ts +36 -0
- package/esm/hal/deviceGpuCache.js +120 -0
- package/esm/hal/gpuHalBase.d.ts +55 -0
- package/esm/hal/gpuHalBase.js +81 -0
- package/esm/hal/index.d.ts +7 -0
- package/esm/hal/index.js +5 -0
- package/esm/hal/mockHal.d.ts +153 -0
- package/esm/hal/mockHal.js +297 -0
- package/esm/hal/oomReporter.d.ts +15 -0
- package/esm/hal/oomReporter.js +22 -0
- package/esm/hal/passIds.d.ts +22 -0
- package/esm/hal/passIds.js +36 -0
- package/esm/hal/regionRegistry.d.ts +11 -0
- package/esm/hal/regionRegistry.js +66 -0
- package/esm/hal/types.d.ts +116 -0
- package/esm/hal/types.js +1 -0
- package/esm/hal/webgl2Hal.d.ts +47 -0
- package/esm/hal/webgl2Hal.js +490 -0
- package/esm/hal/webgpuHal.d.ts +169 -0
- package/esm/hal/webgpuHal.js +722 -0
- package/esm/installUpload.d.ts +91 -0
- package/esm/installUpload.js +94 -0
- package/esm/instanceCache.d.ts +43 -0
- package/esm/instanceCache.js +53 -0
- package/esm/instancePass.d.ts +50 -0
- package/esm/instancePass.js +34 -0
- package/esm/keyedRenderingBackend.d.ts +41 -0
- package/esm/keyedRenderingBackend.js +19 -0
- package/esm/mapUploadSync.d.ts +31 -0
- package/esm/mapUploadSync.js +45 -0
- package/esm/namedReactions.d.ts +29 -0
- package/esm/namedReactions.js +62 -0
- package/esm/perRegionRenderingBackend.d.ts +114 -0
- package/esm/perRegionRenderingBackend.js +93 -0
- package/esm/recoveryBudget.d.ts +40 -0
- package/esm/recoveryBudget.js +56 -0
- package/esm/regionDataMap.d.ts +60 -0
- package/esm/regionDataMap.js +98 -0
- package/esm/renderBlock.d.ts +25 -0
- package/esm/renderBlock.js +10 -0
- package/esm/renderingBackendBase.d.ts +71 -0
- package/esm/renderingBackendBase.js +50 -0
- package/esm/shaders/antialias.js.generated.d.ts +4 -0
- package/esm/shaders/antialias.js.generated.js +25 -0
- package/esm/shaders/capsule.generated.d.ts +1 -0
- package/esm/shaders/capsule.generated.js +3 -0
- package/esm/shaders/colorRampLut.generated.d.ts +1 -0
- package/esm/shaders/colorRampLut.generated.js +3 -0
- package/esm/shaders/coverageBand.generated.d.ts +2 -0
- package/esm/shaders/coverageBand.generated.js +4 -0
- package/esm/shaders/coverageBar.generated.d.ts +4 -0
- package/esm/shaders/coverageBar.generated.js +6 -0
- package/esm/shaders/coverageBar.iface.generated.d.ts +85 -0
- package/esm/shaders/coverageBar.iface.generated.js +114 -0
- package/esm/shaders/coverageIndicator.generated.d.ts +4 -0
- package/esm/shaders/coverageIndicator.generated.js +6 -0
- package/esm/shaders/coverageIndicator.iface.generated.d.ts +85 -0
- package/esm/shaders/coverageIndicator.iface.generated.js +114 -0
- package/esm/shaders/coverageInterbase.generated.d.ts +4 -0
- package/esm/shaders/coverageInterbase.generated.js +6 -0
- package/esm/shaders/coverageInterbase.iface.generated.d.ts +93 -0
- package/esm/shaders/coverageInterbase.iface.generated.js +134 -0
- package/esm/shaders/coverageMod.generated.d.ts +4 -0
- package/esm/shaders/coverageMod.generated.js +6 -0
- package/esm/shaders/coverageMod.iface.generated.d.ts +97 -0
- package/esm/shaders/coverageMod.iface.generated.js +144 -0
- package/esm/shaders/coverageSnp.generated.d.ts +4 -0
- package/esm/shaders/coverageSnp.generated.js +6 -0
- package/esm/shaders/coverageSnp.iface.generated.d.ts +97 -0
- package/esm/shaders/coverageSnp.iface.generated.js +144 -0
- package/esm/shaders/hpmath.js.generated.d.ts +3 -0
- package/esm/shaders/hpmath.js.generated.js +48 -0
- package/esm/shaders/pointGlyph.generated.d.ts +1 -0
- package/esm/shaders/pointGlyph.generated.js +3 -0
- package/esm/shaders/pointGlyph.js.generated.d.ts +1 -0
- package/esm/shaders/pointGlyph.js.generated.js +7 -0
- package/esm/shaders/rowRect.generated.d.ts +3 -0
- package/esm/shaders/rowRect.generated.js +5 -0
- package/esm/shaders/rowRect.js.generated.d.ts +2 -0
- package/esm/shaders/rowRect.js.generated.js +13 -0
- package/esm/shaders/scoreScale.js.generated.d.ts +1 -0
- package/esm/shaders/scoreScale.js.generated.js +46 -0
- package/esm/slangPass.d.ts +49 -0
- package/esm/slangPass.js +22 -0
- package/esm/useEventCallback.d.ts +1 -0
- package/esm/useEventCallback.js +19 -0
- package/esm/useGraphicsCapabilities.d.ts +17 -0
- package/esm/useGraphicsCapabilities.js +38 -0
- package/esm/useRenderingBackend.d.ts +83 -0
- package/esm/useRenderingBackend.js +422 -0
- package/esm/useTabVisibilityRerender.d.ts +13 -0
- package/esm/useTabVisibilityRerender.js +39 -0
- package/esm/webgpuUtils.d.ts +23 -0
- package/esm/webgpuUtils.js +76 -0
- package/package.json +91 -0
- package/src/shaders/antialias.js.generated.ts +33 -0
- package/src/shaders/antialias.slang +112 -0
- package/src/shaders/capsule.generated.ts +4 -0
- package/src/shaders/capsule.slang +62 -0
- package/src/shaders/colorPack.slang +26 -0
- package/src/shaders/colorRampLut.generated.ts +4 -0
- package/src/shaders/colorRampLut.slang +51 -0
- package/src/shaders/coverageBand.generated.ts +6 -0
- package/src/shaders/coverageBand.slang +276 -0
- package/src/shaders/coverageBar.generated.ts +10 -0
- package/src/shaders/coverageBar.iface.generated.ts +172 -0
- package/src/shaders/coverageBar.slang +37 -0
- package/src/shaders/coverageIndicator.generated.ts +10 -0
- package/src/shaders/coverageIndicator.iface.generated.ts +172 -0
- package/src/shaders/coverageIndicator.slang +61 -0
- package/src/shaders/coverageInterbase.generated.ts +10 -0
- package/src/shaders/coverageInterbase.iface.generated.ts +198 -0
- package/src/shaders/coverageInterbase.slang +63 -0
- package/src/shaders/coverageMod.generated.ts +10 -0
- package/src/shaders/coverageMod.iface.generated.ts +211 -0
- package/src/shaders/coverageMod.slang +36 -0
- package/src/shaders/coverageSnp.generated.ts +10 -0
- package/src/shaders/coverageSnp.iface.generated.ts +211 -0
- package/src/shaders/coverageSnp.slang +52 -0
- package/src/shaders/diagonalGrid.slang +25 -0
- package/src/shaders/glyphEdgeAlpha.test.ts +241 -0
- package/src/shaders/hpmath.js.generated.ts +47 -0
- package/src/shaders/hpmath.slang +226 -0
- package/src/shaders/pointGlyph.generated.ts +4 -0
- package/src/shaders/pointGlyph.js.generated.ts +9 -0
- package/src/shaders/pointGlyph.slang +93 -0
- package/src/shaders/rowRect.generated.ts +8 -0
- package/src/shaders/rowRect.js.generated.ts +17 -0
- package/src/shaders/rowRect.slang +160 -0
- package/src/shaders/scoreScale.js.generated.ts +51 -0
- package/src/shaders/scoreScale.slang +68 -0
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { GpuHalBase } from './gpuHalBase.ts';
|
|
2
|
+
import type { GpuHal, PipelineDescriptor, SampleCount, TextureBinding } from './types.ts';
|
|
3
|
+
interface RegionPassBuffer {
|
|
4
|
+
dataBuffer: GPUBuffer;
|
|
5
|
+
count: number;
|
|
6
|
+
}
|
|
7
|
+
export declare class WebGPUHal extends GpuHalBase<RegionPassBuffer> implements GpuHal {
|
|
8
|
+
private device;
|
|
9
|
+
private canvas;
|
|
10
|
+
private context;
|
|
11
|
+
private pipelines;
|
|
12
|
+
private passTextures;
|
|
13
|
+
private passBindGroups;
|
|
14
|
+
private layouts;
|
|
15
|
+
private alignedUniformSize;
|
|
16
|
+
private uniformRingBuffer;
|
|
17
|
+
private uniformStaging;
|
|
18
|
+
private uniformSlot;
|
|
19
|
+
private warnedUniformSlots;
|
|
20
|
+
private uniformOnlyBindGroup;
|
|
21
|
+
private sampleCount;
|
|
22
|
+
private msaaTexture;
|
|
23
|
+
private msaaView;
|
|
24
|
+
private currentTextureView;
|
|
25
|
+
private currentEncoder;
|
|
26
|
+
private currentPass;
|
|
27
|
+
/**
|
|
28
|
+
* Buffers and textures whose destroy landed while the frame's render pass was
|
|
29
|
+
* open, held until the frame has been submitted.
|
|
30
|
+
*
|
|
31
|
+
* WebGPU validates `destroy()` against the submitted command buffer, not
|
|
32
|
+
* against when the draw was encoded: destroying a vertex buffer an already
|
|
33
|
+
* encoded draw references makes `queue.submit` reject the whole frame, so one
|
|
34
|
+
* region re-uploading a pass it drew earlier in the same frame blanks
|
|
35
|
+
* everything else drawn with it. Alignments does exactly that — a chain
|
|
36
|
+
* selection spanning two sections re-uploads `OVERLAY_REGION` once per
|
|
37
|
+
* section, inside the block loop.
|
|
38
|
+
*
|
|
39
|
+
* Deferring is what makes mid-frame replacement legal instead of merely
|
|
40
|
+
* warned about; synteny's `ensureUploaded` has always deleted a pass mid-frame
|
|
41
|
+
* that the open pass never referenced, and that case was never the bug.
|
|
42
|
+
*/
|
|
43
|
+
private pendingDestroy;
|
|
44
|
+
private scissorRect;
|
|
45
|
+
private viewportRect;
|
|
46
|
+
private appliedScissor;
|
|
47
|
+
private appliedViewport;
|
|
48
|
+
private warnedSwapChainLoss;
|
|
49
|
+
private swapChainUnrecoverable;
|
|
50
|
+
private constructor();
|
|
51
|
+
protected limits(): {
|
|
52
|
+
maxBufferBytes: number;
|
|
53
|
+
maxTextureDimensionPx: number;
|
|
54
|
+
};
|
|
55
|
+
protected createBuffer(data: ArrayBuffer | ArrayBufferView, count: number): {
|
|
56
|
+
dataBuffer: GPUBuffer;
|
|
57
|
+
count: number;
|
|
58
|
+
};
|
|
59
|
+
protected destroyBuffer(buf: RegionPassBuffer): void;
|
|
60
|
+
/**
|
|
61
|
+
* Claim the canvas's swap chain, and record that this HAL is the one holding
|
|
62
|
+
* it — see `noteCanvasConfigured` for why that ownership has to be tracked.
|
|
63
|
+
*
|
|
64
|
+
* Called from the constructor rather than from `create`, so that the object
|
|
65
|
+
* doing the claiming exists, and so a throwing constructor leaves no
|
|
66
|
+
* configured context behind with nothing to release it.
|
|
67
|
+
*/
|
|
68
|
+
private configureContext;
|
|
69
|
+
static create(canvas: HTMLCanvasElement, descriptors: PipelineDescriptor[], uniformByteSize: number, sampleCount: SampleCount): Promise<WebGPUHal | null>;
|
|
70
|
+
resize(width: number, height: number): import("./types.ts").CanvasScale;
|
|
71
|
+
private recreateMsaaTexture;
|
|
72
|
+
/**
|
|
73
|
+
* Bind group matching the pipeline layout of `passId`.
|
|
74
|
+
*
|
|
75
|
+
* Keyed on the pass being DRAWN, never on the buffer it draws from:
|
|
76
|
+
* `drawPass(a, key, b)` runs pass `a`'s pipeline over pass `b`'s vertex
|
|
77
|
+
* buffer, so the bind group has to match `a`'s layout. Caching it on the
|
|
78
|
+
* (region, `b`) buffer entry instead bound `b`'s layout to `a`'s pipeline —
|
|
79
|
+
* fine while every such pair happened to be uniform-only, a validation error
|
|
80
|
+
* (and a dropped draw) the moment one side samples a texture.
|
|
81
|
+
*
|
|
82
|
+
* Nothing in a bind group varies per region either: it references the
|
|
83
|
+
* HAL-wide uniform ring buffer plus the pass's own texture/sampler. So
|
|
84
|
+
* uniform-only passes all share `uniformOnlyBindGroup`, and a textured pass
|
|
85
|
+
* gets exactly one, cached until `uploadTexture` replaces its texture.
|
|
86
|
+
* Returns undefined when a pass needs a texture that hasn't arrived yet;
|
|
87
|
+
* drawPass skips those.
|
|
88
|
+
*/
|
|
89
|
+
private getBindGroup;
|
|
90
|
+
/**
|
|
91
|
+
* The one place a GPU resource this HAL owns is released — see
|
|
92
|
+
* {@link pendingDestroy} for why the frame decides when.
|
|
93
|
+
*
|
|
94
|
+
* Every buffer release routes here through the `RegionRegistry` destroy hook,
|
|
95
|
+
* so `uploadBuffer`, `deleteBuffer`, `deleteRegion`, `pruneRegions` and
|
|
96
|
+
* `dispose` are all covered without any of them knowing a frame is open.
|
|
97
|
+
*/
|
|
98
|
+
private destroyWhenIdle;
|
|
99
|
+
private drainPendingDestroy;
|
|
100
|
+
protected createTexture(passId: string, binding: TextureBinding, data: Uint8Array, width: number, height: number): void;
|
|
101
|
+
writeUniforms(data: ArrayBuffer): void;
|
|
102
|
+
/**
|
|
103
|
+
* The canvas texture to draw this frame into, or null when the swap chain is
|
|
104
|
+
* gone and could not be rebuilt.
|
|
105
|
+
*
|
|
106
|
+
* **A configuration can disappear under a live HAL.** The case we have seen is
|
|
107
|
+
* a sibling HAL on a reused canvas element releasing a context it turned out
|
|
108
|
+
* not to own (`noteCanvasConfigured` has the shape), and a browser is free to
|
|
109
|
+
* drop one for its own reasons too. Firefox reports it as `InvalidStateError:
|
|
110
|
+
* GPUCanvasContext.getCurrentTexture: Canvas not configured` — on this call
|
|
111
|
+
* and, measured, on no other. Nothing else in the stack hears about it: there
|
|
112
|
+
* is no context-lost event to fire the recovery in `useRenderingBackend`, so
|
|
113
|
+
* unguarded the throw leaves `RenderLifecycleMixin`'s render autorun, lands in
|
|
114
|
+
* `renderError`, and the display banners a raw DOMException until the tab is
|
|
115
|
+
* reloaded.
|
|
116
|
+
*
|
|
117
|
+
* Reconfiguring restores it in full, so this frame goes on to paint. A
|
|
118
|
+
* reconfigure that does *not* restore it is reported and not retried — every
|
|
119
|
+
* later frame would rebuild a swap chain to no effect, and the display's own
|
|
120
|
+
* Retry is what builds a fresh HAL.
|
|
121
|
+
*/
|
|
122
|
+
private acquireTextureView;
|
|
123
|
+
beginFrame(clearR: number, clearG: number, clearB: number, clearA?: number): void;
|
|
124
|
+
drawPass(passId: string, regionKey: number, bufferPassId?: string): void;
|
|
125
|
+
/**
|
|
126
|
+
* Close the frame's state whether the submit landed or threw.
|
|
127
|
+
*
|
|
128
|
+
* The scopes pushed in `beginFrame` have to be popped either way — leaving a
|
|
129
|
+
* pair pushed makes every later frame's pop read an older frame's errors —
|
|
130
|
+
* and the deferred destroys have to be drained either way, since a frame that
|
|
131
|
+
* threw is a frame no later `endFrame` will run for.
|
|
132
|
+
*/
|
|
133
|
+
private closeFrame;
|
|
134
|
+
endFrame(): void;
|
|
135
|
+
/**
|
|
136
|
+
* Mark `at` as holding the whole attachment — the state a freshly-begun
|
|
137
|
+
* render pass is already in, so seeding with it means the first draw of an
|
|
138
|
+
* unclipped frame issues nothing.
|
|
139
|
+
*/
|
|
140
|
+
private seedApplied;
|
|
141
|
+
/**
|
|
142
|
+
* Re-issue the scissor whenever it differs from what this pass was last told,
|
|
143
|
+
* **including when it has been cleared**.
|
|
144
|
+
*
|
|
145
|
+
* WebGL2 clears by turning the state off — `disable(SCISSOR_TEST)`, and a
|
|
146
|
+
* `viewport` back to the full canvas — and that lands immediately.
|
|
147
|
+
* `setScissorRect` / `setViewport` have no off switch and no reset: they are
|
|
148
|
+
* render-pass state that persists to the end of the pass. So dropping the
|
|
149
|
+
* stored rect on `clearScissor` is not a clear at all — it left the
|
|
150
|
+
* *previous* rect clipping every later draw of the frame, while WebGL2 drew
|
|
151
|
+
* those same calls unclipped.
|
|
152
|
+
*
|
|
153
|
+
* Nothing in tree clears mid-frame today — the two callers
|
|
154
|
+
* (`GpuPerRegionRenderingBackend.renderBlocks` and alignments' own) clear
|
|
155
|
+
* after their last draw — so this is parity kept ahead of the renderer that
|
|
156
|
+
* needs it rather than a fix for a live bug. The bug it would have been is
|
|
157
|
+
* the kind this package exists to refuse: right on Canvas2D, right on WebGL2,
|
|
158
|
+
* wrong on WebGPU alone, and silent everywhere.
|
|
159
|
+
*/
|
|
160
|
+
private applyScissor;
|
|
161
|
+
/** The viewport half of {@link applyScissor}; same reasoning throughout. */
|
|
162
|
+
private applyViewport;
|
|
163
|
+
setScissor(x: number, y: number, w: number, h: number): void;
|
|
164
|
+
clearScissor(): void;
|
|
165
|
+
setViewport(x: number, y: number, w: number, h: number): void;
|
|
166
|
+
clearViewport(): void;
|
|
167
|
+
protected releaseResources(): void;
|
|
168
|
+
}
|
|
169
|
+
export {};
|