mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
109 lines
4.0 KiB
Plaintext
109 lines
4.0 KiB
Plaintext
// language: metal2.0
|
|
#include <metal_stdlib>
|
|
#include <simd/simd.h>
|
|
|
|
using metal::uint;
|
|
|
|
struct _modf_result_f32_ {
|
|
float fract;
|
|
float whole;
|
|
};
|
|
struct _modf_result_vec2_f32_ {
|
|
metal::float2 fract;
|
|
metal::float2 whole;
|
|
};
|
|
struct _modf_result_vec4_f32_ {
|
|
metal::float4 fract;
|
|
metal::float4 whole;
|
|
};
|
|
struct _frexp_result_f32_ {
|
|
float fract;
|
|
int exp;
|
|
};
|
|
struct _frexp_result_vec4_f32_ {
|
|
metal::float4 fract;
|
|
metal::int4 exp;
|
|
};
|
|
|
|
_modf_result_f32_ naga_modf(float arg) {
|
|
float other;
|
|
float fract = metal::modf(arg, other);
|
|
return _modf_result_f32_{ fract, other };
|
|
}
|
|
|
|
_modf_result_vec2_f32_ naga_modf(metal::float2 arg) {
|
|
metal::float2 other;
|
|
metal::float2 fract = metal::modf(arg, other);
|
|
return _modf_result_vec2_f32_{ fract, other };
|
|
}
|
|
|
|
_modf_result_vec4_f32_ naga_modf(metal::float4 arg) {
|
|
metal::float4 other;
|
|
metal::float4 fract = metal::modf(arg, other);
|
|
return _modf_result_vec4_f32_{ fract, other };
|
|
}
|
|
|
|
_frexp_result_f32_ naga_frexp(float arg) {
|
|
int other;
|
|
float fract = metal::frexp(arg, other);
|
|
return _frexp_result_f32_{ fract, other };
|
|
}
|
|
|
|
_frexp_result_vec4_f32_ naga_frexp(metal::float4 arg) {
|
|
int4 other;
|
|
metal::float4 fract = metal::frexp(arg, other);
|
|
return _frexp_result_vec4_f32_{ fract, other };
|
|
}
|
|
|
|
fragment void main_(
|
|
) {
|
|
metal::float4 v = metal::float4(0.0);
|
|
float a = ((1.0) * 57.295779513082322865);
|
|
float b = ((1.0) * 0.017453292519943295474);
|
|
metal::float4 c = ((v) * 57.295779513082322865);
|
|
metal::float4 d = ((v) * 0.017453292519943295474);
|
|
metal::float4 e = metal::saturate(v);
|
|
metal::float4 g = metal::refract(v, v, 1.0);
|
|
int sign_a = metal::select(metal::select(-1, 1, (-1 > 0)), 0, (-1 == 0));
|
|
metal::int4 _e12 = metal::int4(-1);
|
|
metal::int4 sign_b = metal::select(metal::select(int4(-1), int4(1), (_e12 > 0)), 0, (_e12 == 0));
|
|
float sign_c = metal::sign(-1.0);
|
|
metal::float4 sign_d = metal::sign(metal::float4(-1.0));
|
|
int const_dot = ( + metal::int2 {}.x * metal::int2 {}.x + metal::int2 {}.y * metal::int2 {}.y);
|
|
uint _e23 = metal::abs(0u);
|
|
uint first_leading_bit_abs = metal::select(31 - metal::clz(_e23), uint(-1), _e23 == 0 || _e23 == -1);
|
|
int flb_a = metal::select(31 - metal::clz(metal::select(-1, ~-1, -1 < 0)), int(-1), -1 == 0 || -1 == -1);
|
|
metal::int2 _e28 = metal::int2(-1);
|
|
metal::int2 flb_b = metal::select(31 - metal::clz(metal::select(_e28, ~_e28, _e28 < 0)), int2(-1), _e28 == 0 || _e28 == -1);
|
|
metal::uint2 _e31 = metal::uint2(1u);
|
|
metal::uint2 flb_c = metal::select(31 - metal::clz(_e31), uint2(-1), _e31 == 0 || _e31 == -1);
|
|
int ftb_a = (((metal::ctz(-1) + 1) % 33) - 1);
|
|
uint ftb_b = (((metal::ctz(1u) + 1) % 33) - 1);
|
|
metal::int2 ftb_c = (((metal::ctz(metal::int2(-1)) + 1) % 33) - 1);
|
|
metal::uint2 ftb_d = (((metal::ctz(metal::uint2(1u)) + 1) % 33) - 1);
|
|
uint ctz_a = metal::ctz(0u);
|
|
int ctz_b = metal::ctz(0);
|
|
uint ctz_c = metal::ctz(4294967295u);
|
|
int ctz_d = metal::ctz(-1);
|
|
metal::uint2 ctz_e = metal::ctz(metal::uint2(0u));
|
|
metal::int2 ctz_f = metal::ctz(metal::int2(0));
|
|
metal::uint2 ctz_g = metal::ctz(metal::uint2(1u));
|
|
metal::int2 ctz_h = metal::ctz(metal::int2(1));
|
|
int clz_a = metal::clz(-1);
|
|
uint clz_b = metal::clz(1u);
|
|
metal::int2 clz_c = metal::clz(metal::int2(-1));
|
|
metal::uint2 clz_d = metal::clz(metal::uint2(1u));
|
|
float lde_a = metal::ldexp(1.0, 2);
|
|
metal::float2 lde_b = metal::ldexp(metal::float2(1.0, 2.0), metal::int2(3, 4));
|
|
_modf_result_f32_ modf_a = naga_modf(1.5);
|
|
float modf_b = naga_modf(1.5).fract;
|
|
float modf_c = naga_modf(1.5).whole;
|
|
_modf_result_vec2_f32_ modf_d = naga_modf(metal::float2(1.5, 1.5));
|
|
float modf_e = naga_modf(metal::float4(1.5, 1.5, 1.5, 1.5)).whole.x;
|
|
float modf_f = naga_modf(metal::float2(1.5, 1.5)).fract.y;
|
|
_frexp_result_f32_ frexp_a = naga_frexp(1.5);
|
|
float frexp_b = naga_frexp(1.5).fract;
|
|
int frexp_c = naga_frexp(1.5).exp;
|
|
int frexp_d = naga_frexp(metal::float4(1.5, 1.5, 1.5, 1.5)).exp.x;
|
|
}
|