2023-09-18 18:11:07 +00:00
|
|
|
// language: metal1.0
|
2023-09-20 14:45:30 +00:00
|
|
|
#include <metal_stdlib>
|
|
|
|
#include <simd/simd.h>
|
|
|
|
|
|
|
|
using metal::uint;
|
|
|
|
|
2023-09-29 18:09:59 +00:00
|
|
|
constant uint TWO = 2u;
|
|
|
|
constant int THREE = 3;
|
2023-09-28 23:31:59 +00:00
|
|
|
constant int FOUR = 4;
|
2023-09-29 14:08:04 +00:00
|
|
|
constant int FOUR_ALIAS = 4;
|
|
|
|
constant int TEST_CONSTANT_ADDITION = 8;
|
|
|
|
constant int TEST_CONSTANT_ALIAS_ADDITION = 8;
|
2023-09-29 18:11:31 +00:00
|
|
|
constant float PI = 3.141;
|
|
|
|
constant float phi_sun = 6.282;
|
|
|
|
constant metal::float4 DIV = metal::float4(0.44444445, 0.0, 0.0, 0.0);
|
2023-09-29 18:12:14 +00:00
|
|
|
constant int TEXTURE_KIND_REGULAR = 0;
|
|
|
|
constant int TEXTURE_KIND_WARP = 1;
|
|
|
|
constant int TEXTURE_KIND_SKY = 2;
|
2023-09-20 14:45:30 +00:00
|
|
|
|
2023-09-20 23:01:00 +00:00
|
|
|
void swizzle_of_compose(
|
2023-09-20 14:45:30 +00:00
|
|
|
) {
|
2023-10-05 21:46:02 +00:00
|
|
|
metal::int4 out = metal::int4(4, 3, 2, 1);
|
2023-09-20 23:01:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void index_of_compose(
|
|
|
|
) {
|
2023-10-05 21:46:02 +00:00
|
|
|
int out_1 = 2;
|
2023-09-20 23:01:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void compose_three_deep(
|
|
|
|
) {
|
2023-10-05 21:46:02 +00:00
|
|
|
int out_2 = 6;
|
2023-09-20 23:01:00 +00:00
|
|
|
}
|
|
|
|
|
2023-09-20 23:01:00 +00:00
|
|
|
void non_constant_initializers(
|
|
|
|
) {
|
|
|
|
int w = 30;
|
|
|
|
int x = {};
|
|
|
|
int y = {};
|
|
|
|
int z = 70;
|
2023-10-05 21:46:02 +00:00
|
|
|
metal::int4 out_3 = {};
|
2023-09-20 23:01:00 +00:00
|
|
|
int _e2 = w;
|
|
|
|
x = _e2;
|
|
|
|
int _e4 = x;
|
|
|
|
y = _e4;
|
2023-10-05 21:46:02 +00:00
|
|
|
int _e8 = w;
|
|
|
|
int _e9 = x;
|
|
|
|
int _e10 = y;
|
|
|
|
int _e11 = z;
|
|
|
|
out_3 = metal::int4(_e8, _e9, _e10, _e11);
|
2023-09-20 23:01:00 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-09-28 23:31:59 +00:00
|
|
|
void splat_of_constant(
|
|
|
|
) {
|
2023-10-05 21:46:02 +00:00
|
|
|
metal::int4 out_4 = metal::int4(-4, -4, -4, -4);
|
2023-09-28 23:31:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void compose_of_constant(
|
|
|
|
) {
|
2023-10-05 21:46:02 +00:00
|
|
|
metal::int4 out_5 = metal::int4(-4, -4, -4, -4);
|
2023-09-28 23:31:59 +00:00
|
|
|
}
|
|
|
|
|
2023-09-29 18:12:14 +00:00
|
|
|
uint map_texture_kind(
|
|
|
|
int texture_kind
|
|
|
|
) {
|
|
|
|
switch(texture_kind) {
|
|
|
|
case 0: {
|
|
|
|
return 10u;
|
|
|
|
}
|
|
|
|
case 1: {
|
|
|
|
return 20u;
|
|
|
|
}
|
|
|
|
case 2: {
|
|
|
|
return 30u;
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
return 0u;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-09-20 23:01:00 +00:00
|
|
|
kernel void main_(
|
|
|
|
) {
|
2023-10-05 21:46:02 +00:00
|
|
|
swizzle_of_compose();
|
|
|
|
index_of_compose();
|
|
|
|
compose_three_deep();
|
|
|
|
non_constant_initializers();
|
|
|
|
splat_of_constant();
|
|
|
|
compose_of_constant();
|
2023-09-20 14:45:30 +00:00
|
|
|
return;
|
|
|
|
}
|