James Price | 085093d | 2024-06-06 02:09:47 +0000 | [diff] [blame] | 1 | #include <metal_stdlib> |
| 2 | using namespace metal; |
James Price | 48be7e8 | 2024-06-19 22:38:07 +0000 | [diff] [blame] | 3 | |
James Price | 085093d | 2024-06-06 02:09:47 +0000 | [diff] [blame] | 4 | struct tint_module_vars_struct { |
| 5 | device float* prevent_dce; |
| 6 | }; |
James Price | 48be7e8 | 2024-06-19 22:38:07 +0000 | [diff] [blame] | 7 | |
James Price | 2cc6b3c | 2024-06-13 20:31:41 +0000 | [diff] [blame] | 8 | struct VertexOutput { |
| 9 | float4 pos; |
| 10 | float prevent_dce; |
| 11 | }; |
James Price | 48be7e8 | 2024-06-19 22:38:07 +0000 | [diff] [blame] | 12 | |
James Price | 085093d | 2024-06-06 02:09:47 +0000 | [diff] [blame] | 13 | struct vertex_main_outputs { |
James Price | 2cc6b3c | 2024-06-13 20:31:41 +0000 | [diff] [blame] | 14 | float4 VertexOutput_pos [[position]]; |
| 15 | float VertexOutput_prevent_dce [[user(locn0)]] [[flat]]; |
James Price | 085093d | 2024-06-06 02:09:47 +0000 | [diff] [blame] | 16 | }; |
dan sinclair | f1f381a | 2023-11-22 09:44:15 +0000 | [diff] [blame] | 17 | |
James Price | 2cc6b3c | 2024-06-13 20:31:41 +0000 | [diff] [blame] | 18 | float fract_fa5c71() { |
James Price | 085093d | 2024-06-06 02:09:47 +0000 | [diff] [blame] | 19 | float res = 0.25f; |
James Price | 2cc6b3c | 2024-06-13 20:31:41 +0000 | [diff] [blame] | 20 | return res; |
dan sinclair | f1f381a | 2023-11-22 09:44:15 +0000 | [diff] [blame] | 21 | } |
James Price | 48be7e8 | 2024-06-19 22:38:07 +0000 | [diff] [blame] | 22 | |
James Price | 085093d | 2024-06-06 02:09:47 +0000 | [diff] [blame] | 23 | fragment void fragment_main(device float* prevent_dce [[buffer(0)]]) { |
| 24 | tint_module_vars_struct const tint_module_vars = tint_module_vars_struct{.prevent_dce=prevent_dce}; |
James Price | 2cc6b3c | 2024-06-13 20:31:41 +0000 | [diff] [blame] | 25 | (*tint_module_vars.prevent_dce) = fract_fa5c71(); |
dan sinclair | f1f381a | 2023-11-22 09:44:15 +0000 | [diff] [blame] | 26 | } |
James Price | 48be7e8 | 2024-06-19 22:38:07 +0000 | [diff] [blame] | 27 | |
James Price | 085093d | 2024-06-06 02:09:47 +0000 | [diff] [blame] | 28 | kernel void compute_main(device float* prevent_dce [[buffer(0)]]) { |
| 29 | tint_module_vars_struct const tint_module_vars = tint_module_vars_struct{.prevent_dce=prevent_dce}; |
James Price | 2cc6b3c | 2024-06-13 20:31:41 +0000 | [diff] [blame] | 30 | (*tint_module_vars.prevent_dce) = fract_fa5c71(); |
dan sinclair | f1f381a | 2023-11-22 09:44:15 +0000 | [diff] [blame] | 31 | } |
James Price | 48be7e8 | 2024-06-19 22:38:07 +0000 | [diff] [blame] | 32 | |
James Price | 2cc6b3c | 2024-06-13 20:31:41 +0000 | [diff] [blame] | 33 | VertexOutput vertex_main_inner() { |
| 34 | VertexOutput out = {}; |
| 35 | out.pos = float4(0.0f); |
| 36 | out.prevent_dce = fract_fa5c71(); |
| 37 | return out; |
| 38 | } |
James Price | 48be7e8 | 2024-06-19 22:38:07 +0000 | [diff] [blame] | 39 | |
James Price | 2cc6b3c | 2024-06-13 20:31:41 +0000 | [diff] [blame] | 40 | vertex vertex_main_outputs vertex_main() { |
| 41 | VertexOutput const v = vertex_main_inner(); |
| 42 | return vertex_main_outputs{.VertexOutput_pos=v.pos, .VertexOutput_prevent_dce=v.prevent_dce}; |
dan sinclair | f1f381a | 2023-11-22 09:44:15 +0000 | [diff] [blame] | 43 | } |