Parallel Asset Loading for Game Load Screens in Rust

Why should a load screen work in parallel?

Modern processor speeds have not become significantly faster in the past several years. However, most cpus now have multiple cores. This means that in order to maximize your utilization of processor resources in your game, your game must do some operations in parallel. This performance is most apparent in game load screens.

Why Rust?

C++ is a conservative choice for game design. Why should anyone consider using a new tool like Rust if it lacks many of the library integrations that you might expect for game development?

Rust was specifically designed to make writing parallel code thread safe and more sane. C++ lacks in this area where it is very easy to slip into a memory corruption that can be near impossible to trace back to the cause. Instead, the Rust compiler will help identify flaws in your program using a more advanced type system that can detect causes of memory corruption like use-after-free and other similar bugs.

How Rust?

To program a game application in Rust I use dioxus because it is very easy to get started and to write a cross platform application. It is now possible to write one program that compiles to run on Windows, Mac Desktop, Linux Desktop, Android Mobile, iPhone, and Web all from the same codebase. For reference I am personally developing through Windows Subsystem for Linux Ubuntu running on Windows through a third party X Server. It really just works!

use dioxus::prelude::*;
use dioxus_desktop::tao::menu::MenuBar;

fn main() {
    dioxus::desktop::launch_cfg(app, |c| c.with_window(|w| w.with_menu(MenuBar::default())));
}

fn app(cx: Scope) -> Element {
    cx.render(rsx! (
        div { "Hello, world!" }
    ))
}