@jbrowse/render-core 5.0.0-beta.1 → 5.0.0-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (352) hide show
  1. package/esm/RenderCanvas.d.ts +2 -2
  2. package/esm/RenderLifecycleMixin.d.ts +52 -20
  3. package/esm/RenderLifecycleMixin.js +89 -23
  4. package/esm/canvas2dUtils.d.ts +90 -23
  5. package/esm/canvas2dUtils.js +119 -36
  6. package/esm/colorRampLut.d.ts +5 -5
  7. package/esm/colorRampLut.js +6 -6
  8. package/esm/computePipeline.d.ts +14 -0
  9. package/esm/computePipeline.js +62 -0
  10. package/esm/contractReports.d.ts +54 -0
  11. package/esm/contractReports.js +112 -0
  12. package/esm/coverageBand.d.ts +13 -8
  13. package/esm/coverageBand.js +15 -5
  14. package/esm/coverageBandBuffers.d.ts +2 -9
  15. package/esm/coverageBandBuffers.js +1 -13
  16. package/esm/createRenderingBackend.d.ts +14 -18
  17. package/esm/createRenderingBackend.js +4 -2
  18. package/esm/displayPhase.d.ts +83 -104
  19. package/esm/displayPhase.js +42 -82
  20. package/esm/encodeMemo.d.ts +14 -0
  21. package/esm/encodeMemo.js +48 -0
  22. package/esm/gpuContextLostError.d.ts +30 -0
  23. package/esm/gpuContextLostError.js +40 -0
  24. package/esm/gpuDevice.d.ts +29 -10
  25. package/esm/gpuDevice.js +35 -16
  26. package/esm/graphicsCapabilities.d.ts +27 -19
  27. package/esm/graphicsCapabilities.js +40 -18
  28. package/esm/hal/createHal.d.ts +4 -5
  29. package/esm/hal/createHal.js +14 -4
  30. package/esm/hal/deviceGpuCache.d.ts +25 -30
  31. package/esm/hal/deviceGpuCache.js +88 -97
  32. package/esm/hal/gpuHalBase.d.ts +5 -4
  33. package/esm/hal/gpuHalBase.js +25 -14
  34. package/esm/hal/index.d.ts +2 -2
  35. package/esm/hal/index.js +1 -1
  36. package/esm/hal/mockHal.d.ts +15 -10
  37. package/esm/hal/mockHal.js +31 -18
  38. package/esm/hal/oomReporter.d.ts +7 -0
  39. package/esm/hal/oomReporter.js +10 -0
  40. package/esm/hal/passIds.d.ts +8 -7
  41. package/esm/hal/passIds.js +11 -10
  42. package/esm/hal/regionRegistry.d.ts +0 -1
  43. package/esm/hal/regionRegistry.js +3 -15
  44. package/esm/hal/types.d.ts +55 -18
  45. package/esm/hal/webgl2Hal.d.ts +23 -6
  46. package/esm/hal/webgl2Hal.js +161 -155
  47. package/esm/hal/webgpuHal.d.ts +29 -13
  48. package/esm/hal/webgpuHal.js +221 -153
  49. package/esm/installUpload.d.ts +16 -3
  50. package/esm/installUpload.js +13 -41
  51. package/esm/instanceCache.d.ts +10 -7
  52. package/esm/instanceCache.js +14 -15
  53. package/esm/instancePass.d.ts +2 -1
  54. package/esm/mapUploadSync.d.ts +2 -10
  55. package/esm/mapUploadSync.js +2 -3
  56. package/esm/marks/barMark.d.ts +30 -0
  57. package/esm/marks/barMark.js +149 -0
  58. package/esm/marks/colorFill.d.ts +17 -0
  59. package/esm/marks/colorFill.js +26 -0
  60. package/esm/marks/drawAgainstHit.d.ts +113 -0
  61. package/esm/marks/drawAgainstHit.js +407 -0
  62. package/esm/marks/ellipseDistance.d.ts +10 -0
  63. package/esm/marks/ellipseDistance.js +136 -0
  64. package/esm/marks/glyphPaint.d.ts +36 -0
  65. package/esm/marks/glyphPaint.js +77 -0
  66. package/esm/marks/index.d.ts +33 -0
  67. package/esm/marks/index.js +20 -0
  68. package/esm/marks/lineMark.d.ts +37 -0
  69. package/esm/marks/lineMark.js +416 -0
  70. package/esm/marks/linkMark.d.ts +76 -0
  71. package/esm/marks/linkMark.js +585 -0
  72. package/esm/marks/markBackend.d.ts +118 -0
  73. package/esm/marks/markBackend.js +196 -0
  74. package/esm/marks/markHit.d.ts +32 -0
  75. package/esm/marks/markHit.js +61 -0
  76. package/esm/marks/markInk.d.ts +18 -0
  77. package/esm/marks/markInk.js +71 -0
  78. package/esm/marks/markPaint.d.ts +14 -0
  79. package/esm/marks/markPaint.js +32 -0
  80. package/esm/marks/markPlan.d.ts +25 -0
  81. package/esm/marks/markPlan.js +20 -0
  82. package/esm/marks/markRamp.d.ts +72 -0
  83. package/esm/marks/markRamp.js +197 -0
  84. package/esm/marks/nearestMarkHit.d.ts +55 -0
  85. package/esm/marks/nearestMarkHit.js +158 -0
  86. package/esm/marks/pathRecorder.d.ts +14 -0
  87. package/esm/marks/pathRecorder.js +80 -0
  88. package/esm/marks/pointMark.d.ts +42 -0
  89. package/esm/marks/pointMark.js +125 -0
  90. package/esm/marks/rowLane.d.ts +39 -0
  91. package/esm/marks/rowLane.js +41 -0
  92. package/esm/marks/rowSpanIndex.d.ts +29 -0
  93. package/esm/marks/rowSpanIndex.js +141 -0
  94. package/esm/marks/rowTable.d.ts +41 -0
  95. package/esm/marks/rowTable.js +75 -0
  96. package/esm/marks/ruleMark.d.ts +21 -0
  97. package/esm/marks/ruleMark.js +91 -0
  98. package/esm/marks/spanMark.d.ts +42 -0
  99. package/esm/marks/spanMark.js +81 -0
  100. package/esm/marks/types.d.ts +261 -0
  101. package/esm/marks/types.js +175 -0
  102. package/esm/marks/valueScale.d.ts +23 -0
  103. package/esm/marks/valueScale.js +11 -0
  104. package/esm/namedReactions.d.ts +3 -4
  105. package/esm/namedReactions.js +3 -4
  106. package/esm/perRegionRenderingBackend.d.ts +21 -3
  107. package/esm/perRegionRenderingBackend.js +37 -3
  108. package/esm/regionDataMap.d.ts +2 -2
  109. package/esm/regionDataMap.js +25 -23
  110. package/esm/renderBlock.d.ts +14 -0
  111. package/esm/renderBlock.js +25 -0
  112. package/esm/renderingBackendBase.d.ts +20 -14
  113. package/esm/renderingBackendBase.js +12 -7
  114. package/esm/scoreScale.d.ts +27 -0
  115. package/esm/scoreScale.js +88 -0
  116. package/esm/shaders/barMark.generated.d.ts +3 -0
  117. package/esm/shaders/barMark.generated.js +7 -0
  118. package/esm/shaders/barMark.glsl.generated.d.ts +2 -0
  119. package/esm/shaders/barMark.glsl.generated.js +4 -0
  120. package/esm/shaders/barMark.iface.generated.d.ts +90 -0
  121. package/esm/shaders/barMark.iface.generated.js +205 -0
  122. package/esm/shaders/barMark.wgsl.generated.d.ts +1 -0
  123. package/esm/shaders/barMark.wgsl.generated.js +3 -0
  124. package/esm/shaders/capsule.js.generated.d.ts +1 -0
  125. package/esm/shaders/capsule.js.generated.js +11 -0
  126. package/esm/shaders/clipStrip.generated.d.ts +2 -0
  127. package/esm/shaders/clipStrip.generated.js +4 -0
  128. package/esm/shaders/clipStrip.js.generated.d.ts +1 -0
  129. package/esm/shaders/clipStrip.js.generated.js +21 -0
  130. package/esm/shaders/colorRampLut.js.generated.d.ts +1 -0
  131. package/esm/shaders/colorRampLut.js.generated.js +17 -0
  132. package/esm/shaders/coverageBar.generated.d.ts +2 -3
  133. package/esm/shaders/coverageBar.generated.js +4 -3
  134. package/esm/shaders/coverageBar.glsl.generated.d.ts +2 -0
  135. package/esm/shaders/coverageBar.glsl.generated.js +4 -0
  136. package/esm/shaders/coverageBar.iface.generated.js +1 -1
  137. package/esm/shaders/coverageBar.wgsl.generated.d.ts +1 -0
  138. package/esm/shaders/coverageBar.wgsl.generated.js +3 -0
  139. package/esm/shaders/coverageClip.generated.d.ts +3 -0
  140. package/esm/shaders/coverageClip.generated.js +7 -0
  141. package/esm/shaders/coverageClip.glsl.generated.d.ts +2 -0
  142. package/esm/shaders/coverageClip.glsl.generated.js +4 -0
  143. package/esm/shaders/coverageClip.iface.generated.d.ts +85 -0
  144. package/esm/shaders/coverageClip.iface.generated.js +114 -0
  145. package/esm/shaders/coverageClip.wgsl.generated.d.ts +1 -0
  146. package/esm/shaders/coverageClip.wgsl.generated.js +3 -0
  147. package/esm/shaders/coverageIndicator.generated.d.ts +2 -3
  148. package/esm/shaders/coverageIndicator.generated.js +4 -3
  149. package/esm/shaders/coverageIndicator.glsl.generated.d.ts +2 -0
  150. package/esm/shaders/coverageIndicator.glsl.generated.js +4 -0
  151. package/esm/shaders/coverageIndicator.iface.generated.js +1 -1
  152. package/esm/shaders/coverageIndicator.wgsl.generated.d.ts +1 -0
  153. package/esm/shaders/coverageIndicator.wgsl.generated.js +3 -0
  154. package/esm/shaders/coverageInterbase.generated.d.ts +2 -3
  155. package/esm/shaders/coverageInterbase.generated.js +4 -3
  156. package/esm/shaders/coverageInterbase.glsl.generated.d.ts +2 -0
  157. package/esm/shaders/coverageInterbase.glsl.generated.js +4 -0
  158. package/esm/shaders/coverageInterbase.iface.generated.js +1 -1
  159. package/esm/shaders/coverageInterbase.wgsl.generated.d.ts +1 -0
  160. package/esm/shaders/coverageInterbase.wgsl.generated.js +3 -0
  161. package/esm/shaders/coverageMod.generated.d.ts +2 -3
  162. package/esm/shaders/coverageMod.generated.js +4 -3
  163. package/esm/shaders/coverageMod.glsl.generated.d.ts +2 -0
  164. package/esm/shaders/coverageMod.glsl.generated.js +4 -0
  165. package/esm/shaders/coverageMod.iface.generated.js +1 -1
  166. package/esm/shaders/coverageMod.wgsl.generated.d.ts +1 -0
  167. package/esm/shaders/coverageMod.wgsl.generated.js +3 -0
  168. package/esm/shaders/coverageSnp.generated.d.ts +2 -3
  169. package/esm/shaders/coverageSnp.generated.js +4 -3
  170. package/esm/shaders/coverageSnp.glsl.generated.d.ts +2 -0
  171. package/esm/shaders/coverageSnp.glsl.generated.js +4 -0
  172. package/esm/shaders/coverageSnp.iface.generated.js +1 -1
  173. package/esm/shaders/coverageSnp.wgsl.generated.d.ts +1 -0
  174. package/esm/shaders/coverageSnp.wgsl.generated.js +3 -0
  175. package/esm/shaders/curveDistance.js.generated.d.ts +5 -0
  176. package/esm/shaders/curveDistance.js.generated.js +87 -0
  177. package/esm/shaders/hpmath.js.generated.d.ts +2 -1
  178. package/esm/shaders/hpmath.js.generated.js +5 -2
  179. package/esm/shaders/lineCenterMark.generated.d.ts +3 -0
  180. package/esm/shaders/lineCenterMark.generated.js +7 -0
  181. package/esm/shaders/lineCenterMark.glsl.generated.d.ts +2 -0
  182. package/esm/shaders/lineCenterMark.glsl.generated.js +4 -0
  183. package/esm/shaders/lineCenterMark.iface.generated.d.ts +104 -0
  184. package/esm/shaders/lineCenterMark.iface.generated.js +237 -0
  185. package/esm/shaders/lineCenterMark.wgsl.generated.d.ts +1 -0
  186. package/esm/shaders/lineCenterMark.wgsl.generated.js +3 -0
  187. package/esm/shaders/lineCommon.generated.d.ts +2 -0
  188. package/esm/shaders/lineCommon.generated.js +4 -0
  189. package/esm/shaders/lineStepMark.generated.d.ts +3 -0
  190. package/esm/shaders/lineStepMark.generated.js +7 -0
  191. package/esm/shaders/lineStepMark.glsl.generated.d.ts +2 -0
  192. package/esm/shaders/lineStepMark.glsl.generated.js +4 -0
  193. package/esm/shaders/lineStepMark.iface.generated.d.ts +98 -0
  194. package/esm/shaders/lineStepMark.iface.generated.js +225 -0
  195. package/esm/shaders/lineStepMark.wgsl.generated.d.ts +1 -0
  196. package/esm/shaders/lineStepMark.wgsl.generated.js +3 -0
  197. package/esm/shaders/linkMark.consts.generated.d.ts +14 -0
  198. package/esm/shaders/linkMark.consts.generated.js +16 -0
  199. package/esm/shaders/linkMark.generated.d.ts +4 -0
  200. package/esm/shaders/linkMark.generated.js +8 -0
  201. package/esm/shaders/linkMark.glsl.generated.d.ts +2 -0
  202. package/esm/shaders/linkMark.glsl.generated.js +4 -0
  203. package/esm/shaders/linkMark.iface.generated.d.ts +142 -0
  204. package/esm/shaders/linkMark.iface.generated.js +1829 -0
  205. package/esm/shaders/linkMark.js.generated.d.ts +7 -0
  206. package/esm/shaders/linkMark.js.generated.js +159 -0
  207. package/esm/shaders/linkMark.wgsl.generated.d.ts +1 -0
  208. package/esm/shaders/linkMark.wgsl.generated.js +3 -0
  209. package/esm/shaders/markColor.generated.d.ts +9 -0
  210. package/esm/shaders/markColor.generated.js +11 -0
  211. package/esm/shaders/pointGlyph.js.generated.d.ts +2 -0
  212. package/esm/shaders/pointGlyph.js.generated.js +15 -0
  213. package/esm/shaders/pointMark.consts.generated.d.ts +7 -0
  214. package/esm/shaders/pointMark.consts.generated.js +9 -0
  215. package/esm/shaders/pointMark.generated.d.ts +4 -0
  216. package/esm/shaders/pointMark.generated.js +8 -0
  217. package/esm/shaders/pointMark.glsl.generated.d.ts +2 -0
  218. package/esm/shaders/pointMark.glsl.generated.js +4 -0
  219. package/esm/shaders/pointMark.iface.generated.d.ts +98 -0
  220. package/esm/shaders/pointMark.iface.generated.js +219 -0
  221. package/esm/shaders/pointMark.js.generated.d.ts +3 -0
  222. package/esm/shaders/pointMark.js.generated.js +93 -0
  223. package/esm/shaders/pointMark.wgsl.generated.d.ts +1 -0
  224. package/esm/shaders/pointMark.wgsl.generated.js +3 -0
  225. package/esm/shaders/rowRect.generated.d.ts +0 -1
  226. package/esm/shaders/rowRect.generated.js +0 -1
  227. package/esm/shaders/rowTable.generated.d.ts +1 -0
  228. package/esm/shaders/rowTable.generated.js +3 -0
  229. package/esm/shaders/rowTable.js.generated.d.ts +5 -0
  230. package/esm/shaders/rowTable.js.generated.js +29 -0
  231. package/esm/shaders/scoreScale.generated.d.ts +2 -0
  232. package/esm/shaders/scoreScale.generated.js +4 -0
  233. package/esm/shaders/scoreScale.js.generated.d.ts +1 -0
  234. package/esm/shaders/scoreScale.js.generated.js +50 -23
  235. package/esm/shaders/spanMark.generated.d.ts +3 -0
  236. package/esm/shaders/spanMark.generated.js +7 -0
  237. package/esm/shaders/spanMark.glsl.generated.d.ts +2 -0
  238. package/esm/shaders/spanMark.glsl.generated.js +4 -0
  239. package/esm/shaders/spanMark.iface.generated.d.ts +81 -0
  240. package/esm/shaders/spanMark.iface.generated.js +215 -0
  241. package/esm/shaders/spanMark.wgsl.generated.d.ts +1 -0
  242. package/esm/shaders/spanMark.wgsl.generated.js +3 -0
  243. package/esm/sharedBackendKey.d.ts +18 -0
  244. package/esm/{keyedRenderingBackend.js → sharedBackendKey.js} +5 -0
  245. package/esm/slangPass.d.ts +18 -11
  246. package/esm/slangPass.js +12 -4
  247. package/esm/useGraphicsCapabilities.d.ts +1 -1
  248. package/esm/useGraphicsCapabilities.js +1 -1
  249. package/esm/useRenderingBackend.d.ts +13 -13
  250. package/esm/useRenderingBackend.js +58 -20
  251. package/esm/webgpuUtils.d.ts +3 -11
  252. package/esm/webgpuUtils.js +12 -33
  253. package/package.json +32 -7
  254. package/src/shaders/antialias.slang +46 -0
  255. package/src/shaders/arcHull.test.ts +267 -0
  256. package/src/shaders/barMark.generated.ts +11 -0
  257. package/src/shaders/barMark.glsl.generated.ts +6 -0
  258. package/src/shaders/barMark.iface.generated.ts +285 -0
  259. package/src/shaders/barMark.slang +167 -0
  260. package/src/shaders/barMark.wgsl.generated.ts +4 -0
  261. package/src/shaders/capsule.js.generated.ts +14 -0
  262. package/src/shaders/capsule.slang +12 -4
  263. package/src/shaders/clipStrip.generated.ts +6 -0
  264. package/src/shaders/clipStrip.js.generated.ts +22 -0
  265. package/src/shaders/clipStrip.slang +34 -0
  266. package/src/shaders/clipStrip.test.ts +39 -0
  267. package/src/shaders/colorPack.slang +5 -1
  268. package/src/shaders/colorRampLut.js.generated.ts +22 -0
  269. package/src/shaders/colorRampLut.slang +15 -1
  270. package/src/shaders/coverageBand.slang +64 -32
  271. package/src/shaders/coverageBar.generated.ts +6 -5
  272. package/src/shaders/coverageBar.glsl.generated.ts +6 -0
  273. package/src/shaders/coverageBar.iface.generated.ts +1 -1
  274. package/src/shaders/coverageBar.slang +10 -10
  275. package/src/shaders/coverageBar.wgsl.generated.ts +4 -0
  276. package/src/shaders/coverageClip.generated.ts +11 -0
  277. package/src/shaders/coverageClip.glsl.generated.ts +6 -0
  278. package/src/shaders/coverageClip.iface.generated.ts +172 -0
  279. package/src/shaders/coverageClip.slang +38 -0
  280. package/src/shaders/coverageClip.wgsl.generated.ts +4 -0
  281. package/src/shaders/coverageIndicator.generated.ts +6 -5
  282. package/src/shaders/coverageIndicator.glsl.generated.ts +6 -0
  283. package/src/shaders/coverageIndicator.iface.generated.ts +1 -1
  284. package/src/shaders/coverageIndicator.wgsl.generated.ts +4 -0
  285. package/src/shaders/coverageInterbase.generated.ts +6 -5
  286. package/src/shaders/coverageInterbase.glsl.generated.ts +6 -0
  287. package/src/shaders/coverageInterbase.iface.generated.ts +1 -1
  288. package/src/shaders/coverageInterbase.wgsl.generated.ts +4 -0
  289. package/src/shaders/coverageMod.generated.ts +6 -5
  290. package/src/shaders/coverageMod.glsl.generated.ts +6 -0
  291. package/src/shaders/coverageMod.iface.generated.ts +1 -1
  292. package/src/shaders/coverageMod.wgsl.generated.ts +4 -0
  293. package/src/shaders/coverageSnp.generated.ts +6 -5
  294. package/src/shaders/coverageSnp.glsl.generated.ts +6 -0
  295. package/src/shaders/coverageSnp.iface.generated.ts +1 -1
  296. package/src/shaders/coverageSnp.wgsl.generated.ts +4 -0
  297. package/src/shaders/curveDistance.js.generated.ts +91 -0
  298. package/src/shaders/curveDistance.slang +265 -0
  299. package/src/shaders/hpClampFloor.test.ts +87 -0
  300. package/src/shaders/hpmath.js.generated.ts +6 -2
  301. package/src/shaders/hpmath.slang +100 -48
  302. package/src/shaders/insetValueScale.test.ts +67 -0
  303. package/src/shaders/lineCenterMark.generated.ts +11 -0
  304. package/src/shaders/lineCenterMark.glsl.generated.ts +6 -0
  305. package/src/shaders/lineCenterMark.iface.generated.ts +328 -0
  306. package/src/shaders/lineCenterMark.slang +127 -0
  307. package/src/shaders/lineCenterMark.wgsl.generated.ts +4 -0
  308. package/src/shaders/lineCommon.generated.ts +6 -0
  309. package/src/shaders/lineCommon.slang +102 -0
  310. package/src/shaders/lineStepMark.generated.ts +11 -0
  311. package/src/shaders/lineStepMark.glsl.generated.ts +6 -0
  312. package/src/shaders/lineStepMark.iface.generated.ts +311 -0
  313. package/src/shaders/lineStepMark.slang +125 -0
  314. package/src/shaders/lineStepMark.wgsl.generated.ts +4 -0
  315. package/src/shaders/linkMark.consts.generated.ts +30 -0
  316. package/src/shaders/linkMark.generated.ts +12 -0
  317. package/src/shaders/linkMark.glsl.generated.ts +6 -0
  318. package/src/shaders/linkMark.iface.generated.ts +1954 -0
  319. package/src/shaders/linkMark.js.generated.ts +167 -0
  320. package/src/shaders/linkMark.slang +439 -0
  321. package/src/shaders/linkMark.wgsl.generated.ts +4 -0
  322. package/src/shaders/markColor.generated.ts +20 -0
  323. package/src/shaders/markColor.slang +128 -0
  324. package/src/shaders/pointGlyph.js.generated.ts +20 -0
  325. package/src/shaders/pointGlyph.slang +23 -7
  326. package/src/shaders/pointGlyphPad.test.ts +242 -0
  327. package/src/shaders/pointMark.consts.generated.ts +16 -0
  328. package/src/shaders/pointMark.generated.ts +12 -0
  329. package/src/shaders/pointMark.glsl.generated.ts +6 -0
  330. package/src/shaders/pointMark.iface.generated.ts +304 -0
  331. package/src/shaders/pointMark.js.generated.ts +99 -0
  332. package/src/shaders/pointMark.slang +227 -0
  333. package/src/shaders/pointMark.wgsl.generated.ts +4 -0
  334. package/src/shaders/rowRect.generated.ts +0 -2
  335. package/src/shaders/rowRect.slang +39 -58
  336. package/src/shaders/rowTable.generated.ts +4 -0
  337. package/src/shaders/rowTable.js.generated.ts +37 -0
  338. package/src/shaders/rowTable.slang +98 -0
  339. package/src/shaders/scoreScale.generated.ts +6 -0
  340. package/src/shaders/scoreScale.js.generated.ts +48 -23
  341. package/src/shaders/scoreScale.slang +49 -55
  342. package/src/shaders/sdEllipse.test.ts +211 -0
  343. package/src/shaders/spanMark.generated.ts +11 -0
  344. package/src/shaders/spanMark.glsl.generated.ts +6 -0
  345. package/src/shaders/spanMark.iface.generated.ts +289 -0
  346. package/src/shaders/spanMark.slang +77 -0
  347. package/src/shaders/spanMark.wgsl.generated.ts +4 -0
  348. package/src/shaders/valueScale.slang +26 -0
  349. package/src/shaders/wideCircleLeg.test.ts +85 -0
  350. package/esm/globalRenderingBackend.d.ts +0 -90
  351. package/esm/globalRenderingBackend.js +0 -53
  352. package/esm/keyedRenderingBackend.d.ts +0 -41
@@ -0,0 +1,285 @@
1
+ // AUTO-GENERATED by packages/shader-tools/src/shader-codegen from barMark.slang.
2
+ // Do not edit. Run `pnpm gen:shaders` to regenerate.
3
+
4
+ import type { VertexAttributeLayout, ShaderBinding, TextureBinding } from '@jbrowse/render-core/hal'
5
+
6
+ export const BINDINGS: readonly ShaderBinding[] = [
7
+ { index: 1, kind: 'uniform', name: 'u', stages: ['vertex', 'fragment'] },
8
+ { index: 2, kind: 'texture', name: 'colorRamp', stages: ['vertex'] },
9
+ { index: 3, kind: 'sampler', name: 'colorRamp', stages: ['vertex'] },
10
+ { index: 4, kind: 'texture', name: 'rowTable', stages: ['vertex'] },
11
+ { index: 5, kind: 'sampler', name: 'rowTable', stages: ['vertex'] },
12
+ ]
13
+
14
+ export const VERTS_PER_INSTANCE = 12
15
+
16
+ export const UNIFORMS_SIZE_BYTES = 288
17
+
18
+ // Word indices into a Float32Array view over the uniform buffer.
19
+ export const UNIFORM_OFFSET_F32 = {
20
+ bpRangeX: 0,
21
+ canvasHeight: 3,
22
+ domainMin: 4,
23
+ domainMax: 5,
24
+ valueSymlogConstant: 7,
25
+ rampMin: 9,
26
+ rampMax: 10,
27
+ rampMidNorm: 11,
28
+ originYPx: 60,
29
+ rowHeight: 61,
30
+ rowBandPx: 62,
31
+ rowOffsetPx: 63,
32
+ zero: 64,
33
+ minCellDenomPx: 65,
34
+ minWidthPx: 66,
35
+ devicePixelRatio: 67,
36
+ } as const
37
+
38
+ // Word indices into a Int32Array view over the uniform buffer.
39
+ export const UNIFORM_OFFSET_I32 = {
40
+ valueScaleType: 6,
41
+ rampMode: 8,
42
+ colorCutCount: 12,
43
+ rowTableKeys: 68,
44
+ } as const
45
+
46
+
47
+ // Word indices of each array field’s elements, into a 4-byte-word
48
+ // view over the uniform buffer (Uint32Array or Float32Array — the
49
+ // field’s scalar type picks, same as UNIFORM_OFFSET_*). NOT
50
+ // consecutive: std140 pads every array element to 16 bytes.
51
+ export const UNIFORM_SLOT_ARRAYS = {
52
+ colorCuts: [16, 20] as const,
53
+ colorBands: [24, 28, 32, 36, 40, 44, 48, 52, 56] as const,
54
+ } as const
55
+
56
+ // Element `i` of the `colorCuts` uniform array (4 components).
57
+ export function setUniformColorCuts(
58
+ f32: Float32Array,
59
+ i: number,
60
+ v0: number,
61
+ v1: number,
62
+ v2: number,
63
+ v3: number,
64
+ ) {
65
+ const o = UNIFORM_SLOT_ARRAYS.colorCuts[i]!
66
+ f32[o] = v0
67
+ f32[o + 1] = v1
68
+ f32[o + 2] = v2
69
+ f32[o + 3] = v3
70
+ }
71
+
72
+ // Element `i` of the `colorBands` uniform array (4 components).
73
+ export function setUniformColorBands(
74
+ f32: Float32Array,
75
+ i: number,
76
+ v0: number,
77
+ v1: number,
78
+ v2: number,
79
+ v3: number,
80
+ ) {
81
+ const o = UNIFORM_SLOT_ARRAYS.colorBands[i]!
82
+ f32[o] = v0
83
+ f32[o + 1] = v1
84
+ f32[o + 2] = v2
85
+ f32[o + 3] = v3
86
+ }
87
+
88
+
89
+ export interface Uniforms {
90
+ bpRangeX: [number, number, number]
91
+ canvasHeight: number
92
+ domainMin: number
93
+ domainMax: number
94
+ valueScaleType: number
95
+ valueSymlogConstant: number
96
+ rampMode: number
97
+ rampMin: number
98
+ rampMax: number
99
+ rampMidNorm: number
100
+ colorCutCount: number
101
+ colorCuts: [[number, number, number, number], [number, number, number, number]]
102
+ colorBands: [[number, number, number, number], [number, number, number, number], [number, number, number, number], [number, number, number, number], [number, number, number, number], [number, number, number, number], [number, number, number, number], [number, number, number, number], [number, number, number, number]]
103
+ originYPx: number
104
+ rowHeight: number
105
+ rowBandPx: number
106
+ rowOffsetPx: number
107
+ zero: number
108
+ minCellDenomPx: number
109
+ minWidthPx: number
110
+ devicePixelRatio: number
111
+ rowTableKeys: number
112
+ }
113
+
114
+ export function writeUniforms(buf: ArrayBuffer, uniforms: Uniforms) {
115
+ const f32 = new Float32Array(buf)
116
+ const i32 = new Int32Array(buf)
117
+ f32[0] = uniforms.bpRangeX[0]
118
+ f32[1] = uniforms.bpRangeX[1]
119
+ f32[2] = uniforms.bpRangeX[2]
120
+ f32[3] = uniforms.canvasHeight
121
+ f32[4] = uniforms.domainMin
122
+ f32[5] = uniforms.domainMax
123
+ i32[6] = uniforms.valueScaleType
124
+ f32[7] = uniforms.valueSymlogConstant
125
+ i32[8] = uniforms.rampMode
126
+ f32[9] = uniforms.rampMin
127
+ f32[10] = uniforms.rampMax
128
+ f32[11] = uniforms.rampMidNorm
129
+ i32[12] = uniforms.colorCutCount
130
+ f32[16] = uniforms.colorCuts[0][0]
131
+ f32[17] = uniforms.colorCuts[0][1]
132
+ f32[18] = uniforms.colorCuts[0][2]
133
+ f32[19] = uniforms.colorCuts[0][3]
134
+ f32[20] = uniforms.colorCuts[1][0]
135
+ f32[21] = uniforms.colorCuts[1][1]
136
+ f32[22] = uniforms.colorCuts[1][2]
137
+ f32[23] = uniforms.colorCuts[1][3]
138
+ f32[24] = uniforms.colorBands[0][0]
139
+ f32[25] = uniforms.colorBands[0][1]
140
+ f32[26] = uniforms.colorBands[0][2]
141
+ f32[27] = uniforms.colorBands[0][3]
142
+ f32[28] = uniforms.colorBands[1][0]
143
+ f32[29] = uniforms.colorBands[1][1]
144
+ f32[30] = uniforms.colorBands[1][2]
145
+ f32[31] = uniforms.colorBands[1][3]
146
+ f32[32] = uniforms.colorBands[2][0]
147
+ f32[33] = uniforms.colorBands[2][1]
148
+ f32[34] = uniforms.colorBands[2][2]
149
+ f32[35] = uniforms.colorBands[2][3]
150
+ f32[36] = uniforms.colorBands[3][0]
151
+ f32[37] = uniforms.colorBands[3][1]
152
+ f32[38] = uniforms.colorBands[3][2]
153
+ f32[39] = uniforms.colorBands[3][3]
154
+ f32[40] = uniforms.colorBands[4][0]
155
+ f32[41] = uniforms.colorBands[4][1]
156
+ f32[42] = uniforms.colorBands[4][2]
157
+ f32[43] = uniforms.colorBands[4][3]
158
+ f32[44] = uniforms.colorBands[5][0]
159
+ f32[45] = uniforms.colorBands[5][1]
160
+ f32[46] = uniforms.colorBands[5][2]
161
+ f32[47] = uniforms.colorBands[5][3]
162
+ f32[48] = uniforms.colorBands[6][0]
163
+ f32[49] = uniforms.colorBands[6][1]
164
+ f32[50] = uniforms.colorBands[6][2]
165
+ f32[51] = uniforms.colorBands[6][3]
166
+ f32[52] = uniforms.colorBands[7][0]
167
+ f32[53] = uniforms.colorBands[7][1]
168
+ f32[54] = uniforms.colorBands[7][2]
169
+ f32[55] = uniforms.colorBands[7][3]
170
+ f32[56] = uniforms.colorBands[8][0]
171
+ f32[57] = uniforms.colorBands[8][1]
172
+ f32[58] = uniforms.colorBands[8][2]
173
+ f32[59] = uniforms.colorBands[8][3]
174
+ f32[60] = uniforms.originYPx
175
+ f32[61] = uniforms.rowHeight
176
+ f32[62] = uniforms.rowBandPx
177
+ f32[63] = uniforms.rowOffsetPx
178
+ f32[64] = uniforms.zero
179
+ f32[65] = uniforms.minCellDenomPx
180
+ f32[66] = uniforms.minWidthPx
181
+ f32[67] = uniforms.devicePixelRatio
182
+ i32[68] = uniforms.rowTableKeys
183
+ }
184
+
185
+ export const INSTANCE_STRIDE_BYTES = 20
186
+ export const INSTANCE_STRIDE_WORDS = 5
187
+
188
+ // Word indices into a Float32Array view over the instance buffer.
189
+ export const INSTANCE_OFFSET_F32 = {
190
+ y: 2,
191
+ } as const
192
+
193
+ // Word indices into a Uint32Array view over the instance buffer.
194
+ export const INSTANCE_OFFSET_U32 = {
195
+ x: 0,
196
+ x2: 1,
197
+ color: 3,
198
+ row: 4,
199
+ } as const
200
+
201
+ export const VERTEX_ATTRIBUTES: readonly VertexAttributeLayout[] = [
202
+ { name: 'a_x', components: 1, type: 'uint', offsetBytes: 0, integer: true },
203
+ { name: 'a_x2', components: 1, type: 'uint', offsetBytes: 4, integer: true },
204
+ { name: 'a_y', components: 1, type: 'float', offsetBytes: 8, integer: false },
205
+ { name: 'a_color', components: 1, type: 'uint', offsetBytes: 12, integer: true },
206
+ { name: 'a_row', components: 1, type: 'uint', offsetBytes: 16, integer: true },
207
+ ]
208
+
209
+ export interface InstanceArrays {
210
+ x: ArrayLike<number>
211
+ x2: ArrayLike<number>
212
+ y: ArrayLike<number>
213
+ color: ArrayLike<number>
214
+ row: ArrayLike<number>
215
+ }
216
+
217
+ export function packInstances(
218
+ arrays: InstanceArrays,
219
+ numInstances: number,
220
+ buf: ArrayBuffer = new ArrayBuffer(numInstances * INSTANCE_STRIDE_BYTES),
221
+ ) {
222
+ const f32 = new Float32Array(buf)
223
+ const u32 = new Uint32Array(buf)
224
+ const { x, x2, y, color, row } = arrays
225
+ for (let i = 0; i < numInstances; i++) {
226
+ const o = i * INSTANCE_STRIDE_WORDS
227
+ u32[o + 0] = x[i]!
228
+ u32[o + 1] = x2[i]!
229
+ f32[o + 2] = y[i]!
230
+ u32[o + 3] = color[i]!
231
+ u32[o + 4] = row[i]!
232
+ }
233
+ return buf
234
+ }
235
+
236
+ // Instance `i`'s `x`.
237
+ export function getInstanceX(u32: Uint32Array, i: number) {
238
+ return u32[i * INSTANCE_STRIDE_WORDS]!
239
+ }
240
+
241
+ export function setInstanceX(u32: Uint32Array, i: number, v: number) {
242
+ u32[i * INSTANCE_STRIDE_WORDS] = v
243
+ }
244
+
245
+ // Instance `i`'s `x2`.
246
+ export function getInstanceX2(u32: Uint32Array, i: number) {
247
+ return u32[i * INSTANCE_STRIDE_WORDS + 1]!
248
+ }
249
+
250
+ export function setInstanceX2(u32: Uint32Array, i: number, v: number) {
251
+ u32[i * INSTANCE_STRIDE_WORDS + 1] = v
252
+ }
253
+
254
+ // Instance `i`'s `y`.
255
+ export function getInstanceY(f32: Float32Array, i: number) {
256
+ return f32[i * INSTANCE_STRIDE_WORDS + 2]!
257
+ }
258
+
259
+ export function setInstanceY(f32: Float32Array, i: number, v: number) {
260
+ f32[i * INSTANCE_STRIDE_WORDS + 2] = v
261
+ }
262
+
263
+ // Instance `i`'s `color`.
264
+ export function getInstanceColor(u32: Uint32Array, i: number) {
265
+ return u32[i * INSTANCE_STRIDE_WORDS + 3]!
266
+ }
267
+
268
+ export function setInstanceColor(u32: Uint32Array, i: number, v: number) {
269
+ u32[i * INSTANCE_STRIDE_WORDS + 3] = v
270
+ }
271
+
272
+ // Instance `i`'s `row`.
273
+ export function getInstanceRow(u32: Uint32Array, i: number) {
274
+ return u32[i * INSTANCE_STRIDE_WORDS + 4]!
275
+ }
276
+
277
+ export function setInstanceRow(u32: Uint32Array, i: number, v: number) {
278
+ u32[i * INSTANCE_STRIDE_WORDS + 4] = v
279
+ }
280
+
281
+ // Combined `Sampler2D` bindings. Texture unit indices start at 0.
282
+ export const TEXTURES: readonly [TextureBinding, ...TextureBinding[]] = [
283
+ { name: 'colorRamp', glTextureUnit: 0, glUniformName: 'u_colorRamp', filter: 'linear' },
284
+ { name: 'rowTable', glTextureUnit: 1, glUniformName: 'u_rowTable', filter: 'nearest' },
285
+ ]
@@ -0,0 +1,167 @@
1
+ // The `bar` mark shape: one instance is a rectangle spanning [x, x2) in
2
+ // absolute genomic coords, standing between the `origin` value and the
3
+ // instance's own `y` on the shared `valueScale` — the quantitative bar a BED
4
+ // score column, a CNV segment ratio or a bedGraph-shaped interval draws as.
5
+ //
6
+ // The scale is `valueScale`'s and the anchor is this shape's own (ADR-097): the
7
+ // point shape centres a glyph on the value, this one grows from the baseline to
8
+ // it, and both read one `valueToYPxScaled`.
9
+ //
10
+ // The band is the instance's `row`: `rowHeight` px per row, the value scale
11
+ // ruling each band on its own over `rowBandPx` of it, `rowOffsetPx` below the
12
+ // row's top. A caller with one row sends the canvas height for both and no
13
+ // offset, so its bars stand where they always did (ADR-126). The row is read
14
+ // through the bound row table, as `spanMark` reads it; a pass binding none
15
+ // (`rowTableKeys` −1) draws `row` as the band.
16
+ //
17
+ // The two HORIZONTAL cuts are antialiased analytically, as wiggle's xyplot bar
18
+ // does: the top cut IS the datum, so it must not quantise to the output grid,
19
+ // and the band is the difference of the two cuts' ramps so a bar thinner than a
20
+ // device pixel covers exactly its area. The VERTICAL cuts stay hard on purpose
21
+ // — intervals that tile (segments, bins) split a pixel column with their
22
+ // neighbours, and per-fragment alpha on both sides of that shared edge
23
+ // composites to less than full ink. That fractional edge is why this shader
24
+ // declares no `//! coverage: analytic`: the multisampled target resolves it.
25
+ //
26
+ // The min-width floor grows off the START edge (`extendToMinWidthX`), which is
27
+ // what the painter's `spanLeft` does too, so a reversed block's bars stay exact
28
+ // mirrors of a forward block's.
29
+ //! targets: wgsl, glsl
30
+
31
+ import antialias;
32
+ import hpmath;
33
+ import colorPack;
34
+ import clipStrip;
35
+ import markColor;
36
+ import rowTable;
37
+ import valueScale;
38
+
39
+ // Two quads: the bar, then its clip strip, which every vertex of a bar the
40
+ // domain did not cut sends off clip.
41
+ public static const uint VERTS_PER_INSTANCE = 12u;
42
+
43
+ struct BarMarkInstance {
44
+ uint x : ATTR0;
45
+ uint x2 : ATTR1;
46
+ float y : ATTR2;
47
+ uint color : ATTR3;
48
+ uint row : ATTR4;
49
+ };
50
+
51
+ struct Uniforms {
52
+ float3 bpRangeX;
53
+ float canvasHeight;
54
+ float domainMin;
55
+ float domainMax;
56
+ // `scoreScale`'s scale-type vocabulary, for the declared y scale.
57
+ int valueScaleType;
58
+ // Already resolved from the domain (`resolveSymlogConstant`); read by symlog alone.
59
+ float valueSymlogConstant;
60
+ // `markColor`'s: 0 packs the instance's colour, 1 and 2 read its slot as a
61
+ // value through the ramp below.
62
+ int rampMode;
63
+ float rampMin;
64
+ float rampMax;
65
+ float rampMidNorm;
66
+ // `markColor`'s threshold: how many cuts are in use, the cuts four to a
67
+ // vector, and the colour of each interval between them.
68
+ int colorCutCount;
69
+ float4 colorCuts[2];
70
+ float4 colorBands[MAX_COLOR_BANDS];
71
+ // The baseline, in CSS px below the band's top: `origin` through the same
72
+ // scale `y` reads, resolved on the CPU because the whole draw shares it.
73
+ float originYPx;
74
+ // CSS px per row band; the canvas height where every instance is on row 0.
75
+ float rowHeight;
76
+ // CSS px the value scale runs over inside a row, and how far below the
77
+ // row's top it starts: an inset, less a scroll.
78
+ float rowBandPx;
79
+ float rowOffsetPx;
80
+ float zero;
81
+ // The CSS width `minWidthPx` is measured against; see rowRect's
82
+ // `minCellDenomPx` for why it has to be a CSS width.
83
+ float minCellDenomPx;
84
+ float minWidthPx;
85
+ float devicePixelRatio;
86
+ int rowTableKeys;
87
+ };
88
+ [[vk::binding(1, 0)]] ConstantBuffer<Uniforms> u;
89
+ [[vk::binding(2, 0)]] Sampler2D<float4> colorRamp;
90
+ [[vk::binding(4, 0)]] Sampler2D<float4> rowTable;
91
+
92
+ struct VsOut {
93
+ float4 position : SV_Position;
94
+ float4 color : COLOR0;
95
+ // CSS px below the bar's top cut (.x) and below its bottom cut (.y), both
96
+ // affine in screen y with unit slope, so the fragment's ramp is one output
97
+ // pixel wide by construction and takes no derivative.
98
+ float2 barInkPx : TEXCOORD0;
99
+ };
100
+
101
+ float bpToClipX(uint bp, Uniforms u) {
102
+ return hpToClipX(hpSplitUint(bp), u.bpRangeX, u.zero);
103
+ }
104
+
105
+ // One device pixel in CSS px: the ramp's full width and the geometry pad, so
106
+ // every fragment the ramp gives ink to is fully covered by the quad.
107
+ float barAaPx() {
108
+ return 2.0 * aaHalfPx(u.devicePixelRatio);
109
+ }
110
+
111
+ [shader("vertex")]
112
+ VsOut vs_main(BarMarkInstance inst, uint vid : SV_VertexID) {
113
+ VsOut o;
114
+ RowPlacement place = rowTableLookup(rowTable, inst.row, u.rowTableKeys,
115
+ markScaleColor(colorRamp, inst.color, u.rampMode, u.rampMin, u.rampMax, u.rampMidNorm, u.colorCutCount, u.colorCuts[0], u.colorCuts[1], u.colorBands));
116
+ if (place.hidden) {
117
+ o.position = float4(2.0, 2.0, 0.0, 1.0);
118
+ o.color = float4(0.0);
119
+ o.barInkPx = float2(0.0);
120
+ return o;
121
+ }
122
+ float sx1 = bpToClipX(inst.x, u);
123
+ float sx2 = bpToClipX(inst.x2, u);
124
+ sx2 = extendToMinWidthX(sx1, sx2, u.minWidthPx, u.minCellDenomPx);
125
+ float2 q = quadLocal(vid);
126
+
127
+ float bandTop = rowBandTopPx(u.rowOffsetPx, u.rowHeight, place.slot);
128
+ float padPx = barAaPx();
129
+
130
+ if (vid >= 6u) {
131
+ // The clip strip: CLIP_STRIP_PX across the band edge that cut the bar,
132
+ // antialiased at its two horizontal cuts as the bar is.
133
+ int side = clipSide(inst.y, u.domainMin, u.domainMax, u.valueScaleType);
134
+ if (side == 0) {
135
+ o.position = float4(2.0, 2.0, 0.0, 1.0);
136
+ o.color = float4(0.0);
137
+ o.barInkPx = float2(0.0);
138
+ return o;
139
+ }
140
+ float stripTop = side > 0 ? bandTop : bandTop + u.rowBandPx - CLIP_STRIP_PX;
141
+ float stripBot = stripTop + CLIP_STRIP_PX;
142
+ float sy = lerp(stripBot + padPx, stripTop - padPx, q.y);
143
+ o.position = float4(lerp(sx1, sx2, q.x), yPxToClipY(sy, u.canvasHeight), 0.0, 1.0);
144
+ o.color = float4(unpackRGBA(CLIP_STRIP_COLOR).rgb, 1.0);
145
+ o.barInkPx = float2(sy - stripTop, sy - stripBot);
146
+ return o;
147
+ }
148
+
149
+ float valueY = bandTop + valueToYPxScaled(inst.y, u.domainMin, u.domainMax, u.rowBandPx, u.valueScaleType, u.valueSymlogConstant);
150
+ float originY = bandTop + u.originYPx;
151
+ float topPx = min(valueY, originY);
152
+ float botPx = max(valueY, originY);
153
+ float vy = lerp(botPx + padPx, topPx - padPx, q.y);
154
+
155
+ o.position = float4(lerp(sx1, sx2, q.x), yPxToClipY(vy, u.canvasHeight), 0.0, 1.0);
156
+ o.color = place.color;
157
+ o.barInkPx = float2(vy - topPx, vy - botPx);
158
+ return o;
159
+ }
160
+
161
+ [shader("fragment")]
162
+ float4 fs_main(VsOut v) : SV_Target {
163
+ float aaPx = barAaPx();
164
+ float alpha = aaRamp(v.barInkPx.x, aaPx) - aaRamp(v.barInkPx.y, aaPx);
165
+ if (alpha <= 0.0) discard;
166
+ return float4(v.color.rgb, v.color.a * alpha);
167
+ }
@@ -0,0 +1,4 @@
1
+ // AUTO-GENERATED by packages/shader-tools/src/shader-codegen from barMark.slang.
2
+ // Do not edit. Run `pnpm gen:shaders` to regenerate.
3
+
4
+ export const WGSL_SOURCE = "struct Uniforms_std140_0\n{\n @align(16) bpRangeX_0 : vec3<f32>,\n @align(4) canvasHeight_0 : f32,\n @align(16) domainMin_0 : f32,\n @align(4) domainMax_0 : f32,\n @align(8) valueScaleType_0 : i32,\n @align(4) valueSymlogConstant_0 : f32,\n @align(16) rampMode_0 : i32,\n @align(4) rampMin_0 : f32,\n @align(8) rampMax_0 : f32,\n @align(4) rampMidNorm_0 : f32,\n @align(16) colorCutCount_0 : i32,\n @align(16) colorCuts_0 : array<vec4<f32>, i32(2)>,\n @align(16) colorBands_0 : array<vec4<f32>, i32(9)>,\n @align(16) originYPx_0 : f32,\n @align(4) rowHeight_0 : f32,\n @align(8) rowBandPx_0 : f32,\n @align(4) rowOffsetPx_0 : f32,\n @align(16) zero_0 : f32,\n @align(4) minCellDenomPx_0 : f32,\n @align(8) minWidthPx_0 : f32,\n @align(4) devicePixelRatio_0 : f32,\n @align(16) rowTableKeys_0 : i32,\n};\n\n@binding(1) @group(0) var<uniform> u_0 : Uniforms_std140_0;\n@binding(2) @group(0) var colorRamp_texture_0 : texture_2d<f32>;\n\n@binding(3) @group(0) var colorRamp_sampler_0 : sampler;\n\n@binding(4) @group(0) var rowTable_texture_0 : texture_2d<f32>;\n\n@binding(5) @group(0) var rowTable_sampler_0 : sampler;\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 rampMidT_0( t_0 : f32, mid_0 : f32) -> f32\n{\n var _S1 : f32 = max(mid_0, 1.0f - mid_0);\n return clamp((t_0 + (_S1 - mid_0)) / (2.0f * _S1), 0.0f, 1.0f);\n}\n\nfn rampColor_0( ramp_texture_0 : texture_2d<f32>, ramp_sampler_0 : sampler, t_1 : f32) -> vec4<f32>\n{\n return (textureSampleLevel((ramp_texture_0), (ramp_sampler_0), (vec2<f32>((clamp(t_1, 0.0f, 1.0f) * 255.0f + 0.5f) / 256.0f, 0.5f)), (0.0f)));\n}\n\nfn colorCutAt_0( i_0 : i32, cutsLo_0 : vec4<f32>, cutsHi_0 : vec4<f32>) -> f32\n{\n var _S2 : f32;\n if(i_0 < i32(4))\n {\n _S2 = cutsLo_0[i_0];\n }\n else\n {\n _S2 = cutsHi_0[i_0 - i32(4)];\n }\n return _S2;\n}\n\nfn thresholdBand_0( value_0 : f32, cutCount_0 : i32, cutsLo_1 : vec4<f32>, cutsHi_1 : vec4<f32>) -> i32\n{\n var band_0 : i32 = i32(0);\n var i_1 : i32 = i32(0);\n for(;;)\n {\n if(i_1 < cutCount_0)\n {\n }\n else\n {\n break;\n }\n if(value_0 >= (colorCutAt_0(i_1, cutsLo_1, cutsHi_1)))\n {\n band_0 = i_1 + i32(1);\n }\n i_1 = i_1 + i32(1);\n }\n return band_0;\n}\n\nfn log1pf_0( x_0 : f32) -> f32\n{\n var u_1 : f32 = 1.0f + x_0;\n var _S3 : f32;\n if(u_1 == 1.0f)\n {\n _S3 = x_0;\n }\n else\n {\n _S3 = log(u_1) * (x_0 / (u_1 - 1.0f));\n }\n return _S3;\n}\n\nfn symlogTransform_0( x_1 : f32, c_1 : f32) -> f32\n{\n return f32((i32(sign((x_1))))) * log1pf_0(abs(x_1 / c_1));\n}\n\nfn normalizeScoreUnclamped_0( score_0 : f32, domainMin_1 : f32, domainMax_1 : f32, scaleType_0 : i32, symlogConstant_0 : f32) -> f32\n{\n var tMax_0 : f32;\n var tMin_0 : f32;\n var t_2 : f32;\n if(scaleType_0 == i32(2))\n {\n var _S4 : f32 = symlogTransform_0(score_0, symlogConstant_0);\n var _S5 : f32 = symlogTransform_0(domainMin_1, symlogConstant_0);\n tMax_0 = symlogTransform_0(domainMax_1, symlogConstant_0);\n tMin_0 = _S5;\n t_2 = _S4;\n }\n else\n {\n if(scaleType_0 == i32(1))\n {\n if(domainMin_1 > 0.0f)\n {\n tMax_0 = domainMin_1;\n }\n else\n {\n tMax_0 = 1.0f;\n }\n var _S6 : f32 = log2(max(score_0, tMax_0));\n var _S7 : f32 = log2(tMax_0);\n tMax_0 = log2(max(domainMax_1, tMax_0));\n tMin_0 = _S7;\n t_2 = _S6;\n }\n else\n {\n tMax_0 = domainMax_1;\n tMin_0 = domainMin_1;\n t_2 = score_0;\n }\n }\n var tRange_0 : f32 = tMax_0 - tMin_0;\n if(tRange_0 <= 0.0f)\n {\n if(t_2 > tMin_0)\n {\n tMax_0 = 1.0f;\n }\n else\n {\n tMax_0 = 0.0f;\n }\n return tMax_0;\n }\n return (t_2 - tMin_0) / tRange_0;\n}\n\nfn normalizeScore_0( score_1 : f32, domainMin_2 : f32, domainMax_2 : f32, scaleType_1 : i32, symlogConstant_1 : f32) -> f32\n{\n return clamp(normalizeScoreUnclamped_0(score_1, domainMin_2, domainMax_2, scaleType_1, symlogConstant_1), 0.0f, 1.0f);\n}\n\nfn rowTableWidth_0( keys_0 : u32) -> u32\n{\n return max(min(keys_0, u32(2048)), u32(1));\n}\n\nfn rowTablePlaneHeight_0( keys_1 : u32) -> u32\n{\n var w_0 : u32 = rowTableWidth_0(keys_1);\n var _S8 : u32 = (keys_1 + w_0 - u32(1)) / w_0;\n return max(_S8, u32(1));\n}\n\nfn rowTableTexelX_0( key_0 : u32, keys_2 : u32) -> u32\n{\n var _S9 : u32 = key_0 % rowTableWidth_0(keys_2);\n return _S9;\n}\n\nfn rowTableTexelY_0( key_1 : u32, keys_3 : u32) -> u32\n{\n var _S10 : u32 = key_1 / rowTableWidth_0(keys_3);\n return _S10;\n}\n\nfn byteOf_0( channel_0 : f32) -> u32\n{\n return u32(channel_0 * 255.0f + 0.5f);\n}\n\nstruct RowPlacement_0\n{\n hidden_0 : bool,\n slot_0 : u32,\n color_0 : vec4<f32>,\n};\n\nfn rowTableLookup_0( table_texture_0 : texture_2d<f32>, table_sampler_0 : sampler, key_2 : u32, keys_4 : i32, own_0 : vec4<f32>) -> RowPlacement_0\n{\n var p_0 : RowPlacement_0;\n p_0.hidden_0 = false;\n p_0.slot_0 = key_2;\n p_0.color_0 = own_0;\n if(keys_4 < i32(0))\n {\n return p_0;\n }\n var n_0 : u32 = u32(keys_4);\n if(key_2 >= n_0)\n {\n p_0.hidden_0 = true;\n return p_0;\n }\n var h_0 : u32 = rowTablePlaneHeight_0(n_0);\n var _S11 : u32 = rowTableTexelX_0(key_2, n_0);\n var u_2 : f32 = (f32(_S11) + 0.5f) / f32(rowTableWidth_0(n_0));\n var rows_0 : f32 = f32(u32(2) * h_0);\n var y_0 : u32 = rowTableTexelY_0(key_2, n_0);\n var _S12 : vec4<f32> = (textureSampleLevel((table_texture_0), (table_sampler_0), (vec2<f32>(u_2, (f32(y_0) + 0.5f) / rows_0)), (0.0f)));\n if((_S12.w) < 0.5f)\n {\n p_0.hidden_0 = true;\n return p_0;\n }\n p_0.slot_0 = ((((byteOf_0(_S12.x)) | ((((byteOf_0(_S12.y)) << (u32(8))))))) | ((((byteOf_0(_S12.z)) << (u32(16))))));\n var _S13 : vec4<f32> = (textureSampleLevel((table_texture_0), (table_sampler_0), (vec2<f32>(u_2, (f32(y_0 + h_0) + 0.5f) / rows_0)), (0.0f)));\n var _S14 : vec4<f32>;\n if((_S13.w) > 0.0f)\n {\n _S14 = _S13;\n }\n else\n {\n _S14 = own_0;\n }\n p_0.color_0 = _S14;\n return p_0;\n}\n\nfn hpSplitUint_0( value_1 : u32) -> vec2<f32>\n{\n var lo_0 : u32 = (value_1 & (u32(4095)));\n return vec2<f32>(f32(value_1 - lo_0), f32(lo_0));\n}\n\nfn hpToClipX_0( splitPos_0 : vec2<f32>, bpRange_0 : vec3<f32>, hpZero_0 : f32) -> f32\n{\n var floorBp_0 : f32 = -3.00000000549775576e+38f + hpZero_0;\n var step_0 : f32 = 2.0f / bpRange_0.z;\n return dot(vec3<f32>(-1.0f, max(splitPos_0.x - bpRange_0.x, floorBp_0), max(splitPos_0.y - bpRange_0.y, floorBp_0)), vec3<f32>(1.0f, step_0, step_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 extendToMinWidthPx_0( x1_0 : f32, x2_0 : f32, minWidth_0 : f32) -> f32\n{\n var dx_0 : f32 = x2_0 - x1_0;\n var _S15 : f32;\n if((abs(dx_0)) < minWidth_0)\n {\n if(dx_0 < 0.0f)\n {\n _S15 = - minWidth_0;\n }\n else\n {\n _S15 = minWidth_0;\n }\n _S15 = x1_0 + _S15;\n }\n else\n {\n _S15 = x2_0;\n }\n return _S15;\n}\n\nfn extendToMinWidthX_0( x1_1 : f32, x2_1 : f32, minWidthPx_1 : f32, canvasWidth_0 : f32) -> f32\n{\n return extendToMinWidthPx_0(x1_1, x2_1, pxToClipLen_0(minWidthPx_1, canvasWidth_0));\n}\n\nfn quadLocal_0( vid_0 : u32) -> vec2<f32>\n{\n var v_0 : u32 = vid_0 % u32(6);\n var _S16 : bool = v_0 == u32(0);\n var _S17 : bool;\n if(_S16)\n {\n _S17 = true;\n }\n else\n {\n _S17 = v_0 == u32(2);\n }\n if(_S17)\n {\n _S17 = true;\n }\n else\n {\n _S17 = v_0 == u32(3);\n }\n var _S18 : f32;\n if(_S17)\n {\n _S18 = 0.0f;\n }\n else\n {\n _S18 = 1.0f;\n }\n if(_S16)\n {\n _S17 = true;\n }\n else\n {\n _S17 = v_0 == u32(1);\n }\n if(_S17)\n {\n _S17 = true;\n }\n else\n {\n _S17 = v_0 == u32(4);\n }\n var _S19 : f32;\n if(_S17)\n {\n _S19 = 0.0f;\n }\n else\n {\n _S19 = 1.0f;\n }\n return vec2<f32>(_S18, _S19);\n}\n\nfn rowBandTopPx_0( rowOffsetPx_1 : f32, rowHeight_1 : f32, slot_1 : u32) -> f32\n{\n return rowOffsetPx_1 + rowHeight_1 * f32(slot_1);\n}\n\nfn aaPx_0( dpr_0 : f32) -> f32\n{\n return 1.0f / max(dpr_0, 1.0f);\n}\n\nfn aaHalfPx_0( dpr_1 : f32) -> f32\n{\n return 0.5f * aaPx_0(dpr_1);\n}\n\nfn barAaPx_0() -> f32\n{\n return 2.0f * aaHalfPx_0(u_0.devicePixelRatio_0);\n}\n\nfn clipSide_0( value_2 : f32, domainMin_3 : f32, domainMax_3 : f32, scaleType_2 : i32) -> i32\n{\n var tolerance_0 : f32 = (domainMax_3 - domainMin_3) * 0.00000999999974738f;\n if(value_2 > (domainMax_3 + tolerance_0))\n {\n return i32(1);\n }\n var _S20 : bool;\n if(value_2 < (domainMin_3 - tolerance_0))\n {\n _S20 = scaleType_2 != i32(1);\n }\n else\n {\n _S20 = false;\n }\n if(_S20)\n {\n return i32(-1);\n }\n return i32(0);\n}\n\nfn yPxToClipY_0( yPx_0 : f32, canvasHeight_1 : f32) -> f32\n{\n return 1.0f - yPx_0 / canvasHeight_1 * 2.0f;\n}\n\nfn valueToYPxScaled_0( value_3 : f32, domainMin_4 : f32, domainMax_4 : f32, h_1 : f32, scaleType_3 : i32, symlogConstant_2 : f32) -> f32\n{\n return (1.0f - normalizeScore_0(value_3, domainMin_4, domainMax_4, scaleType_3, symlogConstant_2)) * h_1;\n}\n\nstruct VsOut_0\n{\n @builtin(position) position_0 : vec4<f32>,\n @location(0) color_1 : vec4<f32>,\n @location(1) barInkPx_0 : vec2<f32>,\n};\n\nstruct vertexInput_0\n{\n @location(0) x_2 : u32,\n @location(1) x2_2 : u32,\n @location(2) y_1 : f32,\n @location(3) color_2 : u32,\n @location(4) row_0 : u32,\n};\n\nfn markScaleColor_0( _S21 : texture_2d<f32>, _S22 : sampler, _S23 : u32, _S24 : i32, _S25 : f32, _S26 : f32, _S27 : f32, _S28 : i32, _S29 : vec4<f32>, _S30 : vec4<f32>) -> vec4<f32>\n{\n if(_S24 == i32(0))\n {\n return unpackRGBA_0(_S23);\n }\n if(_S23 == u32(2143289345))\n {\n return unpackRGBA_0(u32(4289703855));\n }\n var scaleType_4 : i32;\n if(((_S23 & (u32(2139095040)))) == u32(2139095040))\n {\n if(((_S23 & (u32(8388607)))) != u32(0))\n {\n return unpackRGBA_0(u32(4286611584));\n }\n var negative_0 : bool = ((_S23 & (u32(2147483648)))) != u32(0);\n if(_S24 == i32(3))\n {\n if(negative_0)\n {\n scaleType_4 = i32(0);\n }\n else\n {\n scaleType_4 = _S28;\n }\n return u_0.colorBands_0[scaleType_4];\n }\n var _S31 : f32;\n if(negative_0)\n {\n _S31 = 0.0f;\n }\n else\n {\n _S31 = 1.0f;\n }\n return rampColor_0(_S21, _S22, rampMidT_0(_S31, _S27));\n }\n var value_4 : f32 = (bitcast<f32>((_S23)));\n if(_S24 == i32(3))\n {\n return u_0.colorBands_0[thresholdBand_0(value_4, _S28, _S29, _S30)];\n }\n if(_S24 == i32(2))\n {\n scaleType_4 = i32(1);\n }\n else\n {\n scaleType_4 = i32(0);\n }\n return rampColor_0(_S21, _S22, rampMidT_0(normalizeScore_0(value_4, _S25, _S26, scaleType_4, 1.0f), _S27));\n}\n\nfn bpToClipX_0( _S32 : u32) -> f32\n{\n return hpToClipX_0(hpSplitUint_0(_S32), u_0.bpRangeX_0, u_0.zero_0);\n}\n\n@vertex\nfn vs_main( _S33 : vertexInput_0, @builtin(vertex_index) vid_1 : u32) -> VsOut_0\n{\n var o_0 : VsOut_0;\n var _S34 : RowPlacement_0 = rowTableLookup_0(rowTable_texture_0, rowTable_sampler_0, _S33.row_0, u_0.rowTableKeys_0, markScaleColor_0(colorRamp_texture_0, colorRamp_sampler_0, _S33.color_2, u_0.rampMode_0, u_0.rampMin_0, u_0.rampMax_0, u_0.rampMidNorm_0, u_0.colorCutCount_0, u_0.colorCuts_0[i32(0)], u_0.colorCuts_0[i32(1)]));\n if(_S34.hidden_0)\n {\n o_0.position_0 = vec4<f32>(2.0f, 2.0f, 0.0f, 1.0f);\n o_0.color_1 = vec4<f32>(0.0f);\n o_0.barInkPx_0 = vec2<f32>(0.0f);\n return o_0;\n }\n var _S35 : f32 = bpToClipX_0(_S33.x_2);\n var sx2_0 : f32 = extendToMinWidthX_0(_S35, bpToClipX_0(_S33.x2_2), u_0.minWidthPx_0, u_0.minCellDenomPx_0);\n var q_0 : vec2<f32> = quadLocal_0(vid_1);\n var bandTop_0 : f32 = rowBandTopPx_0(u_0.rowOffsetPx_0, u_0.rowHeight_0, _S34.slot_0);\n var padPx_0 : f32 = barAaPx_0();\n if(vid_1 >= u32(6))\n {\n var side_0 : i32 = clipSide_0(_S33.y_1, u_0.domainMin_0, u_0.domainMax_0, u_0.valueScaleType_0);\n if(side_0 == i32(0))\n {\n o_0.position_0 = vec4<f32>(2.0f, 2.0f, 0.0f, 1.0f);\n o_0.color_1 = vec4<f32>(0.0f);\n o_0.barInkPx_0 = vec2<f32>(0.0f);\n return o_0;\n }\n var stripTop_0 : f32;\n if(side_0 > i32(0))\n {\n stripTop_0 = bandTop_0;\n }\n else\n {\n stripTop_0 = bandTop_0 + u_0.rowBandPx_0 - 2.0f;\n }\n var stripBot_0 : f32 = stripTop_0 + 2.0f;\n var sy_0 : f32 = mix(stripBot_0 + padPx_0, stripTop_0 - padPx_0, q_0.y);\n o_0.position_0 = vec4<f32>(mix(_S35, sx2_0, q_0.x), yPxToClipY_0(sy_0, u_0.canvasHeight_0), 0.0f, 1.0f);\n o_0.color_1 = vec4<f32>(unpackRGBA_0(u32(4280821958)).xyz, 1.0f);\n o_0.barInkPx_0 = vec2<f32>(sy_0 - stripTop_0, sy_0 - stripBot_0);\n return o_0;\n }\n var valueY_0 : f32 = bandTop_0 + valueToYPxScaled_0(_S33.y_1, u_0.domainMin_0, u_0.domainMax_0, u_0.rowBandPx_0, u_0.valueScaleType_0, u_0.valueSymlogConstant_0);\n var originY_0 : f32 = bandTop_0 + u_0.originYPx_0;\n var _S36 : f32 = min(valueY_0, originY_0);\n var _S37 : f32 = max(valueY_0, originY_0);\n var vy_0 : f32 = mix(_S37 + padPx_0, _S36 - padPx_0, q_0.y);\n o_0.position_0 = vec4<f32>(mix(_S35, sx2_0, q_0.x), yPxToClipY_0(vy_0, u_0.canvasHeight_0), 0.0f, 1.0f);\n o_0.color_1 = _S34.color_0;\n o_0.barInkPx_0 = vec2<f32>(vy_0 - _S36, vy_0 - _S37);\n return o_0;\n}\n\nfn aaRamp_0( signedInk_0 : f32, widthPx_0 : f32) -> f32\n{\n return clamp(signedInk_0 / widthPx_0 + 0.5f, 0.0f, 1.0f);\n}\n\nstruct pixelOutput_0\n{\n @location(0) output_0 : vec4<f32>,\n};\n\nstruct pixelInput_0\n{\n @location(0) color_3 : vec4<f32>,\n @location(1) barInkPx_1 : vec2<f32>,\n};\n\n@fragment\nfn fs_main( _S38 : pixelInput_0, @builtin(position) position_1 : vec4<f32>) -> pixelOutput_0\n{\n var aaPx_1 : f32 = barAaPx_0();\n var alpha_0 : f32 = aaRamp_0(_S38.barInkPx_1.x, aaPx_1) - aaRamp_0(_S38.barInkPx_1.y, aaPx_1);\n if(alpha_0 <= 0.0f)\n {\n discard;\n }\n var _S39 : pixelOutput_0 = pixelOutput_0( vec4<f32>(_S38.color_3.xyz, _S38.color_3.w * alpha_0) );\n return _S39;\n}\n\n"
@@ -0,0 +1,14 @@
1
+ // AUTO-GENERATED by packages/shader-tools/src/shader-codegen from capsule.slang.
2
+ // Do not edit. Run `pnpm gen:shaders` to regenerate.
3
+
4
+ // Scalar twins of capsule.slang, transliterated from slangc's WGSL so
5
+ // the Canvas2D and SVG paths run the shader's own math. See adr-051.
6
+
7
+ function _max(a: number, b: number) {
8
+ return b > a || Number.isNaN(a) ? b : a
9
+ }
10
+
11
+ export function capsuleDistPx(alongPx: number, acrossPx: number, halfLenPx: number): number {
12
+ let _t0 = _max((Math.abs(alongPx) - halfLenPx), 0.0)
13
+ return Math.sqrt(((_t0 * _t0) + (acrossPx * acrossPx)))
14
+ }
@@ -15,6 +15,7 @@
15
15
  // comes off a clamp and the 2x2 quads straddling the cap/body junction would be
16
16
  // differentiating a discontinuity.
17
17
  //! export-consts: CAPSULE_MIN_LEN_PX
18
+ //! js-export: capsuleDistPx
18
19
  module capsule;
19
20
 
20
21
  import antialias;
@@ -54,9 +55,16 @@ public float2 capsuleQuadLocal(
54
55
  return float2(q.x * (halfLenPx + ext), q.y * ext);
55
56
  }
56
57
 
57
- // CSS-px distance from `local` (the segment's frame, center-anchored) to the
58
- // segment {(-halfLen,0)..(halfLen,0)}. Collapses to distance-from-origin for a
59
- // degenerate segment — the circular dot of radius halfWidth.
58
+ // CSS-px distance from a point in the segment's frame (center-anchored, x
59
+ // along, y across) to the segment {(-halfLen,0)..(halfLen,0)}. Collapses to
60
+ // distance-from-origin for a degenerate segment — the circular dot of radius
61
+ // halfWidth. Scalar so `//! js-export` can lift it: the dotplot's pick measures
62
+ // the cursor against the same capsule the fragment inks, end caps included.
63
+ public float capsuleDistPx(float alongPx, float acrossPx, float halfLenPx) {
64
+ float beyond = max(abs(alongPx) - halfLenPx, 0.0);
65
+ return sqrt(beyond * beyond + acrossPx * acrossPx);
66
+ }
67
+
60
68
  public float capsuleDist(float2 local, float halfLenPx) {
61
- return length(float2(max(abs(local.x) - halfLenPx, 0.0), local.y));
69
+ return capsuleDistPx(local.x, local.y, halfLenPx);
62
70
  }
@@ -0,0 +1,6 @@
1
+ // AUTO-GENERATED by packages/shader-tools/src/shader-codegen from clipStrip.slang.
2
+ // Do not edit. Run `pnpm gen:shaders` to regenerate.
3
+
4
+ export const CLIP_STRIP_PX = 2
5
+
6
+ export const CLIP_STRIP_COLOR = 4280821958
@@ -0,0 +1,22 @@
1
+ // AUTO-GENERATED by packages/shader-tools/src/shader-codegen from clipStrip.slang.
2
+ // Do not edit. Run `pnpm gen:shaders` to regenerate.
3
+
4
+ // Scalar twins of clipStrip.slang, transliterated from slangc's WGSL so
5
+ // the Canvas2D and SVG paths run the shader's own math. See adr-051.
6
+
7
+ export function clipSide(value: number, domainMin: number, domainMax: number, scaleType: number): number {
8
+ let tolerance = ((domainMax - domainMin) * 0.00000999999974738)
9
+ if ((value > (domainMax + tolerance))) {
10
+ return 1
11
+ }
12
+ let _t0: boolean
13
+ if ((value < (domainMin - tolerance))) {
14
+ _t0 = (scaleType != 1)
15
+ } else {
16
+ _t0 = false
17
+ }
18
+ if (_t0) {
19
+ return ((-1) | 0)
20
+ }
21
+ return 0
22
+ }
@@ -0,0 +1,34 @@
1
+ // The clip strip: 2 CSS px of red across the cut edge of a bar whose value
2
+ // the domain excludes, so a bar clamped to full height does not read as its
3
+ // value (ADR-183). Wiggle's xyplot, the coverage band and the `bar` shape each
4
+ // draw it as a second quad, or a pass, off the same instance, and their
5
+ // Canvas2D painters draw it off `clipSide`'s twin.
6
+ //! export-consts: CLIP_STRIP_PX, CLIP_STRIP_COLOR
7
+ //! js-export: clipSide
8
+ module clipStrip;
9
+
10
+ import scoreScale;
11
+
12
+ public static const float CLIP_STRIP_PX = 2.0;
13
+ // #c62828, packed ABGR as every instance colour is: a red a shade darker than
14
+ // the coverage band's hard-clip triangles, which stand just above the strip.
15
+ public static const uint CLIP_STRIP_COLOR = 0xFF2828C6u;
16
+
17
+ // Which edge of the axis cut the bar: 1 the top, -1 the bottom, 0 neither. A
18
+ // log scale has no bottom to cut, since a value under its floor stands on the
19
+ // baseline as a bar of no height, which reads as what it is.
20
+ //
21
+ // The cut is measured with a tolerance of a hundred-thousandth of the domain:
22
+ // the coverage band rebuilds a depth as float32 relDepth times the region's
23
+ // peak, and a quantile that lands on an observed depth would otherwise strip
24
+ // on the backend whose rounding came out high and not on the other.
25
+ public int clipSide(float value, float domainMin, float domainMax, int scaleType) {
26
+ float tolerance = (domainMax - domainMin) * 1e-5;
27
+ if (value > domainMax + tolerance) {
28
+ return 1;
29
+ }
30
+ if (value < domainMin - tolerance && scaleType != SCALE_TYPE_LOG) {
31
+ return -1;
32
+ }
33
+ return 0;
34
+ }
@@ -0,0 +1,39 @@
1
+ import {
2
+ SCALE_TYPE_LINEAR,
3
+ SCALE_TYPE_LOG,
4
+ SCALE_TYPE_SYMLOG,
5
+ } from '../scoreScale.ts'
6
+ import { CLIP_STRIP_COLOR, CLIP_STRIP_PX } from './clipStrip.generated.ts'
7
+ import { clipSide } from './clipStrip.js.generated.ts'
8
+
9
+ // The twin every Canvas2D painter reads: which edge of the axis cut a bar. A
10
+ // log scale has no bottom to cut, since a value under its floor is a bar of no
11
+ // height on the baseline.
12
+ test('clipSide names the cut edge, and a log scale has no bottom', () => {
13
+ for (const scaleType of [SCALE_TYPE_LINEAR, SCALE_TYPE_SYMLOG]) {
14
+ expect(clipSide(12, 0, 10, scaleType)).toBe(1)
15
+ expect(clipSide(10, 0, 10, scaleType)).toBe(0)
16
+ expect(clipSide(5, 0, 10, scaleType)).toBe(0)
17
+ expect(clipSide(0, 0, 10, scaleType)).toBe(0)
18
+ expect(clipSide(-3, 0, 10, scaleType)).toBe(-1)
19
+ }
20
+ expect(clipSide(200, 1, 100, SCALE_TYPE_LOG)).toBe(1)
21
+ expect(clipSide(0.5, 1, 100, SCALE_TYPE_LOG)).toBe(0)
22
+ })
23
+
24
+ // A depth rebuilt from float32 relDepth lands a few ulps off the quantile it
25
+ // equals, on one backend and not the other.
26
+ test('a value one float32 rounding past the domain is not cut', () => {
27
+ const max = 37
28
+ const rebuilt = Math.fround(max / 775) * 775
29
+ expect(rebuilt).not.toBe(max)
30
+ expect(clipSide(rebuilt, 0, max, SCALE_TYPE_LINEAR)).toBe(0)
31
+ expect(clipSide(max * 1.001, 0, max, SCALE_TYPE_LINEAR)).toBe(1)
32
+ })
33
+
34
+ test('the strip is 2 px of #c62828', () => {
35
+ expect(CLIP_STRIP_PX).toBe(2)
36
+ expect(
37
+ [0, 8, 16, 24].map(shift => (CLIP_STRIP_COLOR >>> shift) & 0xff),
38
+ ).toEqual([0xc6, 0x28, 0x28, 0xff])
39
+ })
@@ -15,7 +15,11 @@ module colorPack;
15
15
  //
16
16
  // Declare such a palette as `float4[N]` instead — a vector element needs no
17
17
  // wrapper struct, lowers correctly, AND costs the same 16 bytes per slot that
18
- // std140 was padding the uint to anyway, so packing bought nothing here. Packing
18
+ // std140 was padding the uint to anyway, so packing one colour per element
19
+ // bought nothing here. FOUR to a `uint4` element, read as `p[i >> 2][i & 3]`,
20
+ // does compile and does save — it is the only form that beats the padding — and
21
+ // on alignments' 23-colour palette it was measured and declined:
22
+ // agent-docs/reference/ARCHITECTURAL_LIMITS.md §"The uniform ring". Packing
19
23
  // still earns its keep in VERTEX ATTRIBUTES, which is what this is for.
20
24
  public float4 unpackRGBA(uint c) {
21
25
  return float4(
@@ -0,0 +1,22 @@
1
+ // AUTO-GENERATED by packages/shader-tools/src/shader-codegen from colorRampLut.slang.
2
+ // Do not edit. Run `pnpm gen:shaders` to regenerate.
3
+
4
+ // Scalar twins of colorRampLut.slang, transliterated from slangc's WGSL so
5
+ // the Canvas2D and SVG paths run the shader's own math. See adr-051.
6
+
7
+ function _clamp(x: number, lo: number, hi: number) {
8
+ return _min(_max(x, lo), hi)
9
+ }
10
+
11
+ function _max(a: number, b: number) {
12
+ return b > a || Number.isNaN(a) ? b : a
13
+ }
14
+
15
+ function _min(a: number, b: number) {
16
+ return b < a || Number.isNaN(a) ? b : a
17
+ }
18
+
19
+ export function rampMidT(t: number, mid: number): number {
20
+ let _t0 = _max(mid, (1.0 - mid))
21
+ return _clamp(((t + (_t0 - mid)) / (2.0 * _t0)), 0.0, 1.0)
22
+ }