πŸ“¦ Bigfoot71 / rsoft

Simple Odin software rasterizer

β˜… 1 stars β‘‚ 0 forks πŸ‘ 1 watching βš–οΈ MIT License
πŸ“₯ Clone https://github.com/Bigfoot71/rsoft.git
HTTPS git clone https://github.com/Bigfoot71/rsoft.git
SSH git clone git@github.com:Bigfoot71/rsoft.git
CLI gh repo clone Bigfoot71/rsoft
Le Juez Victor Le Juez Victor add license 1a26a26 1 months ago πŸ“ History
πŸ“‚ master View all commits β†’
πŸ“ rsoft
πŸ“ tests
πŸ“„ example.odin
πŸ“„ LICENSE
πŸ“„ README.md
πŸ“„ README.md

RSoft - Simple Odin Rasterizer

A small unpretentious software rasterizer written in Odin, just for fun.

NOTE: The pipeline only supports 4D floating-point vectors. This includes buffers, varyings, uniforms, and framebuffers.

Features

  • SIMD rasterization
  • Vertex and fragment shaders
  • Shader uniforms
  • Dynamic attributes/varyings
  • Perspective correct
  • Texture sampling
  • Depth function
  • Blend function
  • Depth mask
  • Clipping
  • Configurable face culling
  • MRT

Performance

Performance isn't "wow", but for a triangle in a 400Γ—225 box on my Ryzen 3600, here are the 10 second averages:

With shader indirection:

Clear:   101.81 Β΅s (9.8%)
Render:   92.15 Β΅s (8.9%)
Blit:    269.04 Β΅s (26.0%)
Present: 572.09 Β΅s (55.3%)

Without shader indirection:

Clear:   114.07 Β΅s (11.3%)
Render:   58.12 Β΅s (5.7%)
Blit:    269.47 Β΅s (26.6%)
Present: 569.83 Β΅s (56.3%)

Render is the part that rasterizes the triangle (~90k pixels).

  • With indirection: ~92β€―Β΅s
  • Without indirection: ~58β€―Β΅s
Which roughly gives (ballpark, please don’t quote me in court):

  • Total cycles: 0.000058s * 3.6GHz ~= 208,800 cycles
  • Per SIMD iteration: 208'800 / 11'250 ~= 18.6 cycles
  • Per pixel: 18.6 / 8 ~= 2.3 cycles
The most expensive step is Blit, because the rendering is done in an internal framebuffer where each component is stored as vectors of 8 floats (SoA), and then needs to be converted to an RGBA8 buffer.

Compilation flags used:

-o:speed -microarch:native

So these tests are rough and I'm not aiming for maximum performance. This is mainly for fun, and if it allows cool offline renders that's more than enough :D