14,081 karma · joined Mar 7, 2014 (12y ago) · 1,887 submissions
1172.
Xi-Editor Retrospective(raphlinus.github.io ↗)
538 points · by raphlinus · 6y ago · 157 comments
comment 6y ago · link · parent
comment 6y ago · link · parent
comment 6y ago · link · parent
The "impedance mismatch" is that you (generally) have to write in a style to extract lots of parallelism. This tends to be very different than the way you'd write scalar CPU code, but not completely alien to me as it has a lot of similarity with the way you'd write SIMD. I've pretty much gotten the hang of it now. I'm thinking of a blog post of redoing path_coarse.comp from its current basically scalar style to a more parallel version, as that would I think illuminate the issues.
[1] http://comparch.gatech.edu/hparch/papers/gera_ispass18.pdf
comment 6y ago · link · parent
You can, people have tried this, and it sucks. The main problem is that the conversion of Bézier paths to triangles is a hard problem with lots of conditional branching. Even when you do it, there is the other problem of rendering triangles with really good antialiasing, MSAA forces a compromise between performance and quality. By contrast, piet-gpu does an exact-area calculation for antialiasing.
So it's not a question of whether you can do it, but whether it works well, and approaches like piet-gpu absolutely stomp triangles.
comment 6y ago · link · parent
Of course CPU rendering is always more straightforward than GPU, the higher performance comes at a significant cost in complexity.
comment 6y ago · link · parent
comment 6y ago · link · parent
And: historically they've been computed mostly on CPU, but I think it's time for that to change.
comment 6y ago · link · parent
comment 6y ago · link · parent
Doing a warp transformation in the element processing kernel would probably work just fine, and give you realistic movement and razor-sharp rendering.
I'd love to see such a thing and would very much like to encourage people to build it based on my results :)
comment 6y ago · link · parent
comment 6y ago · link · parent
A lot of the academic literature (Massively Parallel Vector Graphics, the Li et al scanline work) is dependent on CUDA, but that's just because tools for doing compute on general purpose graphics APIs are so primitive. I have a talk and a bunch of blog posts on exactly this topic, as I had to explore deeply to figure it out. See https://news.ycombinator.com/item?id=22880502 and https://raphlinus.github.io/gpu/2020/04/30/prefix-sum.html for more breadcrumbs on that.
comment 6y ago · link · parent
They might use it for other stuff like glyph compositing (I think this is one reason they got rid of RGB subpixeling, to make it more amenable to GPU), but last I profiled it, it was still doing a lot of the pixels on CPU, as others have stated.
comment 6y ago · link · parent
comment 6y ago · link · parent
Also, I see a lot of variations of this question, but I should state this more clearly. There's been accelerated graphics in one form or another for a long time, but what I'm doing is a completely different type of thing. In my world, on the CPU you just encode the scene into a binary representation that's optimized for GPU but in many ways is like flatbuffers, and then the GPU runs a highly parallel program to render the whole thing. In previous approaches, the CPU is deeply involved in taking the scene apart and putting it back together in a form that's well suited to relatively dumb pixel pipes. Now that GPUs are really fast, that approach runs into limitations.
It also depends what you're trying to do. I'm focusing here on dynamic paths (and thus font rendering), while most of the libraries optimized for UI put text into texture atlases and then use the GPU to composite quads to the final surface, something they can do well.
https://blog.mecheye.net/2019/05/why-is-2d-graphics-is-harde...
comment 6y ago · link · parent
comment 6y ago · link · parent
It is likely that CPU-side encoding can be made more efficient, though, by just filling in quantities to a template, rather than encoding from scratch.
comment 6y ago · link · parent
In the meantime, antigrain.com is one good (if old) source. The original PostScript "red book" was extremely influential in its time (it's where I learned a lot of this stuff) but is quite dated now. Best of luck, and I'm also happy to field requests for more specific areas. For example, for color theory (an important aspect of 2D graphics!), handprint.com is quite a remarkable resource.
comment 6y ago · link · parent
1195.
Fast 2D Rendering on GPU(raphlinus.github.io ↗)
286 points · by raphlinus · 6y ago · 123 comments
comment 6y ago · link · parent
But for graphics, why should this be the goal? Perhaps a better goal is high contrast of edges, and for this the box filter is one of the very best. An additional advantage of the box filter is that it has only positive support, so there's no clipping beyond white and black. This is especially helpful when rendering text.
And honestly I believe that those huge sinc-approximating reconstruction filters are overly fetishized even in the audio space. The main reason they sound "nearly perfect" is that the cutoff is safely outside the audible range. Try filtering a perfect slow sawtooth through a brick wall with a cutoff in the audio range, say 8kHz. It sounds like a very audible "ping" at that frequency, with pre-echo at that because of the symmetry of sinc.
comment 6y ago · link · parent
One of my favs (apropos for the HN crowd): I would code it differently by sending the ajax request to the backend server and randomize the number there :Grinning face with smiling eyes: #magento #php #laravel
comment 6y ago · link · parent
https://twitter.com/jburnmurdoch/status/1268450736398098433
The paywall is also easily crossed by, for example, archive.is