changed 6 months ago
Linked with GitHub

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →


whoami

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →


Agenda

  1. Landscape of GPU abstractions
  2. History of wgpu
  3. Blade of difference

GPU abstractions

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →


Map of Portability

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →


Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →


case: glow

Purity:

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Safety:
Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

  • OpenGL is safe, but Rust API is not

Backends: GL/GLES/WebGL

  • no compute on Apple platforms

Overhead:

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

  • API itself is close to zero overhead
  • but actual platforms may involve translation

Ergonomics: AA+

  • relatively small API
  • boilerplate related to bindings and framebuffers

Downloads: every 8 seconds


case: Ash

Purity:

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
(no shader solution)
Safety:
Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Backends: Vulkan
Overhead:
Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Ergonomics: A
Downloads: every 9 seconds

  • is a dependency of many others

case: Vulkano

vulkano-logo

Purity:

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
host,
Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
shader processing (3rd party C++)
Safety:
Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
host,
Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
shaders, relies on robust buffer/image access
Backends: Vulkan
Overhead:
Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

  • every draw/dispatch is iterating all the used resources
  • actual commands are recorded at the end of the pass

Ergonomics: AA

  • automatic barriers, bit of type sugar

Downloads: every 2.5 minutes


case: wgpu

wgpu-logo

Purity:

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
(includes shader solution via naga)
Safety:
Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
(includes shader instrumentation)
Backends: Vulkan, D3D12, Metal, GL, WebGPU, WebGL2
Overhead:
Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

  • tracking every bind group setup
  • actual commands are recorded at the end of the pass

Ergonomics: AAA

  • simple specification
  • automatic state tracking

Downloads: every 12 seconds


case: wgpu-hal

Purity:

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
(includes shader solution via naga)
Safety:
Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Backends: Vulkan, D3D12, Metal, GL/GLES/WebGL2, WebGPU
Overhead:
Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
(directly mapped)
Ergonomics: A+

  • a bit simpler than Vulkan

Downloads: every 12 seconds (same as wgpu)


case: Blade

blade-logo

Purity:

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
(includes shader solution via naga)
Safety:
Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Backends: Vulkan, Metal, GLES/WebGL2
Overhead:
Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
(directly mapped)
GPU penalty:
Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
(to be discussed)
Ergonomics: AAA+

  • doesn't involve any bind group layout business
  • no resource states or barriers
  • but requires manual resource destruction

Downloads: every 15 minutes


Ergonomics scale

ergononimcs


logo


wgpu: Implementation of WebGPU

webgpu-problem


WebGPU: Targets

wgpu-intersection


wgpu: History

wgpu-history


wgpu: Architecture

wgpu-graph


wgpu: Safety

Core idea: validating correctness takes as much computation as providing it.


wgpu: Synchronization

wgpu-usageswgpu-sync


WebGPU Shading Language

webgpu-shading-language2


WGSL: Motivation

  • one of the drivers behind early Web was the ability to inspect/edit/write pages directly.
  • no shading language is designed for safety and lack of UB.
  • GLSL is outdated, SPIR-V spec is difficult, everything else is poorly specified

Naga shows GLSL -> SPIRV in just 1.5ms per shader.


naga: Architecture

naga-architecture


wgpu: Conclusion

  • most mature, portable, well specified
  • pretty fast, and the only truly safe

vangers debug


blade

Lean and mean graphics API


blade: Motivation

  • it's not always worth it to provide the driver with all the info ahead of time.
  • lots of workflows are leaning to compute-only, e.g. 2D graphics rendering, ray tracing, neural networks.
  • most API complexity is from rasterization.
  • modern APIs are too verbose.

Screenshot 2024-10-28 222030


blade: Principles

  1. hacking graphics should be fun!
    - we can live without resource barriers
    - shader resource layouts can be simpler
    - uniforms are just data
  2. simplicity >> safety
    - no runtime validation
    - copyable handles

validation


blade: Look, ma, no bindings!

Shader:

var<storage,read_write> particles: array<Particle>;
var<uniform> parameters: Parameters;

Host:

pc.bind(0, &MainData {
    particles: particle_buffer.into(),
    parameters:  Parameters {
        my_uniform: [1,2,3,4],
    },
});
pc.dispatch([group_count, 1, 1]);

blade: Synchronization

if let mut pass = command_encoder.compute("fill-gbuf") {
    let mut pc = pass.with(&self.fill_pipeline);
    pc.bind(0, &FillData {...});
    pc.dispatch(groups);
}
// implicit barrier between passes
if let mut pass = command_encoder.compute("ray-trace") {
    let mut pc = pass.with(&self.main_pipeline);
    pc.bind(0, &MainData {...});
    pc.dispatch(groups);
}

blade-zed


blade: Performance

API translation and command recording:

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Rasterization:

GPU blade wgpu-hal
Ryzen 3500U 20K 20K
Ryzen 6850U 70K 70K
GeForce 3050 100K 100K

blade: GPU Penalty

@krOoze on Khronos forums:

Supplying GENERAL everywhere sure is state-of-the-art weapons-grade laziness…

Drivers:

Easy to mitigate by inserting transitions around render passes.


blade: conclusion

  • easy to use, hackable
  • very fast and portable

game


Thank you!
Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

torus

Select a repo