Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Propagate precision qualifiers for constant declarations
Make Metal shaders use half/float types depending on precision
- Loading branch information
1 parent
6ce55b5
commit c7eae86
Showing
7 changed files
with
129 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#version 300 es | ||
#define gl_FragData _glesFragData | ||
layout(location = 0) out mediump vec4 _glesFragData[1]; | ||
|
||
struct v2f { | ||
highp vec4 pos; | ||
mediump vec2 uv; | ||
}; | ||
|
||
struct u2v { | ||
highp vec4 vertex; | ||
mediump vec2 texcoord; | ||
}; | ||
|
||
const mediump vec3[3] ha = vec3[3]( vec3( 1.0, 2.0, 3.0), vec3( 4.0, 5.0, 6.0), vec3( 7.0, 8.0, 9.0)); | ||
const highp vec3[3] fa = vec3[3]( vec3( 11.0, 12.0, 13.0), vec3( 14.0, 15.0, 16.0), vec3( 17.0, 18.0, 19.0)); | ||
|
||
mediump vec4 frag( in v2f i ) { | ||
mediump vec3 h = vec3( 0.0); | ||
highp vec3 f = vec3( 0.0); | ||
highp vec3 p = vec3( i.uv.xy, 1.0); | ||
highp int j = 0; | ||
for ( ; (j < int((i.uv.x * 3.0))); (j++)) { | ||
h += ha[j]; | ||
f += fa[j]; | ||
f += (p * ha[0]); | ||
} | ||
return vec4( h.xy, f.xy); | ||
} | ||
|
||
in mediump vec2 xlv_TEXCOORD0; | ||
void main() { | ||
mediump vec4 xl_retval; | ||
v2f xlt_i; | ||
xlt_i.pos = vec4(0.0); | ||
xlt_i.uv = vec2(xlv_TEXCOORD0); | ||
xl_retval = frag( xlt_i); | ||
gl_FragData[0] = vec4(xl_retval); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#version 300 es | ||
layout(location=0) out mediump vec4 _glesFragData[1]; | ||
in mediump vec2 xlv_TEXCOORD0; | ||
void main () | ||
{ | ||
mediump vec4 tmpvar_1; | ||
mediump vec2 tmpvar_2; | ||
tmpvar_2 = xlv_TEXCOORD0; | ||
highp vec3 p_4; | ||
highp vec3 f_5; | ||
mediump vec3 h_6; | ||
h_6 = vec3(0.0, 0.0, 0.0); | ||
f_5 = vec3(0.0, 0.0, 0.0); | ||
mediump vec3 tmpvar_7; | ||
tmpvar_7.z = 1.0; | ||
tmpvar_7.xy = xlv_TEXCOORD0; | ||
p_4 = tmpvar_7; | ||
for (highp int j_3 = 0; j_3 < int((tmpvar_2.x * 3.0)); j_3++) { | ||
h_6 = (h_6 + vec3[3](vec3(1.0, 2.0, 3.0), vec3(4.0, 5.0, 6.0), vec3(7.0, 8.0, 9.0))[j_3]); | ||
f_5 = (f_5 + vec3[3](vec3(11.0, 12.0, 13.0), vec3(14.0, 15.0, 16.0), vec3(17.0, 18.0, 19.0))[j_3]); | ||
f_5 = (f_5 + (p_4 * vec3(1.0, 2.0, 3.0))); | ||
}; | ||
highp vec4 tmpvar_8; | ||
tmpvar_8.xy = h_6.xy; | ||
tmpvar_8.zw = f_5.xy; | ||
tmpvar_1 = tmpvar_8; | ||
_glesFragData[0] = tmpvar_1; | ||
} | ||
|
||
|
||
// stats: 12 alu 0 tex 2 flow | ||
// inputs: 1 | ||
// #0: xlv_TEXCOORD0 (medium float) 2x1 [-1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#include <metal_stdlib> | ||
#pragma clang diagnostic ignored "-Wparentheses-equality" | ||
using namespace metal; | ||
constant half3 _xlat_mtl_const1[3] = {float3(1.0, 2.0, 3.0), float3(4.0, 5.0, 6.0), float3(7.0, 8.0, 9.0)}; | ||
constant float3 _xlat_mtl_const2[3] = {float3(11.0, 12.0, 13.0), float3(14.0, 15.0, 16.0), float3(17.0, 18.0, 19.0)}; | ||
struct xlatMtlShaderInput { | ||
half2 xlv_TEXCOORD0; | ||
}; | ||
struct xlatMtlShaderOutput { | ||
half4 _glesFragData_0 [[color(0)]]; | ||
}; | ||
struct xlatMtlShaderUniform { | ||
}; | ||
fragment xlatMtlShaderOutput xlatMtlMain (xlatMtlShaderInput _mtl_i [[stage_in]], constant xlatMtlShaderUniform& _mtl_u [[buffer(0)]]) | ||
{ | ||
xlatMtlShaderOutput _mtl_o; | ||
half4 tmpvar_1; | ||
half2 tmpvar_2; | ||
tmpvar_2 = _mtl_i.xlv_TEXCOORD0; | ||
float3 p_4; | ||
float3 f_5; | ||
half3 h_6; | ||
h_6 = half3(float3(0.0, 0.0, 0.0)); | ||
f_5 = float3(0.0, 0.0, 0.0); | ||
half3 tmpvar_7; | ||
tmpvar_7.z = half(1.0); | ||
tmpvar_7.xy = _mtl_i.xlv_TEXCOORD0; | ||
p_4 = float3(tmpvar_7); | ||
for (int j_3 = 0; j_3 < short((tmpvar_2.x * (half)3.0)); j_3++) { | ||
h_6 = (h_6 + _xlat_mtl_const1[j_3]); | ||
f_5 = (f_5 + _xlat_mtl_const2[j_3]); | ||
f_5 = (f_5 + (p_4 * float3(1.0, 2.0, 3.0))); | ||
}; | ||
float4 tmpvar_8; | ||
tmpvar_8.xy = float2(h_6.xy); | ||
tmpvar_8.zw = f_5.xy; | ||
tmpvar_1 = half4(tmpvar_8); | ||
_mtl_o._glesFragData_0 = tmpvar_1; | ||
return _mtl_o; | ||
} | ||
|
||
|
||
// stats: 12 alu 0 tex 2 flow | ||
// inputs: 1 | ||
// #0: xlv_TEXCOORD0 (medium float) 2x1 [-1] |