-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Port the high-level Blade engine from RayCraft
- Loading branch information
Showing
18 changed files
with
1,006 additions
and
223 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Blade EGUI | ||
|
||
[![Docs](https://docs.rs/blade-egui/badge.svg)](https://docs.rs/blade-egui) | ||
[![Crates.io](https://img.shields.io/crates/v/blade-egui.svg?maxAge=2592000)](https://crates.io/crates/blade-egui) | ||
|
||
[EGUI](https://www.egui.rs/) support for [Blade-graphics](https://crates.io/crates/blade-graphics). | ||
|
||
![scene editor](etc/scene-editor.jpg) | ||
|
||
## Instructions | ||
|
||
Just the usual :crab: workflow. E.g. to run the bunny-mark benchmark run: | ||
```bash | ||
cargo run --release --example bunnymark | ||
``` | ||
|
||
## Platforms | ||
|
||
The full-stack Blade Engine can only run on Vulkan with hardware Ray Tracing support. | ||
However, on secondary platforms, such as Metal and GLES/WebGL2, one can still use Blde-Graphics and Blade-Egui. |
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Blade Graphics | ||
|
||
[![Docs](https://docs.rs/blade-graphics/badge.svg)](https://docs.rs/blade-graphics) | ||
[![Crates.io](https://img.shields.io/crates/v/blade-graphics.svg?maxAge=2592000)](https://crates.io/crates/blade-graphics) | ||
|
||
Blade-graphics is a lean and mean [GPU abstraction](https://youtu.be/63dnzjw4azI?t=623) aimed at ergonomics and fun. See [motivation](etc/motivation.md), [FAQ](etc/FAQ.md), and [performance](etc/performance.md) for details. | ||
|
||
## Examples | ||
|
||
![ray-query example](etc/ray-query.gif) | ||
![particles example](etc/particles.png) | ||
|
||
## Platforms | ||
|
||
The backend is selected automatically based on the host platform: | ||
- *Vulkan* on desktop Linux, Windows, and Android | ||
- *Metal* on desktop macOS, and iOS | ||
- *OpenGL ES3* on the Web | ||
|
||
| Feature | Vulkan | Metal | GLES | | ||
| ------- | ------ | ----- | ---- | | ||
| compute | :white_check_mark: | :white_check_mark: | | | ||
| ray tracing | :white_check_mark: | | | | ||
|
||
### OpenGL ES | ||
|
||
GLES is also supported at a basic level. It's enabled for `wasm32-unknown-unknown` target, and can also be force-enabled on native: | ||
```bash | ||
RUSTFLAGS="--cfg gles" CARGO_TARGET_DIR=./target-gl cargo test | ||
``` | ||
|
||
This path can be activated on all platforms via Angle library. | ||
For example, on macOS it's sufficient to place `libEGL.dylib` and `libGLESv2.dylib` in the working directory. | ||
|
||
### WebGL2 | ||
|
||
Following command will start a web server offering the `bunnymark` example: | ||
```bash | ||
cargo run-wasm --example bunnymark | ||
``` | ||
|
||
### Vulkan Portability | ||
|
||
First, ensure to load the environment from the Vulkan SDK: | ||
```bash | ||
cd /opt/VulkanSDK && source setup-env.sh | ||
``` | ||
|
||
Vulkan backend can be forced on using "vulkan" config flag. Example invocation that produces a vulkan (portability) build into another target folder: | ||
```bash | ||
RUSTFLAGS="--cfg vulkan" CARGO_TARGET_DIR=./target-vk cargo test | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,22 @@ | ||
# Frequency Asked Questions | ||
|
||
## When should I *not* use Blade? | ||
|
||
- When you *target the Web*. Blade currently has no Web backends supported. Targeting WebGPU is desired, but will not be as performant as native. | ||
- Similarly, when you target the *low-end GPUs* or old drivers. Blade has no OpenGL/D3D11 support, and it requires fresh drivers on Vulkan. | ||
- When you render with 10K or *more draw calls*. State switching has overhead with Blade, and it is lower in GPU abstractions/libraries that have barriers and explicit bind groups. | ||
- When you need something *off the shelf*. Blade is experimental and young, it assumes you'll be customizing it. | ||
|
||
## Why investing into this when there is `wgpu`? | ||
|
||
`wgpu` is becoming a standard solution for GPU access in Rust and beyond. It's wonderful, and by any means just use it if you have any doubts. It's a strong local maxima in a chosen space of low-level portability. It may very well be the global maxima as well, but we don't know this until we explore the *other* local maximas. Blade is an attempt to strike where `wgpu` can't reach, it makes a lot of the opposite design solutions. Try it and see. | ||
|
||
## Isn't this going to be slow? | ||
|
||
Blade creating a descriptor set (in Vulkan) for each draw call. It doesn't care about pipeline compatibility to preserve the bindings. How is this fast? | ||
|
||
Short answer is - yes, it's unlikely going to be faster than wgpu-hal. Long answer is - slow doesn't matter here. | ||
|
||
Take a look at Vulkan [performance](performance.md) numbers. wgpu-hal can get 60K bunnies on a slow machine, which is pretty much the maximum. Both wgpu and blade can reach about 20K. Honestly, if you are relying on 20K unique draw calls being fast, you are in a strange place. Generally, developers should switch to instancing or other batching methods whenever the object count grows above 100, not to mention a 1000. | ||
|
||
Similar reasoning goes to pipeline switches. If you are relying on many pipeline switches done efficiently, then it's good to reconsider your shaders, perhaps turning into the megashader alley a bit. In D3D12, a pipeline change requires all resources to be rebound anyway (and this is what wgpu-hal/dx12 does regardless of the pipeline compatibility), so this is fine in Blade. | ||
# Frequency Asked Questions | ||
|
||
## When should I *not* use Blade? | ||
|
||
- When you *target the Web*. Blade currently has no Web backends supported. Targeting WebGPU is desired, but will not be as performant as native. | ||
- Similarly, when you target the *low-end GPUs* or old drivers. Blade has no OpenGL/D3D11 support, and it requires fresh drivers on Vulkan. | ||
- When you render with 10K or *more draw calls*. State switching has overhead with Blade, and it is lower in GPU abstractions/libraries that have barriers and explicit bind groups. | ||
- When you need something *off the shelf*. Blade is experimental and young, it assumes you'll be customizing it. | ||
|
||
## Why investing into this when there is `wgpu`? | ||
|
||
`wgpu` is becoming a standard solution for GPU access in Rust and beyond. It's wonderful, and by any means just use it if you have any doubts. It's a strong local maxima in a chosen space of low-level portability. It may very well be the global maxima as well, but we don't know this until we explore the *other* local maximas. Blade is an attempt to strike where `wgpu` can't reach, it makes a lot of the opposite design solutions. Try it and see. | ||
|
||
## Isn't this going to be slow? | ||
|
||
Blade creating a descriptor set (in Vulkan) for each draw call. It doesn't care about pipeline compatibility to preserve the bindings. How is this fast? | ||
|
||
Short answer is - yes, it's unlikely going to be faster than wgpu-hal. Long answer is - slow doesn't matter here. | ||
|
||
Take a look at Vulkan [performance](performance.md) numbers. wgpu-hal can get 60K bunnies on a slow machine, which is pretty much the maximum. Both wgpu and blade can reach about 20K. Honestly, if you are relying on 20K unique draw calls being fast, you are in a strange place. Generally, developers should switch to instancing or other batching methods whenever the object count grows above 100, not to mention a 1000. | ||
|
||
Similar reasoning goes to pipeline switches. If you are relying on many pipeline switches done efficiently, then it's good to reconsider your shaders, perhaps turning into the megashader alley a bit. In D3D12, a pipeline change requires all resources to be rebound anyway (and this is what wgpu-hal/dx12 does regardless of the pipeline compatibility), so this is fine in Blade. |
Oops, something went wrong.