Ben Clayton | f2ec7f3 | 2021-06-29 11:53:15 +0000 | [diff] [blame] | 1 | #include <metal_stdlib> |
Ben Clayton | 6a77236 | 2021-06-18 18:56:13 +0000 | [diff] [blame] | 2 | |
Ben Clayton | f2ec7f3 | 2021-06-29 11:53:15 +0000 | [diff] [blame] | 3 | using namespace metal; |
Ben Clayton | 6a77236 | 2021-06-18 18:56:13 +0000 | [diff] [blame] | 4 | struct SB_RW { |
Ben Clayton | f2ec7f3 | 2021-06-29 11:53:15 +0000 | [diff] [blame] | 5 | /* 0x0000 */ atomic_int arg_0; |
Ben Clayton | 0a32a72 | 2021-06-18 18:56:13 +0000 | [diff] [blame] | 6 | }; |
| 7 | |
Ben Clayton | f2ec7f3 | 2021-06-29 11:53:15 +0000 | [diff] [blame] | 8 | void atomicOr_8d96a0(device SB_RW& sb_rw) { |
| 9 | int res = atomic_fetch_or_explicit(&(sb_rw.arg_0), 1, memory_order_relaxed); |
Ben Clayton | 0a32a72 | 2021-06-18 18:56:13 +0000 | [diff] [blame] | 10 | } |
| 11 | |
Ben Clayton | f2ec7f3 | 2021-06-29 11:53:15 +0000 | [diff] [blame] | 12 | fragment void fragment_main(device SB_RW& sb_rw [[buffer(0)]]) { |
| 13 | atomicOr_8d96a0(sb_rw); |
| 14 | return; |
Ben Clayton | 0a32a72 | 2021-06-18 18:56:13 +0000 | [diff] [blame] | 15 | } |
| 16 | |
Ben Clayton | f2ec7f3 | 2021-06-29 11:53:15 +0000 | [diff] [blame] | 17 | kernel void compute_main(device SB_RW& sb_rw [[buffer(0)]]) { |
| 18 | atomicOr_8d96a0(sb_rw); |
| 19 | return; |
Ben Clayton | 0a32a72 | 2021-06-18 18:56:13 +0000 | [diff] [blame] | 20 | } |
| 21 | |