[][src]Crate emu_core

emu_core is a library that serves as a compute-focused abstraction over WebGPU. Despite its name, WebGPU allows Emu to support most platforms (through Vulkan, Metal, DX) and eventually even the web itself (through WebAssembly - API changes to support this should be minimal).

You can see the crate for how to add Emu to your Rust project (emu_core = "*") and the examples for how to use Emu. The following link to documentation of what are essentially the building blocks of Emu.

Note that Device and pool are the lowest-level building blocks for the rest of Emu and as such, you could technically use either just Device and pool or just the rest of Emu. In practice though, you will probably do both. You will use the rest of Emu for most of your application/library and then drop down to low-level Device-and-pool usage in rare cases when you want to work with the underlying WebGPU data (maybe to mix in graphics with your compute) structures or to have finer control over certain parameters.

And about features - there is 1 feature that by default is switched off - glsl-compile. You should enable this feature if you would like to use Glsl or GlslKernel. This feature has one important dependency - shaderc. In the future, when a Rust-based GLSL-to-SPIR-V compiler is finished (there is work going towards this), there will be a simpler pure-Rust dependency but until then, you should follow steps here to ensure the platforms you target will have shaderc. Of course, if you really don't want to use shaderc, you could always compile your code to SPIR-V at compile time and then use SPIR-V as input to Emu.

Also, some basic guides that will likely be helpful in using Emu are the following.

Modules

boxed

Functions for working with DeviceBox<T> and the device pool

cache

Infrastructure for caching kernels that are already JIT compiled

compile

The whole source-to-DeviceFnMut compilation pipeline

compile_impls

A few implemented source languages that can be compiled to SPIR-V

device

The lowest-level, core functionality for controlling a GPU device

error

Various error types

pool

Tools for managing the device pool either implicitly or explicitly

prelude

The module to import to import everything else

spawn

Functions for spawning threads and launching compiled DeviceFnMuts

Macros

call

A macro which evaluates to something that can be passed into launch