Better HN
topnewbestaskshowjobs
Log inSign up

raphlinus

14,081 karma · joined Mar 7, 2014 (12y ago) · 1,887 submissions

I do research on fundamental UI technology and 2D graphics, with a focus on Rust and fonts. @raph@mastodon.online
Submissions

comment 2y ago · link · parent

Cool to see! The tweak suggested in the blog post when you're near the vertex of the parabola is valid, and the implementation that was in Vello did something very similar. This is also the flatten algorithm that's in kurbo[1], and the code for that is probably the most accessible source for the ideas. However, if approaching this again I'd suggest placing a subdivision point at the vertex, which will also handle the degenerate colinear case; I now have reason to believe that the error metric that all this is based on works for monotonic curvature, and can fail otherwise.

I say "was" as the new version in Vello is much more sophisticated, and handles both flattening and stroke expansion, all on the GPU. A paper is in the works, and I'll post it to HN when it's ready.

[1]: https://docs.rs/kurbo/latest/kurbo/struct.BezPath.html#metho...

comment 2y ago · link · parent

For the math aficionados in this thread, I have a frequency domain related set of ideas I'd like to develop into a more rigorous mathematical theory. Basically, represent a curve as Chebyshev polynomial: T_1 represents a line, T_2 represents an arc, T_3 an Euler spiral, etc. Smooth curves have rapidly decreasing Chebyshev coefficients, and this whole thing is potentially a lot easier to work with than Fréchet distance, which is the usual error metric but very annoying.

This is conceptual and theoretical, but potentially has immediate application for computing a better offset of a cubic Bézier, used for stroke expansion.

If this sounds intriguing, a good starting point is the Zulip thread[1] I'm using to write down the ideas. I'd especially be interested in a collaborator who has the experience and motivation to coauthor a paper; I can supply the intuition and experimental approach, but the details of the math take me a long time to work out. (That said, I'm starting to wonder if engaging that slog myself might not actually be a good way to level up my math skills)

[1]: https://xi.zulipchat.com/#narrow/stream/260979-kurbo/topic/E...

comment 2y ago · link · parent

To me it recalls "This has made a lot of people very angry and has been widely regarded as a bad move," which is a bit from the introduction and first chapter of the Hitchhiker's Guide.

comment 2y ago · link · parent

Very cool project, and I love to see more work in this space.

Something else to look at is the Vortex project from Georgia Tech[1]. Rather than recapitulating the fixed-function past of GPU design, I think it looks toward the future, as it's at heart a highly parallel computer, based on RISC-V with some extensions to handle GPU workloads better. The boards it runs on are a few thousand dollars, so it's not exactly a hobbyist friendly, but it certainly is more accessible than closed, proprietary development. There's a 2.0 release that just landed a few months ago.

[1]: https://vortex.cc.gatech.edu/

comment 2y ago · link · parent

I think you've got a point here. 2D rendering is reasonably well defined. The problem is the overwhelming complexity of the GPU ecosystem. If you just had a decent parallel computer, it wouldn't be so hard. But instead you have to adapt your rendering logic to the particular combination of pile of hacks your GPU infrastructure supports, each having an exquisitely unique set of limitations and tradeoffs.

You'll likely enjoy our upcoming GPU-friendly stroke expansion paper - the core of it is exactly numerical methods with error bounds for the exact symbolic integrals of (certain curvature metrics) of curves. And the code is in Vello main (shader/flatten.wgsl) if you're curious and want to look at it now.

comment 2y ago · link · parent

I'm looking forward to doing careful benchmarking, as this renderer absolutely looks like it will be competitive. It turns out that is really hard to do, if you want meaningful results.

My initial take is that performance will be pretty dependent on hardware, in particular support for pixel local storage[1]. From what I've seen so far, Apple Silicon is the sweet spot, as there is hardware support for binning and sorting to tiles, and then asking for fragment shader execution to be serialized within a tile works well. On other hardware, I expect the cost of serializing those invocations to be much higher.

One reason we haven't done deep benchmarking on the Vello side is that our performance story is far from done. We know one current issue is the use of device atomics for aggregating bounding boxes. We have a prototype implementation [2] that uses monoids for segmented reduction, and that looks like a nice improvement. Additionally, we plan to do f16 math (which should be a major win especially on mobile), as well as using subgroups for various prefix sum steps (subgroups are in the process of landing in WebGPU[3]).

Overall, I'm thrilled to see this released as open source, and that there's so much activity in fast GPU vector graphics rendering. I'd love to see a future in which CPU path rendering is seen as being behind the times, and this moves us closer to that future.

[1]: https://dawn.googlesource.com/dawn/+/refs/heads/main/docs/da...

[2]: https://github.com/linebender/vello/issues/259

[3]: https://github.com/gpuweb/gpuweb/issues/4306

comment 2y ago · link · parent

Good further reading on this change is "Windowless controls are not magic"[1] from Raymond Chen, and the followup "Windows are not cheap objects"[2]. It's a fascinating tradeoff space. I think fine-grained windows worked reasonably well on limited hardware but did not scale to super-rich applications like web browsers, or a more sophisticated imaging model where widgets need to be composited with alpha-transparency.

[1]: https://devblogs.microsoft.com/oldnewthing/20050211-00/?p=36...

[2]: https://devblogs.microsoft.com/oldnewthing/20050315-00/?p=36...

comment 2y ago · link · parent

Often does it actually improve the title?

I think the actual use case is stuff like "how I cross-compiled Eliza to the IBM 1401 using Zig", where it is a little cleaner without.

comment 2y ago · link · parent

Indeed. I learned color theory from "The Measurement of Appearance" by Richards Hunter and Harold, and one of the strengths of that work is that goes well beyond simple color into things like gloss, opalescence, etc. Highly recommended.

Also Bruce MacEvoy's in-progress book "Color Experience"[1] looks like it will be a fairly definitive treatment of the topic. It is also rooted in physical colorants (the author is an extremely serious watercolorist).

[1]: https://www.handprint.com/CE/book.html

comment 2y ago · link · parent

Indeed, and there's a most excellent essay that goes into considerably more detail on this: https://www.exurbe.com/tools-for-thinking-about-censorship/ , written partly in response to the Chengdu debacle, but also covering lots of Western examples, including Galileo vs the church, the comics code, and more.

comment 2y ago · link · parent

I joined Android in April 2012. Looking back, at that time Android was incredibly lean for what it was accomplishing. The entire Frameworks team reported to one manager, and we would fit in a medium size conference room. That included all of UI toolkit and the bulk of the Java APIs an app would call into, including Binder. (Networking, phone, graphics, Bluetooth, etc were other teams, but we worked closely together. And I think graphics was like 5 people). At the time I was slightly worried that I had joined a mature project and that it had already seen most of its success. Little did I know. (Disclosure: Chet was my manager for a couple years, until I left in late 2016 to join Fuchsia, largely because I was impatient to develop in Rust).

Chet is a great comedian, I think he'll do well in his new interest. I'll bend the norms here and tell a joke. It'll be funny to Android insiders, apologies otherwise.

At one point, he hosted a get-together in his house, which was one of many things that led to incredible team cohesion. It was somewhat chilly, and we were sitting around in our jackets shivering a bit. One person said, "we should have an Android app for turning on the heat to warm us up." My response: "we already do, it's called GMSCore."

comment 2y ago · link · parent

The Metalium repo is here: https://github.com/tenstorrent-metal/tt-metal/

There's also an "unboxing video" from Dr Ian Cuttress and Jasmina Vasiljevic from a few months ago: https://www.youtube.com/watch?v=WJpJkvNw9Ts . It's a bit out of date because a lot of the stuff that was promised as "coming soon" has actually happened.

I personally think making this open source is huge and am cautiously optimistic that the hardware has potential for general purpose parallel computing, so I've ordered a card.

comment 2y ago · link · parent

It's a good question and one we're looking into. We're not planning tight integration with the system compositor on our 2024 roadmap, partly because it's extremely platform dependent, and presents compatibility challenges (you basically don't get it on X). But even for damage regions, which is on the roadmap, we're going to need to extend wgpu.

comment 2y ago · link · parent

Much of that is latency added by the design of modern compositors (see "the compositor is evil").

The good-ish news is that as the frame rate goes up, compositor latency goes down, as it's usually an integer multiple of frame refresh time.

I'm also interested in influencing the design of next gen systems to reduce compositor latency, but I'm apparently pretty much alone in that interest.

comment 2y ago · link · parent

I think the distinction is not as hard and fast as you make it out. I found "Tools for thinking about censorship"[1] to be extremely thought-provoking. There are many nuanced arguments, but a central one is that governments often leverage self-censorship in order to effect their control over the flow of information.

[1]: https://www.exurbe.com/tools-for-thinking-about-censorship/

comment 2y ago · link · parent

I'd recommend wgpu. It should be a fairly easy migration from Metal, as Apple has been actively involved in the design, and there are similar concerns for developer experience (unlike, say, Vulkan).

Unfortunately, graphics is in many ways the easy part. Really excellent integration with system menus, preferences, keyboard, input method editing, all have more variation across platforms and a still-evolving story of solid Rust abstractions. Lately, we've decided to try joining forces with the winit project to see if we can get those problems solved well.

comment 2y ago · link · parent

It should be. There's AccessKit integration in egui (the most prominent Rust immediate mode GUI implementation) now, thanks to Matt Campbell's work. I would welcome GPUI and Zed adopting that, and I'm sure Matt can offer help in getting it integrated.

comment 2y ago · link · parent

This is in fact touched on (if briefly), in the roadmap - it's "virtual lists" and absolutely is a priority for this year. Performant UI is not possible without it.

The idea is not so much that you have a custom widget, but rather that you have a container view which is tightly coupled to a corresponding container widget. As you scroll, that widget requests its view to materialize (and de-materialize) views for the child widgets that become visible. It doesn't need custom widgets, the child widgets can be standard, and because it's Rust the cost of allocating and deallocating the child widgets (as opposed to recycling existing widgets as in Android RecyclerView) is modest.

(Point of clarification for those following more closely: I'm talking about views here, while the linked post is focused on widgets. The widget tree will provide a documented protocol for requesting child widgets, estimating layout sizes, syncing up scroll adjustments, and so on. This protocol will be a bit messy and complicated, because the underlying problems are hard. We'll develop it in tandem with the corresponding Xilem view, which will we hope will provide a really nice clean developer experience, especially in conjunction with an immutable list data structure which can produce sparse deltas. Then, as people want to do their own reactive layer, they can figure out how to do the plumbing from their own take on the incremental computation engine into this protocol.)

We prototyped this last year, enough to be confident in the direction, and it is absolutely a goal to wire it all up this year.

comment 2y ago · link · parent

Similar. I've done experiments with subgroups suggesting approximately a 2.5x speedup for sorting (using the WLMS technique of Onesweep). Binding arrays will be very helpful for rendering images in the compute shader. A caveat is that descriptor indexing is not supported on mid-old phones like Pixel 4, but it is on Pixel 6. I somewhat doubt device buffer address will be supported, as I think the security aspect is complicated (it resembles a raw pointer), but it's possible they'll figure out how to do it.

comment 2y ago · link · parent

This is for Cortex A8, which was the chip in the Nexus One. I wrote the original version of sound synthesis directly in ARM assembler[1]. It was very highly optimized, I remember using a cycle counting app that flagged any dependency chain that would cause the processor to stall, and ultimately utilization was in the 90%+ range. Back in those days, processors were simple enough you could do this kind of optimization by hand. By the time of Cortex A15 (Nexus 10 etc), instruction issue was out-of-order and much harder to reason about.

The best current info I could find for the latency advice is [2]. Quoting, "Moving data from NEON to ARM registers is Cortex-A8 is expensive." Looking at [3] partially reveals the reason why: the NEON pipeline is entirely after the integer pipeline, so moves from integer to NEON are cheap, but the reverse direction is potentially a large pipeline stall. This is an unusual design decision that as far as I know is not true for any other CPUs. Edit: I found [4], which is a more authoritative source.

[1]: https://github.com/google/music-synthesizer-for-android/blob...

[2]: https://community.arm.com/support-forums/f/armds-forum/757/n...

[3]: https://www.design-reuse.com/articles/11580/architecture-and...

[4]: https://developer.arm.com/documentation/den0018/a/Optimizing...

comment 2y ago · link · parent

Historically yes. This is most definitely not true since processors had SSE3 (~2004), using the FISTTP instruction, or I think you can also use the packed float to integer instructions like CVTTPS2PI as far back as SSE (1999).

comment 2y ago · link · parent

I am very familiar with such low level workings. On a modern, fast machine, the amount of computation required by FM synthesis is so small compared with the machine's throughput that it just doesn't matter.

Yes, on modern chips float math will generally be faster than fixed point. This is not so much because the integer units get clogged, as that there's a huge amount of chip area and optimization that goes into the float units (often SIMD, and a lot of FM synthesis can benefit from this, though feedback creates data dependencies). For example, multiply-and-add is usually one cycle in float, but would always be two separate instructions in integers.

My recollection is that older ARM chips have a special issue with latency of data dependencies originating from the float unit (NEON, which is optimized for SIMD vector operations) to the integer unit. I suspect this is no longer the case, or is less of an issue.

233.

Xilem 2024 Plans(linebender.org ↗)

10 points · by raphlinus · 2y ago · discuss

comment 2y ago · link · parent

Prof Wirth was a major inspiration for me as a kid. I eagerly read his book on Pascal, at the time not appreciating how unusual it was for its elegance and simplicity. I also followed with interest his development of the Oberon language and Lilith workstation. When I was 13, he gave a talk not too far away, I think it might have been Johns Hopkins, and my dad took me to it. It was a wonderful experience, he was very kind and encouraging, as I think the linked photo[1] shows.

[1]: https://mastodon.online/@raph/111693863925852135

comment 2y ago · link · parent

I haven't been in touch with him in over 20 years, so have no idea where even to start. Best of luck with that!

comment 2y ago · link · parent

Sending much love. It's gratifying to see work on this continue, from seeds planted so long ago.

comment 2y ago · link · parent

In a recent talk[1], Bill Dally of Nvidia suggests using actual logarithms, as they're more consistent in relative error than floats, which is especially relevant at low precision as increasingly used in AI. Multiplications then become simple additions, but then addition becomes more complicated, as in general it needs lookup tables. This is the same mechanism as a slide rule, and also reminds me of the way the Yamaha DX7 works. The lookup tables can be expensive, and the talk contains an idea how to batch them when adding up the results of many many multiplications (as is also often the case for AI workloads).

[1]: https://www.youtube.com/watch?v=kLiwvnr4L80

comment 2y ago · link · parent

There is a copy of this in the Museo Galileo in Florence as well, which I visited a couple of weeks ago. Highly recommended if you get the opportunity. They also have an extensive multimedia guide, which is also available online[1] (though they may be having server problems, it hasn't been loading 100% reliably for me).

[1]: https://mostre.museogalileo.it/framauro/en/

comment 2y ago · link · parent

From the 2023 Octoverse report[1], "In 2023, Shell and Hashicorp Configuration Language (HCL) once again emerged as top languages across open source projects, indicating that operations and IaC work are gaining prominence in the open source space." The accompanying chart shows it as #11, ranking above Dart, Kotlin, and Ruby.

I think this is a case where the citation bears out the claim, and there's no need for Mitchell to feel embarrassment.

[1]: https://github.blog/2023-11-08-the-state-of-open-source-and-...

comment 2y ago · link · parent

Good call. So this doesn't look like a blocker to SYCL compatibility. I'm interested in learning more about this.
1
789
63