-- Compute shader example -- Demonstrates: shared memory, barriers, compute builtins, buffer bindings struct Params count: uint end uniform params: Params buffer data: [1024]float -- Workgroup-shared memory (visible to all threads in a workgroup) shared tile: [64]float @entry(compute) @workgroup_size(64, 1, 1) function main( @builtin(global_invocation_id) gid: uvec3, @builtin(local_invocation_index) lid: uint ) -- Load data into shared memory if gid.x < params.count then tile[lid] = data[gid.x] else tile[lid] = 0.0 end -- Synchronize all threads in the workgroup barrier() -- Write back (example: each thread reads neighbor's value) if gid.x < params.count then if lid > uint(0) then data[gid.x] = tile[lid] + tile[lid - uint(1)] else data[gid.x] = tile[lid] * 2.0 end end end