Live data from Hacker News

Rasterizer: A GPU-accelerated 2D vector graphics engine in ~4k LOC

github.com

41–50 of 58 posts

Re: Rasterizer: A GPU-accelerated 2D vector graphics engine in ~4k LOC

#41
post #40

Earlier quoted context omitted.

Slug is primarily designed for text rendering. Vello is general purpose, like Rasterizer, but is based on GPU compute. Rasterizer uses the 'traditional' GPU pipeline. Performance numbers for both look very competitive, although Vello seems to have issues with GPU lock up at certain zoom scales. Rasterizer has been heavily tested with huge scenes at any scale.

Stupid question: Why not use the hardware (fixed function) rasterizer inside the GPU? I guess that one is only optimized for triangles.

Good question and answer ;-)

Re: Rasterizer: A GPU-accelerated 2D vector graphics engine in ~4k LOC

#42
post #40

Earlier quoted context omitted.

Slug is primarily designed for text rendering. Vello is general purpose, like Rasterizer, but is based on GPU compute. Rasterizer uses the 'traditional' GPU pipeline. Performance numbers for both look very competitive, although Vello seems to have issues with GPU lock up at certain zoom scales. Rasterizer has been heavily tested with huge scenes at any scale.

Stupid question: Why not use the hardware (fixed function) rasterizer inside the GPU? I guess that one is only optimized for triangles.

The longer answer is that using straight-edged geometry to represent curves is a resolution-dependent operation, e.g. a full screen circle may need to be flattened to an 80-sided polygon.

Rasterizer can solve quadratic curves in the fragment shaders, which massively reduces the geometry needed for a scene.

Also, the native rasterizer only supports MSAA, which is inferior to reference analytic area AA.

Re: Rasterizer: A GPU-accelerated 2D vector graphics engine in ~4k LOC

#43
post #2

I've been working on this problem on and off for over 10 years. AMA ;-)

This project made me happy. You mentioned Flash as an inspiration. Have you looked at how Ruffle is handling vector art?

From what I recall they are converting it to triangles. Your solution (curves in the shaders?) seems both cheaper and more accurate, so I'm wondering if they could use it!

Re: Rasterizer: A GPU-accelerated 2D vector graphics engine in ~4k LOC

#44
I recall many years ago nvidia released an openGL extension for rasterizing vectors/svg type stuff. A bit of googling found this from 2011:

https://developer.download.nvidia.com/assets/gamedev/files/N...

and this:

https://developer.nvidia.com/nv-path-rendering-videos

The faq points 30 & 31 say it use multisampling (up to 32 samples per pixel) for AA, and the winding at each sample is calculated analytically from the curve.

From other searching, it seems no other vendor supports that extension.

Re: Rasterizer: A GPU-accelerated 2D vector graphics engine in ~4k LOC

#45
I find that caching of renders brings orders of magnitude higher performance when using the native iOS / macOS canvas, however I get the feeling that there is really a limit to the direct drawing performance possible with a canvas API. I haven’t tried this yet so I’d be happy to be surprised.

Re: Rasterizer: A GPU-accelerated 2D vector graphics engine in ~4k LOC

#47
post #2

I've been working on this problem on and off for over 10 years. AMA ;-)

Nice work! I’d love to hear about your goals with this project, do you want to get it into PDF or browser engines, or anything like that?

Mark Kilgard surveyed some path rendering engines with a few curves that most have trouble with. It’d be fun to see how Rasterizer stacks up, and perhaps a nice bragging point if you dominate the competition. https://arxiv.org/pdf/2007.12254

Having used the quadratic solver code that you found on ShaderToy (sqBezier), you might be able to shave some cycles by doing a constant-folding pass on the code. It can be simplified from the state it’s in. Also the constant in there 1.73205 is just sqrt(3), and IMO it’s nicer to see the sqrt(3) than the constant, and it won’t slow anything down, the compiler will compute the constant for you. Also, it might be nice to additionally link to the original source of that code on pouet.

Re: Rasterizer: A GPU-accelerated 2D vector graphics engine in ~4k LOC

#48

I find that caching of renders brings orders of magnitude higher performance when using the native iOS / macOS canvas, however I get the feeling that there is really a limit to the direct drawing performance possible with a canvas API. I haven’t tried this yet so I’d be happy to be surprised.

Drawing cached renders in quads is how Core Animation works, but they do not scale well. You are ultimately limited by the CPU. Rasterizer enables a fully-animated canvas @ 60fps.

Re: Rasterizer: A GPU-accelerated 2D vector graphics engine in ~4k LOC

#49

Wow, that is an amazing piece of work, more so because it is so small. You should probably be more explicit about commercial licensing so companies that want to use it know where and how to contact you.

My email address is in every file ;-)

Re: Rasterizer: A GPU-accelerated 2D vector graphics engine in ~4k LOC

#50

I recall many years ago nvidia released an openGL extension for rasterizing vectors/svg type stuff. A bit of googling found this from 2011: https://developer.download.nvidia.com/assets/gamedev/files/N... and this: https://developer.nvidia.com/nv-path-rendering-videos The faq points 30 & 31 say it use multisampling (up to 32 samples per pixel) for AA, and the winding at each sample is calculated analytically from the…

My original target was iOS, so this was unavailable. I did experiment with their algorithm, but 4x MSAA was slow and had poor quality compared to Core Graphics, which was my reference.
Post reply on HN