Skip to content

feat: Add @typegpu/sort scaffolding with simple bitonic sort implementation #7151

feat: Add @typegpu/sort scaffolding with simple bitonic sort implementation

feat: Add @typegpu/sort scaffolding with simple bitonic sort implementation #7151

Triggered via pull request February 11, 2026 13:51
Status Failure
Total duration 3m 24s
Artifacts

ci.yml

on: pull_request
Fit to window
Zoom out
Zoom in

Annotations

2 errors
build-and-test
Process completed with exit code 1.
tests/examples/individual/bitonic-sort.test.ts > bitonic sort example > should produce valid code: packages/typegpu/tests/examples/individual/bitonic-sort.test.ts#L20
Error: Snapshot `bitonic sort example > should produce valid code 1` mismatched - Expected + Received @@ -1,70 +1,6 @@ - "struct fullScreenTriangle_Input { - @Builtin(vertex_index) vertexIndex: u32, - } - - struct fullScreenTriangle_Output { - @Builtin(position) pos: vec4f, - @location(0) uv: vec2f, - } - - @vertex fn fullScreenTriangle(in: fullScreenTriangle_Input) -> fullScreenTriangle_Output { - const pos = array<vec2f, 3>(vec2f(-1, -1), vec2f(3, -1), vec2f(-1, 3)); - const uv = array<vec2f, 3>(vec2f(0, 1), vec2f(2, 1), vec2f(0, -1)); - - return fullScreenTriangle_Output(vec4f(pos[in.vertexIndex], 0, 1), uv[in.vertexIndex]); - } - - @group(0) @binding(0) var<storage, read> data: array<u32>; - - struct fragmentFn_Input { - @location(0) uv: vec2f, - } - - @Fragment fn fragmentFn(input: fragmentFn_Input) -> @location(0) vec4f { - let arrayLength_1 = arrayLength(&data); - const maxValue = 255u; - let cols = u32(ceil(sqrt(f32(arrayLength_1)))); - let rows = u32(ceil((f32(arrayLength_1) / f32(cols)))); - let col = u32(floor((input.uv.x * f32(cols)))); - let row = u32(floor((input.uv.y * f32(rows)))); - let idx = ((row * cols) + col); - if ((idx >= arrayLength_1)) { - return vec4f(0.10000000149011612, 0.10000000149011612, 0.10000000149011612, 1); - } - let value = data[idx]; - let normalized = (f32(value) / f32(maxValue)); - return vec4f(normalized, normalized, normalized, 1f); - } - - struct copyParamsType { - srcLength: u32, - dstLength: u32, - paddingValue: u32, - } - - @group(0) @binding(2) var<uniform> params: copyParamsType; - - @group(0) @binding(1) var<storage, read_write> dst: array<u32>; - - @group(0) @binding(0) var<storage, read> src: array<u32>; - - struct copyPadKernel_Input { - @Builtin(global_invocation_id) gid: vec3u, - } - - @compute @workgroup_size(256) fn copyPadKernel(input: copyPadKernel_Input) { - let idx = input.gid.x; - let dstLength = params.dstLength; - let srcLength = params.srcLength; - if ((idx >= dstLength)) { - return; - } - dst[idx] = select(params.paddingValue, src[idx], (idx < srcLength)); - } - - struct sortUniformsType { + "struct sortUniformsType { k: u32, jShift: u32, } @group(0) @binding(1) var<uniform> uniforms: sortUniformsType; @@ -101,27 +37,42 @@ data[i] = right; data[ixj] = left; } } - struct copyParamsType { - srcLength: u32, - dstLength: u32, - paddingValue: u32, - } - - @group(0) @binding(2) var<uniform> params: copyParamsType; - - @group(0) @binding(1) var<storage, read_write> dst: array<u32>; + struct fullScreenTriangle_Input { + @Builtin(vertex_index) vertexIndex: u32, + } + + struct fullScreenTriangle_Output { + @Builtin(position) pos: vec4f, + @location(0) uv: vec2f, + } + + @vertex fn fullScreenTriangle(in: fullScreenTriangle_Input) -> fullScreenTriangle_Output { + const pos = array<vec2f, 3>(vec2f(-1, -1), vec2f(3, -1), vec2f(-1, 3)); + const uv = array<vec2f, 3>(vec2f(0, 1), vec2f(2, 1), vec2f(0, -1)); + + return fullScreenTriangle_Output(vec4f(pos[in.vertexIndex], 0, 1), uv[in.vertexIndex]); + } - @group(0) @binding(0) var<storage, read> src: array<u32>; + @group(0) @binding(0) var<storage, read> data: array<u32>; - struct copyBackKernel_Input { - @Builtin(global_invocation_id) gid: vec3u, + struct fragmentFn_Input { + @location(0) uv: vec2f, } - @compute @workgroup_size(256) fn copyBackKernel(input: copyBackKernel_Input) { - let idx = input.gid.x; + @Fragment fn fragmentFn(input: fragmentFn_Input) -> @location(0) vec4f { + let arrayLength_1 = arrayLength(&data); + const maxValue = 255u; + let cols = u32(ceil(sqrt(f32(arrayLength_1)))); + let rows = u32(ceil((f32(arrayLength_1) / f32(cols)))); + let col = u32(floor((input.uv.x * f32(cols)))); + let row = u32(floor((input.uv.y * f32(rows)))); + let idx = ((row * cols) + col); - if ((idx < params.srcLength)) { + if ((idx >= arrayLength_1)) { - dst[idx] = src[idx]; - } + return vec4f(0.10000000149011612, 0.10000000149011612, 0.10000000149011612, 1); + } + let val