bgfx/3rdparty/glsl-optimizer/tests/fragment/z-fxaa-preset3-outES3Metal.txt

304 lines
10 KiB
Plaintext
Raw Normal View History

2014-10-11 23:32:43 +04:00
#include <metal_stdlib>
2016-03-05 21:48:54 +03:00
#pragma clang diagnostic ignored "-Wparentheses-equality"
2014-10-11 23:32:43 +04:00
using namespace metal;
struct xlatMtlShaderInput {
float2 xlv_TEXCOORD0;
};
struct xlatMtlShaderOutput {
half4 _fragData [[color(0)]];
};
struct xlatMtlShaderUniform {
float4 _MainTex_TexelSize;
};
fragment xlatMtlShaderOutput xlatMtlMain (xlatMtlShaderInput _mtl_i [[stage_in]], constant xlatMtlShaderUniform& _mtl_u [[buffer(0)]]
, texture2d<half> _MainTex [[texture(0)]], sampler _mtlsmp__MainTex [[sampler(0)]])
{
xlatMtlShaderOutput _mtl_o;
2016-09-22 07:01:52 +03:00
float2 rcpFrame_1 = 0;
2014-10-11 23:32:43 +04:00
rcpFrame_1 = _mtl_u._MainTex_TexelSize.xy;
2016-09-22 07:01:52 +03:00
half3 tmpvar_2 = 0;
bool doneP_4 = false;
bool doneN_5 = false;
half lumaEndP_6 = 0;
half lumaEndN_7 = 0;
float2 offNP_8 = 0;
float2 posP_9 = 0;
float2 posN_10 = 0;
half gradientN_11 = 0;
float lengthSign_12 = 0;
half3 rgbL_13 = 0;
half lumaS_14 = 0;
half lumaN_15 = 0;
float4 tmpvar_16 = 0;
2014-10-11 23:32:43 +04:00
tmpvar_16.zw = float2(0.0, 0.0);
tmpvar_16.xy = (_mtl_i.xlv_TEXCOORD0 + (float2(0.0, -1.0) * _mtl_u._MainTex_TexelSize.xy));
2016-09-22 07:01:52 +03:00
half4 tmpvar_17 = 0;
2014-10-11 23:32:43 +04:00
tmpvar_17 = _MainTex.sample(_mtlsmp__MainTex, (float2)(tmpvar_16.xy), level(0.0));
2016-09-22 07:01:52 +03:00
float4 tmpvar_18 = 0;
2014-10-11 23:32:43 +04:00
tmpvar_18.zw = float2(0.0, 0.0);
tmpvar_18.xy = (_mtl_i.xlv_TEXCOORD0 + (float2(-1.0, 0.0) * _mtl_u._MainTex_TexelSize.xy));
2016-09-22 07:01:52 +03:00
half4 tmpvar_19 = 0;
2014-10-11 23:32:43 +04:00
tmpvar_19 = _MainTex.sample(_mtlsmp__MainTex, (float2)(tmpvar_18.xy), level(0.0));
2016-09-22 07:01:52 +03:00
half4 tmpvar_20 = 0;
2014-10-11 23:32:43 +04:00
tmpvar_20 = _MainTex.sample(_mtlsmp__MainTex, (float2)(_mtl_i.xlv_TEXCOORD0), level(0.0));
2016-09-22 07:01:52 +03:00
float4 tmpvar_21 = 0;
2014-10-11 23:32:43 +04:00
tmpvar_21.zw = float2(0.0, 0.0);
tmpvar_21.xy = (_mtl_i.xlv_TEXCOORD0 + (float2(1.0, 0.0) * _mtl_u._MainTex_TexelSize.xy));
2016-09-22 07:01:52 +03:00
half4 tmpvar_22 = 0;
2014-10-11 23:32:43 +04:00
tmpvar_22 = _MainTex.sample(_mtlsmp__MainTex, (float2)(tmpvar_21.xy), level(0.0));
2016-09-22 07:01:52 +03:00
float4 tmpvar_23 = 0;
2014-10-11 23:32:43 +04:00
tmpvar_23.zw = float2(0.0, 0.0);
tmpvar_23.xy = (_mtl_i.xlv_TEXCOORD0 + (float2(0.0, 1.0) * _mtl_u._MainTex_TexelSize.xy));
2016-09-22 07:01:52 +03:00
half4 tmpvar_24 = 0;
2014-10-11 23:32:43 +04:00
tmpvar_24 = _MainTex.sample(_mtlsmp__MainTex, (float2)(tmpvar_23.xy), level(0.0));
2016-09-22 07:01:52 +03:00
half tmpvar_25 = 0;
tmpvar_25 = ((tmpvar_17.y * (half)(1.963211)) + tmpvar_17.x);
2014-10-11 23:32:43 +04:00
lumaN_15 = tmpvar_25;
2016-09-22 07:01:52 +03:00
half tmpvar_26 = 0;
tmpvar_26 = ((tmpvar_19.y * (half)(1.963211)) + tmpvar_19.x);
half tmpvar_27 = 0;
tmpvar_27 = ((tmpvar_20.y * (half)(1.963211)) + tmpvar_20.x);
half tmpvar_28 = 0;
tmpvar_28 = ((tmpvar_22.y * (half)(1.963211)) + tmpvar_22.x);
half tmpvar_29 = 0;
tmpvar_29 = ((tmpvar_24.y * (half)(1.963211)) + tmpvar_24.x);
2014-10-11 23:32:43 +04:00
lumaS_14 = tmpvar_29;
2016-09-22 07:01:52 +03:00
half tmpvar_30 = 0;
2014-10-11 23:32:43 +04:00
tmpvar_30 = max (max (tmpvar_27, tmpvar_25), max (max (tmpvar_26, tmpvar_29), tmpvar_28));
2016-09-22 07:01:52 +03:00
half tmpvar_31 = 0;
2014-10-11 23:32:43 +04:00
tmpvar_31 = (tmpvar_30 - min (min (tmpvar_27, tmpvar_25), min (
min (tmpvar_26, tmpvar_29)
, tmpvar_28)));
2016-09-22 07:01:52 +03:00
half tmpvar_32 = 0;
tmpvar_32 = max ((half)0.04166667, (tmpvar_30 * (half)(0.125)));
2014-10-11 23:32:43 +04:00
if ((tmpvar_31 < tmpvar_32)) {
tmpvar_2 = tmpvar_20.xyz;
} else {
2016-09-22 07:01:52 +03:00
half tmpvar_33 = 0;
2014-10-11 23:32:43 +04:00
tmpvar_33 = min ((half)0.75, (max ((half)0.0,
((abs((
2016-09-22 07:01:52 +03:00
(((tmpvar_25 + tmpvar_26) + (tmpvar_28 + tmpvar_29)) * (half)(0.25))
- tmpvar_27)) / tmpvar_31) - (half)(0.25))
) * (half)(1.333333)));
float4 tmpvar_34 = 0;
2014-10-11 23:32:43 +04:00
tmpvar_34.zw = float2(0.0, 0.0);
tmpvar_34.xy = (_mtl_i.xlv_TEXCOORD0 - _mtl_u._MainTex_TexelSize.xy);
2016-09-22 07:01:52 +03:00
half4 tmpvar_35 = 0;
2014-10-11 23:32:43 +04:00
tmpvar_35 = _MainTex.sample(_mtlsmp__MainTex, (float2)(tmpvar_34.xy), level(0.0));
2016-09-22 07:01:52 +03:00
float4 tmpvar_36 = 0;
2014-10-11 23:32:43 +04:00
tmpvar_36.zw = float2(0.0, 0.0);
tmpvar_36.xy = (_mtl_i.xlv_TEXCOORD0 + (float2(1.0, -1.0) * _mtl_u._MainTex_TexelSize.xy));
2016-09-22 07:01:52 +03:00
half4 tmpvar_37 = 0;
2014-10-11 23:32:43 +04:00
tmpvar_37 = _MainTex.sample(_mtlsmp__MainTex, (float2)(tmpvar_36.xy), level(0.0));
2016-09-22 07:01:52 +03:00
float4 tmpvar_38 = 0;
2014-10-11 23:32:43 +04:00
tmpvar_38.zw = float2(0.0, 0.0);
tmpvar_38.xy = (_mtl_i.xlv_TEXCOORD0 + (float2(-1.0, 1.0) * _mtl_u._MainTex_TexelSize.xy));
2016-09-22 07:01:52 +03:00
half4 tmpvar_39 = 0;
2014-10-11 23:32:43 +04:00
tmpvar_39 = _MainTex.sample(_mtlsmp__MainTex, (float2)(tmpvar_38.xy), level(0.0));
2016-09-22 07:01:52 +03:00
float4 tmpvar_40 = 0;
2014-10-11 23:32:43 +04:00
tmpvar_40.zw = float2(0.0, 0.0);
tmpvar_40.xy = (_mtl_i.xlv_TEXCOORD0 + _mtl_u._MainTex_TexelSize.xy);
2016-09-22 07:01:52 +03:00
half4 tmpvar_41 = 0;
2014-10-11 23:32:43 +04:00
tmpvar_41 = _MainTex.sample(_mtlsmp__MainTex, (float2)(tmpvar_40.xy), level(0.0));
rgbL_13 = (((tmpvar_17.xyz + tmpvar_19.xyz) + (tmpvar_20.xyz + tmpvar_22.xyz)) + ((tmpvar_24.xyz + tmpvar_35.xyz) + (
(tmpvar_37.xyz + tmpvar_39.xyz)
+ tmpvar_41.xyz)));
2016-09-22 07:01:52 +03:00
rgbL_13 = (rgbL_13 * (half3)(float3(0.1111111, 0.1111111, 0.1111111)));
half tmpvar_42 = 0;
tmpvar_42 = ((tmpvar_35.y * (half)(1.963211)) + tmpvar_35.x);
half tmpvar_43 = 0;
tmpvar_43 = ((tmpvar_37.y * (half)(1.963211)) + tmpvar_37.x);
half tmpvar_44 = 0;
tmpvar_44 = ((tmpvar_39.y * (half)(1.963211)) + tmpvar_39.x);
half tmpvar_45 = 0;
tmpvar_45 = ((tmpvar_41.y * (half)(1.963211)) + tmpvar_41.x);
bool tmpvar_46 = false;
2014-10-11 23:32:43 +04:00
tmpvar_46 = (((
2016-09-22 07:01:52 +03:00
abs(((((half)(0.25) * tmpvar_42) + ((half)(-0.5) * tmpvar_26)) + ((half)(0.25) * tmpvar_44)))
2014-10-11 23:32:43 +04:00
+
2016-09-22 07:01:52 +03:00
abs(((((half)(0.5) * tmpvar_25) - tmpvar_27) + ((half)(0.5) * tmpvar_29)))
2014-10-11 23:32:43 +04:00
) + abs(
2016-09-22 07:01:52 +03:00
((((half)(0.25) * tmpvar_43) + ((half)(-0.5) * tmpvar_28)) + ((half)(0.25) * tmpvar_45))
2014-10-11 23:32:43 +04:00
)) >= ((
2016-09-22 07:01:52 +03:00
abs(((((half)(0.25) * tmpvar_42) + ((half)(-0.5) * tmpvar_25)) + ((half)(0.25) * tmpvar_43)))
2014-10-11 23:32:43 +04:00
+
2016-09-22 07:01:52 +03:00
abs(((((half)(0.5) * tmpvar_26) - tmpvar_27) + ((half)(0.5) * tmpvar_28)))
2014-10-11 23:32:43 +04:00
) + abs(
2016-09-22 07:01:52 +03:00
((((half)(0.25) * tmpvar_44) + ((half)(-0.5) * tmpvar_29)) + ((half)(0.25) * tmpvar_45))
2014-10-11 23:32:43 +04:00
)));
2016-09-22 07:01:52 +03:00
float tmpvar_47 = 0;
2014-10-11 23:32:43 +04:00
if (tmpvar_46) {
tmpvar_47 = -(_mtl_u._MainTex_TexelSize.y);
} else {
tmpvar_47 = -(_mtl_u._MainTex_TexelSize.x);
};
lengthSign_12 = tmpvar_47;
if (!(tmpvar_46)) {
lumaN_15 = tmpvar_26;
};
if (!(tmpvar_46)) {
lumaS_14 = tmpvar_28;
};
2016-09-22 07:01:52 +03:00
half tmpvar_48 = 0;
2014-10-11 23:32:43 +04:00
tmpvar_48 = abs((lumaN_15 - tmpvar_27));
gradientN_11 = tmpvar_48;
2016-09-22 07:01:52 +03:00
half tmpvar_49 = 0;
2014-10-11 23:32:43 +04:00
tmpvar_49 = abs((lumaS_14 - tmpvar_27));
2016-09-22 07:01:52 +03:00
lumaN_15 = ((lumaN_15 + tmpvar_27) * (half)(0.5));
lumaS_14 = ((lumaS_14 + tmpvar_27) * (half)(0.5));
bool tmpvar_50 = false;
2014-10-11 23:32:43 +04:00
tmpvar_50 = (tmpvar_48 >= tmpvar_49);
if (!(tmpvar_50)) {
lumaN_15 = lumaS_14;
};
if (!(tmpvar_50)) {
gradientN_11 = tmpvar_49;
};
if (!(tmpvar_50)) {
lengthSign_12 = -(tmpvar_47);
};
2016-09-22 07:01:52 +03:00
float tmpvar_51 = 0;
2014-10-11 23:32:43 +04:00
if (tmpvar_46) {
tmpvar_51 = 0.0;
} else {
tmpvar_51 = (lengthSign_12 * 0.5);
};
posN_10.x = (_mtl_i.xlv_TEXCOORD0.x + tmpvar_51);
2016-09-22 07:01:52 +03:00
float tmpvar_52 = 0;
2014-10-11 23:32:43 +04:00
if (tmpvar_46) {
tmpvar_52 = (lengthSign_12 * 0.5);
} else {
tmpvar_52 = 0.0;
};
posN_10.y = (_mtl_i.xlv_TEXCOORD0.y + tmpvar_52);
2016-09-22 07:01:52 +03:00
gradientN_11 = (gradientN_11 * (half)(0.25));
2014-10-11 23:32:43 +04:00
posP_9 = posN_10;
2016-09-22 07:01:52 +03:00
float2 tmpvar_53 = 0;
2014-10-11 23:32:43 +04:00
if (tmpvar_46) {
2016-09-22 07:01:52 +03:00
float2 tmpvar_54 = 0;
2014-10-11 23:32:43 +04:00
tmpvar_54.y = 0.0;
tmpvar_54.x = rcpFrame_1.x;
tmpvar_53 = tmpvar_54;
} else {
2016-09-22 07:01:52 +03:00
float2 tmpvar_55 = 0;
2014-10-11 23:32:43 +04:00
tmpvar_55.x = 0.0;
tmpvar_55.y = rcpFrame_1.y;
tmpvar_53 = tmpvar_55;
};
offNP_8 = tmpvar_53;
lumaEndN_7 = lumaN_15;
lumaEndP_6 = lumaN_15;
doneN_5 = bool(bool(0));
doneP_4 = bool(bool(0));
posN_10 = (posN_10 - tmpvar_53);
posP_9 = (posP_9 + tmpvar_53);
for (int i_3 = 0; i_3 < 16; i_3++) {
if (!(doneN_5)) {
2016-09-22 07:01:52 +03:00
half4 tmpvar_56 = 0;
2014-10-11 23:32:43 +04:00
tmpvar_56 = _MainTex.sample(_mtlsmp__MainTex, (float2)(posN_10), level(0.0));
2016-09-22 07:01:52 +03:00
lumaEndN_7 = ((tmpvar_56.y * (half)(1.963211)) + tmpvar_56.x);
2014-10-11 23:32:43 +04:00
};
if (!(doneP_4)) {
2016-09-22 07:01:52 +03:00
half4 tmpvar_57 = 0;
2014-10-11 23:32:43 +04:00
tmpvar_57 = _MainTex.sample(_mtlsmp__MainTex, (float2)(posP_9), level(0.0));
2016-09-22 07:01:52 +03:00
lumaEndP_6 = ((tmpvar_57.y * (half)(1.963211)) + tmpvar_57.x);
2014-10-11 23:32:43 +04:00
};
2016-09-22 07:01:52 +03:00
bool tmpvar_58 = false;
2014-10-11 23:32:43 +04:00
if (doneN_5) {
tmpvar_58 = bool(bool(1));
} else {
tmpvar_58 = (abs((lumaEndN_7 - lumaN_15)) >= gradientN_11);
};
doneN_5 = tmpvar_58;
2016-09-22 07:01:52 +03:00
bool tmpvar_59 = false;
2014-10-11 23:32:43 +04:00
if (doneP_4) {
tmpvar_59 = bool(bool(1));
} else {
tmpvar_59 = (abs((lumaEndP_6 - lumaN_15)) >= gradientN_11);
};
doneP_4 = tmpvar_59;
if ((tmpvar_58 && tmpvar_59)) {
break;
};
if (!(tmpvar_58)) {
posN_10 = (posN_10 - offNP_8);
};
if (!(tmpvar_59)) {
posP_9 = (posP_9 + offNP_8);
};
};
2016-09-22 07:01:52 +03:00
float tmpvar_60 = 0;
2014-10-11 23:32:43 +04:00
if (tmpvar_46) {
tmpvar_60 = (_mtl_i.xlv_TEXCOORD0.x - posN_10.x);
} else {
tmpvar_60 = (_mtl_i.xlv_TEXCOORD0.y - posN_10.y);
};
2016-09-22 07:01:52 +03:00
float tmpvar_61 = 0;
2014-10-11 23:32:43 +04:00
if (tmpvar_46) {
tmpvar_61 = (posP_9.x - _mtl_i.xlv_TEXCOORD0.x);
} else {
tmpvar_61 = (posP_9.y - _mtl_i.xlv_TEXCOORD0.y);
};
2016-09-22 07:01:52 +03:00
bool tmpvar_62 = false;
2014-10-11 23:32:43 +04:00
tmpvar_62 = (tmpvar_60 < tmpvar_61);
2016-09-22 07:01:52 +03:00
half tmpvar_63 = 0;
2014-10-11 23:32:43 +04:00
if (tmpvar_62) {
tmpvar_63 = lumaEndN_7;
} else {
tmpvar_63 = lumaEndP_6;
};
lumaEndN_7 = tmpvar_63;
2016-09-22 07:01:52 +03:00
if ((((tmpvar_27 - lumaN_15) < (half)(0.0)) == ((tmpvar_63 - lumaN_15) < (half)(0.0)))) {
2014-10-11 23:32:43 +04:00
lengthSign_12 = 0.0;
};
2016-09-22 07:01:52 +03:00
float tmpvar_64 = 0;
2014-10-11 23:32:43 +04:00
tmpvar_64 = (tmpvar_61 + tmpvar_60);
2016-09-22 07:01:52 +03:00
float tmpvar_65 = 0;
2014-10-11 23:32:43 +04:00
if (tmpvar_62) {
tmpvar_65 = tmpvar_60;
} else {
tmpvar_65 = tmpvar_61;
};
2016-09-22 07:01:52 +03:00
float tmpvar_66 = 0;
2014-10-11 23:32:43 +04:00
tmpvar_66 = ((0.5 + (tmpvar_65 *
(-1.0 / tmpvar_64)
)) * lengthSign_12);
2016-09-22 07:01:52 +03:00
float tmpvar_67 = 0;
2014-10-11 23:32:43 +04:00
if (tmpvar_46) {
tmpvar_67 = 0.0;
} else {
tmpvar_67 = tmpvar_66;
};
2016-09-22 07:01:52 +03:00
float tmpvar_68 = 0;
2014-10-11 23:32:43 +04:00
if (tmpvar_46) {
tmpvar_68 = tmpvar_66;
} else {
tmpvar_68 = 0.0;
};
2016-09-22 07:01:52 +03:00
float2 tmpvar_69 = 0;
2014-10-11 23:32:43 +04:00
tmpvar_69.x = (_mtl_i.xlv_TEXCOORD0.x + tmpvar_67);
tmpvar_69.y = (_mtl_i.xlv_TEXCOORD0.y + tmpvar_68);
2016-09-22 07:01:52 +03:00
half4 tmpvar_70 = 0;
2014-10-11 23:32:43 +04:00
tmpvar_70 = _MainTex.sample(_mtlsmp__MainTex, (float2)(tmpvar_69), level(0.0));
2016-09-22 07:01:52 +03:00
half3 tmpvar_71 = 0;
2014-10-11 23:32:43 +04:00
tmpvar_71.x = -(tmpvar_33);
tmpvar_71.y = -(tmpvar_33);
tmpvar_71.z = -(tmpvar_33);
tmpvar_2 = ((tmpvar_71 * tmpvar_70.xyz) + ((rgbL_13 * half3(tmpvar_33)) + tmpvar_70.xyz));
};
2016-09-22 07:01:52 +03:00
half4 tmpvar_72 = 0;
2014-10-11 23:32:43 +04:00
tmpvar_72.w = half(0.0);
tmpvar_72.xyz = tmpvar_2;
_mtl_o._fragData = tmpvar_72;
return _mtl_o;
}
// stats: 191 alu 12 tex 26 flow
// inputs: 1
// #0: xlv_TEXCOORD0 (high float) 2x1 [-1]
// uniforms: 1 (total size: 16)
// #0: _MainTex_TexelSize (high float) 4x1 [-1] loc 0
// textures: 1
// #0: _MainTex (low 2d) 0x0 [-1] loc 0