0

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.

  • What is the issue you see when you try to use the shader. I believe you just need to wrap the `arrayLength` in an `i32(arrayLength(&v_indices))` as the type of `i` is `i32` and the result of `arrayLength` is `u32`. – dj2 Aug 11 '23 at 21:13

0 Answers0