Edit this page

NA-MIC Project Weeks

Back to Projects List

SlicerWGPU

Key Investigators

Project Description

Explore the utility of using WebGPU from python in Slicer.

A working prototype already exists here: https://github.com/pieper/SlicerWGPU

Objective

  1. Bounce the idea off people as a sanity check
  2. Collect ideas for possible use cases
  3. See if anyone wants to try implementing something practical

Progress and Next Steps

Illustrations

image

Figure 1: Simple compute shader example that inverts the values of a volume.

@group(0) @binding(0)
var<storage,read> data1: array<i32>;
@group(0) @binding(1)
var<storage,read_write> data2: array<i32>;
@stage(compute)
@workgroup_size(1)
fn main(@builtin(global_invocation_id) index: vec3<u32>) {
    let i: u32 = index.x * @@SLICE_SIZE@@ + index.y * @@ROW_SIZE@@ + index.z;
    data2[i] = -1 * data1[i];
}

Figure 2: Example WGSL compute shader code.

image

Figure 3: Off-screen GPU render example.

Background and References

See the README for links and background.