[−][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.
- See
Device
andpool
for the lowest-level, core primitives abstracting directly over WebGPU - See
DeviceBox<T>
,AsDeviceBoxed
,IntoDeviceBoxed
for boxing data on the GPU - See
SpirvBuilder
,Glsl
,GlslKernel
for simple source languages to use for writing compute kernels - See
compile
for compiling source language toSpirvOrFinished
and then finishing toDeviceFnMut
- See
spawn
for spawning threads on GPU and launching compiled kernels (DeviceFnMut
s) - See
pool
'spool
/select
/take
for managing the global pool of devices - See
assert_device_pool_initialized
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.
- How to use CUDA - This explains the idea of launching kernels on a 3-dimensional space of threads, which Emu and CUDA share
- How to write GLSL compute shaders - This explains some of the stuff that is specific to SPIR-V, which Emu uses as input
Modules
boxed | Functions for working with |
cache | Infrastructure for caching kernels that are already JIT compiled |
compile | The whole source-to- |
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 |
Macros
call | A macro which evaluates to something that can be passed into |