Is there any way to pass a callback to a function in WGSL?

169 views Asked by At

I can't seem to figure out how or if it is acually possible to pass acallback to a function in WGSL. I would like to make something along these lines.

fn foo(x: f32, bar: ?callback?) {
    bar(x);
}


fn baz(y: f32) -> f32 {
    return y + 1;
}

@compute 
fn main() {
    foo(5, baz) // => 6
}

My intelisense hinted me

bar: Fn

but compiler doesn't like that.

1

There are 1 answers

1
dj2 On BEST ANSWER

WGSL does not have function pointers, so you can't pass a function as a parameter.