MSL test shader refactoring to avoid optimization crashes.

This commit is contained in:
Bill Hollings 2017-12-26 18:40:46 -05:00
Родитель a68b32733a
Коммит 95910ddd5a
59 изменённых файлов: 531 добавлений и 198 удалений

Просмотреть файл

@ -25,7 +25,7 @@ struct _10
_9 _m12;
};
constant _10 _51 = {};
constant float _57 = {};
struct main0_out
{
@ -35,7 +35,7 @@ struct main0_out
fragment main0_out main0()
{
main0_out out = {};
out.m_3 = float4(_51._m0, _51._m1, _51._m2, _51._m3);
out.m_3 = float4(_57);
return out;
}

Просмотреть файл

@ -5,10 +5,5 @@ using namespace metal;
fragment void main0()
{
int _16;
int _23;
for (int _22 = 35; _22 >= 0; _23 = _22 - 1, _22 = _23)
{
}
}

Просмотреть файл

@ -16,10 +16,8 @@ fragment main0_out main0()
main0_out out = {};
float4 _20;
float4 _21;
float4 _51;
float4 _52;
_51 = _50;
for (;;)
do
{
if (0.0 != 0.0)
{
@ -33,7 +31,7 @@ fragment main0_out main0()
}
_52 = _38;
break;
}
} while (false);
out._entryPointOutput = _52;
return out;
}

Просмотреть файл

@ -3,7 +3,15 @@
using namespace metal;
constant uint3 gl_WorkGroupSize = uint3(8u, 4u, 2u);
kernel void main0(uint3 gl_LocalInvocationID [[thread_position_in_threadgroup]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]], uint gl_LocalInvocationIndex [[thread_index_in_threadgroup]], uint3 gl_NumWorkGroups [[threadgroups_per_grid]], uint3 gl_WorkGroupID [[threadgroup_position_in_grid]])
{
uint3 local_id = gl_LocalInvocationID;
uint3 global_id = gl_GlobalInvocationID;
uint local_index = gl_LocalInvocationIndex;
uint3 work_group_size = gl_WorkGroupSize;
uint3 num_work_groups = gl_NumWorkGroups;
uint3 work_group_id = gl_WorkGroupID;
}

Просмотреть файл

@ -12,10 +12,12 @@ struct SSBO
kernel void main0(device SSBO& _13 [[buffer(0)]])
{
float4 _17 = _13.data;
_13.data = float4(_17.x, _17.yz + float2(10.0), _17.w);
float2 _27 = float2(10.0);
float2 _28 = _17.yz + _27;
_13.data = float4(_17.x, _28, _17.w);
_13.data = (_17 + _17) + _17;
_13.data = (_17.yz + float2(10.0)).xxyy;
_13.data = float4((_17.yz + float2(10.0)).y);
_13.data = float4((_17.zw + float2(10.0))[_13.index]);
_13.data = _28.xxyy;
_13.data = float4(_28.y);
_13.data = float4((_17.zw + _27)[_13.index]);
}

Просмотреть файл

@ -12,8 +12,6 @@ constant int _69 = {};
kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO2& _27 [[buffer(0)]])
{
int _29;
int _65;
if (gl_GlobalInvocationID.x == 2u)
{
_27.out_data[gl_GlobalInvocationID.x] = float4(20.0);
@ -26,7 +24,7 @@ kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], devic
return;
}
}
for (int _68 = 0; _68 < 20; _65 = _69 + 1, _68 = _65)
while (true)
{
return;
}

Просмотреть файл

@ -20,7 +20,6 @@ kernel void main0(device SSBO& _9 [[buffer(0)]])
_9.a ^= 10;
_9.a %= 40;
_9.a |= 1;
bool _65 = false && true;
_9.a = int(_65 && (true || _65));
_9.a = 0;
}

Просмотреть файл

@ -1,85 +0,0 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct SSBO
{
float4x4 mvp;
float4 in_data[1];
};
struct SSBO2
{
float4 out_data[1];
};
constant uint _98 = {};
kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO& _24 [[buffer(0)]], device SSBO2& _89 [[buffer(1)]])
{
float4 _30;
float4 _46;
int _33;
int _48;
int _40;
int _77;
uint _12;
uint _75;
float4 _71;
uint _73;
int _83;
_30 = _24.in_data[gl_GlobalInvocationID.x];
float4 _93;
int _94;
_93 = _30;
_94 = 0;
for (;;)
{
_40 = _94 + 1;
if (_40 < 10)
{
_46 = _93 * 2.0;
_48 = _40 + 1;
_93 = _46;
_94 = _48;
continue;
}
else
{
break;
}
}
float4 _95;
int _96;
_95 = _93;
_96 = _40;
float4 _100;
uint _101;
for (uint _97 = 0u, _99 = _98; _97 < 16u; _75 = _97 + uint(1), _77 = _96 + 1, _95 = _100, _96 = _77, _97 = _75, _99 = _101)
{
_100 = _95;
_101 = 0u;
for (; _101 < 30u; _73 = _101 + uint(1), _100 = _71, _101 = _73)
{
_71 = _24.mvp * _100;
}
}
int _102;
_102 = _96;
for (;;)
{
_83 = _102 + 1;
if (_83 > 10)
{
_102 = _83;
continue;
}
else
{
break;
}
}
_89.out_data[gl_GlobalInvocationID.x] = _95;
}

Просмотреть файл

@ -3,21 +3,11 @@
using namespace metal;
struct S0
{
float4 a;
};
struct S1
{
float4 a;
};
struct SSBO0
{
S0 s0s[1];
};
struct SSBO1
{
S1 s1s[1];
@ -28,8 +18,8 @@ struct SSBO2
float4 outputs[1];
};
kernel void main0(device SSBO0& _36 [[buffer(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO1& _55 [[buffer(1)]], device SSBO2& _66 [[buffer(2)]])
kernel void main0(device SSBO1& _36 [[buffer(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO1& _55 [[buffer(1)]], device SSBO2& _66 [[buffer(2)]])
{
_66.outputs[gl_GlobalInvocationID.x] = _36.s0s[gl_GlobalInvocationID.x].a + _55.s1s[gl_GlobalInvocationID.x].a;
_66.outputs[gl_GlobalInvocationID.x] = _36.s1s[gl_GlobalInvocationID.x].a + _55.s1s[gl_GlobalInvocationID.x].a;
}

Просмотреть файл

@ -3,18 +3,13 @@
using namespace metal;
struct SSBO2
{
uint outputs[1];
};
struct SSBO
{
uint inputs[1];
};
kernel void main0(device SSBO2& _10 [[buffer(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO& _23 [[buffer(1)]])
kernel void main0(device SSBO& _10 [[buffer(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO& _23 [[buffer(1)]])
{
_10.outputs[gl_GlobalInvocationID.x] = _23.inputs[gl_GlobalInvocationID.x] / 29u;
_10.inputs[gl_GlobalInvocationID.x] = _23.inputs[gl_GlobalInvocationID.x] / 29u;
}

Просмотреть файл

@ -1,26 +0,0 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct main0_in
{
float4 VertGeom [[user(locn0)]];
};
struct main0_out
{
float4 FragColor0 [[color(0)]];
float4 FragColor1 [[color(1)]];
};
fragment main0_out main0(main0_in in [[stage_in]], texture2d<float> TextureBase [[texture(0)]], sampler TextureBaseSmplr [[sampler(0)]], texture2d<float> TextureDetail [[texture(1)]], sampler TextureDetailSmplr [[sampler(1)]])
{
main0_out out = {};
float4 _20 = TextureBase.sample(TextureBaseSmplr, in.VertGeom.xy);
float4 _31 = TextureDetail.sample(TextureDetailSmplr, in.VertGeom.xy, int2(3, 2));
out.FragColor0 = as_type<float4>(as_type<int4>(_20)) * as_type<float4>(as_type<int4>(_31));
out.FragColor1 = as_type<float4>(as_type<uint4>(_20)) * as_type<float4>(as_type<uint4>(_31));
return out;
}

Просмотреть файл

@ -8,6 +8,8 @@ struct Structy
float4 c;
};
constant Structy _47 = {};
struct main0_out
{
float4 FragColor [[color(0)]];

Просмотреть файл

@ -11,10 +11,9 @@ struct main0_out
fragment main0_out main0()
{
main0_out out = {};
int _12;
int _27;
int _26;
int _43;
int _12;
int _59;
int _83;
int2 _93;
@ -22,7 +21,7 @@ fragment main0_out main0()
int _62;
int _128;
out.FragColor = 16;
for (int _140 = 0; _140 < 25; _27 = _140 + 1, _140 = _27)
while (true)
{
out.FragColor += 10;
}
@ -30,17 +29,17 @@ fragment main0_out main0()
{
out.FragColor += 11;
}
int _142;
_142 = 0;
for (; _142 < 20; _59 = _142 + 1, _142 = _59)
int _143;
_143 = 0;
for (; _143 < 20; _59 = _143 + 1, _143 = _59)
{
out.FragColor += 12;
}
_62 = _142 + 3;
_62 = _143 + 3;
out.FragColor += _62;
if (_62 == 40)
{
for (int _143 = 0; _143 < 40; _83 = _143 + 1, _143 = _83)
for (int _144 = 0; _144 < 40; _83 = _144 + 1, _144 = _83)
{
out.FragColor += 13;
}
@ -50,15 +49,15 @@ fragment main0_out main0()
{
out.FragColor += _62;
}
int2 _144;
_144 = int2(0);
for (; _144.x < 10; _139 = _144, _139.x = _144.x + 4, _144 = _139)
int2 _145;
_145 = int2(0);
for (; _145.x < 10; _139 = _145, _139.x = _145.x + 4, _145 = _139)
{
out.FragColor += _144.y;
out.FragColor += _145.y;
}
for (int _145 = _62; _145 < 40; _128 = _145 + 1, _145 = _128)
for (int _146 = _62; _146 < 40; _128 = _146 + 1, _146 = _128)
{
out.FragColor += _145;
out.FragColor += _146;
}
out.FragColor += _62;
return out;

Просмотреть файл

@ -1,22 +0,0 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
constant float a_tmp [[function_constant(1)]];
constant float a = is_function_constant_defined(a_tmp) ? a_tmp : 1.0;
constant float b_tmp [[function_constant(2)]];
constant float b = is_function_constant_defined(b_tmp) ? b_tmp : 2.0;
struct main0_out
{
float4 FragColor [[color(0)]];
};
fragment main0_out main0()
{
main0_out out = {};
out.FragColor = float4(a + b);
return out;
}

Просмотреть файл

@ -16,6 +16,7 @@ struct _6
kernel void main0(uint3 gl_WorkGroupID [[threadgroup_position_in_grid]], device _6& _8 [[buffer(0)]], device _6& _9 [[buffer(1)]])
{
uint3 _23 = gl_WorkGroupSize;
_8._m0[gl_WorkGroupID.x] = _9._m0[gl_WorkGroupID.x] + _8._m0[gl_WorkGroupID.x];
}

Просмотреть файл

@ -5,6 +5,7 @@ using namespace metal;
kernel void main0(texture2d<float> uImageIn [[texture(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]], texture2d<float, access::write> uImageOut [[texture(1)]])
{
uImageOut.write(uImageIn.read(uint2((int2(gl_GlobalInvocationID.xy) + int2(uImageIn.get_width(), uImageIn.get_height())))), uint2(int2(gl_GlobalInvocationID.xy)));
float4 v = uImageIn.read(uint2((int2(gl_GlobalInvocationID.xy) + int2(uImageIn.get_width(), uImageIn.get_height()))));
uImageOut.write(v, uint2(int2(gl_GlobalInvocationID.xy)));
}

Просмотреть файл

@ -10,6 +10,7 @@ struct SSBO2
kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO2& _22 [[buffer(0)]])
{
_22.out_data[gl_GlobalInvocationID.x] = float3x3(float3(10.0), float3(20.0), float3(40.0));
uint ident = gl_GlobalInvocationID.x;
_22.out_data[ident] = float3x3(float3(10.0), float3(20.0), float3(40.0));
}

Просмотреть файл

@ -0,0 +1,51 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct SSBO
{
float4x4 mvp;
float4 in_data[1];
};
struct SSBO2
{
float4 out_data[1];
};
kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO& _24 [[buffer(0)]], device SSBO2& _89 [[buffer(1)]])
{
uint ident = gl_GlobalInvocationID.x;
float4 idat = _24.in_data[ident];
int k = 0;
for (;;)
{
int _39 = k;
int _40 = _39 + 1;
k = _40;
if (_40 < 10)
{
idat *= 2.0;
k++;
continue;
}
else
{
break;
}
}
for (uint i = 0u; i < 16u; i++, k++)
{
for (uint j = 0u; j < 30u; j++)
{
idat = _24.mvp * idat;
}
}
do
{
k++;
} while (k > 10);
_89.out_data[ident] = idat;
}

Просмотреть файл

@ -5,7 +5,9 @@ using namespace metal;
fragment void main0(texture2d_ms<float> uImageMS [[texture(0)]], texture2d_array<float, access::read_write> uImageArray [[texture(1)]], texture2d<float, access::write> uImage [[texture(2)]])
{
uImage.write(uImageMS.read(uint2(int2(1, 2)), 2), uint2(int2(2, 3)));
uImageArray.write(uImageArray.read(uint2(int3(1, 2, 4).xy), uint(int3(1, 2, 4).z)), uint2(int3(2, 3, 7).xy), uint(int3(2, 3, 7).z));
float4 a = uImageMS.read(uint2(int2(1, 2)), 2);
float4 b = uImageArray.read(uint2(int3(1, 2, 4).xy), uint(int3(1, 2, 4).z));
uImage.write(a, uint2(int2(2, 3)));
uImageArray.write(b, uint2(int3(2, 3, 7).xy), uint(int3(2, 3, 7).z));
}

Просмотреть файл

@ -0,0 +1,30 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct main0_in
{
float4 VertGeom [[user(locn0)]];
};
struct main0_out
{
float4 FragColor0 [[color(0)]];
float4 FragColor1 [[color(1)]];
};
fragment main0_out main0(main0_in in [[stage_in]], texture2d<float> TextureBase [[texture(0)]], sampler TextureBaseSmplr [[sampler(0)]], texture2d<float> TextureDetail [[texture(1)]], sampler TextureDetailSmplr [[sampler(1)]])
{
main0_out out = {};
float4 texSample0 = TextureBase.sample(TextureBaseSmplr, in.VertGeom.xy);
float4 texSample1 = TextureDetail.sample(TextureDetailSmplr, in.VertGeom.xy, int2(3, 2));
int4 iResult0 = as_type<int4>(texSample0);
int4 iResult1 = as_type<int4>(texSample1);
out.FragColor0 = as_type<float4>(iResult0) * as_type<float4>(iResult1);
uint4 uResult0 = as_type<uint4>(texSample0);
uint4 uResult1 = as_type<uint4>(texSample1);
out.FragColor1 = as_type<float4>(uResult0) * as_type<float4>(uResult1);
return out;
}

Просмотреть файл

@ -16,9 +16,8 @@ struct main0_out
fragment main0_out main0(main0_in in [[stage_in]], texture2d<float> Texture [[texture(0)]], sampler TextureSmplr [[sampler(0)]])
{
main0_out out = {};
float4 _19 = Texture.sample(TextureSmplr, in.vTexCoord);
float _22 = _19.x;
out.FragColor = float4(_22 * _22);
float f = Texture.sample(TextureSmplr, in.vTexCoord).x;
out.FragColor = float4(f * f);
return out;
}

Просмотреть файл

@ -1,3 +1,5 @@
#pragma clang diagnostic ignored "-Wmissing-prototypes"
#include <metal_stdlib>
#include <simd/simd.h>
@ -19,13 +21,20 @@ struct main0_out
float4 FragColor [[color(0)]];
};
float4 resolve(thread const Foobar& f)
{
return float4(f.a + f.b);
}
fragment main0_out main0(main0_in in [[stage_in]])
{
main0_out out = {};
float4 indexable[3] = {float4(1.0), float4(2.0), float4(3.0)};
float4 indexable_1[2][2] = {{float4(1.0), float4(2.0)}, {float4(8.0), float4(10.0)}};
Foobar param = {10.0, 20.0};
Foobar indexable_2[2] = {{10.0, 40.0}, {90.0, 70.0}};
out.FragColor = ((indexable[in.index] + (indexable_1[in.index][in.index + 1])) + float4(10.0 + 20.0)) + float4(indexable_2[in.index].a + indexable_2[in.index].b);
Foobar param_1 = indexable_2[in.index];
out.FragColor = ((indexable[in.index] + (indexable_1[in.index][in.index + 1])) + resolve(param)) + resolve(param_1);
return out;
}

Просмотреть файл

@ -11,8 +11,8 @@ struct main0_out
fragment main0_out main0(float4 gl_FragCoord [[position]], texture2d_ms<float> uSampler [[texture(0)]], sampler uSamplerSmplr [[sampler(0)]])
{
main0_out out = {};
int2 _17 = int2(gl_FragCoord.xy);
out.FragColor = ((uSampler.read(uint2(_17), 0) + uSampler.read(uint2(_17), 1)) + uSampler.read(uint2(_17), 2)) + uSampler.read(uint2(_17), 3);
int2 coord = int2(gl_FragCoord.xy);
out.FragColor = ((uSampler.read(uint2(coord), 0) + uSampler.read(uint2(coord), 1)) + uSampler.read(uint2(coord), 2)) + uSampler.read(uint2(coord), 3);
return out;
}

Просмотреть файл

@ -1,3 +1,5 @@
#pragma clang diagnostic ignored "-Wmissing-prototypes"
#include <metal_stdlib>
#include <simd/simd.h>
@ -14,10 +16,16 @@ struct main0_out
float4 FragColor [[color(0)]];
};
float4 sample_texture(thread const texture2d<float> tex, thread const sampler& texSmplr, thread const float2& uv)
{
return tex.sample(texSmplr, uv);
}
fragment main0_out main0(main0_in in [[stage_in]], texture2d<float> uTex [[texture(0)]], sampler uTexSmplr [[sampler(0)]])
{
main0_out out = {};
out.FragColor = in.vColor * uTex.sample(uTexSmplr, in.vTex);
float2 param = in.vTex;
out.FragColor = in.vColor * sample_texture(uTex, uTexSmplr, param);
return out;
}

Просмотреть файл

@ -1,3 +1,5 @@
#pragma clang diagnostic ignored "-Wmissing-prototypes"
#include <metal_stdlib>
#include <simd/simd.h>
@ -8,10 +10,15 @@ struct main0_out
float4 FragColor [[color(0)]];
};
float4 samp(thread const texture2d<float> t, thread const sampler s)
{
return t.sample(s, float2(0.5));
}
fragment main0_out main0(texture2d<float> uDepth [[texture(0)]], sampler uSampler [[sampler(0)]])
{
main0_out out = {};
out.FragColor = uDepth.sample(uSampler, float2(0.5));
out.FragColor = samp(uDepth, uSampler);
return out;
}

Просмотреть файл

@ -0,0 +1,47 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct Light
{
packed_float3 Position;
float Radius;
float4 Color;
};
struct UBO
{
float4x4 uMVP;
Light lights[4];
};
struct main0_in
{
float3 aNormal [[attribute(1)]];
float4 aVertex [[attribute(0)]];
};
struct main0_out
{
float4 vColor [[user(locn0)]];
float4 gl_Position [[position]];
};
vertex main0_out main0(main0_in in [[stage_in]], constant UBO& _21 [[buffer(0)]])
{
main0_out out = {};
out.gl_Position = _21.uMVP * in.aVertex;
out.vColor = float4(0.0);
for (int i = 0; i < 4; i++)
{
Light light;
light.Position = _21.lights[i].Position;
light.Radius = _21.lights[i].Radius;
light.Color = _21.lights[i].Color;
float3 L = in.aVertex.xyz - light.Position;
out.vColor += ((_21.lights[i].Color * clamp(1.0 - (length(L) / light.Radius), 0.0, 1.0)) * dot(in.aNormal, normalize(L)));
}
return out;
}

Просмотреть файл

@ -0,0 +1,43 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct Light
{
packed_float3 Position;
float Radius;
float4 Color;
};
struct UBO
{
float4x4 uMVP;
Light lights[4];
};
struct main0_in
{
float3 aNormal [[attribute(1)]];
float4 aVertex [[attribute(0)]];
};
struct main0_out
{
float4 vColor [[user(locn0)]];
float4 gl_Position [[position]];
};
vertex main0_out main0(main0_in in [[stage_in]], constant UBO& _21 [[buffer(0)]])
{
main0_out out = {};
out.gl_Position = _21.uMVP * in.aVertex;
out.vColor = float4(0.0);
for (int i = 0; i < 4; i++)
{
float3 L = in.aVertex.xyz - _21.lights[i].Position;
out.vColor += ((_21.lights[i].Color * clamp(1.0 - (length(L) / _21.lights[i].Radius), 0.0, 1.0)) * dot(in.aNormal, normalize(L)));
}
return out;
}

Просмотреть файл

@ -0,0 +1,189 @@
#pragma clang diagnostic ignored "-Wmissing-prototypes"
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct attr_desc
{
int type;
int attribute_size;
int starting_offset;
int stride;
int swap_bytes;
int is_volatile;
};
struct VertexBuffer
{
float4x4 scale_offset_mat;
uint vertex_base_index;
int4 input_attributes[16];
};
struct VertexConstantsBuffer
{
float4 vc[16];
};
constant float4 _295 = {};
struct main0_out
{
float4 tc0 [[user(locn0)]];
float4 back_color [[user(locn10)]];
float4 gl_Position [[position]];
};
attr_desc fetch_desc(thread const int& location, constant VertexBuffer& v_227)
{
int attribute_flags = v_227.input_attributes[location].w;
attr_desc result;
result.type = v_227.input_attributes[location].x;
result.attribute_size = v_227.input_attributes[location].y;
result.starting_offset = v_227.input_attributes[location].z;
result.stride = attribute_flags & 255;
result.swap_bytes = (attribute_flags >> 8) & 1;
result.is_volatile = (attribute_flags >> 9) & 1;
return result;
}
uint get_bits(thread const uint4& v, thread const int& swap)
{
if (swap != 0)
{
return ((v.w | (v.z << uint(8))) | (v.y << uint(16))) | (v.x << uint(24));
}
return ((v.x | (v.y << uint(8))) | (v.z << uint(16))) | (v.w << uint(24));
}
float4 fetch_attr(thread const attr_desc& desc, thread const int& vertex_id, thread const texture2d<uint> input_stream)
{
float4 result = float4(0.0, 0.0, 0.0, 1.0);
bool reverse_order = false;
int first_byte = (vertex_id * desc.stride) + desc.starting_offset;
for (int n = 0; n < 4; n++)
{
if (n == desc.attribute_size)
{
break;
}
uint4 tmp;
switch (desc.type)
{
case 0:
{
int _131 = first_byte;
first_byte = _131 + 1;
tmp.x = input_stream.read(uint2(_131, 0)).x;
int _138 = first_byte;
first_byte = _138 + 1;
tmp.y = input_stream.read(uint2(_138, 0)).x;
uint4 param = tmp;
int param_1 = desc.swap_bytes;
result[n] = float(get_bits(param, param_1));
break;
}
case 1:
{
int _156 = first_byte;
first_byte = _156 + 1;
tmp.x = input_stream.read(uint2(_156, 0)).x;
int _163 = first_byte;
first_byte = _163 + 1;
tmp.y = input_stream.read(uint2(_163, 0)).x;
int _170 = first_byte;
first_byte = _170 + 1;
tmp.z = input_stream.read(uint2(_170, 0)).x;
int _177 = first_byte;
first_byte = _177 + 1;
tmp.w = input_stream.read(uint2(_177, 0)).x;
uint4 param_2 = tmp;
int param_3 = desc.swap_bytes;
result[n] = as_type<float>(get_bits(param_2, param_3));
break;
}
case 2:
{
int _195 = first_byte;
first_byte = _195 + 1;
result[n] = float(input_stream.read(uint2(_195, 0)).x);
reverse_order = desc.swap_bytes != 0;
break;
}
}
}
float4 _209;
if (reverse_order)
{
_209 = result.wzyx;
}
else
{
_209 = result;
}
return _209;
}
float4 read_location(thread const int& location, constant VertexBuffer& v_227, thread uint& gl_VertexIndex, thread texture2d<uint> buff_in_2, thread texture2d<uint> buff_in_1)
{
int param = location;
attr_desc desc = fetch_desc(param, v_227);
int vertex_id = gl_VertexIndex - int(v_227.vertex_base_index);
if (desc.is_volatile != 0)
{
attr_desc param_1 = desc;
int param_2 = vertex_id;
return fetch_attr(param_1, param_2, buff_in_2);
}
else
{
attr_desc param_3 = desc;
int param_4 = vertex_id;
return fetch_attr(param_3, param_4, buff_in_1);
}
}
void vs_adjust(thread float4& dst_reg0, thread float4& dst_reg1, thread float4& dst_reg7, constant VertexBuffer& v_227, thread uint& gl_VertexIndex, thread texture2d<uint> buff_in_2, thread texture2d<uint> buff_in_1, constant VertexConstantsBuffer& v_309)
{
int param = 3;
float4 in_diff_color = read_location(param, v_227, gl_VertexIndex, buff_in_2, buff_in_1);
int param_1 = 0;
float4 in_pos = read_location(param_1, v_227, gl_VertexIndex, buff_in_2, buff_in_1);
int param_2 = 8;
float4 in_tc0 = read_location(param_2, v_227, gl_VertexIndex, buff_in_2, buff_in_1);
dst_reg1 = in_diff_color * v_309.vc[13];
float4 tmp0;
tmp0.x = float4(dot(float4(in_pos.xyz, 1.0), v_309.vc[4])).x;
tmp0.y = float4(dot(float4(in_pos.xyz, 1.0), v_309.vc[5])).y;
tmp0.z = float4(dot(float4(in_pos.xyz, 1.0), v_309.vc[6])).z;
float4 tmp1;
tmp1 = float4(in_tc0.xy.x, in_tc0.xy.y, tmp1.z, tmp1.w);
tmp1.z = v_309.vc[15].x;
dst_reg7.y = float4(dot(float4(tmp1.xyz, 1.0), v_309.vc[8])).y;
dst_reg7.x = float4(dot(float4(tmp1.xyz, 1.0), v_309.vc[7])).x;
dst_reg0.y = float4(dot(float4(tmp0.xyz, 1.0), v_309.vc[1])).y;
dst_reg0.x = float4(dot(float4(tmp0.xyz, 1.0), v_309.vc[0])).x;
}
vertex main0_out main0(constant VertexBuffer& v_227 [[buffer(0)]], uint gl_VertexIndex [[vertex_id]], texture2d<uint> buff_in_2 [[texture(0)]], texture2d<uint> buff_in_1 [[texture(1)]], constant VertexConstantsBuffer& v_309 [[buffer(1)]])
{
main0_out out = {};
float4 dst_reg0 = float4(0.0, 0.0, 0.0, 1.0);
float4 dst_reg1 = float4(0.0);
float4 dst_reg7 = float4(0.0);
float4 param = dst_reg0;
float4 param_1 = dst_reg1;
float4 param_2 = dst_reg7;
vs_adjust(param, param_1, param_2, v_227, gl_VertexIndex, buff_in_2, buff_in_1, v_309);
dst_reg0 = param;
dst_reg1 = param_1;
dst_reg7 = param_2;
out.gl_Position = dst_reg0;
out.back_color = dst_reg1;
out.tc0 = dst_reg7;
out.gl_Position *= v_227.scale_offset_mat;
return out;
}

Просмотреть файл

@ -0,0 +1,17 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct main0_out
{
float4 gl_Position [[position]];
};
vertex main0_out main0(texture2d<float> uSamp [[texture(0)]], texture2d<float> uSampo [[texture(1)]])
{
main0_out out = {};
out.gl_Position = uSamp.read(uint2(10, 0)) + uSampo.read(uint2(100, 0));
return out;
}

Просмотреть файл

@ -0,0 +1,74 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
constant float a_tmp [[function_constant(1)]];
constant float a = is_function_constant_defined(a_tmp) ? a_tmp : 1.0;
constant float b_tmp [[function_constant(2)]];
constant float b = is_function_constant_defined(b_tmp) ? b_tmp : 2.0;
constant int c_tmp [[function_constant(3)]];
constant int c = is_function_constant_defined(c_tmp) ? c_tmp : 3;
constant int d_tmp [[function_constant(4)]];
constant int d = is_function_constant_defined(d_tmp) ? d_tmp : 4;
constant uint e_tmp [[function_constant(5)]];
constant uint e = is_function_constant_defined(e_tmp) ? e_tmp : 5u;
constant uint f_tmp [[function_constant(6)]];
constant uint f = is_function_constant_defined(f_tmp) ? f_tmp : 6u;
constant bool g_tmp [[function_constant(7)]];
constant bool g = is_function_constant_defined(g_tmp) ? g_tmp : false;
constant bool h_tmp [[function_constant(8)]];
constant bool h = is_function_constant_defined(h_tmp) ? h_tmp : true;
struct main0_out
{
float4 FragColor [[color(0)]];
};
fragment main0_out main0()
{
main0_out out = {};
float t0 = a;
float t1 = b;
uint c0 = (uint(c) + 0u);
int c1 = (-c);
int c2 = (~c);
int c3 = (c + d);
int c4 = (c - d);
int c5 = (c * d);
int c6 = (c / d);
uint c7 = (e / f);
int c8 = (c % d);
uint c9 = (e % f);
int c10 = (c >> d);
uint c11 = (e >> f);
int c12 = (c << d);
int c13 = (c | d);
int c14 = (c ^ d);
int c15 = (c & d);
bool c16 = (g || h);
bool c17 = (g && h);
bool c18 = (!g);
bool c19 = (g == h);
bool c20 = (g != h);
bool c21 = (c == d);
bool c22 = (c != d);
bool c23 = (c < d);
bool c24 = (e < f);
bool c25 = (c > d);
bool c26 = (e > f);
bool c27 = (c <= d);
bool c28 = (e <= f);
bool c29 = (c >= d);
bool c30 = (e >= f);
int c31 = c8 + c3;
int c32 = int(e + 0u);
bool c33 = (c != int(0u));
bool c34 = (e != 0u);
int c35 = int(g);
uint c36 = uint(g);
float c37 = float(g);
out.FragColor = float4(t0 + t1);
return out;
}

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -11,6 +11,7 @@ echo "Using spirv-opt in: $(which spirv-opt)."
./test_shaders.py shaders --opt || exit 1
./test_shaders.py shaders-msl --msl || exit 1
./test_shaders.py shaders-msl --msl --opt || exit 1
./test_shaders.py shaders-msl-no-opt --msl || exit 1
./test_shaders.py shaders-hlsl --hlsl || exit 1
./test_shaders.py shaders-hlsl --hlsl --opt || exit 1