bgfx/3rdparty/glsl-optimizer/tests/vertex/loops-for-withvec4inductorW-outES3Metal.txt
2015-04-02 23:30:48 -07:00

97 lines
5.1 KiB
Text

#include <metal_stdlib>
using namespace metal;
struct xlatMtlShaderInput {
float4 in_POSITION0 [[attribute(0)]];
float4 in_NORMAL0 [[attribute(1)]];
float4 in_TEXCOORD0 [[attribute(2)]];
};
struct xlatMtlShaderOutput {
float4 gl_Position [[position]];
float4 TEXCOORD0;
float4 COLOR0;
};
struct xlatMtlShaderUniform {
float4 unity_LightColor[8];
float4 unity_LightPosition[8];
float4 unity_LightAtten[8];
float4 unity_SpotDirection[8];
float4x4 glstate_matrix_mvp;
float4x4 glstate_matrix_modelview0;
float4x4 glstate_matrix_invtrans_modelview0;
float4 glstate_lightmodel_ambient;
float4 _MainTex_ST;
float4 _Color;
float4 _ReflectColor;
};
;
vertex xlatMtlShaderOutput xlatMtlMain (xlatMtlShaderInput _mtl_i [[stage_in]], constant xlatMtlShaderUniform& _mtl_u [[buffer(0)]])
{
xlatMtlShaderOutput _mtl_o;
float4 phase0_Output2_1;
float4 Temp_2_2;
float4 Temp_3_3;
int4 Temp_int_0_4;
int4 Temp_int_1_5;
Temp_int_0_4 = as_type<int4>((_mtl_i.in_POSITION0.yyyy * _mtl_u.glstate_matrix_mvp[1]));
Temp_int_0_4 = as_type<int4>(((_mtl_u.glstate_matrix_mvp[0] * _mtl_i.in_POSITION0.xxxx) + as_type<float4>(Temp_int_0_4)));
Temp_int_0_4 = as_type<int4>(((_mtl_u.glstate_matrix_mvp[2] * _mtl_i.in_POSITION0.zzzz) + as_type<float4>(Temp_int_0_4)));
phase0_Output2_1 = ((_mtl_u.glstate_matrix_mvp[3] * _mtl_i.in_POSITION0.wwww) + as_type<float4>(Temp_int_0_4));
_mtl_o.TEXCOORD0.xy = ((_mtl_i.in_TEXCOORD0.xy * _mtl_u._MainTex_ST.xy) + _mtl_u._MainTex_ST.zw);
Temp_int_0_4.xyz = as_type<int3>((_mtl_i.in_POSITION0.yyy * _mtl_u.glstate_matrix_modelview0[1].xyz));
Temp_int_0_4.xyz = as_type<int3>(((_mtl_u.glstate_matrix_modelview0[0].xyz * _mtl_i.in_POSITION0.xxx) + as_type<float4>(Temp_int_0_4).xyz));
Temp_int_0_4.xyz = as_type<int3>(((_mtl_u.glstate_matrix_modelview0[2].xyz * _mtl_i.in_POSITION0.zzz) + as_type<float4>(Temp_int_0_4).xyz));
Temp_int_0_4.xyz = as_type<int3>(((_mtl_u.glstate_matrix_modelview0[3].xyz * _mtl_i.in_POSITION0.www) + as_type<float4>(Temp_int_0_4).xyz));
Temp_int_1_5.xyz = as_type<int3>((_mtl_i.in_NORMAL0.yyy * _mtl_u.glstate_matrix_invtrans_modelview0[1].xyz));
Temp_int_1_5.xyz = as_type<int3>(((_mtl_u.glstate_matrix_invtrans_modelview0[0].xyz * _mtl_i.in_NORMAL0.xxx) + as_type<float4>(Temp_int_1_5).xyz));
Temp_int_1_5.xyz = as_type<int3>(((_mtl_u.glstate_matrix_invtrans_modelview0[2].xyz * _mtl_i.in_NORMAL0.zzz) + as_type<float4>(Temp_int_1_5).xyz));
Temp_int_0_4.w = as_type<int>(dot (as_type<float4>(Temp_int_1_5).xyz, as_type<float4>(Temp_int_1_5).xyz));
Temp_int_0_4.w = as_type<int>(rsqrt(as_type<float4>(Temp_int_0_4).w));
Temp_int_1_5.xyz = as_type<int3>((as_type<float4>(Temp_int_0_4).www * as_type<float4>(Temp_int_1_5).xyz));
Temp_2_2.xyz = _mtl_u.glstate_lightmodel_ambient.xyz;
Temp_int_0_4.w = 0;
for (; Temp_int_0_4.w < 4; Temp_int_0_4.w = (Temp_int_0_4.w + 1)) {
Temp_3_3.xyz = ((-(
as_type<float4>(Temp_int_0_4)
.xyz) * _mtl_u.unity_LightPosition[Temp_int_0_4.w].www) + _mtl_u.unity_LightPosition[Temp_int_0_4.w].xyz);
Temp_int_1_5.w = as_type<int>(dot (Temp_3_3.xyz, Temp_3_3.xyz));
Temp_2_2.w = rsqrt(as_type<float4>(Temp_int_1_5).w);
Temp_3_3.xyz = (Temp_2_2.www * Temp_3_3.xyz);
Temp_int_1_5.w = as_type<int>(((
as_type<float4>(Temp_int_1_5)
.w * _mtl_u.unity_LightAtten[Temp_int_0_4.w].z) + 1.0));
Temp_int_1_5.w = as_type<int>((1.0/(as_type<float4>(Temp_int_1_5).w)));
Temp_2_2.w = dot (Temp_3_3.xyz, _mtl_u.unity_SpotDirection[Temp_int_0_4.w].xyz);
Temp_2_2.w = max (Temp_2_2.w, 0.0);
Temp_2_2.w = (Temp_2_2.w - _mtl_u.unity_LightAtten[Temp_int_0_4.w].x);
Temp_2_2.w = (Temp_2_2.w * _mtl_u.unity_LightAtten[Temp_int_0_4.w].y);
Temp_2_2.w = clamp (Temp_2_2.w, 0.0, 1.0);
Temp_int_1_5.w = as_type<int>((as_type<float4>(Temp_int_1_5).w * Temp_2_2.w));
Temp_2_2.w = dot (as_type<float4>(Temp_int_1_5).xyz, Temp_3_3.xyz);
Temp_2_2.w = max (Temp_2_2.w, 0.0);
Temp_int_1_5.w = as_type<int>((as_type<float4>(Temp_int_1_5).w * Temp_2_2.w));
Temp_2_2.xyz = ((_mtl_u.unity_LightColor[Temp_int_0_4.w].xyz * as_type<float4>(Temp_int_1_5).www) + Temp_2_2.xyz);
};
_mtl_o.COLOR0.xyz = (Temp_2_2.xyz * _mtl_u._Color.xyz);
_mtl_o.COLOR0.w = (_mtl_u._Color.w * _mtl_u._ReflectColor.w);
_mtl_o.gl_Position = phase0_Output2_1;
return _mtl_o;
}
// stats: 88 alu 0 tex 2 flow
// inputs: 3
// #0: in_POSITION0 (high float) 4x1 [-1] loc 0
// #1: in_NORMAL0 (high float) 4x1 [-1] loc 1
// #2: in_TEXCOORD0 (high float) 4x1 [-1] loc 2
// uniforms: 11 (total size: 768)
// #0: unity_LightColor (high float) 4x1 [8] loc 0
// #1: unity_LightPosition (high float) 4x1 [8] loc 128
// #2: unity_LightAtten (high float) 4x1 [8] loc 256
// #3: unity_SpotDirection (high float) 4x1 [8] loc 384
// #4: glstate_matrix_mvp (high float) 4x4 [-1] loc 512
// #5: glstate_matrix_modelview0 (high float) 4x4 [-1] loc 576
// #6: glstate_matrix_invtrans_modelview0 (high float) 4x4 [-1] loc 640
// #7: glstate_lightmodel_ambient (high float) 4x1 [-1] loc 704
// #8: _MainTex_ST (high float) 4x1 [-1] loc 720
// #9: _Color (high float) 4x1 [-1] loc 736
// #10: _ReflectColor (high float) 4x1 [-1] loc 752