Gfx-rs nuts and bolts

Gfx-rs is a low-level graphics abstraction layer in Rust. This blog supposedly hosts the major milestones, concepts, and recaps of the project.


Bringing Vulkan everywhere

09 Apr 2018

gfx-rs pursues to provide a graphics API around the current open graphics libraries (Vulkan, D3D11/12, Metal and OpenGL). Last year we realized that we want to provide a low-level API, and it’s reasonable to mimic Vulkan, since it is an existing API with detailed specification and in our analysis regarding mapping from D3D12 and Metal it seemed possible. This also matches the goal of the Vulkan Portability Initiative to define a subset of Vulkan which can be efficiently implemented on top of D3D12 and Metal. We started experimenting with a C wrapper that implements “vulkan.h” on a target system. However, getting from a hacked prototype to a production-ready library is most difficult (spoiler: we aren’t there yet).

MoltenVK

In the meantime, MoltenVK has been open-sourced with Valve’s help. This changed the landscape of portability and the perception of Vulkan by game developers. Some of the alternative Vulkan on Metal implementations got deprecated, but gfx-rs portability is still moving forward. We’ve been working in Vulkan Portability TSG (technical subgroup) from day one, contributing our research and discussing the portability issues. Our Metal backend is not nearly at the same quality level as MoltenVK yet, but we see a few ways where we can excel in terms of performance, as well as benefit from low maintenance cost of pure-Rust codebase in the long run.

Vulkan CTS

So, supposing we want to ship a Vulkan portability library one day. How do we know it’s ready? By passing the official Conformance Test Suite, of course. We got the CTS ported to OSX and have been tracking the progress on all three major backends (Vulkan, D3D12, Metal). As of today, we aren’t reaching the end of CTS, panicking in the middle, but we pass over a thousand of tests on all backends. Our goal will be to get the whole CTS running trough and gradually improve the pass rate. It’s still a long way until we pass the over 250k+ tests!

We have a super talented team of volunteer contributors, but there is still so much work to be done that we feel overwhelmed with it and would be happy to accept any help. Good thing is - there is a clear goal to reach, which we can measure quantitatively, and the work can be split effectively. Let the gfx-rs implementation period kick off!