blob: b712edf3fdffee2562fc70e87ce07ef14fb12d67 [file] [log] [blame]
Ben Claytonc0af5c52022-06-02 14:36:10 +00001#include <metal_stdlib>
2
3using namespace metal;
4uint tint_first_trailing_bit(uint v) {
5 uint x = uint(v);
6 uint const b16 = select(16u, 0u, bool((x & 65535u)));
7 x = (x >> b16);
8 uint const b8 = select(8u, 0u, bool((x & 255u)));
9 x = (x >> b8);
10 uint const b4 = select(4u, 0u, bool((x & 15u)));
11 x = (x >> b4);
12 uint const b2 = select(2u, 0u, bool((x & 3u)));
13 x = (x >> b2);
14 uint const b1 = select(1u, 0u, bool((x & 1u)));
15 uint const is_zero = select(0u, 4294967295u, (x == 0u));
16 return uint((((((b16 | b8) | b4) | b2) | b1) | is_zero));
17}
18
Natalie Chouinarde9027182024-06-13 18:50:19 +000019uint firstTrailingBit_47d475() {
Ben Claytonc0af5c52022-06-02 14:36:10 +000020 uint arg_0 = 1u;
21 uint res = tint_first_trailing_bit(arg_0);
Natalie Chouinarde9027182024-06-13 18:50:19 +000022 return res;
Ben Claytonc0af5c52022-06-02 14:36:10 +000023}
24
Natalie Chouinarde9027182024-06-13 18:50:19 +000025fragment void fragment_main(device uint* tint_symbol_1 [[buffer(0)]]) {
26 *(tint_symbol_1) = firstTrailingBit_47d475();
27 return;
28}
29
30kernel void compute_main(device uint* tint_symbol_2 [[buffer(0)]]) {
31 *(tint_symbol_2) = firstTrailingBit_47d475();
32 return;
33}
34
35struct VertexOutput {
36 float4 pos;
37 uint prevent_dce;
Ben Claytonc0af5c52022-06-02 14:36:10 +000038};
39
Natalie Chouinarde9027182024-06-13 18:50:19 +000040struct tint_symbol {
41 uint prevent_dce [[user(locn0)]] [[flat]];
42 float4 pos [[position]];
43};
44
45VertexOutput vertex_main_inner() {
46 VertexOutput out = {};
47 out.pos = float4(0.0f);
48 out.prevent_dce = firstTrailingBit_47d475();
49 return out;
Ben Claytonc0af5c52022-06-02 14:36:10 +000050}
51
Natalie Chouinarde9027182024-06-13 18:50:19 +000052vertex tint_symbol vertex_main() {
53 VertexOutput const inner_result = vertex_main_inner();
Ben Claytonc0af5c52022-06-02 14:36:10 +000054 tint_symbol wrapper_result = {};
Natalie Chouinarde9027182024-06-13 18:50:19 +000055 wrapper_result.pos = inner_result.pos;
56 wrapper_result.prevent_dce = inner_result.prevent_dce;
Ben Claytonc0af5c52022-06-02 14:36:10 +000057 return wrapper_result;
58}
59