Peng Huang | c00ff7f | 2023-03-31 17:55:19 +0000 | [diff] [blame] | 1 | RWByteAddressBuffer sb_rw : register(u0); |
Antonio Maiorano | 08f4b55 | 2022-05-31 13:20:28 +0000 | [diff] [blame] | 2 | |
Ben Clayton | 1a1b527 | 2023-02-24 17:16:55 +0000 | [diff] [blame] | 3 | int sb_rwatomicSub(uint offset, int value) { |
James Price | f9d1971 | 2021-08-26 15:26:25 +0000 | [diff] [blame] | 4 | int original_value = 0; |
Ben Clayton | 1a1b527 | 2023-02-24 17:16:55 +0000 | [diff] [blame] | 5 | sb_rw.InterlockedAdd(offset, -value, original_value); |
James Price | f9d1971 | 2021-08-26 15:26:25 +0000 | [diff] [blame] | 6 | return original_value; |
| 7 | } |
| 8 | |
James Price | f9d1971 | 2021-08-26 15:26:25 +0000 | [diff] [blame] | 9 | |
Ben Clayton | 77a90cb | 2023-03-06 18:25:08 +0000 | [diff] [blame] | 10 | RWByteAddressBuffer prevent_dce : register(u0, space2); |
| 11 | |
James Price | f9d1971 | 2021-08-26 15:26:25 +0000 | [diff] [blame] | 12 | void atomicSub_051100() { |
Ben Clayton | 1a1b527 | 2023-02-24 17:16:55 +0000 | [diff] [blame] | 13 | int res = sb_rwatomicSub(0u, 1); |
Ben Clayton | 77a90cb | 2023-03-06 18:25:08 +0000 | [diff] [blame] | 14 | prevent_dce.Store(0u, asuint(res)); |
James Price | f9d1971 | 2021-08-26 15:26:25 +0000 | [diff] [blame] | 15 | } |
| 16 | |
| 17 | void fragment_main() { |
| 18 | atomicSub_051100(); |
| 19 | return; |
| 20 | } |
| 21 | |
| 22 | [numthreads(1, 1, 1)] |
| 23 | void compute_main() { |
| 24 | atomicSub_051100(); |
| 25 | return; |
| 26 | } |