Files
wgpu/tests/out/msl/collatz.msl
T
6035b07b78 [wgsl-in] Implement module-level scoping.
Fixes #1745: Support out-of-order module scope declarations in WGSL
Fixes #1044: Forbid local variable shadowing in WGSL
Fixes #2076: [wgsl-in] no error for duplicated type definition
Fixes #2071: Global item does not support 'const'
Fixes #2105: [wgsl-in] Type aliases for a vecN<T> doesn't work when constructing vec from a single argument
Fixes #1775: Referencing a function without a return type yields an unknown identifier error.
Fixes #2089: Error span reported on the declaration of a variable instead of its use
Fixes #1996: [wgsl-in] Confusing error: "expected unsigned/signed integer literal, found '1'"

Separate parsing from lowering by generating an AST, which desugars as
much as possible down to something like Naga IR. The AST is then used
to resolve identifiers while lowering to Naga IR.

Co-authored-by: Teodor Tanasoaia <28601907+teoxoy@users.noreply.github.com>
Co-authored-by: Jim Blandy <jimb@red-bean.com>
2023-01-12 09:37:08 -08:00

58 lines
1.1 KiB
Plaintext

// language: metal2.0
#include <metal_stdlib>
#include <simd/simd.h>
using metal::uint;
struct _mslBufferSizes {
uint size0;
};
typedef uint type_1[1];
struct PrimeIndices {
type_1 data;
};
uint collatz_iterations(
uint n_base
) {
uint n = {};
uint i = {};
n = n_base;
i = 0u;
while(true) {
uint _e4 = n;
if (_e4 > 1u) {
} else {
break;
}
{
uint _e7 = n;
if ((_e7 % 2u) == 0u) {
uint _e12 = n;
n = _e12 / 2u;
} else {
uint _e16 = n;
n = (3u * _e16) + 1u;
}
uint _e20 = i;
i = _e20 + 1u;
}
}
uint _e23 = i;
return _e23;
}
struct main_Input {
};
kernel void main_(
metal::uint3 global_id [[thread_position_in_grid]]
, device PrimeIndices& v_indices [[user(fake0)]]
, constant _mslBufferSizes& _buffer_sizes [[user(fake0)]]
) {
uint _e9 = v_indices.data[global_id.x];
uint _e10 = collatz_iterations(_e9);
v_indices.data[global_id.x] = _e10;
return;
}