4 ms·
I agree with you that using a GPU accelerated API has many more benefits. I was trying to learn Xlib and Cairo to learn the 'nuts and bolts' of rendering and al
by leakbang 4y ago
I agree with you that using a GPU accelerated API has many more benefits. I was trying to learn Xlib and Cairo to learn the 'nuts and bolts' of rendering and also because they didn't require other libraries. I will look both at C# and GPU accelerated APIs. My only concern with C# is the cross compatibility. Thank you for your recommendations.
- Const-me 4y ago> to learn the 'nuts and bolts' of rendering These nuts and bolts are very different between CPU and GPU. CPU-based libraries are painting pixels in bitmaps in system memory. Most GPU-based libraries are uploading indexed triangle meshes, and rendering them with weird shaders. Worse, there're no good open source implementations of GPU-based ones. Microsoft ships an implementation as a part of OS (Direct2D) but it's not open source. Linux simply doesn't have an equivalent. At least for initial versions, consider C interop with this https://github.com/memononen/nanovg https://github.com/memononen/nanovg It cuts a few corners (no cleartype for text, CPU overhead for repeated rendering of same static paths) but it's still good overall, simple, and easy to use. > My only concern with C# is the cross compatibility Works well on Linux, Windows and OSX, including ARM CPUs. Not sure about Android and iOS, never tested. My largest concern with C# would be performance. Technically the language allows to code in any style, but most guides and examples are using OO-heavy one. Less than ideal for performance-critical pieces where you'd want cache-friendly RAM layout i.e. mostly value types, minimize dynamic memory allocations (e.g. lambdas are using managed heap when created), and so on. My largest concern with the project overall would be the scale. Browsers are incredibly complicated. In C# the standard library contains many important pieces (HTTP stack, WebSockets, XML, etc.), you'll definitely find good free libraries to deal with HTML and CSS, you'll probably find libraries to interpret or JIT-compile JavaScript, but still, the remaining pieces are huge.
- leakbang 4y ago> Worse, there're no good open source implementations of GPU-based ones. Microsoft ships an implementation as a part of OS (Direct2D) but it's not open source. Linux simply doesn't have an equivalent. What about OpenGL? I believe that the Firefox/Servo WebRender (written in Rust) also uses OpenGL. But I do believe that the GPU acceleration implementation is more complete on Windows and Mac OS. > you'll definitely find good free libraries to deal with HTML and CSS, you'll probably find libraries to interpret or JIT-compile JavaScript, but still, the remaining pieces are huge. I really want to not use libraries as much as possible and do everything on my own. It won't be good as the libraries but I see a lot of value in doing everything myself and learn it.
- Const-me 4y ago> What about OpenGL? Yeah, GL is good now. Vulkan too, when supported by GPU driver. However, both GL and VK can only render triangle meshes. Browsers don't quite need meshes (except WebGL but that's another story), they need 2D graphics and text. On Windows, browsers and most other modern apps are using Direct2D and DirectWrite. They are OS-provided libraries which render 2D graphics and text with triangle meshes using Direct3D 11 underneath. While modern GL is comparable to D3D11 (and VK comparable to D3D12), there's no equivalent libraries on Linux, i.e. you'll need to do that part on your side, instead of consuming OS-provided libraries. These parts are far from being trivial. > I really want to not use libraries as much as possible and do everything on my own OK but at least you'll be able to look how other people did that. Also the standard library is a part of the language runtime, no reason not to use it. In C# it contains quite a few complicated low-level pieces, like network protocols and cryptography.