When working with compute shader in WGSL, how to loop till the length of the binded buffer?

318 Views Asked by At

On a compute shader, I want to use runtime buffer array length for the loop. However shading languages don't allow conditions that can be resolved only in runtime.

//runtime sized buffer
@group(0)
@binding(0)
var<storage, read_write> v_indices: array<u32>; 


fn some_function() {
    //this doesn't work
    for(var i = 0 ; i <= arrayLength(&v_indices);i=i+1){
    
    }
}

I think i can make fixed buffer size as that will solve this intermediate problem, but that will defeat the purpose of implementing BigInt in wgsl.

i tried fixed buffer size as that will solve this intermediate problem, but that will defeat the purpose of implementing BigInt in wgsl.

0

There are 0 best solutions below