@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,276 @@
|
|
|
1
|
+
// Shared coverage-band primitive: the uniform block, the band geometry and the
|
|
2
|
+
// depth-normalizer every mark in a coverage histogram is placed by.
|
|
3
|
+
//
|
|
4
|
+
// Two displays draw exactly this band — the alignments pileup's depth/SNP/
|
|
5
|
+
// modification/interbase strip and the MAF display's depth/SNP/interbase strip
|
|
6
|
+
// — off the same worker-packed buffers (`@jbrowse/alignments-core`'s
|
|
7
|
+
// `packCoverageBinsForGpu`, `computeSNPCoverage`, `computeInterbaseCoverage`).
|
|
8
|
+
// The five entry-point shaders beside this file are the only copy of each pass,
|
|
9
|
+
// so a change to a bar's height rule lands in both displays by construction.
|
|
10
|
+
//
|
|
11
|
+
// It shipped as the alignments plugin's own passes over its plugin-wide
|
|
12
|
+
// `Uniforms` struct, with the MAF band on Canvas2D only. Lifting them here cost
|
|
13
|
+
// the alignments renderer one extra UBO write per band per block (it already
|
|
14
|
+
// does the same for its arc band) and bought a second consumer that cannot
|
|
15
|
+
// drift: MAF's band is now the same five draws, not a second reading of them.
|
|
16
|
+
//
|
|
17
|
+
// Colors arrive as packed u32 ABGR (one slot each, no std140 vec3 padding) and
|
|
18
|
+
// are read with `unpackRGBA(u.colorX).xyz` from colorPack.
|
|
19
|
+
//! export-consts: TRIANGLE_HW, TRIANGLE_H
|
|
20
|
+
// The band's px-space decisions, lifted for the Canvas2D and SVG painters that
|
|
21
|
+
// have to land on the same pixels (adr-051). They live in
|
|
22
|
+
// @jbrowse/alignments-core because that is where those painters are, and it
|
|
23
|
+
// cannot depend on a plugin — nor, being upstream of it, on this package.
|
|
24
|
+
//! js-export: covEffectiveHeightPx, covBottomOffsetPx, normalizeDepthScalar
|
|
25
|
+
//! js-export-out: packages/alignments-core/src/coverageBandLayout.generated.ts
|
|
26
|
+
//! consts-out: packages/alignments-core/src/indicatorTriangle.generated.ts
|
|
27
|
+
//! js-skip: covExpandMinWidthX — a 1 CSS px floor over hpmath's expandToMinWidthX, which is where the rule and the reason it has no Canvas2D twin are recorded
|
|
28
|
+
module coverageBand;
|
|
29
|
+
|
|
30
|
+
import colorPack;
|
|
31
|
+
import hpmath;
|
|
32
|
+
import scoreScale;
|
|
33
|
+
|
|
34
|
+
public struct CoverageBandUniforms {
|
|
35
|
+
// HP-split bp range: hi = base-pair offset (high 20 bits), lo = fractional
|
|
36
|
+
// low 12 bits, len = visible span in bp. See hpmath.slang.
|
|
37
|
+
public float bpHi;
|
|
38
|
+
public float bpLo;
|
|
39
|
+
public float bpLen;
|
|
40
|
+
// Runtime 0.0 sentinel. HP math uses 1/hpZero to materialize +inf without the
|
|
41
|
+
// compiler folding the hi/lo combination. MUST always be uploaded as 0.0.
|
|
42
|
+
public float hpZero;
|
|
43
|
+
|
|
44
|
+
public float canvasW;
|
|
45
|
+
public float canvasH;
|
|
46
|
+
|
|
47
|
+
// The band box. `covTop` is the screen-pixel Y of the band's top edge: 0 for
|
|
48
|
+
// a band pinned to the canvas top, a scrolled offset for one that travels
|
|
49
|
+
// with a stacked section. `covYOffset` is the scalebar-label inset, reserved
|
|
50
|
+
// at BOTH ends — see covEffectiveHeightPx.
|
|
51
|
+
public float covHeight;
|
|
52
|
+
public float covYOffset;
|
|
53
|
+
public float covTop;
|
|
54
|
+
|
|
55
|
+
// The depth axis. `regionMaxDepth` is what the buffer's `relDepth` is a
|
|
56
|
+
// fraction of, so it is what recovers a raw depth; the domain is the display's
|
|
57
|
+
// autoscaled one, so a rescale needs no repack.
|
|
58
|
+
public float regionMaxDepth;
|
|
59
|
+
public float depthDomainMax;
|
|
60
|
+
public float depthDomainMin;
|
|
61
|
+
// symlog's linear-region width, already resolved from the domain on the JS
|
|
62
|
+
// side (see resolveSymlogConstant). Unread by the other two scales.
|
|
63
|
+
public float coverageSymlogConstant;
|
|
64
|
+
|
|
65
|
+
// Bin width in bp for the depth bars: 1 for per-bp coverage, wider once the
|
|
66
|
+
// producer downsamples.
|
|
67
|
+
public float binSize;
|
|
68
|
+
// Full-scale height in px of the interbase histogram — see
|
|
69
|
+
// `interbaseBarHeightPx`, which is the one rule the draw, the hit test and
|
|
70
|
+
// this uniform share.
|
|
71
|
+
public float interbaseHeight;
|
|
72
|
+
// Allele-fraction floor for the SNP segments: a segment whose `segHeight`
|
|
73
|
+
// (its share of THIS position's depth) is below this is folded away. 0 draws
|
|
74
|
+
// every mismatch. The depth bar underneath is not gated, so a hidden segment
|
|
75
|
+
// reads as reference rather than as a gap.
|
|
76
|
+
public float snpMinFreq;
|
|
77
|
+
public float reversed;
|
|
78
|
+
|
|
79
|
+
public int coverageScaleType; // 0 = linear, 1 = log2, 2 = symlog
|
|
80
|
+
|
|
81
|
+
public uint colorCoverage;
|
|
82
|
+
public uint colorBaseA;
|
|
83
|
+
public uint colorBaseC;
|
|
84
|
+
public uint colorBaseG;
|
|
85
|
+
public uint colorBaseT;
|
|
86
|
+
// Also what a non-A/C/G/T base takes, and the muted grey a palette collapse
|
|
87
|
+
// writes into all five. Resolved on the CPU so the shader has one lookup and
|
|
88
|
+
// no mode to branch on.
|
|
89
|
+
public uint colorBaseN;
|
|
90
|
+
// The band's own indicator variants (lightened in dark mode), distinct from
|
|
91
|
+
// the pileup's insertion/clip fills; see covClipKindColor.
|
|
92
|
+
public uint colorInsertionIndicator;
|
|
93
|
+
public uint colorSoftclipIndicator;
|
|
94
|
+
public uint colorHardclipIndicator;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
// Coverage-band clip indicator triangle, in CSS px: half-width and height.
|
|
98
|
+
// Four consumers depend on this one number: coverageIndicator.slang draws the
|
|
99
|
+
// triangle, coverageInterbase.slang hangs its bars directly below one, and the
|
|
100
|
+
// Canvas2D painter + hit test read it from `@jbrowse/alignments-core` — which
|
|
101
|
+
// the `consts-out` directive above generates from these declarations, so the
|
|
102
|
+
// cross-package copy can't drift either.
|
|
103
|
+
public static const float TRIANGLE_HW = 3.5;
|
|
104
|
+
public static const float TRIANGLE_H = 4.5;
|
|
105
|
+
|
|
106
|
+
// Shared vertex output for the band's four solid-fill passes. The indicator
|
|
107
|
+
// pass carries a barycentric varying as well and declares its own.
|
|
108
|
+
public struct CoverageVsOut {
|
|
109
|
+
public float4 position : SV_Position;
|
|
110
|
+
public float4 color : COLOR0;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
// Fold a vertex to the origin (degenerate, invisible), for an instance a gate
|
|
114
|
+
// dropped. Folding rather than shrinking is what leaves the rest of the stack
|
|
115
|
+
// where it was.
|
|
116
|
+
public CoverageVsOut covDiscardVertex() {
|
|
117
|
+
CoverageVsOut o;
|
|
118
|
+
o.position = float4(0.0);
|
|
119
|
+
o.color = float4(0.0);
|
|
120
|
+
return o;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
public float covBpToClipX(uint bp, CoverageBandUniforms u) {
|
|
124
|
+
return hpToClipX(hpSplitUint(bp), float3(u.bpHi, u.bpLo, u.bpLen), u.hpZero);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
public float covFlipX(float x, CoverageBandUniforms u) {
|
|
128
|
+
return lerp(x, -x, u.reversed);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// Widen a [x1,x2] clip-space span to a minimum of 1 CSS pixel about its
|
|
132
|
+
// MIDPOINT, so sub-pixel-narrow marks (a coverage bin, a 1bp SNP slice) stay
|
|
133
|
+
// visible without sliding off the coordinate they report. The 1.0 is this
|
|
134
|
+
// band's floor; hpmath's `expandToMinWidthX` is the rule.
|
|
135
|
+
public float2 covExpandMinWidthX(float x1, float x2, float canvasWidth) {
|
|
136
|
+
return expandToMinWidthX(x1, x2, 1.0, canvasWidth);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// Clip-space position of one corner of a box mark: interpolate the
|
|
140
|
+
// [x0,x1] x [yBot,yTop] clip box by the quadLocal() corner and apply the
|
|
141
|
+
// reverse-strand X flip. Y args are (bottom, top) to match quadLocal's Y-up
|
|
142
|
+
// local.y.
|
|
143
|
+
public float4 covFlippedQuad(float x0, float x1, float yBot, float yTop,
|
|
144
|
+
float2 local, CoverageBandUniforms u) {
|
|
145
|
+
return float4(covFlipX(lerp(x0, x1, local.x), u), lerp(yBot, yTop, local.y),
|
|
146
|
+
0.0, 1.0);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// The band's two px-space numbers, factored out of the clip-space conversions
|
|
150
|
+
// below so `//! js-export` can lift them. `covYOffset` is the scalebar-label
|
|
151
|
+
// inset, reserved at BOTH ends — hence the drawable height losing two of them
|
|
152
|
+
// while the baseline loses one.
|
|
153
|
+
//
|
|
154
|
+
// `coverageLayout` in @jbrowse/alignments-core's coverageBandBox.ts is the
|
|
155
|
+
// generated twin, read by the coverage bars, the SNP segments, the modification
|
|
156
|
+
// segments and the y-axis ticks. Both backends measure every mark from these,
|
|
157
|
+
// so disagreeing shifts the whole band rather than one glyph — visible only
|
|
158
|
+
// against the other backend.
|
|
159
|
+
//
|
|
160
|
+
// Floored at 0 here, at the declaration, because a band shorter than its two
|
|
161
|
+
// insets otherwise INVERTS rather than degrades: every mark is
|
|
162
|
+
// `baseline - fraction * effectiveH`, so a negative height grows the depth
|
|
163
|
+
// bars, the SNP segments stacked in them and the interbase bars DOWNWARD from a
|
|
164
|
+
// baseline sitting near the band's top edge. `covHeight` reaches here unclamped
|
|
165
|
+
// — a resize handle floors at 20 but a config slot declaring less is left where
|
|
166
|
+
// it is — and 2 * covYOffset is 10, so any band under 10px drew upside down on
|
|
167
|
+
// both backends.
|
|
168
|
+
public float covEffectiveHeightPx(float covHeight, float covYOffset) {
|
|
169
|
+
return max(covHeight - 2.0 * covYOffset, 0.0);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// Distance from the band's top edge down to the bars' baseline.
|
|
173
|
+
public float covBottomOffsetPx(float covHeight, float covYOffset) {
|
|
174
|
+
return covHeight - covYOffset;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
public float covEffHeight(CoverageBandUniforms u) {
|
|
178
|
+
return covEffectiveHeightPx(u.covHeight, u.covYOffset);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// Clip-space Y of the band's top edge. Single source for where every
|
|
182
|
+
// top-anchored mark (bars, SNP/mod segments, indicators, interbase histogram)
|
|
183
|
+
// starts. covTop == 0 → clip-top (1.0), the pinned-band behavior; a stacked
|
|
184
|
+
// section passes its scrolled top.
|
|
185
|
+
public float covAreaTop(CoverageBandUniforms u) {
|
|
186
|
+
return yPxToClipY(u.covTop, u.canvasH);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
public float covBottom(CoverageBandUniforms u) {
|
|
190
|
+
return covAreaTop(u)
|
|
191
|
+
- (covBottomOffsetPx(u.covHeight, u.covYOffset) / u.canvasH) * 2.0;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// Normalize a raw coverage depth to [0,1] over the domain [min, max], on the
|
|
195
|
+
// current scale type — `scoreScale.slang`'s normalizer under the coverage
|
|
196
|
+
// band's name for it.
|
|
197
|
+
//
|
|
198
|
+
// The name is what the alignments coverage reads it by: it is the scalar twin
|
|
199
|
+
// of makeScoreNormalizer in packages/wiggle-core/src/normalize.ts, which is
|
|
200
|
+
// what the Canvas2D coverage draws and the y-axis ticks go through, and
|
|
201
|
+
// `coverageNormalizeParity.test.ts` pins all of those against each other. The
|
|
202
|
+
// three branches themselves are no longer here — this band and the wiggle
|
|
203
|
+
// renderer had a copy each and they had drifted (see scoreScale.slang).
|
|
204
|
+
public float normalizeDepthScalar(float rawDepth, float domainMin, float domainMax, int scaleType, float symlogConstant) {
|
|
205
|
+
return normalizeScore(rawDepth, domainMin, domainMax, scaleType, symlogConstant);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// The uniform-block wrapper every pass calls. Recovers the raw depth from the
|
|
209
|
+
// packed `relDepth` (= rawDepth / regionMaxDepth) and hands it to the scalar
|
|
210
|
+
// above — the same product Canvas2D forms, rather than a round trip through the
|
|
211
|
+
// domain. Multiplying by `regionMaxDepth / domainMax` and then by `domainMax`
|
|
212
|
+
// cancels algebraically and does not cancel in floats: a domainMax of 0, which
|
|
213
|
+
// `getNiceDomain` returns verbatim for a typed `Set max score` of 0, made the
|
|
214
|
+
// first factor +inf and the product NaN, reaching `clamp(NaN, 0, 1)`.
|
|
215
|
+
// Split in two so the scalar half can be `//! js-export`ed — the twin emitter
|
|
216
|
+
// cannot carry a uniform struct across.
|
|
217
|
+
public float covNormalizeDepth(float relDepth, CoverageBandUniforms u) {
|
|
218
|
+
float rawDepth = relDepth * u.regionMaxDepth;
|
|
219
|
+
return normalizeDepthScalar(
|
|
220
|
+
rawDepth, u.depthDomainMin, u.depthDomainMax, u.coverageScaleType,
|
|
221
|
+
u.coverageSymlogConstant);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// Bar height scale: maps relDepth to a clip-space height multiplier. Shared by
|
|
225
|
+
// every stacked-segment pass so the formula can't drift between them.
|
|
226
|
+
public float covBarScale(float relDepth, CoverageBandUniforms u) {
|
|
227
|
+
return covNormalizeDepth(relDepth, u) * covEffHeight(u) / u.canvasH * 2.0;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// Stacked-segment quad — the geometry of EVERY bar in the band. A `widthBp`-wide
|
|
231
|
+
// rect whose bottom/top are the yOffset / yOffset+segHeight fractions of this
|
|
232
|
+
// position's coverage bar (covBarScale(relDepth)).
|
|
233
|
+
//
|
|
234
|
+
// The three passes differ only in what they put in those parameters. The SNP and
|
|
235
|
+
// modification segments are 1bp slices of a bar (widthBp 1, a partial y span);
|
|
236
|
+
// the depth bar itself is the whole bar (widthBp = u.binSize, y span 0..1), and
|
|
237
|
+
// coverageBar.slang open-coded it once — the same four calls in the same order,
|
|
238
|
+
// so the band could shift under its own segments without anything catching it.
|
|
239
|
+
// Passing `0.0, 1.0` is not a special case here, it is what "the whole bar"
|
|
240
|
+
// spells.
|
|
241
|
+
public float4 covSegQuad(uint position, uint widthBp, float yOffset,
|
|
242
|
+
float segHeight, float relDepth, float2 local,
|
|
243
|
+
CoverageBandUniforms u) {
|
|
244
|
+
float2 xx = covExpandMinWidthX(
|
|
245
|
+
covBpToClipX(position, u), covBpToClipX(position + widthBp, u), u.canvasW);
|
|
246
|
+
float bottom = covBottom(u);
|
|
247
|
+
float k = covBarScale(relDepth, u);
|
|
248
|
+
float segBot = bottom + yOffset * k;
|
|
249
|
+
float segTop = segBot + segHeight * k;
|
|
250
|
+
return covFlippedQuad(xx.x, xx.y, segBot, segTop, local, u);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
// SNP segment fill. colorType encodes 1=A 2=C 3=G 4=T 5=N; 5 and any other type
|
|
254
|
+
// take the dedicated N color. `snpColorForType` in @jbrowse/alignments-core is
|
|
255
|
+
// the Canvas2D twin.
|
|
256
|
+
public float3 covSnpColor(float ct, CoverageBandUniforms u) {
|
|
257
|
+
switch (int(ct)) {
|
|
258
|
+
case 1: return unpackRGBA(u.colorBaseA).xyz;
|
|
259
|
+
case 2: return unpackRGBA(u.colorBaseC).xyz;
|
|
260
|
+
case 3: return unpackRGBA(u.colorBaseG).xyz;
|
|
261
|
+
case 4: return unpackRGBA(u.colorBaseT).xyz;
|
|
262
|
+
default: return unpackRGBA(u.colorBaseN).xyz;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
// Interbase mark fill, for both the histogram bars and the indicator triangles:
|
|
267
|
+
// 1=insertion 2=softclip 3=hardclip, with anything else taking the insertion
|
|
268
|
+
// color — the same fallback `drawIndicators`' lut takes for an out-of-range
|
|
269
|
+
// kind. Nothing reaches that arm today (the interbase compute only ever emits
|
|
270
|
+
// 1..3), which is exactly why the two spellings disagreeing would be invisible.
|
|
271
|
+
public float3 covClipKindColor(float ct, CoverageBandUniforms u) {
|
|
272
|
+
int ci = int(ct);
|
|
273
|
+
if (ci == 2) { return unpackRGBA(u.colorSoftclipIndicator).xyz; }
|
|
274
|
+
if (ci == 3) { return unpackRGBA(u.colorHardclipIndicator).xyz; }
|
|
275
|
+
return unpackRGBA(u.colorInsertionIndicator).xyz;
|
|
276
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// AUTO-GENERATED by packages/shader-tools/src/shader-codegen from coverageBar.slang.
|
|
2
|
+
// Do not edit. Run `pnpm gen:shaders` to regenerate.
|
|
3
|
+
|
|
4
|
+
export const WGSL_SOURCE = "struct CoverageBandUniforms_std140_0\n{\n @align(16) bpHi_0 : f32,\n @align(4) bpLo_0 : f32,\n @align(8) bpLen_0 : f32,\n @align(4) hpZero_0 : f32,\n @align(16) canvasW_0 : f32,\n @align(4) canvasH_0 : f32,\n @align(8) covHeight_0 : f32,\n @align(4) covYOffset_0 : f32,\n @align(16) covTop_0 : f32,\n @align(4) regionMaxDepth_0 : f32,\n @align(8) depthDomainMax_0 : f32,\n @align(4) depthDomainMin_0 : f32,\n @align(16) coverageSymlogConstant_0 : f32,\n @align(4) binSize_0 : f32,\n @align(8) interbaseHeight_0 : f32,\n @align(4) snpMinFreq_0 : f32,\n @align(16) reversed_0 : f32,\n @align(4) coverageScaleType_0 : i32,\n @align(8) colorCoverage_0 : u32,\n @align(4) colorBaseA_0 : u32,\n @align(16) colorBaseC_0 : u32,\n @align(4) colorBaseG_0 : u32,\n @align(8) colorBaseT_0 : u32,\n @align(4) colorBaseN_0 : u32,\n @align(16) colorInsertionIndicator_0 : u32,\n @align(4) colorSoftclipIndicator_0 : u32,\n @align(8) colorHardclipIndicator_0 : u32,\n};\n\n@binding(1) @group(0) var<uniform> u_0 : CoverageBandUniforms_std140_0;\nfn quadLocal_0( vid_0 : u32) -> vec2<f32>\n{\n var v_0 : u32 = vid_0 % u32(6);\n var _S1 : bool = v_0 == u32(0);\n var _S2 : bool;\n if(_S1)\n {\n _S2 = true;\n }\n else\n {\n _S2 = v_0 == u32(2);\n }\n if(_S2)\n {\n _S2 = true;\n }\n else\n {\n _S2 = v_0 == u32(3);\n }\n var _S3 : f32;\n if(_S2)\n {\n _S3 = 0.0f;\n }\n else\n {\n _S3 = 1.0f;\n }\n if(_S1)\n {\n _S2 = true;\n }\n else\n {\n _S2 = v_0 == u32(1);\n }\n if(_S2)\n {\n _S2 = true;\n }\n else\n {\n _S2 = v_0 == u32(4);\n }\n var _S4 : f32;\n if(_S2)\n {\n _S4 = 0.0f;\n }\n else\n {\n _S4 = 1.0f;\n }\n return vec2<f32>(_S3, _S4);\n}\n\nfn hpSplitUint_0( value_0 : u32) -> vec2<f32>\n{\n var lo_0 : u32 = (value_0 & (u32(4095)));\n return vec2<f32>(f32(value_0 - lo_0), f32(lo_0));\n}\n\nfn hpToClipX_0( splitPos_0 : vec2<f32>, bpRange_0 : vec3<f32>, hpZero_1 : f32) -> f32\n{\n var step_0 : f32 = 2.0f / bpRange_0.z;\n var _S5 : f32 = - (1.0f / hpZero_1);\n return dot(vec3<f32>(-1.0f, max(splitPos_0.x - bpRange_0.x, _S5), max(splitPos_0.y - bpRange_0.y, _S5)), vec3<f32>(1.0f, step_0, step_0));\n}\n\nfn covBpToClipX_0( bp_0 : u32, u_1 : ptr<function, CoverageBandUniforms_std140_0>) -> f32\n{\n return hpToClipX_0(hpSplitUint_0(bp_0), vec3<f32>((*u_1).bpHi_0, (*u_1).bpLo_0, (*u_1).bpLen_0), (*u_1).hpZero_0);\n}\n\nfn expandToMinWidthPx_0( x1_0 : f32, x2_0 : f32, minWidth_0 : f32) -> vec2<f32>\n{\n if((x2_0 - x1_0) < minWidth_0)\n {\n var mid_0 : f32 = (x1_0 + x2_0) * 0.5f;\n var _S6 : f32 = minWidth_0 * 0.5f;\n return vec2<f32>(mid_0 - _S6, mid_0 + _S6);\n }\n return vec2<f32>(x1_0, x2_0);\n}\n\nfn expandToMinWidthX_0( x1_1 : f32, x2_1 : f32, minWidthPx_0 : f32, canvasWidth_0 : f32) -> vec2<f32>\n{\n return expandToMinWidthPx_0(x1_1, x2_1, minWidthPx_0 * 2.0f / canvasWidth_0);\n}\n\nfn covExpandMinWidthX_0( x1_2 : f32, x2_2 : f32, canvasWidth_1 : f32) -> vec2<f32>\n{\n return expandToMinWidthX_0(x1_2, x2_2, 1.0f, canvasWidth_1);\n}\n\nfn yPxToClipY_0( yPx_0 : f32, canvasHeight_0 : f32) -> f32\n{\n return 1.0f - yPx_0 / canvasHeight_0 * 2.0f;\n}\n\nfn covAreaTop_0( u_2 : ptr<function, CoverageBandUniforms_std140_0>) -> f32\n{\n return yPxToClipY_0((*u_2).covTop_0, (*u_2).canvasH_0);\n}\n\nfn covBottomOffsetPx_0( covHeight_1 : f32, covYOffset_1 : f32) -> f32\n{\n return covHeight_1 - covYOffset_1;\n}\n\nfn covBottom_0( u_3 : ptr<function, CoverageBandUniforms_std140_0>) -> f32\n{\n var _S7 : f32 = covAreaTop_0(&((*u_3)));\n return _S7 - covBottomOffsetPx_0((*u_3).covHeight_0, (*u_3).covYOffset_0) / (*u_3).canvasH_0 * 2.0f;\n}\n\nfn symlogTransform_0( x_0 : f32, c_0 : f32) -> f32\n{\n return f32((i32(sign((x_0))))) * log(1.0f + abs(x_0 / c_0));\n}\n\nfn normalizeScore_0( score_0 : f32, domainMin_0 : f32, domainMax_0 : f32, scaleType_0 : i32, symlogConstant_0 : f32) -> f32\n{\n if(scaleType_0 == i32(2))\n {\n var tMin_0 : f32 = symlogTransform_0(domainMin_0, symlogConstant_0);\n var tRange_0 : f32 = symlogTransform_0(domainMax_0, symlogConstant_0) - tMin_0;\n if(tRange_0 <= 0.0f)\n {\n return 0.0f;\n }\n return clamp((symlogTransform_0(score_0, symlogConstant_0) - tMin_0) / tRange_0, 0.0f, 1.0f);\n }\n if(scaleType_0 == i32(1))\n {\n var floorV_0 : f32;\n if(domainMin_0 > 0.0f)\n {\n floorV_0 = domainMin_0;\n }\n else\n {\n floorV_0 = 1.0f;\n }\n var logMin_0 : f32 = log2(floorV_0);\n var logRange_0 : f32 = log2(max(domainMax_0, floorV_0)) - logMin_0;\n if(logRange_0 <= 0.0f)\n {\n return 0.0f;\n }\n return clamp((log2(max(score_0, floorV_0)) - logMin_0) / logRange_0, 0.0f, 1.0f);\n }\n var range_0 : f32 = domainMax_0 - domainMin_0;\n if(range_0 <= 0.0f)\n {\n return 0.0f;\n }\n return clamp((score_0 - domainMin_0) / range_0, 0.0f, 1.0f);\n}\n\nfn normalizeDepthScalar_0( rawDepth_0 : f32, domainMin_1 : f32, domainMax_1 : f32, scaleType_1 : i32, symlogConstant_1 : f32) -> f32\n{\n return normalizeScore_0(rawDepth_0, domainMin_1, domainMax_1, scaleType_1, symlogConstant_1);\n}\n\nfn covNormalizeDepth_0( relDepth_0 : f32, u_4 : ptr<function, CoverageBandUniforms_std140_0>) -> f32\n{\n return normalizeDepthScalar_0(relDepth_0 * (*u_4).regionMaxDepth_0, (*u_4).depthDomainMin_0, (*u_4).depthDomainMax_0, (*u_4).coverageScaleType_0, (*u_4).coverageSymlogConstant_0);\n}\n\nfn covEffectiveHeightPx_0( covHeight_2 : f32, covYOffset_2 : f32) -> f32\n{\n return max(covHeight_2 - 2.0f * covYOffset_2, 0.0f);\n}\n\nfn covEffHeight_0( u_5 : ptr<function, CoverageBandUniforms_std140_0>) -> f32\n{\n return covEffectiveHeightPx_0((*u_5).covHeight_0, (*u_5).covYOffset_0);\n}\n\nfn covBarScale_0( relDepth_1 : f32, u_6 : ptr<function, CoverageBandUniforms_std140_0>) -> f32\n{\n var _S8 : f32 = covNormalizeDepth_0(relDepth_1, &((*u_6)));\n var _S9 : f32 = covEffHeight_0(&((*u_6)));\n return _S8 * _S9 / (*u_6).canvasH_0 * 2.0f;\n}\n\nfn covFlipX_0( x_1 : f32, u_7 : ptr<function, CoverageBandUniforms_std140_0>) -> f32\n{\n return mix(x_1, - x_1, (*u_7).reversed_0);\n}\n\nfn covFlippedQuad_0( x0_0 : f32, x1_3 : f32, yBot_0 : f32, yTop_0 : f32, local_0 : vec2<f32>, u_8 : ptr<function, CoverageBandUniforms_std140_0>) -> vec4<f32>\n{\n var _S10 : f32 = covFlipX_0(mix(x0_0, x1_3, local_0.x), &((*u_8)));\n return vec4<f32>(_S10, mix(yBot_0, yTop_0, local_0.y), 0.0f, 1.0f);\n}\n\nfn covSegQuad_0( position_0 : u32, widthBp_0 : u32, yOffset_0 : f32, segHeight_0 : f32, relDepth_2 : f32, local_1 : vec2<f32>, u_9 : ptr<function, CoverageBandUniforms_std140_0>) -> vec4<f32>\n{\n var _S11 : f32 = covBpToClipX_0(position_0, &((*u_9)));\n var _S12 : f32 = covBpToClipX_0(position_0 + widthBp_0, &((*u_9)));\n var xx_0 : vec2<f32> = covExpandMinWidthX_0(_S11, _S12, (*u_9).canvasW_0);\n var _S13 : f32 = covBottom_0(&((*u_9)));\n var _S14 : f32 = covBarScale_0(relDepth_2, &((*u_9)));\n var segBot_0 : f32 = _S13 + yOffset_0 * _S14;\n var _S15 : vec4<f32> = covFlippedQuad_0(xx_0.x, xx_0.y, segBot_0, segBot_0 + segHeight_0 * _S14, local_1, &((*u_9)));\n return _S15;\n}\n\nfn unpackRGBA_0( c_1 : u32) -> vec4<f32>\n{\n return vec4<f32>(f32((((c_1 >> (u32(0)))) & (u32(255)))), f32((((c_1 >> (u32(8)))) & (u32(255)))), f32((((c_1 >> (u32(16)))) & (u32(255)))), f32((((c_1 >> (u32(24)))) & (u32(255))))) / vec4<f32>(255.0f);\n}\n\nstruct CoverageVsOut_0\n{\n @builtin(position) position_1 : vec4<f32>,\n @location(0) color_0 : vec4<f32>,\n};\n\nstruct vertexInput_0\n{\n @location(0) position_2 : u32,\n @location(1) relDepth_3 : f32,\n};\n\n@vertex\nfn vs_main( _S16 : vertexInput_0, @builtin(vertex_index) vid_1 : u32) -> CoverageVsOut_0\n{\n var o_0 : CoverageVsOut_0;\n var _S17 : u32 = u32(u_0.binSize_0);\n var _S18 : vec2<f32> = quadLocal_0(vid_1);\n var _S19 : CoverageBandUniforms_std140_0 = u_0;\n var _S20 : vec4<f32> = covSegQuad_0(_S16.position_2, _S17, 0.0f, 1.0f, _S16.relDepth_3, _S18, &(_S19));\n o_0.position_1 = _S20;\n o_0.color_0 = vec4<f32>(unpackRGBA_0(u_0.colorCoverage_0).xyz, 1.0f);\n return o_0;\n}\n\nstruct pixelOutput_0\n{\n @location(0) output_0 : vec4<f32>,\n};\n\nstruct pixelInput_0\n{\n @location(0) color_1 : vec4<f32>,\n};\n\n@fragment\nfn fs_main( _S21 : pixelInput_0, @builtin(position) position_3 : vec4<f32>) -> pixelOutput_0\n{\n var _S22 : pixelOutput_0 = pixelOutput_0( _S21.color_1 );\n return _S22;\n}\n\n"
|
|
5
|
+
|
|
6
|
+
export const GLSL_VERTEX = "#version 300 es\nprecision highp float;\nprecision highp int;\nstruct CoverageBandUniforms_0\n{\n float bpHi_0;\n float bpLo_0;\n float bpLen_0;\n float hpZero_0;\n float canvasW_0;\n float canvasH_0;\n float covHeight_0;\n float covYOffset_0;\n float covTop_0;\n float regionMaxDepth_0;\n float depthDomainMax_0;\n float depthDomainMin_0;\n float coverageSymlogConstant_0;\n float binSize_0;\n float interbaseHeight_0;\n float snpMinFreq_0;\n float reversed_0;\n int coverageScaleType_0;\n uint colorCoverage_0;\n uint colorBaseA_0;\n uint colorBaseC_0;\n uint colorBaseG_0;\n uint colorBaseT_0;\n uint colorBaseN_0;\n uint colorInsertionIndicator_0;\n uint colorSoftclipIndicator_0;\n uint colorHardclipIndicator_0;\n};\n\n\nlayout(std140) uniform Uniforms\n{\n float bpHi_0;\n float bpLo_0;\n float bpLen_0;\n float hpZero_0;\n float canvasW_0;\n float canvasH_0;\n float covHeight_0;\n float covYOffset_0;\n float covTop_0;\n float regionMaxDepth_0;\n float depthDomainMax_0;\n float depthDomainMin_0;\n float coverageSymlogConstant_0;\n float binSize_0;\n float interbaseHeight_0;\n float snpMinFreq_0;\n float reversed_0;\n int coverageScaleType_0;\n uint colorCoverage_0;\n uint colorBaseA_0;\n uint colorBaseC_0;\n uint colorBaseG_0;\n uint colorBaseT_0;\n uint colorBaseN_0;\n uint colorInsertionIndicator_0;\n uint colorSoftclipIndicator_0;\n uint colorHardclipIndicator_0;\n}u_0;\n\nvec2 quadLocal_0(uint vid_0)\n{\n\n uint v_0 = vid_0 % 6U;\n\n bool _S1 = v_0 == 0U;\n\n bool _S2;\n\n if(_S1)\n {\n\n _S2 = true;\n\n }\n else\n {\n\n _S2 = v_0 == 2U;\n\n }\n\n if(_S2)\n {\n\n _S2 = true;\n\n }\n else\n {\n\n _S2 = v_0 == 3U;\n\n }\n\n float _S3;\n\n if(_S2)\n {\n\n _S3 = 0.0;\n\n }\n else\n {\n\n _S3 = 1.0;\n\n }\n if(_S1)\n {\n\n _S2 = true;\n\n }\n else\n {\n\n _S2 = v_0 == 1U;\n\n }\n\n if(_S2)\n {\n\n _S2 = true;\n\n }\n else\n {\n\n _S2 = v_0 == 4U;\n\n }\n\n float _S4;\n\n if(_S2)\n {\n\n _S4 = 0.0;\n\n }\n else\n {\n\n _S4 = 1.0;\n\n }\n\n return vec2(_S3, _S4);\n}\n\n\nvec2 hpSplitUint_0(uint value_0)\n{\n\n uint lo_0 = value_0 & 4095U;\n\n return vec2(float(value_0 - lo_0), float(lo_0));\n}\n\n\nfloat hpToClipX_0(vec2 splitPos_0, vec3 bpRange_0, float hpZero_1)\n{\n float step_0 = 2.0 / bpRange_0.z;\n float _S5 = - (1.0 / hpZero_1);\n\n return dot(vec3(-1.0, max(splitPos_0.x - bpRange_0.x, _S5), max(splitPos_0.y - bpRange_0.y, _S5)), vec3(1.0, step_0, step_0));\n}\n\n\nfloat covBpToClipX_0(uint bp_0, CoverageBandUniforms_0 u_1)\n{\n\n return hpToClipX_0(hpSplitUint_0(bp_0), vec3(u_1.bpHi_0, u_1.bpLo_0, u_1.bpLen_0), u_1.hpZero_0);\n}\n\n\nvec2 expandToMinWidthPx_0(float x1_0, float x2_0, float minWidth_0)\n{\n\n if((x2_0 - x1_0) < minWidth_0)\n {\n\n float mid_0 = (x1_0 + x2_0) * 0.5;\n float _S6 = minWidth_0 * 0.5;\n\n return vec2(mid_0 - _S6, mid_0 + _S6);\n }\n return vec2(x1_0, x2_0);\n}\n\nvec2 expandToMinWidthX_0(float x1_1, float x2_1, float minWidthPx_0, float canvasWidth_0)\n{\n\n return expandToMinWidthPx_0(x1_1, x2_1, minWidthPx_0 * 2.0 / canvasWidth_0);\n}\n\n\nvec2 covExpandMinWidthX_0(float x1_2, float x2_2, float canvasWidth_1)\n{\n\n return expandToMinWidthX_0(x1_2, x2_2, 1.0, canvasWidth_1);\n}\n\n\nfloat yPxToClipY_0(float yPx_0, float canvasHeight_0)\n{\n\n return 1.0 - yPx_0 / canvasHeight_0 * 2.0;\n}\n\n\nfloat covAreaTop_0(CoverageBandUniforms_0 u_2)\n{\n\n return yPxToClipY_0(u_2.covTop_0, u_2.canvasH_0);\n}\n\n\nfloat covBottomOffsetPx_0(float covHeight_1, float covYOffset_1)\n{\n\n return covHeight_1 - covYOffset_1;\n}\n\n\nfloat covBottom_0(CoverageBandUniforms_0 u_3)\n{\n\n return covAreaTop_0(u_3) - covBottomOffsetPx_0(u_3.covHeight_0, u_3.covYOffset_0) / u_3.canvasH_0 * 2.0;\n}\n\n\nfloat symlogTransform_0(float x_0, float c_0)\n{\n\n return float((int(sign((x_0))))) * log(1.0 + abs(x_0 / c_0));\n}\n\nfloat normalizeScore_0(float score_0, float domainMin_0, float domainMax_0, int scaleType_0, float symlogConstant_0)\n{\n\n if(scaleType_0 == 2)\n {\n\n float tMin_0 = symlogTransform_0(domainMin_0, symlogConstant_0);\n\n float tRange_0 = symlogTransform_0(domainMax_0, symlogConstant_0) - tMin_0;\n if(tRange_0 <= 0.0)\n {\n\n return 0.0;\n }\n return clamp((symlogTransform_0(score_0, symlogConstant_0) - tMin_0) / tRange_0, 0.0, 1.0);\n }\n if(scaleType_0 == 1)\n {\n\n float floorV_0;\n\n if(domainMin_0 > 0.0)\n {\n\n floorV_0 = domainMin_0;\n\n }\n else\n {\n\n floorV_0 = 1.0;\n\n }\n float logMin_0 = log2(floorV_0);\n\n float logRange_0 = log2(max(domainMax_0, floorV_0)) - logMin_0;\n if(logRange_0 <= 0.0)\n {\n\n return 0.0;\n }\n return clamp((log2(max(score_0, floorV_0)) - logMin_0) / logRange_0, 0.0, 1.0);\n }\n float range_0 = domainMax_0 - domainMin_0;\n if(range_0 <= 0.0)\n {\n\n return 0.0;\n }\n\n return clamp((score_0 - domainMin_0) / range_0, 0.0, 1.0);\n}\n\n\nfloat normalizeDepthScalar_0(float rawDepth_0, float domainMin_1, float domainMax_1, int scaleType_1, float symlogConstant_1)\n{\n\n return normalizeScore_0(rawDepth_0, domainMin_1, domainMax_1, scaleType_1, symlogConstant_1);\n}\n\n\nfloat covNormalizeDepth_0(float relDepth_0, CoverageBandUniforms_0 u_4)\n{\n return normalizeDepthScalar_0(relDepth_0 * u_4.regionMaxDepth_0, u_4.depthDomainMin_0, u_4.depthDomainMax_0, u_4.coverageScaleType_0, u_4.coverageSymlogConstant_0);\n}\n\n\nfloat covEffectiveHeightPx_0(float covHeight_2, float covYOffset_2)\n{\n\n return max(covHeight_2 - 2.0 * covYOffset_2, 0.0);\n}\n\n\nfloat covEffHeight_0(CoverageBandUniforms_0 u_5)\n{\n\n return covEffectiveHeightPx_0(u_5.covHeight_0, u_5.covYOffset_0);\n}\n\n\nfloat covBarScale_0(float relDepth_1, CoverageBandUniforms_0 u_6)\n{\n\n return covNormalizeDepth_0(relDepth_1, u_6) * covEffHeight_0(u_6) / u_6.canvasH_0 * 2.0;\n}\n\n\nfloat covFlipX_0(float x_1, CoverageBandUniforms_0 u_7)\n{\n\n return mix(x_1, - x_1, u_7.reversed_0);\n}\n\n\nvec4 covFlippedQuad_0(float x0_0, float x1_3, float yBot_0, float yTop_0, vec2 local_0, CoverageBandUniforms_0 u_8)\n{\n return vec4(covFlipX_0(mix(x0_0, x1_3, local_0.x), u_8), mix(yBot_0, yTop_0, local_0.y), 0.0, 1.0);\n}\n\n\nvec4 covSegQuad_0(uint position_0, uint widthBp_0, float yOffset_0, float segHeight_0, float relDepth_2, vec2 local_1, CoverageBandUniforms_0 u_9)\n{\n\n vec2 xx_0 = covExpandMinWidthX_0(covBpToClipX_0(position_0, u_9), covBpToClipX_0(position_0 + widthBp_0, u_9), u_9.canvasW_0);\n\n\n float k_0 = covBarScale_0(relDepth_2, u_9);\n float segBot_0 = covBottom_0(u_9) + yOffset_0 * k_0;\n\n return covFlippedQuad_0(xx_0.x, xx_0.y, segBot_0, segBot_0 + segHeight_0 * k_0, local_1, u_9);\n}\n\n\nvec4 unpackRGBA_0(uint c_1)\n{\n\n return vec4(float((c_1 >> 0U) & 255U), float((c_1 >> 8U) & 255U), float((c_1 >> 16U) & 255U), float((c_1 >> 24U) & 255U)) / 255.0;\n}\n\n\nout vec4 v_color;\n\n\nlayout(location = 0)\nin uint a_position;\n\n\nlayout(location = 1)\nin float a_relDepth;\n\n\nstruct CoverageVsOut_0\n{\n vec4 position_1;\n vec4 color_0;\n};\n\n\nvoid main()\n{\n\n CoverageVsOut_0 o_0;\n\n CoverageBandUniforms_0 _S7 = CoverageBandUniforms_0(u_0.bpHi_0, u_0.bpLo_0, u_0.bpLen_0, u_0.hpZero_0, u_0.canvasW_0, u_0.canvasH_0, u_0.covHeight_0, u_0.covYOffset_0, u_0.covTop_0, u_0.regionMaxDepth_0, u_0.depthDomainMax_0, u_0.depthDomainMin_0, u_0.coverageSymlogConstant_0, u_0.binSize_0, u_0.interbaseHeight_0, u_0.snpMinFreq_0, u_0.reversed_0, u_0.coverageScaleType_0, u_0.colorCoverage_0, u_0.colorBaseA_0, u_0.colorBaseC_0, u_0.colorBaseG_0, u_0.colorBaseT_0, u_0.colorBaseN_0, u_0.colorInsertionIndicator_0, u_0.colorSoftclipIndicator_0, u_0.colorHardclipIndicator_0);\n\n o_0.position_1 = covSegQuad_0(a_position, uint(u_0.binSize_0), 0.0, 1.0, a_relDepth, quadLocal_0(uint(gl_VertexID)), _S7);\n\n o_0.color_0 = vec4(unpackRGBA_0(u_0.colorCoverage_0).xyz, 1.0);\n CoverageVsOut_0 _S8 = o_0;\n\n gl_Position = o_0.position_1;\n\n v_color = _S8.color_0;\n\n return;\n}\n\n"
|
|
7
|
+
|
|
8
|
+
export const GLSL_FRAGMENT = "#version 300 es\nprecision highp float;\nprecision highp int;\nlayout(location = 0)\nout vec4 entryPointParam_fs_main_0;\n\n\nin vec4 v_color;\n\n\nvoid main()\n{\n\n entryPointParam_fs_main_0 = v_color;\n\n return;\n}\n\n"
|
|
9
|
+
|
|
10
|
+
export * from './coverageBar.iface.generated.ts'
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
// AUTO-GENERATED by packages/shader-tools/src/shader-codegen from coverageBar.slang.
|
|
2
|
+
// Do not edit. Run `pnpm gen:shaders` to regenerate.
|
|
3
|
+
|
|
4
|
+
import type { VertexAttributeLayout, ShaderBinding } from '@jbrowse/render-core/hal'
|
|
5
|
+
|
|
6
|
+
export const BINDINGS: readonly ShaderBinding[] = [
|
|
7
|
+
{ index: 1, kind: 'uniform', name: 'u' },
|
|
8
|
+
]
|
|
9
|
+
|
|
10
|
+
export const VERTS_PER_INSTANCE = 6
|
|
11
|
+
|
|
12
|
+
export const UNIFORMS_SIZE_BYTES = 112
|
|
13
|
+
|
|
14
|
+
// Word indices into a Float32Array view over the uniform buffer.
|
|
15
|
+
export const UNIFORM_OFFSET_F32 = {
|
|
16
|
+
bpHi: 0,
|
|
17
|
+
bpLo: 1,
|
|
18
|
+
bpLen: 2,
|
|
19
|
+
hpZero: 3,
|
|
20
|
+
canvasW: 4,
|
|
21
|
+
canvasH: 5,
|
|
22
|
+
covHeight: 6,
|
|
23
|
+
covYOffset: 7,
|
|
24
|
+
covTop: 8,
|
|
25
|
+
regionMaxDepth: 9,
|
|
26
|
+
depthDomainMax: 10,
|
|
27
|
+
depthDomainMin: 11,
|
|
28
|
+
coverageSymlogConstant: 12,
|
|
29
|
+
binSize: 13,
|
|
30
|
+
interbaseHeight: 14,
|
|
31
|
+
snpMinFreq: 15,
|
|
32
|
+
reversed: 16,
|
|
33
|
+
} as const
|
|
34
|
+
|
|
35
|
+
// Word indices into a Uint32Array view over the uniform buffer.
|
|
36
|
+
export const UNIFORM_OFFSET_U32 = {
|
|
37
|
+
colorCoverage: 18,
|
|
38
|
+
colorBaseA: 19,
|
|
39
|
+
colorBaseC: 20,
|
|
40
|
+
colorBaseG: 21,
|
|
41
|
+
colorBaseT: 22,
|
|
42
|
+
colorBaseN: 23,
|
|
43
|
+
colorInsertionIndicator: 24,
|
|
44
|
+
colorSoftclipIndicator: 25,
|
|
45
|
+
colorHardclipIndicator: 26,
|
|
46
|
+
} as const
|
|
47
|
+
|
|
48
|
+
// Word indices into a Int32Array view over the uniform buffer.
|
|
49
|
+
export const UNIFORM_OFFSET_I32 = {
|
|
50
|
+
coverageScaleType: 17,
|
|
51
|
+
} as const
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
export interface Uniforms {
|
|
55
|
+
bpHi: number
|
|
56
|
+
bpLo: number
|
|
57
|
+
bpLen: number
|
|
58
|
+
hpZero: number
|
|
59
|
+
canvasW: number
|
|
60
|
+
canvasH: number
|
|
61
|
+
covHeight: number
|
|
62
|
+
covYOffset: number
|
|
63
|
+
covTop: number
|
|
64
|
+
regionMaxDepth: number
|
|
65
|
+
depthDomainMax: number
|
|
66
|
+
depthDomainMin: number
|
|
67
|
+
coverageSymlogConstant: number
|
|
68
|
+
binSize: number
|
|
69
|
+
interbaseHeight: number
|
|
70
|
+
snpMinFreq: number
|
|
71
|
+
reversed: number
|
|
72
|
+
coverageScaleType: number
|
|
73
|
+
colorCoverage: number
|
|
74
|
+
colorBaseA: number
|
|
75
|
+
colorBaseC: number
|
|
76
|
+
colorBaseG: number
|
|
77
|
+
colorBaseT: number
|
|
78
|
+
colorBaseN: number
|
|
79
|
+
colorInsertionIndicator: number
|
|
80
|
+
colorSoftclipIndicator: number
|
|
81
|
+
colorHardclipIndicator: number
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export function writeUniforms(buf: ArrayBuffer, uniforms: Uniforms) {
|
|
85
|
+
const f32 = new Float32Array(buf)
|
|
86
|
+
const u32 = new Uint32Array(buf)
|
|
87
|
+
const i32 = new Int32Array(buf)
|
|
88
|
+
f32[0] = uniforms.bpHi
|
|
89
|
+
f32[1] = uniforms.bpLo
|
|
90
|
+
f32[2] = uniforms.bpLen
|
|
91
|
+
f32[3] = uniforms.hpZero
|
|
92
|
+
f32[4] = uniforms.canvasW
|
|
93
|
+
f32[5] = uniforms.canvasH
|
|
94
|
+
f32[6] = uniforms.covHeight
|
|
95
|
+
f32[7] = uniforms.covYOffset
|
|
96
|
+
f32[8] = uniforms.covTop
|
|
97
|
+
f32[9] = uniforms.regionMaxDepth
|
|
98
|
+
f32[10] = uniforms.depthDomainMax
|
|
99
|
+
f32[11] = uniforms.depthDomainMin
|
|
100
|
+
f32[12] = uniforms.coverageSymlogConstant
|
|
101
|
+
f32[13] = uniforms.binSize
|
|
102
|
+
f32[14] = uniforms.interbaseHeight
|
|
103
|
+
f32[15] = uniforms.snpMinFreq
|
|
104
|
+
f32[16] = uniforms.reversed
|
|
105
|
+
i32[17] = uniforms.coverageScaleType
|
|
106
|
+
u32[18] = uniforms.colorCoverage
|
|
107
|
+
u32[19] = uniforms.colorBaseA
|
|
108
|
+
u32[20] = uniforms.colorBaseC
|
|
109
|
+
u32[21] = uniforms.colorBaseG
|
|
110
|
+
u32[22] = uniforms.colorBaseT
|
|
111
|
+
u32[23] = uniforms.colorBaseN
|
|
112
|
+
u32[24] = uniforms.colorInsertionIndicator
|
|
113
|
+
u32[25] = uniforms.colorSoftclipIndicator
|
|
114
|
+
u32[26] = uniforms.colorHardclipIndicator
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export const INSTANCE_STRIDE_BYTES = 8
|
|
118
|
+
export const INSTANCE_STRIDE_WORDS = 2
|
|
119
|
+
|
|
120
|
+
// Word indices into a Float32Array view over the instance buffer.
|
|
121
|
+
export const INSTANCE_OFFSET_F32 = {
|
|
122
|
+
relDepth: 1,
|
|
123
|
+
} as const
|
|
124
|
+
|
|
125
|
+
// Word indices into a Uint32Array view over the instance buffer.
|
|
126
|
+
export const INSTANCE_OFFSET_U32 = {
|
|
127
|
+
position: 0,
|
|
128
|
+
} as const
|
|
129
|
+
|
|
130
|
+
export const VERTEX_ATTRIBUTES: readonly VertexAttributeLayout[] = [
|
|
131
|
+
{ name: 'a_position', components: 1, type: 'uint', offsetBytes: 0, integer: true },
|
|
132
|
+
{ name: 'a_relDepth', components: 1, type: 'float', offsetBytes: 4, integer: false },
|
|
133
|
+
]
|
|
134
|
+
|
|
135
|
+
export interface InstanceArrays {
|
|
136
|
+
position: ArrayLike<number>
|
|
137
|
+
relDepth: ArrayLike<number>
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export function packInstances(
|
|
141
|
+
arrays: InstanceArrays,
|
|
142
|
+
numInstances: number,
|
|
143
|
+
buf: ArrayBuffer = new ArrayBuffer(numInstances * INSTANCE_STRIDE_BYTES),
|
|
144
|
+
) {
|
|
145
|
+
const f32 = new Float32Array(buf)
|
|
146
|
+
const u32 = new Uint32Array(buf)
|
|
147
|
+
const { position, relDepth } = arrays
|
|
148
|
+
for (let i = 0; i < numInstances; i++) {
|
|
149
|
+
const o = i * INSTANCE_STRIDE_WORDS
|
|
150
|
+
u32[o + 0] = position[i]!
|
|
151
|
+
f32[o + 1] = relDepth[i]!
|
|
152
|
+
}
|
|
153
|
+
return buf
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// Instance `i`'s `position`.
|
|
157
|
+
export function getInstancePosition(u32: Uint32Array, i: number) {
|
|
158
|
+
return u32[i * INSTANCE_STRIDE_WORDS]!
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export function setInstancePosition(u32: Uint32Array, i: number, v: number) {
|
|
162
|
+
u32[i * INSTANCE_STRIDE_WORDS] = v
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// Instance `i`'s `relDepth`.
|
|
166
|
+
export function getInstanceRelDepth(f32: Float32Array, i: number) {
|
|
167
|
+
return f32[i * INSTANCE_STRIDE_WORDS + 1]!
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export function setInstanceRelDepth(f32: Float32Array, i: number, v: number) {
|
|
171
|
+
f32[i * INSTANCE_STRIDE_WORDS + 1] = v
|
|
172
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// Coverage-band depth bars: one bar per coverage bin, filled with the palette's
|
|
2
|
+
// coverage color. Bar height is covNormalizeDepth(relDepth) * the band's
|
|
3
|
+
// drawable height. Shared by the alignments pileup band and the MAF band — see
|
|
4
|
+
// coverageBand.slang.
|
|
5
|
+
//! targets: wgsl, glsl
|
|
6
|
+
//! layout-out: packages/alignments-core/src/coverageLayout.generated.ts
|
|
7
|
+
|
|
8
|
+
import coverageBand;
|
|
9
|
+
import colorPack;
|
|
10
|
+
import hpmath;
|
|
11
|
+
|
|
12
|
+
public static const uint VERTS_PER_INSTANCE = 6u;
|
|
13
|
+
[[vk::binding(1, 0)]] ConstantBuffer<CoverageBandUniforms> u;
|
|
14
|
+
|
|
15
|
+
// `relDepth` is depths[bin] / regionMaxDepth, the same packing the SNP and
|
|
16
|
+
// modification segments carry (see coverageSnp.slang) — covNormalizeDepth
|
|
17
|
+
// recovers the raw depth from it. The bin spans `u.binSize` bp: 1 for per-bp
|
|
18
|
+
// coverage, wider once the producer downsamples.
|
|
19
|
+
struct Instance {
|
|
20
|
+
uint position : ATTR0;
|
|
21
|
+
float relDepth : ATTR1;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
[shader("vertex")]
|
|
25
|
+
CoverageVsOut vs_main(Instance inst, uint vid : SV_VertexID) {
|
|
26
|
+
CoverageVsOut o;
|
|
27
|
+
// The whole bar: y span 0..1 of itself. Same quad the segments stack inside.
|
|
28
|
+
o.position = covSegQuad(inst.position, uint(u.binSize), 0.0, 1.0,
|
|
29
|
+
inst.relDepth, quadLocal(vid), u);
|
|
30
|
+
o.color = float4(unpackRGBA(u.colorCoverage).xyz, 1.0);
|
|
31
|
+
return o;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
[shader("fragment")]
|
|
35
|
+
float4 fs_main(CoverageVsOut fragIn) : SV_Target {
|
|
36
|
+
return fragIn.color;
|
|
37
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// AUTO-GENERATED by packages/shader-tools/src/shader-codegen from coverageIndicator.slang.
|
|
2
|
+
// Do not edit. Run `pnpm gen:shaders` to regenerate.
|
|
3
|
+
|
|
4
|
+
export const WGSL_SOURCE = "struct CoverageBandUniforms_std140_0\n{\n @align(16) bpHi_0 : f32,\n @align(4) bpLo_0 : f32,\n @align(8) bpLen_0 : f32,\n @align(4) hpZero_0 : f32,\n @align(16) canvasW_0 : f32,\n @align(4) canvasH_0 : f32,\n @align(8) covHeight_0 : f32,\n @align(4) covYOffset_0 : f32,\n @align(16) covTop_0 : f32,\n @align(4) regionMaxDepth_0 : f32,\n @align(8) depthDomainMax_0 : f32,\n @align(4) depthDomainMin_0 : f32,\n @align(16) coverageSymlogConstant_0 : f32,\n @align(4) binSize_0 : f32,\n @align(8) interbaseHeight_0 : f32,\n @align(4) snpMinFreq_0 : f32,\n @align(16) reversed_0 : f32,\n @align(4) coverageScaleType_0 : i32,\n @align(8) colorCoverage_0 : u32,\n @align(4) colorBaseA_0 : u32,\n @align(16) colorBaseC_0 : u32,\n @align(4) colorBaseG_0 : u32,\n @align(8) colorBaseT_0 : u32,\n @align(4) colorBaseN_0 : u32,\n @align(16) colorInsertionIndicator_0 : u32,\n @align(4) colorSoftclipIndicator_0 : u32,\n @align(8) colorHardclipIndicator_0 : u32,\n};\n\n@binding(1) @group(0) var<uniform> u_0 : CoverageBandUniforms_std140_0;\nfn hpSplitUint_0( value_0 : u32) -> vec2<f32>\n{\n var lo_0 : u32 = (value_0 & (u32(4095)));\n return vec2<f32>(f32(value_0 - lo_0), f32(lo_0));\n}\n\nfn hpToClipX_0( splitPos_0 : vec2<f32>, bpRange_0 : vec3<f32>, hpZero_1 : f32) -> f32\n{\n var step_0 : f32 = 2.0f / bpRange_0.z;\n var _S1 : f32 = - (1.0f / hpZero_1);\n return dot(vec3<f32>(-1.0f, max(splitPos_0.x - bpRange_0.x, _S1), max(splitPos_0.y - bpRange_0.y, _S1)), vec3<f32>(1.0f, step_0, step_0));\n}\n\nfn covBpToClipX_0( bp_0 : u32, u_1 : ptr<function, CoverageBandUniforms_std140_0>) -> f32\n{\n return hpToClipX_0(hpSplitUint_0(bp_0), vec3<f32>((*u_1).bpHi_0, (*u_1).bpLo_0, (*u_1).bpLen_0), (*u_1).hpZero_0);\n}\n\nfn pxToClipLen_0( px_0 : f32, size_0 : f32) -> f32\n{\n return px_0 * 2.0f / size_0;\n}\n\nfn yPxToClipY_0( yPx_0 : f32, canvasHeight_0 : f32) -> f32\n{\n return 1.0f - yPx_0 / canvasHeight_0 * 2.0f;\n}\n\nfn covAreaTop_0( u_2 : ptr<function, CoverageBandUniforms_std140_0>) -> f32\n{\n return yPxToClipY_0((*u_2).covTop_0, (*u_2).canvasH_0);\n}\n\nfn covFlipX_0( x_0 : f32, u_3 : ptr<function, CoverageBandUniforms_std140_0>) -> f32\n{\n return mix(x_0, - x_0, (*u_3).reversed_0);\n}\n\nfn unpackRGBA_0( c_0 : u32) -> vec4<f32>\n{\n return vec4<f32>(f32((((c_0 >> (u32(0)))) & (u32(255)))), f32((((c_0 >> (u32(8)))) & (u32(255)))), f32((((c_0 >> (u32(16)))) & (u32(255)))), f32((((c_0 >> (u32(24)))) & (u32(255))))) / vec4<f32>(255.0f);\n}\n\nfn covClipKindColor_0( ct_0 : f32, u_4 : ptr<function, CoverageBandUniforms_std140_0>) -> vec3<f32>\n{\n var ci_0 : i32 = i32(ct_0);\n if(ci_0 == i32(2))\n {\n return unpackRGBA_0((*u_4).colorSoftclipIndicator_0).xyz;\n }\n if(ci_0 == i32(3))\n {\n return unpackRGBA_0((*u_4).colorHardclipIndicator_0).xyz;\n }\n return unpackRGBA_0((*u_4).colorInsertionIndicator_0).xyz;\n}\n\nstruct VsOut_0\n{\n @builtin(position) position_0 : vec4<f32>,\n @location(0) color_0 : vec4<f32>,\n @location(1) bary_0 : vec3<f32>,\n};\n\nstruct vertexInput_0\n{\n @location(0) position_1 : u32,\n @location(1) colorType_0 : f32,\n};\n\n@vertex\nfn vs_main( _S2 : vertexInput_0, @builtin(vertex_index) vid_0 : u32) -> VsOut_0\n{\n var o_0 : VsOut_0;\n var v_0 : u32 = vid_0 % u32(3);\n var _S3 : CoverageBandUniforms_std140_0 = u_0;\n var _S4 : f32 = covBpToClipX_0(_S2.position_1, &(_S3));\n var tw_0 : f32 = pxToClipLen_0(7.0f, u_0.canvasW_0);\n var th_0 : f32 = pxToClipLen_0(4.5f, u_0.canvasH_0);\n var _S5 : f32 = covAreaTop_0(&(_S3));\n var sx_0 : f32;\n var sy_0 : f32;\n if(v_0 == u32(0))\n {\n var _S6 : f32 = _S4 - tw_0 * 0.5f;\n o_0.bary_0 = vec3<f32>(1.0f, 0.0f, 0.0f);\n sx_0 = _S6;\n sy_0 = _S5;\n }\n else\n {\n if(v_0 == u32(1))\n {\n var _S7 : f32 = _S4 + tw_0 * 0.5f;\n o_0.bary_0 = vec3<f32>(0.0f, 1.0f, 0.0f);\n sx_0 = _S7;\n sy_0 = _S5;\n }\n else\n {\n var _S8 : f32 = _S5 - th_0;\n o_0.bary_0 = vec3<f32>(0.0f, 0.0f, 1.0f);\n sx_0 = _S4;\n sy_0 = _S8;\n }\n }\n var _S9 : f32 = covFlipX_0(sx_0, &(_S3));\n o_0.position_0 = vec4<f32>(_S9, sy_0, 0.0f, 1.0f);\n var _S10 : vec3<f32> = covClipKindColor_0(_S2.colorType_0, &(_S3));\n o_0.color_0 = vec4<f32>(_S10, 1.0f);\n return o_0;\n}\n\nstruct pixelOutput_0\n{\n @location(0) output_0 : vec4<f32>,\n};\n\nstruct pixelInput_0\n{\n @location(0) color_1 : vec4<f32>,\n @location(1) bary_1 : vec3<f32>,\n};\n\n@fragment\nfn fs_main( _S11 : pixelInput_0, @builtin(position) position_2 : vec4<f32>) -> pixelOutput_0\n{\n var _S12 : pixelOutput_0 = pixelOutput_0( vec4<f32>(_S11.color_1.xyz, _S11.color_1.w * smoothstep(0.0f, 1.0f, min(_S11.bary_1.y * 3.70000004768371582f, _S11.bary_1.x * 3.70000004768371582f))) );\n return _S12;\n}\n\n"
|
|
5
|
+
|
|
6
|
+
export const GLSL_VERTEX = "#version 300 es\nprecision highp float;\nprecision highp int;\nstruct CoverageBandUniforms_0\n{\n float bpHi_0;\n float bpLo_0;\n float bpLen_0;\n float hpZero_0;\n float canvasW_0;\n float canvasH_0;\n float covHeight_0;\n float covYOffset_0;\n float covTop_0;\n float regionMaxDepth_0;\n float depthDomainMax_0;\n float depthDomainMin_0;\n float coverageSymlogConstant_0;\n float binSize_0;\n float interbaseHeight_0;\n float snpMinFreq_0;\n float reversed_0;\n int coverageScaleType_0;\n uint colorCoverage_0;\n uint colorBaseA_0;\n uint colorBaseC_0;\n uint colorBaseG_0;\n uint colorBaseT_0;\n uint colorBaseN_0;\n uint colorInsertionIndicator_0;\n uint colorSoftclipIndicator_0;\n uint colorHardclipIndicator_0;\n};\n\n\nlayout(std140) uniform Uniforms\n{\n float bpHi_0;\n float bpLo_0;\n float bpLen_0;\n float hpZero_0;\n float canvasW_0;\n float canvasH_0;\n float covHeight_0;\n float covYOffset_0;\n float covTop_0;\n float regionMaxDepth_0;\n float depthDomainMax_0;\n float depthDomainMin_0;\n float coverageSymlogConstant_0;\n float binSize_0;\n float interbaseHeight_0;\n float snpMinFreq_0;\n float reversed_0;\n int coverageScaleType_0;\n uint colorCoverage_0;\n uint colorBaseA_0;\n uint colorBaseC_0;\n uint colorBaseG_0;\n uint colorBaseT_0;\n uint colorBaseN_0;\n uint colorInsertionIndicator_0;\n uint colorSoftclipIndicator_0;\n uint colorHardclipIndicator_0;\n}u_0;\n\nvec2 hpSplitUint_0(uint value_0)\n{\n\n uint lo_0 = value_0 & 4095U;\n\n return vec2(float(value_0 - lo_0), float(lo_0));\n}\n\n\nfloat hpToClipX_0(vec2 splitPos_0, vec3 bpRange_0, float hpZero_1)\n{\n float step_0 = 2.0 / bpRange_0.z;\n float _S1 = - (1.0 / hpZero_1);\n\n return dot(vec3(-1.0, max(splitPos_0.x - bpRange_0.x, _S1), max(splitPos_0.y - bpRange_0.y, _S1)), vec3(1.0, step_0, step_0));\n}\n\n\nfloat covBpToClipX_0(uint bp_0, CoverageBandUniforms_0 u_1)\n{\n\n return hpToClipX_0(hpSplitUint_0(bp_0), vec3(u_1.bpHi_0, u_1.bpLo_0, u_1.bpLen_0), u_1.hpZero_0);\n}\n\n\nfloat pxToClipLen_0(float px_0, float size_0)\n{\n\n return px_0 * 2.0 / size_0;\n}\n\n\nfloat yPxToClipY_0(float yPx_0, float canvasHeight_0)\n{\n\n return 1.0 - yPx_0 / canvasHeight_0 * 2.0;\n}\n\n\nfloat covAreaTop_0(CoverageBandUniforms_0 u_2)\n{\n\n return yPxToClipY_0(u_2.covTop_0, u_2.canvasH_0);\n}\n\n\nfloat covFlipX_0(float x_0, CoverageBandUniforms_0 u_3)\n{\n\n return mix(x_0, - x_0, u_3.reversed_0);\n}\n\n\nvec4 unpackRGBA_0(uint c_0)\n{\n\n return vec4(float((c_0 >> 0U) & 255U), float((c_0 >> 8U) & 255U), float((c_0 >> 16U) & 255U), float((c_0 >> 24U) & 255U)) / 255.0;\n}\n\n\nvec3 covClipKindColor_0(float ct_0, CoverageBandUniforms_0 u_4)\n{\n\n int ci_0 = int(ct_0);\n if(ci_0 == 2)\n {\n\n return unpackRGBA_0(u_4.colorSoftclipIndicator_0).xyz;\n }\n\n if(ci_0 == 3)\n {\n\n return unpackRGBA_0(u_4.colorHardclipIndicator_0).xyz;\n }\n\n return unpackRGBA_0(u_4.colorInsertionIndicator_0).xyz;\n}\n\n\nout vec4 v_color;\n\n\nout vec3 v_bary;\n\n\nlayout(location = 0)\nin uint a_position;\n\n\nlayout(location = 1)\nin float a_colorType;\n\n\nstruct VsOut_0\n{\n vec4 position_0;\n vec4 color_0;\n vec3 bary_0;\n};\n\nvoid main()\n{\n\n VsOut_0 o_0;\n uint v_0 = uint(gl_VertexID) % 3U;\n\n CoverageBandUniforms_0 _S2 = CoverageBandUniforms_0(u_0.bpHi_0, u_0.bpLo_0, u_0.bpLen_0, u_0.hpZero_0, u_0.canvasW_0, u_0.canvasH_0, u_0.covHeight_0, u_0.covYOffset_0, u_0.covTop_0, u_0.regionMaxDepth_0, u_0.depthDomainMax_0, u_0.depthDomainMin_0, u_0.coverageSymlogConstant_0, u_0.binSize_0, u_0.interbaseHeight_0, u_0.snpMinFreq_0, u_0.reversed_0, u_0.coverageScaleType_0, u_0.colorCoverage_0, u_0.colorBaseA_0, u_0.colorBaseC_0, u_0.colorBaseG_0, u_0.colorBaseT_0, u_0.colorBaseN_0, u_0.colorInsertionIndicator_0, u_0.colorSoftclipIndicator_0, u_0.colorHardclipIndicator_0);\n\n float cx_0 = covBpToClipX_0(a_position, _S2);\n float tw_0 = pxToClipLen_0(7.0, u_0.canvasW_0);\n float th_0 = pxToClipLen_0(4.5, u_0.canvasH_0);\n\n float top_0 = covAreaTop_0(_S2);\n\n float sx_0;\n\n float sy_0;\n\n if(v_0 == 0U)\n {\n\n float _S3 = cx_0 - tw_0 * 0.5;\n\n o_0.bary_0 = vec3(1.0, 0.0, 0.0);\n\n sx_0 = _S3;\n\n sy_0 = top_0;\n\n }\n else\n {\n\n if(v_0 == 1U)\n {\n\n float _S4 = cx_0 + tw_0 * 0.5;\n\n o_0.bary_0 = vec3(0.0, 1.0, 0.0);\n\n sx_0 = _S4;\n\n sy_0 = top_0;\n\n }\n else\n {\n\n float _S5 = top_0 - th_0;\n\n o_0.bary_0 = vec3(0.0, 0.0, 1.0);\n\n sx_0 = cx_0;\n\n sy_0 = _S5;\n\n }\n\n }\n\n\n\n o_0.position_0 = vec4(covFlipX_0(sx_0, _S2), sy_0, 0.0, 1.0);\n o_0.color_0 = vec4(covClipKindColor_0(a_colorType, _S2), 1.0);\n VsOut_0 _S6 = o_0;\n\n gl_Position = o_0.position_0;\n\n v_color = _S6.color_0;\n\n v_bary = _S6.bary_0;\n\n return;\n}\n\n"
|
|
7
|
+
|
|
8
|
+
export const GLSL_FRAGMENT = "#version 300 es\nprecision highp float;\nprecision highp int;\nlayout(location = 0)\nout vec4 entryPointParam_fs_main_0;\n\n\nin vec4 v_color;\n\n\nin vec3 v_bary;\n\n\nvoid main()\n{\n\n entryPointParam_fs_main_0 = vec4(v_color.xyz, v_color.w * smoothstep(0.0, 1.0, min(v_bary.y * 3.70000004768371582, v_bary.x * 3.70000004768371582)));\n\n return;\n}\n\n"
|
|
9
|
+
|
|
10
|
+
export * from './coverageIndicator.iface.generated.ts'
|