|
|
|
|
|
by kragen
8 days ago
|
|
The Riffle program I elicited from Claude last night renders text to pixels about twice as fast as your program on my laptop: https://news.ycombinator.com/item?id=50613058 But that's still slower than memcpy(), although it was 60% faster than memcpy() on the Xeon it was initially tested on. Hopefully I can fix that today! |
|
So it's faster than memcpy only on hardware like Xeons, not on my Ryzen 5 3500U laptop. Rendering a 1080P frame of dense text on my laptop takes about 4 milliseconds on one core, half of which is compositing the glyphs with a procedural background. By contrast, memcpy takes only 0.8 milliseconds.
Moreover, I've decided that you're basically right about damage tracking, and I was wrong. As long as there's a framebuffer somewhere in the pipeline, and nothing is gratuitously clearing it, redrawing part of that framebuffer will take less work than redrawing all of it, because you don't have to memcpy the part you aren't changing.
And this is true whether the framebuffer is a SysV shared memory segment, a buffer of unified system RAM, VRAM on a discrete GPU card, GDDRAM in an LCD controller chip you're talking to over SPI, or particles of electret floating in the oil of a bistable e-paper electrophoretic display. The kind of work you save is different from one to the next, but damage rectangles save work in every case, even if it's just a little. Even in cases where it doesn't update the display faster, it often extends battery life.
In most of these scenarios, you can scroll the unchanged part of the screen by setting a couple of registers to scan out the pixels in a different order, as you said, so I was pretty much wrong about that too.
In particular, my example, "to scroll the contents of a browser window but not the browser chrome," can be handled by redrawing the browser chrome in a different position over part of the scrolled page. I'm not sure how you would design the graphics API to make this simple, but you can clearly do it.
Similarly, I think it is correct that "reusing previously rendered lines is faster than rendering all text on every frame". I was wrong about that.