14,081 karma · joined Mar 7, 2014 (12y ago) · 1,887 submissions
comment 3y ago · link · parent
comment 3y ago · link · parent
Why not then? Because there is a ton of science and empirical evidence that humans cannot hear the difference[1]. Good engineering is about meeting the requirements with minimal cost. If the requirement is that it sounds good to humans, and the cost is number of bits to encode (and thus store and transmit) the signal, then modern codecs like Opus are clearly superior to uncompressed and losslessly compressed signals, much less higher sampling rates.
If your goal is something other than good engineering, for example the aesthetic satisfaction that the bits are the same as what the mastering engineer put on the CD, or for some reason caring how clean spectrum plots of artificial signals look, then the arguments may have some merit. But let's be clear on the goals.
comment 3y ago · link · parent
I also agree that Vulkan is more promising than OpenCL. With recent extensions, it has real pointers (buffer device address), cooperative matrix multiplication (also known as tensor cores or WMMA), scalar types other than 32 bits, proper barrier (including device-scoped, needed for single pass scan), and other important features.
comment 3y ago · link · parent
comment 3y ago · link · parent
I've lately been exploring the idea of a "Good Parallel Computer," which combines most of the agility of a CPU with the efficient parallel throughput of a GPU. The central concept is that the decision to launch a workgroup is made by a programmable controller, rather than just being a cube of (x, y, z) or downstream of triangles. A particular workload it would likely excel at is sparse matrix multiplication, including multiple quantization levels like SpQR[1]. I'm hopeful that it could be an advance in execution model, but also a simplification, as I believe a lot of the complexity of the current GPU model is because of lots of workarounds for the weak execution model.
I'm not optimistic about this being built any time soon, as it requires rethinking the software stack. But it's fun to think about. I might blog about it at some point, but I'm also interested in connecting with people who have been thinking along similar lines.
comment 3y ago · link · parent
Source: wrote a browser[1]. I enjoyed it and learned a lot. My motivation for starting it is that the open source browser landscape was bleak at the time. There was khtml, which seemed fairly solid, but that was KDE and I was firmly in the Gnome camp. Mine was very fast and lean, but wouldn't scale to embrace what's now considered the basics of a web browser: JS and CSS. Motivation tailed off sharply when Mozilla announced they would be open sourcing their browser. If I had known it would take them over 4 years to ship Firefox 1.0, I might have kept at it.
Gambatte!
comment 3y ago · link · parent
comment 3y ago · link · parent
This is true for curve fitting of arbitrary curves, not just circles, though arbitrary curve fitting is a bit tricky (it requires solving quartic equations). I personally think you can take this as evidence that cubic Béziers are "good enough" for all practical tasks requiring curve representation, though for specific applications there might be other representations that work better.
comment 3y ago · link · parent
I need to go through an open source releasing process but I'll get that going. Thanks for your interest!
comment 3y ago · link · parent
I started mine about 6 years ago, put it on the shelf, and am getting back to it. Overall I think Rust is working well for it (and for pico DVI out), but I can also see the advantages of Zig for something this low-level and specialized.
comment 3y ago · link · parent
comment 3y ago · link · parent
comment 3y ago · link · parent
[1]: https://arxiv.org/abs/2205.11659
[2]: https://github.com/raphlinus/raphlinus.github.io/issues/66
comment 3y ago · link · parent
comment 3y ago · link · parent
It does make intuitive sense for handles to be 1/3 of the length of the curve, as that makes the "speed" close to constant, but this is not the smoothest possible choice in general. In particular, it's not the best approximation to a circular arc, which by most reasonable definitions is the smoothest possible curve. I did the math[1] and found that there's a parabola around each endpoint that does result in an accurate arc approximation, and in fact may be easier to apply as it doesn't move around as the length of the curve changes. Rather, each of the parabolas can be applied independently.
Evidence in favor of this is O(n^5) accuracy scaling to approximate Euler spirals (which are also a good candidate for "smoothest possible curve" depending on the way you define that). I suspect, but haven't yet demonstrated, that there's some variational sense in which this choice is optimum, or at least to a first order approximation.
You can think of cubic Béziers as forming a four-dimensional parameter space (the parameters can be accounted as the lengths and angles of the control handles; in this scheme, the positions of the endpoints are not counted). By applying a rule such as 1/3 arc length, or falling on a parabola, that reduces it to a two-dimensional space (same dimensionality as quadratic Beziers, Euler spirals, and sections of rectangular elastica). I think two dimensions is too few, as it doesn't give you the ability to easily form superellipse shapes, a particular strength of cubic Béziers and quite handy for font design, as superellipse is extremely common in fonts. I think there may be some value in exploring a three-dimensional parameter space (which, among other things, is the count for general elastica) and have some ideas.
As for (2), the problem is that for s-shaped curves, cubic Béziers tend to put curvature maxima near but not exactly on endpoints. Since the curvature maximum is visually salient, you do better subdividing your curves so you can place them at joins. Other curve families, notably those based on elastica and Euler spirals, don't have this problem.
[1]: https://raphlinus.github.io/curves/2021/02/19/parallel-curve...
comment 3y ago · link · parent
Both drafts have (exact) Euler spirals inside their parameter space, and thus circular arcs as well. I think that's a good criterion for a Bézier successor.
It's on the back burner for now, but I hope to get back to it, and am open to collaboration.
[1]: https://www.cmyr.net/blog/hyperbezier.html
[2]: https://xi.zulipchat.com/#narrow/stream/260979-kurbo/topic/H...
comment 3y ago · link · parent
[1]: https://xi.zulipchat.com/#narrow/stream/197075-gpu/topic/Gau...
comment 3y ago · link · parent
I imagine the details are tricky (my understanding is that "freeze" took a long time to land in LLVM), but that there's no fundamental reason it can't be done. But I also imagine there are a lot higher priorities; the use case in this blog is pretty niche.
There's more discussion in this thread: [2]
[1]: https://docs.rs/bytemuck/latest/bytemuck/trait.Pod.html
[2]: https://internals.rust-lang.org/t/freeze-maybeuninit-t-maybe...
comment 3y ago · link · parent
I'm interested in this because these linearized tree representations lend themselves well to processing on GPU. We use them in Vello for representing clip and blend groups, with quite deep nesting level allowed. By contrast, the traditional pointer chasing approach to ASTs limits parallelism and has poor utilization of memory bandwidth.
comment 3y ago · link · parent
comment 3y ago · link · parent
I'm pretty sure DEC VT100 and VT220 did not do this. There is some dot-stretching logic in the VT100 and VT220[3], which improves appearance but doesn't increase effective resolution.
Apple ][ is a slightly different story. The high bit (very similar to the HP terminal) does cause a half-pixel shift, but I believe this was almost entirely used to create more colors through NTSC artifacts, not to increase horizontal resolution. I'm unaware of a character ROM that uses the technique, but I could be missing something. The best writeup I've found is [4], and I also found an original description in BYTE magazine[5] from Steve Wozniak himself.
[1]: https://www.youtube.com/watch?v=QikO0WOAGWI&t=371s
[2]: https://archive.org/details/bitsavers_hpterminaleriesCharact...
[3]: https://www.masswerk.at/nowgobang/2019/dec-crt-typography
[4]: https://retrocomputing.stackexchange.com/questions/6271/what...
[5]: https://archive.org/details/byte-magazine-1979-06/page/n61/m...
comment 3y ago · link · parent
[1]: https://kompute.cc/
comment 3y ago · link · parent
There's still a driver and you're still at mercy of it (bugs and all), it's just much more likely to be installed on your Windows or Linux machine than a ROCm stack.
comment 3y ago · link · parent
OpenType shaping is currently defined in terms of a whole bunch of rewrite rules, with some script-specific knowledge (such as reordering vowels in Indic) added in by the shaping engine. The original idea is that it would be declarative and fairly easy for font designers to work with, but in practice it's pretty clunky, and doesn't scale well as complexity goes up. It's also slow to evaluate on modern computers because sequence matching is very branchy, and it's not unusual to require dozens of passes.
A particularly striking example is hieroglyphics. These compose multiple elements together into a block, with rules not unlike CSS grid. Sometimes there's vertical stacking, sometimes horizontal, occasionally more complex interactions like nestling inside an L. It is possible to encode this into OpenType rules, but it's very much a hack - at heart you need to do fairly simple geometry calculations to add up the total widths and divide them proportionally, but think about writing that as a regex and you'll get some idea how it comes out.
This proposal replaces the OpenType shaping rules with a call into WASM, where you can do these sorts of calculations straightforwardly and in a single pass. It is another Turing complete language (as is OpenType shaping, as proved by Behdad a few years ago, and TrueType hints), but there are excellent off-the-shelf implementations and it's well known how to run it securely sandboxed.
Even for Latin, this kind of thing would be useful for making a font that looks like real handwriting, for example. You can fake that in OpenType to a certain extent, but it goes beyond what the format was designed to handle.
This is a first cut, as it only affects positioning of premade glyphs. One thing I'd like to see going forward is adjusting variation parameters. As an example, a typical Devanagari (Hindi) font has 6 or so different widths of "ि" depending on the width of the consonant cluster it composes with (so रि or ल्कि). With variation connected to shaping, you could have one glyph of variable width, and the shaping engine could just set the variation to the right value, and with greater precision to boot.
If I were designing a new font format from scratch, this is definitely the way I'd do it. I'm excited to see where it goes.
comment 3y ago · link · parent
comment 3y ago · link · parent
Here's a sketch of the problem being solved. The raw input is broken into a sequence of nodes, and something like * is turned into a "MaybeEmphasis" node, as it has the potential to turn into emphasis, or remain text if no match for it is found.
Another pass goes through those nodes in sequence, using a stack to find potential matches (the rules for whether a pair of such nodes actually match are quite fiddly and complicated). When a match is found, the MaybeEmphasis node is turned into the appropriate emphasis node, and the entire sequence of nodes between open and close is snipped out and made into a subtree of the new node. This is a somewhat unusual tree transformation, and a straightforward implementation could easily be O(n). But with the flattened AST representation, it can all be done O(1), no matter the number of nodes or stack depth.
For those interested in details, the tree representation is in [2] - there's basically a "child" and "next" index along with the node body - and the tree surgery on emphasis match is in [3].
The performance is excellent. I think pulldown-cmark may not be the single fastest CommonMark parser out there, but it's certainly competitive, and a lot faster than approaches that do, for example, an allocation per node.
[1]: https://fullyfaithful.eu/pulldown-cmark/
[2]: https://github.com/raphlinus/pulldown-cmark/blob/b7e709c0bd6...
[3]: https://github.com/raphlinus/pulldown-cmark/blob/b7e709c0bd6...