Merge pull request #6221 from aliaspider/master

(deps) update SPIRV-Cross.
This commit is contained in:
Twinaphex 2018-02-02 14:24:59 +01:00 committed by GitHub
commit ea6b69f078
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
82 changed files with 849 additions and 156 deletions

0
deps/SPIRV-Cross/checkout_glslang_spirv_tools.sh vendored Normal file → Executable file
View File

View File

@ -0,0 +1,43 @@
struct Foo
{
float a;
float b;
};
static const float _16[4] = { 1.0f, 4.0f, 3.0f, 2.0f };
static const Foo _24 = { 10.0f, 20.0f };
static const Foo _27 = { 30.0f, 40.0f };
static const Foo _28[2] = { { 10.0f, 20.0f }, { 30.0f, 40.0f } };
static float4 FragColor;
static int _line;
struct SPIRV_Cross_Input
{
nointerpolation int _line : TEXCOORD0;
};
struct SPIRV_Cross_Output
{
float4 FragColor : SV_Target0;
};
static float lut[4];
static Foo foos[2];
void frag_main()
{
lut = _16;
foos = _28;
FragColor = lut[_line].xxxx;
FragColor += (foos[_line].a * (foos[1 - _line].a)).xxxx;
}
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
{
_line = stage_input._line;
frag_main();
SPIRV_Cross_Output stage_output;
stage_output.FragColor = FragColor;
return stage_output;
}

View File

@ -0,0 +1,30 @@
Texture2D<float4> uTex : register(t0);
SamplerState uSampler : register(s1);
static int2 FooOut;
struct SPIRV_Cross_Output
{
int2 FooOut : SV_Target0;
};
uint2 SPIRV_Cross_textureSize(Texture2D<float4> Tex, uint Level, out uint Param)
{
uint2 ret;
Tex.GetDimensions(Level, ret.x, ret.y, Param);
return ret;
}
void frag_main()
{
uint _23_dummy_parameter;
FooOut = int2(SPIRV_Cross_textureSize(uTex, uint(0), _23_dummy_parameter));
}
SPIRV_Cross_Output main()
{
frag_main();
SPIRV_Cross_Output stage_output;
stage_output.FooOut = FooOut;
return stage_output;
}

View File

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

View File

@ -101,7 +101,7 @@ struct main0_out
float4 _entryPointOutput [[color(0)]];
};
fragment main0_out main0(main0_in in [[stage_in]], float4 gl_FragCoord [[position]], constant CB0& _19 [[buffer(0)]], texture3d<float> LightMapTexture [[texture(0)]], sampler LightMapSampler [[sampler(0)]], sampler ShadowMapSampler [[sampler(1)]], texture2d<float> ShadowMapTexture [[texture(1)]], texturecube<float> EnvironmentMapTexture [[texture(2)]], sampler EnvironmentMapSampler [[sampler(2)]], sampler DiffuseMapSampler [[sampler(3)]], texture2d<float> DiffuseMapTexture [[texture(3)]], sampler NormalMapSampler [[sampler(4)]], texture2d<float> NormalMapTexture [[texture(4)]], texture2d<float> NormalDetailMapTexture [[texture(5)]], sampler NormalDetailMapSampler [[sampler(5)]], texture2d<float> StudsMapTexture [[texture(6)]], sampler StudsMapSampler [[sampler(6)]], sampler SpecularMapSampler [[sampler(7)]], texture2d<float> SpecularMapTexture [[texture(7)]])
fragment main0_out main0(main0_in in [[stage_in]], constant CB0& _19 [[buffer(0)]], texture3d<float> LightMapTexture [[texture(0)]], texture2d<float> ShadowMapTexture [[texture(1)]], texturecube<float> EnvironmentMapTexture [[texture(2)]], texture2d<float> DiffuseMapTexture [[texture(3)]], texture2d<float> NormalMapTexture [[texture(4)]], texture2d<float> NormalDetailMapTexture [[texture(5)]], texture2d<float> StudsMapTexture [[texture(6)]], texture2d<float> SpecularMapTexture [[texture(7)]], sampler LightMapSampler [[sampler(0)]], sampler ShadowMapSampler [[sampler(1)]], sampler EnvironmentMapSampler [[sampler(2)]], sampler DiffuseMapSampler [[sampler(3)]], sampler NormalMapSampler [[sampler(4)]], sampler NormalDetailMapSampler [[sampler(5)]], sampler StudsMapSampler [[sampler(6)]], sampler SpecularMapSampler [[sampler(7)]], float4 gl_FragCoord [[position]])
{
main0_out out = {};
VertexOutput _128 = _121;

View File

@ -95,7 +95,7 @@ struct main0_out
float4 m_5 [[color(0)]];
};
fragment main0_out main0(float4 gl_FragCoord [[position]], constant _6& _7 [[buffer(0)]], texture2d<float> _8 [[texture(0)]], sampler _9 [[sampler(0)]], constant _10& _11 [[buffer(1)]], texture2d<float> _12 [[texture(1)]], sampler _13 [[sampler(1)]], texture2d<float> _14 [[texture(2)]], sampler _15 [[sampler(2)]], constant _18& _19 [[buffer(2)]])
fragment main0_out main0(constant _6& _7 [[buffer(0)]], constant _10& _11 [[buffer(1)]], constant _18& _19 [[buffer(2)]], texture2d<float> _8 [[texture(0)]], texture2d<float> _12 [[texture(1)]], texture2d<float> _14 [[texture(2)]], sampler _9 [[sampler(0)]], sampler _13 [[sampler(1)]], sampler _15 [[sampler(2)]], float4 gl_FragCoord [[position]])
{
main0_out out = {};
_28 _77 = _74;

View File

@ -21,7 +21,7 @@ struct SSBO3
uint counter;
};
kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO& _23 [[buffer(0)]], device SSBO2& _45 [[buffer(1)]], device SSBO3& _48 [[buffer(2)]])
kernel void main0(device SSBO& _23 [[buffer(0)]], device SSBO2& _45 [[buffer(1)]], device SSBO3& _48 [[buffer(2)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]])
{
float4 _29 = _23.in_data[gl_GlobalInvocationID.x];
if (dot(_29, float4(1.0, 5.0, 6.0, 2.0)) > 8.19999980926513671875)

View File

@ -23,7 +23,7 @@ struct SSBO3
uint count;
};
kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO& _22 [[buffer(0)]], device SSBO2& _38 [[buffer(1)]], device SSBO3& _41 [[buffer(2)]])
kernel void main0(device SSBO& _22 [[buffer(0)]], device SSBO2& _38 [[buffer(1)]], device SSBO3& _41 [[buffer(2)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]])
{
float _28 = _22.in_data[gl_GlobalInvocationID.x];
if (_28 > 12.0)

View File

@ -14,7 +14,7 @@ struct SSBO2
float4 out_data[1];
};
kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO& _28 [[buffer(0)]], device SSBO2& _52 [[buffer(1)]])
kernel void main0(device SSBO& _28 [[buffer(0)]], device SSBO2& _52 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]])
{
int i = 0;
float4 _56;

View File

@ -3,7 +3,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)]])
kernel void main0(texture2d<float> uImageIn [[texture(0)]], texture2d<float, access::write> uImageOut [[texture(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]])
{
uImageOut.write(uImageIn.read(uint2((int2(gl_GlobalInvocationID.xy) + int2(uImageIn.get_width(), uImageIn.get_height())))), uint2(int2(gl_GlobalInvocationID.xy)));
}

View File

@ -14,7 +14,7 @@ struct SSBO2
float4 out_data[1];
};
kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO& _24 [[buffer(0)]], device SSBO2& _177 [[buffer(1)]])
kernel void main0(device SSBO& _24 [[buffer(0)]], device SSBO2& _177 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]])
{
uint ident = gl_GlobalInvocationID.x;
float4 idat = _24.in_data[ident];

View File

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

View File

@ -22,7 +22,7 @@ Tx mod(Tx x, Ty y)
return x - y * floor(x / y);
}
kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO& _23 [[buffer(0)]], device SSBO2& _33 [[buffer(1)]])
kernel void main0(device SSBO& _23 [[buffer(0)]], device SSBO2& _33 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]])
{
_33.out_data[gl_GlobalInvocationID.x] = mod(_23.in_data[gl_GlobalInvocationID.x], _33.out_data[gl_GlobalInvocationID.x]);
_33.out_data[gl_GlobalInvocationID.x] = as_type<float4>(as_type<uint4>(_23.in_data[gl_GlobalInvocationID.x]) % as_type<uint4>(_33.out_data[gl_GlobalInvocationID.x]));

View File

@ -13,7 +13,7 @@ struct SSBO2
float4 out_data[1];
};
kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO& _23 [[buffer(0)]], device SSBO2& _35 [[buffer(1)]])
kernel void main0(device SSBO& _23 [[buffer(0)]], device SSBO2& _35 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]])
{
float4 i;
float4 _31 = modf(_23.in_data[gl_GlobalInvocationID.x], i);

View File

@ -10,7 +10,7 @@ struct SSBO2
constant int _69 = {};
kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO2& _27 [[buffer(0)]])
kernel void main0(device SSBO2& _27 [[buffer(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]])
{
if (gl_GlobalInvocationID.x == 2u)
{

View File

@ -0,0 +1,20 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
constant uint3 gl_WorkGroupSize = uint3(4u, 4u, 1u);
struct SSBO
{
float out_data[1];
};
kernel void main0(device SSBO& _67 [[buffer(0)]], uint3 gl_LocalInvocationID [[thread_position_in_threadgroup]], uint gl_LocalInvocationIndex [[thread_index_in_threadgroup]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]])
{
threadgroup float foo[4][4];
foo[gl_LocalInvocationID.x][gl_LocalInvocationID.y] = float(gl_LocalInvocationIndex);
threadgroup_barrier(mem_flags::mem_threadgroup);
_67.out_data[gl_GlobalInvocationID.x] = (((0.0 + foo[gl_LocalInvocationID.x][0]) + foo[gl_LocalInvocationID.x][1]) + foo[gl_LocalInvocationID.x][2]) + foo[gl_LocalInvocationID.x][3];
}

View File

@ -15,7 +15,7 @@ struct SSBO2
float out_data[1];
};
kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO& _22 [[buffer(0)]], uint gl_LocalInvocationIndex [[thread_index_in_threadgroup]], device SSBO2& _44 [[buffer(1)]])
kernel void main0(device SSBO& _22 [[buffer(0)]], device SSBO2& _44 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]], uint gl_LocalInvocationIndex [[thread_index_in_threadgroup]])
{
threadgroup float sShared[4];
sShared[gl_LocalInvocationIndex] = _22.in_data[gl_GlobalInvocationID.x];

View File

@ -18,7 +18,7 @@ struct SSBO
Foo in_data[1];
};
kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO2& _23 [[buffer(0)]], device SSBO& _30 [[buffer(1)]])
kernel void main0(device SSBO2& _23 [[buffer(0)]], device SSBO& _30 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]])
{
_23.out_data[gl_GlobalInvocationID.x].m = _30.in_data[gl_GlobalInvocationID.x].m * _30.in_data[gl_GlobalInvocationID.x].m;
}

View File

@ -16,15 +16,15 @@ struct SSBO2
constant uint _98 = {};
kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO& _24 [[buffer(0)]], device SSBO2& _89 [[buffer(1)]])
kernel void main0(device SSBO& _24 [[buffer(0)]], device SSBO2& _89 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]])
{
float4 _93;
int _94;
_93 = _24.in_data[gl_GlobalInvocationID.x];
_94 = 0;
int _48;
int _40;
float4 _46;
int _48;
for (;;)
{
_40 = _94 + 1;

View File

@ -28,7 +28,7 @@ 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 SSBO0& _36 [[buffer(0)]], device SSBO1& _55 [[buffer(1)]], device SSBO2& _66 [[buffer(2)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]])
{
_66.outputs[gl_GlobalInvocationID.x] = _36.s0s[gl_GlobalInvocationID.x].a + _55.s1s[gl_GlobalInvocationID.x].a;
}

View File

@ -13,7 +13,7 @@ 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 SSBO2& _10 [[buffer(0)]], device SSBO& _23 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]])
{
_10.outputs[gl_GlobalInvocationID.x] = _23.inputs[gl_GlobalInvocationID.x] / 29u;
}

View File

@ -8,7 +8,7 @@ struct main0_out
float4 FragColor [[color(0)]];
};
fragment main0_out main0(texture2d_ms<float> uSampler [[texture(0)]], sampler uSamplerSmplr [[sampler(0)]], texture2d_ms<float> uSamplerArray [[texture(1)]], sampler uSamplerArraySmplr [[sampler(1)]], texture2d_ms<float> uImage [[texture(2)]], texture2d_ms<float> uImageArray [[texture(3)]])
fragment main0_out main0(texture2d_ms<float> uSampler [[texture(0)]], texture2d_ms<float> uSamplerArray [[texture(1)]], texture2d_ms<float> uImage [[texture(2)]], texture2d_ms<float> uImageArray [[texture(3)]], sampler uSamplerSmplr [[sampler(0)]], sampler uSamplerArraySmplr [[sampler(1)]])
{
main0_out out = {};
out.FragColor = float4(float(((int(uSampler.get_num_samples()) + int(uSamplerArray.get_num_samples())) + int(uImage.get_num_samples())) + int(uImageArray.get_num_samples())));

View File

@ -14,7 +14,7 @@ struct main0_out
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)]])
fragment main0_out main0(main0_in in [[stage_in]], texture2d<float> TextureBase [[texture(0)]], texture2d<float> TextureDetail [[texture(1)]], sampler TextureBaseSmplr [[sampler(0)]], sampler TextureDetailSmplr [[sampler(1)]])
{
main0_out out = {};
float4 _20 = TextureBase.sample(TextureBaseSmplr, in.VertGeom.xy);

View File

@ -0,0 +1,31 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct Foo
{
float a;
float b;
};
struct main0_in
{
int line [[user(locn0)]];
};
struct main0_out
{
float4 FragColor [[color(0)]];
};
fragment main0_out main0(main0_in in [[stage_in]])
{
main0_out out = {};
float lut[4] = {1.0, 4.0, 3.0, 2.0};
Foo foos[2] = {{10.0, 20.0}, {30.0, 40.0}};
out.FragColor = float4(lut[in.line]);
out.FragColor += float4(foos[in.line].a * (foos[1 - in.line].a));
return out;
}

View File

@ -8,7 +8,7 @@ struct main0_out
float4 FragColor [[color(0)]];
};
fragment main0_out main0(float4 gl_FragCoord [[position]], texture2d_ms<float> uSampler [[texture(0)]], sampler uSamplerSmplr [[sampler(0)]])
fragment main0_out main0(texture2d_ms<float> uSampler [[texture(0)]], sampler uSamplerSmplr [[sampler(0)]], float4 gl_FragCoord [[position]])
{
main0_out out = {};
int2 _17 = int2(gl_FragCoord.xy);

View File

@ -15,7 +15,7 @@ struct main0_out
float FragColor [[color(0)]];
};
fragment main0_out main0(main0_in in [[stage_in]], depth2d<float> uShadow2D [[texture(0)]], sampler uShadow2DSmplr [[sampler(0)]], texture1d<float> uSampler1D [[texture(1)]], sampler uSampler1DSmplr [[sampler(1)]], texture2d<float> uSampler2D [[texture(2)]], sampler uSampler2DSmplr [[sampler(2)]], texture3d<float> uSampler3D [[texture(3)]], sampler uSampler3DSmplr [[sampler(3)]])
fragment main0_out main0(main0_in in [[stage_in]], depth2d<float> uShadow2D [[texture(0)]], texture1d<float> uSampler1D [[texture(1)]], texture2d<float> uSampler2D [[texture(2)]], texture3d<float> uSampler3D [[texture(3)]], sampler uShadow2DSmplr [[sampler(0)]], sampler uSampler1DSmplr [[sampler(1)]], sampler uSampler2DSmplr [[sampler(2)]], sampler uSampler3DSmplr [[sampler(3)]])
{
main0_out out = {};
float4 _20 = in.vClip4;

View File

@ -0,0 +1,39 @@
#version 450
struct Params
{
vec4 TextureSize;
vec4 Params1;
vec4 Params2;
vec4 Params3;
vec4 Params4;
vec4 Bloom;
};
layout(binding = 1, std140) uniform CB1
{
Params CB1;
} _8;
uniform sampler2D SPIRV_Cross_CombinedmapTexturemapSampler;
layout(location = 0) in vec2 IN_uv;
layout(location = 0) out vec4 _entryPointOutput;
void main()
{
vec4 _49 = texture(SPIRV_Cross_CombinedmapTexturemapSampler, IN_uv);
float _50 = _49.y;
float _55;
float _58;
_55 = 0.0;
_58 = 0.0;
float _64;
vec4 _72;
float _78;
for (int _60 = -3; _60 <= 3; _64 = float(_60), _72 = texture(SPIRV_Cross_CombinedmapTexturemapSampler, IN_uv + (vec2(0.0, _8.CB1.TextureSize.w) * _64)), _78 = exp(((-_64) * _64) * 0.2222220003604888916015625) * float(abs(_72.y - _50) < clamp((_50 * 80.0) * 0.0007999999797903001308441162109375, 7.999999797903001308441162109375e-05, 0.008000000379979610443115234375)), _55 += (_72.x * _78), _58 += _78, _60++)
{
}
_entryPointOutput = vec4(_55 / _58, _50, 0.0, 1.0);
}

View File

@ -20,9 +20,9 @@ void main()
int _94;
_93 = _24.in_data[gl_GlobalInvocationID.x];
_94 = 0;
int _48;
int _40;
vec4 _46;
int _48;
for (;;)
{
_40 = _94 + 1;

View File

@ -0,0 +1,23 @@
#version 310 es
precision mediump float;
precision highp int;
struct Foo
{
float a;
float b;
};
layout(location = 0) out vec4 FragColor;
layout(location = 0) flat in mediump int _line;
float lut[4];
Foo foos[2];
void main()
{
lut = float[](1.0, 4.0, 3.0, 2.0);
foos = Foo[](Foo(10.0, 20.0), Foo(30.0, 40.0));
FragColor = vec4(lut[_line]);
FragColor += vec4(foos[_line].a * (foos[1 - _line].a));
}

View File

@ -0,0 +1,43 @@
struct Foo
{
float a;
float b;
};
static const float _16[4] = { 1.0f, 4.0f, 3.0f, 2.0f };
static const Foo _24 = { 10.0f, 20.0f };
static const Foo _27 = { 30.0f, 40.0f };
static const Foo _28[2] = { { 10.0f, 20.0f }, { 30.0f, 40.0f } };
static float4 FragColor;
static int _line;
struct SPIRV_Cross_Input
{
nointerpolation int _line : TEXCOORD0;
};
struct SPIRV_Cross_Output
{
float4 FragColor : SV_Target0;
};
static float lut[4];
static Foo foos[2];
void frag_main()
{
lut = _16;
foos = _28;
FragColor = lut[_line].xxxx;
FragColor += (foos[_line].a * (foos[1 - _line].a)).xxxx;
}
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
{
_line = stage_input._line;
frag_main();
SPIRV_Cross_Output stage_output;
stage_output.FragColor = FragColor;
return stage_output;
}

View File

@ -4,6 +4,8 @@ struct B
float b;
};
static const B _80 = { 10.0f, 20.0f };
cbuffer _42 : register(b0)
{
int _42_some_value : packoffset(c0);
@ -61,7 +63,7 @@ void frag_main()
float4 param_3;
branchy_inout_2(param_3);
a = param_3;
B b = { 10.0f, 20.0f };
B b = _80;
B param_4 = b;
partial_inout(param_4);
b = param_4;

View File

@ -0,0 +1,30 @@
Texture2D<float4> uTex : register(t0);
SamplerState uSampler : register(s1);
static int2 FooOut;
struct SPIRV_Cross_Output
{
int2 FooOut : SV_Target0;
};
uint2 SPIRV_Cross_textureSize(Texture2D<float4> Tex, uint Level, out uint Param)
{
uint2 ret;
Tex.GetDimensions(Level, ret.x, ret.y, Param);
return ret;
}
void frag_main()
{
uint _23_dummy_parameter;
FooOut = int2(SPIRV_Cross_textureSize(uTex, uint(0), _23_dummy_parameter));
}
SPIRV_Cross_Output main()
{
frag_main();
SPIRV_Cross_Output stage_output;
stage_output.FooOut = FooOut;
return stage_output;
}

View File

@ -167,7 +167,7 @@ void vs_adjust(thread float4& dst_reg0, thread float4& dst_reg1, thread float4&
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)]])
vertex main0_out main0(constant VertexBuffer& v_227 [[buffer(0)]], constant VertexConstantsBuffer& v_309 [[buffer(1)]], texture2d<uint> buff_in_2 [[texture(0)]], texture2d<uint> buff_in_1 [[texture(1)]], uint gl_VertexIndex [[vertex_id]])
{
main0_out out = {};
float4 dst_reg0 = float4(0.0, 0.0, 0.0, 1.0);

View File

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

View File

@ -101,7 +101,7 @@ struct main0_out
float4 _entryPointOutput [[color(0)]];
};
fragment main0_out main0(main0_in in [[stage_in]], float4 gl_FragCoord [[position]], constant CB0& _19 [[buffer(0)]], texture3d<float> LightMapTexture [[texture(0)]], sampler LightMapSampler [[sampler(0)]], sampler ShadowMapSampler [[sampler(1)]], texture2d<float> ShadowMapTexture [[texture(1)]], texturecube<float> EnvironmentMapTexture [[texture(2)]], sampler EnvironmentMapSampler [[sampler(2)]], sampler DiffuseMapSampler [[sampler(3)]], texture2d<float> DiffuseMapTexture [[texture(3)]], sampler NormalMapSampler [[sampler(4)]], texture2d<float> NormalMapTexture [[texture(4)]], texture2d<float> NormalDetailMapTexture [[texture(5)]], sampler NormalDetailMapSampler [[sampler(5)]], texture2d<float> StudsMapTexture [[texture(6)]], sampler StudsMapSampler [[sampler(6)]], sampler SpecularMapSampler [[sampler(7)]], texture2d<float> SpecularMapTexture [[texture(7)]])
fragment main0_out main0(main0_in in [[stage_in]], constant CB0& _19 [[buffer(0)]], texture3d<float> LightMapTexture [[texture(0)]], texture2d<float> ShadowMapTexture [[texture(1)]], texturecube<float> EnvironmentMapTexture [[texture(2)]], texture2d<float> DiffuseMapTexture [[texture(3)]], texture2d<float> NormalMapTexture [[texture(4)]], texture2d<float> NormalDetailMapTexture [[texture(5)]], texture2d<float> StudsMapTexture [[texture(6)]], texture2d<float> SpecularMapTexture [[texture(7)]], sampler LightMapSampler [[sampler(0)]], sampler ShadowMapSampler [[sampler(1)]], sampler EnvironmentMapSampler [[sampler(2)]], sampler DiffuseMapSampler [[sampler(3)]], sampler NormalMapSampler [[sampler(4)]], sampler NormalDetailMapSampler [[sampler(5)]], sampler StudsMapSampler [[sampler(6)]], sampler SpecularMapSampler [[sampler(7)]], float4 gl_FragCoord [[position]])
{
main0_out out = {};
VertexOutput _128 = _121;

View File

@ -95,7 +95,7 @@ struct main0_out
float4 m_5 [[color(0)]];
};
fragment main0_out main0(float4 gl_FragCoord [[position]], constant _6& _7 [[buffer(0)]], texture2d<float> _8 [[texture(0)]], sampler _9 [[sampler(0)]], constant _10& _11 [[buffer(1)]], texture2d<float> _12 [[texture(1)]], sampler _13 [[sampler(1)]], texture2d<float> _14 [[texture(2)]], sampler _15 [[sampler(2)]], constant _18& _19 [[buffer(2)]])
fragment main0_out main0(constant _6& _7 [[buffer(0)]], constant _10& _11 [[buffer(1)]], constant _18& _19 [[buffer(2)]], texture2d<float> _8 [[texture(0)]], texture2d<float> _12 [[texture(1)]], texture2d<float> _14 [[texture(2)]], sampler _9 [[sampler(0)]], sampler _13 [[sampler(1)]], sampler _15 [[sampler(2)]], float4 gl_FragCoord [[position]])
{
main0_out out = {};
_28 _77 = _74;

View File

@ -21,7 +21,7 @@ struct SSBO3
uint counter;
};
kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO& _23 [[buffer(0)]], device SSBO2& _45 [[buffer(1)]], device SSBO3& _48 [[buffer(2)]])
kernel void main0(device SSBO& _23 [[buffer(0)]], device SSBO2& _45 [[buffer(1)]], device SSBO3& _48 [[buffer(2)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]])
{
uint ident = gl_GlobalInvocationID.x;
float4 idata = _23.in_data[ident];

View File

@ -23,7 +23,7 @@ struct SSBO3
uint count;
};
kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO& _22 [[buffer(0)]], device SSBO2& _38 [[buffer(1)]], device SSBO3& _41 [[buffer(2)]])
kernel void main0(device SSBO& _22 [[buffer(0)]], device SSBO2& _38 [[buffer(1)]], device SSBO3& _41 [[buffer(2)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]])
{
uint ident = gl_GlobalInvocationID.x;
float idata = _22.in_data[ident];

View File

@ -14,7 +14,7 @@ struct SSBO2
float4 out_data[1];
};
kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO& _28 [[buffer(0)]], device SSBO2& _52 [[buffer(1)]])
kernel void main0(device SSBO& _28 [[buffer(0)]], device SSBO2& _52 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]])
{
uint ident = gl_GlobalInvocationID.x;
int i = 0;

View File

@ -5,7 +5,7 @@
using namespace metal;
void myfunc(threadgroup int* foo)
void myfunc(threadgroup int (&foo)[1337])
{
foo[0] = 13;
}

View File

@ -3,7 +3,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)]])
kernel void main0(texture2d<float> uImageIn [[texture(0)]], texture2d<float, access::write> uImageOut [[texture(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]])
{
float4 v = uImageIn.read(uint2((int2(gl_GlobalInvocationID.xy) + int2(uImageIn.get_width(), uImageIn.get_height()))));
uImageOut.write(v, uint2(int2(gl_GlobalInvocationID.xy)));

View File

@ -14,7 +14,7 @@ struct SSBO2
float4 out_data[1];
};
kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO& _24 [[buffer(0)]], device SSBO2& _177 [[buffer(1)]])
kernel void main0(device SSBO& _24 [[buffer(0)]], device SSBO2& _177 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]])
{
uint ident = gl_GlobalInvocationID.x;
float4 idat = _24.in_data[ident];

View File

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

View File

@ -22,7 +22,7 @@ Tx mod(Tx x, Ty y)
return x - y * floor(x / y);
}
kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO& _23 [[buffer(0)]], device SSBO2& _33 [[buffer(1)]])
kernel void main0(device SSBO& _23 [[buffer(0)]], device SSBO2& _33 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]])
{
uint ident = gl_GlobalInvocationID.x;
float4 v = mod(_23.in_data[ident], _33.out_data[ident]);

View File

@ -13,7 +13,7 @@ struct SSBO2
float4 out_data[1];
};
kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO& _23 [[buffer(0)]], device SSBO2& _35 [[buffer(1)]])
kernel void main0(device SSBO& _23 [[buffer(0)]], device SSBO2& _35 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]])
{
uint ident = gl_GlobalInvocationID.x;
float4 i;

View File

@ -8,7 +8,7 @@ struct SSBO2
float4 out_data[1];
};
kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO2& _27 [[buffer(0)]])
kernel void main0(device SSBO2& _27 [[buffer(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]])
{
uint ident = gl_GlobalInvocationID.x;
if (ident == 2u)

View File

@ -0,0 +1,32 @@
#pragma clang diagnostic ignored "-Wmissing-prototypes"
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
constant uint3 gl_WorkGroupSize = uint3(4u, 4u, 1u);
struct SSBO
{
float out_data[1];
};
void work(threadgroup float (&foo)[4][4], thread uint3& gl_LocalInvocationID, thread uint& gl_LocalInvocationIndex, device SSBO& v_67, thread uint3& gl_GlobalInvocationID)
{
foo[gl_LocalInvocationID.x][gl_LocalInvocationID.y] = float(gl_LocalInvocationIndex);
threadgroup_barrier(mem_flags::mem_threadgroup);
float x = 0.0;
x += foo[gl_LocalInvocationID.x][0];
x += foo[gl_LocalInvocationID.x][1];
x += foo[gl_LocalInvocationID.x][2];
x += foo[gl_LocalInvocationID.x][3];
v_67.out_data[gl_GlobalInvocationID.x] = x;
}
kernel void main0(device SSBO& v_67 [[buffer(0)]], uint3 gl_LocalInvocationID [[thread_position_in_threadgroup]], uint gl_LocalInvocationIndex [[thread_index_in_threadgroup]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]])
{
threadgroup float foo[4][4];
work(foo, gl_LocalInvocationID, gl_LocalInvocationIndex, v_67, gl_GlobalInvocationID);
}

View File

@ -15,7 +15,7 @@ struct SSBO2
float out_data[1];
};
kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO& _22 [[buffer(0)]], uint gl_LocalInvocationIndex [[thread_index_in_threadgroup]], device SSBO2& _44 [[buffer(1)]])
kernel void main0(device SSBO& _22 [[buffer(0)]], device SSBO2& _44 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]], uint gl_LocalInvocationIndex [[thread_index_in_threadgroup]])
{
uint ident = gl_GlobalInvocationID.x;
float idata = _22.in_data[ident];

View File

@ -18,7 +18,7 @@ struct SSBO
Foo in_data[1];
};
kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO2& _23 [[buffer(0)]], device SSBO& _30 [[buffer(1)]])
kernel void main0(device SSBO2& _23 [[buffer(0)]], device SSBO& _30 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]])
{
uint ident = gl_GlobalInvocationID.x;
_23.out_data[ident].m = _30.in_data[ident].m * _30.in_data[ident].m;

View File

@ -14,7 +14,7 @@ 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)]])
kernel void main0(device SSBO& _24 [[buffer(0)]], device SSBO2& _89 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]])
{
uint ident = gl_GlobalInvocationID.x;
float4 idat = _24.in_data[ident];

View File

@ -40,7 +40,7 @@ float4 overload(thread const S1& s1)
return s1.a;
}
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 SSBO0& _36 [[buffer(0)]], device SSBO1& _55 [[buffer(1)]], device SSBO2& _66 [[buffer(2)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]])
{
S0 s0;
s0.a = _36.s0s[gl_GlobalInvocationID.x].a;

View File

@ -13,7 +13,7 @@ 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 SSBO2& _10 [[buffer(0)]], device SSBO& _23 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]])
{
_10.outputs[gl_GlobalInvocationID.x] = _23.inputs[gl_GlobalInvocationID.x] / 29u;
}

View File

@ -8,7 +8,7 @@ struct main0_out
float4 FragColor [[color(0)]];
};
fragment main0_out main0(texture2d_ms<float> uSampler [[texture(0)]], sampler uSamplerSmplr [[sampler(0)]], texture2d_ms<float> uSamplerArray [[texture(1)]], sampler uSamplerArraySmplr [[sampler(1)]], texture2d_ms<float> uImage [[texture(2)]], texture2d_ms<float> uImageArray [[texture(3)]])
fragment main0_out main0(texture2d_ms<float> uSampler [[texture(0)]], texture2d_ms<float> uSamplerArray [[texture(1)]], texture2d_ms<float> uImage [[texture(2)]], texture2d_ms<float> uImageArray [[texture(3)]], sampler uSamplerSmplr [[sampler(0)]], sampler uSamplerArraySmplr [[sampler(1)]])
{
main0_out out = {};
out.FragColor = float4(float(((int(uSampler.get_num_samples()) + int(uSamplerArray.get_num_samples())) + int(uImage.get_num_samples())) + int(uImageArray.get_num_samples())));

View File

@ -14,7 +14,7 @@ struct main0_out
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)]])
fragment main0_out main0(main0_in in [[stage_in]], texture2d<float> TextureBase [[texture(0)]], texture2d<float> TextureDetail [[texture(1)]], sampler TextureBaseSmplr [[sampler(0)]], sampler TextureDetailSmplr [[sampler(1)]])
{
main0_out out = {};
float4 texSample0 = TextureBase.sample(TextureBaseSmplr, in.VertGeom.xy);

View File

@ -0,0 +1,31 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct Foo
{
float a;
float b;
};
struct main0_in
{
int line [[user(locn0)]];
};
struct main0_out
{
float4 FragColor [[color(0)]];
};
fragment main0_out main0(main0_in in [[stage_in]])
{
main0_out out = {};
float lut[4] = {1.0, 4.0, 3.0, 2.0};
Foo foos[2] = {{10.0, 20.0}, {30.0, 40.0}};
out.FragColor = float4(lut[in.line]);
out.FragColor += float4(foos[in.line].a * (foos[1 - in.line].a));
return out;
}

View File

@ -8,7 +8,7 @@ struct main0_out
float4 FragColor [[color(0)]];
};
fragment main0_out main0(float4 gl_FragCoord [[position]], texture2d_ms<float> uSampler [[texture(0)]], sampler uSamplerSmplr [[sampler(0)]])
fragment main0_out main0(texture2d_ms<float> uSampler [[texture(0)]], sampler uSamplerSmplr [[sampler(0)]], float4 gl_FragCoord [[position]])
{
main0_out out = {};
int2 coord = int2(gl_FragCoord.xy);

View File

@ -15,7 +15,7 @@ struct main0_out
float FragColor [[color(0)]];
};
fragment main0_out main0(main0_in in [[stage_in]], depth2d<float> uShadow2D [[texture(0)]], sampler uShadow2DSmplr [[sampler(0)]], texture1d<float> uSampler1D [[texture(1)]], sampler uSampler1DSmplr [[sampler(1)]], texture2d<float> uSampler2D [[texture(2)]], sampler uSampler2DSmplr [[sampler(2)]], texture3d<float> uSampler3D [[texture(3)]], sampler uSampler3DSmplr [[sampler(3)]])
fragment main0_out main0(main0_in in [[stage_in]], depth2d<float> uShadow2D [[texture(0)]], texture1d<float> uSampler1D [[texture(1)]], texture2d<float> uSampler2D [[texture(2)]], texture3d<float> uSampler3D [[texture(3)]], sampler uShadow2DSmplr [[sampler(0)]], sampler uSampler1DSmplr [[sampler(1)]], sampler uSampler2DSmplr [[sampler(2)]], sampler uSampler3DSmplr [[sampler(3)]])
{
main0_out out = {};
float4 _20 = in.vClip4;

View File

@ -0,0 +1,39 @@
#version 450
struct Params
{
vec4 TextureSize;
vec4 Params1;
vec4 Params2;
vec4 Params3;
vec4 Params4;
vec4 Bloom;
};
layout(binding = 1, std140) uniform CB1
{
Params CB1;
} _8;
uniform sampler2D SPIRV_Cross_CombinedmapTexturemapSampler;
layout(location = 0) in vec2 IN_uv;
layout(location = 0) out vec4 _entryPointOutput;
void main()
{
vec4 _49 = texture(SPIRV_Cross_CombinedmapTexturemapSampler, IN_uv);
float _50 = _49.y;
float _55;
float _58;
_55 = 0.0;
_58 = 0.0;
float _64;
vec4 _72;
float _78;
for (int _60 = -3; _60 <= 3; _64 = float(_60), _72 = texture(SPIRV_Cross_CombinedmapTexturemapSampler, IN_uv + (vec2(0.0, _8.CB1.TextureSize.w) * _64)), _78 = exp(((-_64) * _64) * 0.2222220003604888916015625) * float(abs(_72.y - _50) < clamp((_50 * 80.0) * 0.0007999999797903001308441162109375, 7.999999797903001308441162109375e-05, 0.008000000379979610443115234375)), _55 += (_72.x * _78), _58 += _78, _60++)
{
}
_entryPointOutput = vec4(_55 / _58, _50, 0.0, 1.0);
}

View File

@ -0,0 +1,23 @@
#version 310 es
precision mediump float;
precision highp int;
struct Foo
{
float a;
float b;
};
layout(location = 0) out vec4 FragColor;
layout(location = 0) flat in mediump int _line;
float lut[4];
Foo foos[2];
void main()
{
lut = float[](1.0, 4.0, 3.0, 2.0);
foos = Foo[](Foo(10.0, 20.0), Foo(30.0, 40.0));
FragColor = vec4(lut[_line]);
FragColor += vec4(foos[_line].a * (foos[1 - _line].a));
}

View File

@ -0,0 +1,20 @@
#version 310 es
precision mediump float;
float lut[4] = float[](1.0, 4.0, 3.0, 2.0);
struct Foo
{
float a;
float b;
};
Foo foos[2] = Foo[](Foo(10.0, 20.0), Foo(30.0, 40.0));
layout(location = 0) out vec4 FragColor;
layout(location = 0) flat in int line;
void main()
{
FragColor = vec4(lut[line]);
FragColor += foos[line].a * foos[1 - line].a;
}

View File

@ -0,0 +1,9 @@
#version 450
layout(set = 0, binding = 0) uniform texture2D uTex;
layout(set = 0, binding = 1) uniform sampler uSampler;
layout(location = 0) out ivec2 FooOut;
void main()
{
FooOut = textureSize(sampler2D(uTex, uSampler), 0);
}

View File

@ -0,0 +1,29 @@
#version 310 es
layout(local_size_x = 4, local_size_y = 4) in;
shared float foo[4][4];
layout(binding = 0, std430) buffer SSBO
{
float out_data[];
};
void work()
{
foo[gl_LocalInvocationID.x][gl_LocalInvocationID.y] = float(gl_LocalInvocationIndex);
memoryBarrierShared();
barrier();
float x = 0.0;
x += foo[gl_LocalInvocationID.x][0];
x += foo[gl_LocalInvocationID.x][1];
x += foo[gl_LocalInvocationID.x][2];
x += foo[gl_LocalInvocationID.x][3];
out_data[gl_GlobalInvocationID.x] = x;
}
void main()
{
work();
}

View File

@ -0,0 +1,20 @@
#version 310 es
precision mediump float;
float lut[4] = float[](1.0, 4.0, 3.0, 2.0);
struct Foo
{
float a;
float b;
};
Foo foos[2] = Foo[](Foo(10.0, 20.0), Foo(30.0, 40.0));
layout(location = 0) out vec4 FragColor;
layout(location = 0) flat in int line;
void main()
{
FragColor = vec4(lut[line]);
FragColor += foos[line].a * foos[1 - line].a;
}

View File

@ -0,0 +1,132 @@
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 3
; Bound: 279
; Schema: 0
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Fragment %main "main" %IN_p %IN_uv %_entryPointOutput
OpExecutionMode %main OriginUpperLeft
OpSource HLSL 500
OpName %main "main"
OpName %Params "Params"
OpMemberName %Params 0 "TextureSize"
OpMemberName %Params 1 "Params1"
OpMemberName %Params 2 "Params2"
OpMemberName %Params 3 "Params3"
OpMemberName %Params 4 "Params4"
OpMemberName %Params 5 "Bloom"
OpName %CB1 "CB1"
OpMemberName %CB1 0 "CB1"
OpName %_ ""
OpName %mapSampler "mapSampler"
OpName %mapTexture "mapTexture"
OpName %IN_p "IN.p"
OpName %IN_uv "IN.uv"
OpName %_entryPointOutput "@entryPointOutput"
OpMemberDecorate %Params 0 Offset 0
OpMemberDecorate %Params 1 Offset 16
OpMemberDecorate %Params 2 Offset 32
OpMemberDecorate %Params 3 Offset 48
OpMemberDecorate %Params 4 Offset 64
OpMemberDecorate %Params 5 Offset 80
OpMemberDecorate %CB1 0 Offset 0
OpDecorate %CB1 Block
OpDecorate %_ DescriptorSet 0
OpDecorate %_ Binding 1
OpDecorate %mapSampler DescriptorSet 1
OpDecorate %mapSampler Binding 2
OpDecorate %mapTexture DescriptorSet 1
OpDecorate %mapTexture Binding 2
OpDecorate %IN_p BuiltIn FragCoord
OpDecorate %IN_uv Location 0
OpDecorate %_entryPointOutput Location 0
%void = OpTypeVoid
%3 = OpTypeFunction %void
%float = OpTypeFloat 32
%v2float = OpTypeVector %float 2
%9 = OpTypeSampler
%11 = OpTypeImage %float 2D 0 0 0 1 Unknown
%v4float = OpTypeVector %float 4
%float_0_222222 = OpConstant %float 0.222222
%33 = OpTypeSampledImage %11
%uint = OpTypeInt 32 0
%float_80 = OpConstant %float 80
%float_0_0008 = OpConstant %float 0.0008
%float_8en05 = OpConstant %float 8e-05
%float_0_008 = OpConstant %float 0.008
%float_0 = OpConstant %float 0
%int = OpTypeInt 32 1
%int_n3 = OpConstant %int -3
%int_3 = OpConstant %int 3
%bool = OpTypeBool
%float_1 = OpConstant %float 1
%int_1 = OpConstant %int 1
%Params = OpTypeStruct %v4float %v4float %v4float %v4float %v4float %v4float
%CB1 = OpTypeStruct %Params
%_ptr_Uniform_CB1 = OpTypePointer Uniform %CB1
%_ = OpVariable %_ptr_Uniform_CB1 Uniform
%int_0 = OpConstant %int 0
%uint_3 = OpConstant %uint 3
%_ptr_Uniform_float = OpTypePointer Uniform %float
%_ptr_UniformConstant_9 = OpTypePointer UniformConstant %9
%mapSampler = OpVariable %_ptr_UniformConstant_9 UniformConstant
%_ptr_UniformConstant_11 = OpTypePointer UniformConstant %11
%mapTexture = OpVariable %_ptr_UniformConstant_11 UniformConstant
%_ptr_Input_v4float = OpTypePointer Input %v4float
%IN_p = OpVariable %_ptr_Input_v4float Input
%_ptr_Input_v2float = OpTypePointer Input %v2float
%IN_uv = OpVariable %_ptr_Input_v2float Input
%_ptr_Output_v4float = OpTypePointer Output %v4float
%_entryPointOutput = OpVariable %_ptr_Output_v4float Output
%main = OpFunction %void None %3
%5 = OpLabel
%158 = OpLoad %v2float %IN_uv
%178 = OpAccessChain %_ptr_Uniform_float %_ %int_0 %int_0 %uint_3
%179 = OpLoad %float %178
%180 = OpCompositeConstruct %v2float %float_0 %179
%184 = OpLoad %9 %mapSampler
%185 = OpLoad %11 %mapTexture
%204 = OpSampledImage %33 %185 %184
%206 = OpImageSampleImplicitLod %v4float %204 %158
%207 = OpCompositeExtract %float %206 1
%209 = OpFMul %float %207 %float_80
%210 = OpFMul %float %209 %float_0_0008
%211 = OpExtInst %float %1 FClamp %210 %float_8en05 %float_0_008
OpBranch %212
%212 = OpLabel
%276 = OpPhi %float %float_0 %5 %252 %218
%277 = OpPhi %float %float_0 %5 %255 %218
%278 = OpPhi %int %int_n3 %5 %257 %218
%217 = OpSLessThanEqual %bool %278 %int_3
OpLoopMerge %213 %218 None
OpBranchConditional %217 %218 %213
%218 = OpLabel
%220 = OpConvertSToF %float %278
%222 = OpFNegate %float %220
%224 = OpFMul %float %222 %220
%226 = OpFMul %float %224 %float_0_222222
%227 = OpExtInst %float %1 Exp %226
%230 = OpSampledImage %33 %185 %184
%234 = OpVectorTimesScalar %v2float %180 %220
%235 = OpFAdd %v2float %158 %234
%236 = OpImageSampleImplicitLod %v4float %230 %235
%273 = OpCompositeExtract %float %236 1
%241 = OpFSub %float %273 %207
%242 = OpExtInst %float %1 FAbs %241
%244 = OpFOrdLessThan %bool %242 %211
%245 = OpSelect %float %244 %float_1 %float_0
%246 = OpFMul %float %227 %245
%275 = OpCompositeExtract %float %236 0
%250 = OpFMul %float %275 %246
%252 = OpFAdd %float %276 %250
%255 = OpFAdd %float %277 %246
%257 = OpIAdd %int %278 %int_1
OpBranch %212
%213 = OpLabel
%260 = OpFDiv %float %276 %277
%190 = OpCompositeConstruct %v4float %260 %207 %float_0 %float_1
OpStore %_entryPointOutput %190
OpReturn
OpFunctionEnd

View File

@ -0,0 +1,20 @@
#version 310 es
precision mediump float;
float lut[4] = float[](1.0, 4.0, 3.0, 2.0);
struct Foo
{
float a;
float b;
};
Foo foos[2] = Foo[](Foo(10.0, 20.0), Foo(30.0, 40.0));
layout(location = 0) out vec4 FragColor;
layout(location = 0) flat in int line;
void main()
{
FragColor = vec4(lut[line]);
FragColor += foos[line].a * foos[1 - line].a;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2016-2017 ARM Limited
* Copyright 2016-2018 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright 2016-2017 ARM Limited
* Copyright 2016-2018 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright 2015-2017 ARM Limited
* Copyright 2015-2018 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright 2015-2017 ARM Limited
* Copyright 2015-2018 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright 2015-2017 ARM Limited
* Copyright 2015-2018 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright 2015-2017 ARM Limited
* Copyright 2015-2018 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright 2015-2017 ARM Limited
* Copyright 2015-2018 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright 2015-2017 ARM Limited
* Copyright 2015-2018 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -1634,10 +1634,10 @@ void CompilerGLSL::replace_illegal_names()
"iimageCubeArray", "image1D", "image1DArray", "image2D", "image2DArray", "image2DMS", "image2DMSArray", "image2DRect",
"image3D", "imageBuffer", "imageCube", "imageCubeArray", "in", "inline", "inout", "input", "int", "interface", "invariant",
"isampler1D", "isampler1DArray", "isampler2D", "isampler2DArray", "isampler2DMS", "isampler2DMSArray", "isampler2DRect",
"isampler3D", "isamplerBuffer", "isamplerCube", "isamplerCubeArray", "ivec2", "ivec3", "ivec4", "layout", "long", "lowp",
"mat2", "mat2x2", "mat2x3", "mat2x4", "mat3", "mat3x2", "mat3x3", "mat3x4", "mat4", "mat4x2", "mat4x3", "mat4x4", "mediump",
"namespace", "noinline", "noperspective", "out", "output", "packed", "partition", "patch", "precision", "public", "readonly",
"resource", "restrict", "return", "row_major", "sample", "sampler1D", "sampler1DArray", "sampler1DArrayShadow",
"isampler3D", "isamplerBuffer", "isamplerCube", "isamplerCubeArray", "ivec2", "ivec3", "ivec4", "layout", "line", "linear", "long", "lowp",
"mat2", "mat2x2", "mat2x3", "mat2x4", "mat3", "mat3x2", "mat3x3", "mat3x4", "mat4", "mat4x2", "mat4x3", "mat4x4", "matrix", "mediump",
"namespace", "noinline", "noperspective", "out", "output", "packed", "partition", "patch", "point", "precision", "public", "readonly",
"resource", "restrict", "return", "row_major", "sample", "sampler", "sampler1D", "sampler1DArray", "sampler1DArrayShadow",
"sampler1DShadow", "sampler2D", "sampler2DArray", "sampler2DArrayShadow", "sampler2DMS", "sampler2DMSArray",
"sampler2DRect", "sampler2DRectShadow", "sampler2DShadow", "sampler3D", "sampler3DRect", "samplerBuffer",
"samplerCube", "samplerCubeArray", "samplerCubeArrayShadow", "samplerCubeShadow", "short", "sizeof", "smooth", "static",
@ -2256,6 +2256,7 @@ string CompilerGLSL::to_expression(uint32_t id)
case TypeConstant:
{
auto &c = get<SPIRConstant>(id);
auto &type = get<SPIRType>(c.constant_type);
// WorkGroupSize may be a constant.
auto &dec = meta[c.self].decoration;
@ -2263,6 +2264,10 @@ string CompilerGLSL::to_expression(uint32_t id)
return builtin_to_glsl(dec.builtin_type, StorageClassGeneric);
else if (c.specialization && options.vulkan_semantics)
return to_name(id);
else if (type.basetype == SPIRType::Struct && !backend.can_declare_struct_inline)
return to_name(id);
else if (!type.array.empty() && !backend.can_declare_arrays_inline)
return to_name(id);
else
return constant_expression(c);
}
@ -5497,6 +5502,8 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction)
if (out_type.basetype == SPIRType::Struct && !backend.can_declare_struct_inline)
forward = false;
if (!out_type.array.empty() && !backend.can_declare_arrays_inline)
forward = false;
string constructor_op;
if (backend.use_initializer_list && composite)
@ -7881,11 +7888,29 @@ void CompilerGLSL::branch(uint32_t from, uint32_t to)
else
{
auto &from_block = get<SPIRBlock>(from);
auto &dominator = get<SPIRBlock>(from_block.loop_dominator);
bool outside_control_flow = false;
uint32_t loop_dominator = 0;
// For non-complex continue blocks, we implicitly branch to the continue block
// by having the continue block be part of the loop header in for (; ; continue-block).
bool outside_control_flow = block_is_outside_flow_control_from_block(dominator, from_block);
// FIXME: Refactor this to not use the old loop_dominator tracking.
if (from_block.merge_block)
{
// If we are a loop header, we don't set the loop dominator,
// so just use "self" here.
loop_dominator = from;
}
else if (from_block.loop_dominator != -1u)
{
loop_dominator = from_block.loop_dominator;
}
if (loop_dominator != 0)
{
auto &dominator = get<SPIRBlock>(loop_dominator);
// For non-complex continue blocks, we implicitly branch to the continue block
// by having the continue block be part of the loop header in for (; ; continue-block).
outside_control_flow = block_is_outside_flow_control_from_block(dominator, from_block);
}
// Some simplification for for-loops. We always end up with a useless continue;
// statement since we branch to a loop block.
@ -8265,6 +8290,10 @@ void CompilerGLSL::emit_block_chain(SPIRBlock &block)
bool emitted_for_loop_header = false;
// If we need to force temporaries for certain IDs due to continue blocks, do it before starting loop header.
// Need to sort these to ensure that reference output is stable.
sort(begin(block.declare_temporary), end(block.declare_temporary),
[](const pair<uint32_t, uint32_t> &a, const pair<uint32_t, uint32_t> &b) { return a.second < b.second; });
for (auto &tmp : block.declare_temporary)
{
auto flags = meta[tmp.second].decoration.decoration_flags;

View File

@ -1,5 +1,5 @@
/*
* Copyright 2015-2017 ARM Limited
* Copyright 2015-2018 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -323,6 +323,7 @@ protected:
bool use_initializer_list = false;
bool use_typed_initializer_list = false;
bool can_declare_struct_inline = true;
bool can_declare_arrays_inline = true;
bool native_row_major_matrix = true;
bool use_constructor_splatting = true;
bool boolean_mix_support = true;

View File

@ -1,5 +1,5 @@
/*
* Copyright 2016-2017 Robert Konrad
* Copyright 2016-2018 Robert Konrad
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -841,6 +841,34 @@ void CompilerHLSL::emit_builtin_variables()
}
}
void CompilerHLSL::emit_composite_constants()
{
// HLSL cannot declare structs or arrays inline, so we must move them out to
// global constants directly.
bool emitted = false;
for (auto &id : ids)
{
if (id.get_type() == TypeConstant)
{
auto &c = id.get<SPIRConstant>();
if (c.specialization)
continue;
auto &type = get<SPIRType>(c.constant_type);
if (type.basetype == SPIRType::Struct || !type.array.empty())
{
auto name = to_name(c.self);
statement("static const ", variable_decl(type, name), " = ", constant_expression(c), ";");
emitted = true;
}
}
}
if (emitted)
statement("");
}
void CompilerHLSL::emit_specialization_constants()
{
bool emitted = false;
@ -880,6 +908,8 @@ void CompilerHLSL::emit_resources()
{
auto &execution = get_entry_point();
replace_illegal_names();
emit_specialization_constants();
// Output all basic struct types which are not Block or BufferBlock as these are declared inplace
@ -898,6 +928,8 @@ void CompilerHLSL::emit_resources()
}
}
emit_composite_constants();
bool emitted = false;
// Output UBOs and SSBOs
@ -3088,8 +3120,11 @@ void CompilerHLSL::emit_instruction(const Instruction &instruction)
{
uint32_t result_type = ops[0];
uint32_t id = ops[1];
emit_op(result_type, id, to_expression(ops[2]), true, true);
// TODO: Maybe change this when separate samplers/images are supported
auto *combined = maybe_get<SPIRCombinedImageSampler>(ops[2]);
if (combined)
emit_op(result_type, id, to_expression(combined->image), true, true);
else
emit_op(result_type, id, to_expression(ops[2]), true, true);
break;
}
@ -3645,6 +3680,7 @@ string CompilerHLSL::compile()
backend.boolean_mix_support = false;
backend.can_swizzle_scalar = true;
backend.can_declare_struct_inline = false;
backend.can_declare_arrays_inline = false;
update_active_builtins();
analyze_sampler_comparison_states();

View File

@ -1,5 +1,5 @@
/*
* Copyright 2016-2017 Robert Konrad
* Copyright 2016-2018 Robert Konrad
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -91,6 +91,7 @@ private:
void emit_modern_uniform(const SPIRVariable &var);
void emit_legacy_uniform(const SPIRVariable &var);
void emit_specialization_constants();
void emit_composite_constants();
void emit_fixup() override;
std::string builtin_to_glsl(spv::BuiltIn builtin, spv::StorageClass storage) override;
std::string layout_for_member(const SPIRType &type, uint32_t index) override;

View File

@ -1,5 +1,5 @@
/*
* Copyright 2016-2017 The Brenwill Workshop Ltd.
* Copyright 2016-2018 The Brenwill Workshop Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -2692,7 +2692,19 @@ string CompilerMSL::entry_point_args(bool append_comma)
convert_to_string(nsi_var.first) + ")]]";
}
// Uniforms
// Output resources, sorted by resource index & type
// We need to sort to work around a bug on macOS 10.13 with NVidia drivers where switching between shaders
// with different order of buffers can result in issues with buffer assignments inside the driver.
struct Resource
{
Variant *id;
string name;
SPIRType::BaseType basetype;
uint32_t index;
};
vector<Resource> resources;
for (auto &id : ids)
{
if (id.get_type() == TypeVariable)
@ -2706,48 +2718,75 @@ string CompilerMSL::entry_point_args(bool append_comma)
var.storage == StorageClassPushConstant || var.storage == StorageClassStorageBuffer) &&
!is_hidden_variable(var))
{
switch (type.basetype)
if (type.basetype == SPIRType::SampledImage)
{
case SPIRType::Struct:
{
auto &m = meta.at(type.self);
if (m.members.size() == 0)
break;
if (!ep_args.empty())
ep_args += ", ";
ep_args += get_argument_address_space(var) + " " + type_to_glsl(type) + "& " + to_name(var_id);
ep_args += " [[buffer(" + convert_to_string(get_metal_resource_index(var, type.basetype)) + ")]]";
break;
}
case SPIRType::Sampler:
if (!ep_args.empty())
ep_args += ", ";
ep_args += type_to_glsl(type) + " " + to_name(var_id);
ep_args += " [[sampler(" + convert_to_string(get_metal_resource_index(var, type.basetype)) + ")]]";
break;
case SPIRType::Image:
if (!ep_args.empty())
ep_args += ", ";
ep_args += type_to_glsl(type, var_id) + " " + to_name(var_id);
ep_args += " [[texture(" + convert_to_string(get_metal_resource_index(var, type.basetype)) + ")]]";
break;
case SPIRType::SampledImage:
if (!ep_args.empty())
ep_args += ", ";
ep_args += type_to_glsl(type, var_id) + " " + to_name(var_id);
ep_args +=
" [[texture(" + convert_to_string(get_metal_resource_index(var, SPIRType::Image)) + ")]]";
resources.push_back(
{ &id, to_name(var_id), SPIRType::Image, get_metal_resource_index(var, SPIRType::Image) });
if (type.image.dim != DimBuffer)
{
ep_args += ", sampler " + to_sampler_expression(var_id);
ep_args +=
" [[sampler(" + convert_to_string(get_metal_resource_index(var, SPIRType::Sampler)) + ")]]";
}
break;
default:
break;
resources.push_back({ &id, to_sampler_expression(var_id), SPIRType::Sampler,
get_metal_resource_index(var, SPIRType::Sampler) });
}
else
{
resources.push_back(
{ &id, to_name(var_id), type.basetype, get_metal_resource_index(var, type.basetype) });
}
}
}
}
std::sort(resources.begin(), resources.end(), [](const Resource &lhs, const Resource &rhs) {
return tie(lhs.basetype, lhs.index) < tie(rhs.basetype, rhs.index);
});
for (auto &r : resources)
{
auto &var = r.id->get<SPIRVariable>();
auto &type = get<SPIRType>(var.basetype);
uint32_t var_id = var.self;
switch (r.basetype)
{
case SPIRType::Struct:
{
auto &m = meta.at(type.self);
if (m.members.size() == 0)
break;
if (!ep_args.empty())
ep_args += ", ";
ep_args += get_argument_address_space(var) + " " + type_to_glsl(type) + "& " + r.name;
ep_args += " [[buffer(" + convert_to_string(r.index) + ")]]";
break;
}
case SPIRType::Sampler:
if (!ep_args.empty())
ep_args += ", ";
ep_args += "sampler " + r.name;
ep_args += " [[sampler(" + convert_to_string(r.index) + ")]]";
break;
case SPIRType::Image:
if (!ep_args.empty())
ep_args += ", ";
ep_args += type_to_glsl(type, var_id) + " " + r.name;
ep_args += " [[texture(" + convert_to_string(r.index) + ")]]";
break;
default:
SPIRV_CROSS_THROW("Unexpected resource type");
break;
}
}
// Builtin variables
for (auto &id : ids)
{
if (id.get_type() == TypeVariable)
{
auto &var = id.get<SPIRVariable>();
uint32_t var_id = var.self;
if (var.storage == StorageClassInput && is_builtin_variable(var))
{
if (!ep_args.empty())
@ -2837,17 +2876,28 @@ string CompilerMSL::argument_decl(const SPIRFunction::Parameter &arg)
decl += "const ";
if (is_builtin_variable(var))
decl += builtin_type_decl((BuiltIn)get_decoration(arg.id, DecorationBuiltIn));
decl += builtin_type_decl(static_cast<BuiltIn>(get_decoration(arg.id, DecorationBuiltIn)));
else
decl += type_to_glsl(type, arg.id);
if (is_array(type))
decl += "*";
{
decl += " (&";
decl += to_name(var.self);
decl += ")";
decl += type_to_array_glsl(type);
}
else if (!pointer)
{
decl += "&";
decl += " ";
decl += to_name(var.self);
decl += " ";
decl += to_name(var.self);
}
else
{
decl += " ";
decl += to_name(var.self);
}
return decl;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2016-2017 The Brenwill Workshop Ltd.
* Copyright 2016-2018 The Brenwill Workshop Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

0
deps/SPIRV-Cross/test_shaders.sh vendored Normal file → Executable file
View File

0
deps/SPIRV-Cross/update_test_shaders.sh vendored Normal file → Executable file
View File

View File

@ -30,7 +30,7 @@
#endif
#include "glslang_util.h"
#ifdef HAVE_VULKAN
#if defined(HAVE_GLSLANG) && !defined(HAVE_GRIFFIN)
#include "glslang.hpp"
#endif
#include "../../verbosity.h"

View File

@ -372,49 +372,10 @@ bool slang_process(
vs->set_options(options);
ps->set_options(options);
std::vector<HLSLVertexAttributeRemap> vs_attrib_remap;
/* not exactly a vertex attribute but this remaps
* float2 FragCoord :TEXCOORD# to float4 FragCoord : SV_POSITION */
std::vector<HLSLVertexAttributeRemap> ps_attrib_remap;
/* "line" is a reserved keyword in hlsl
* maybe there is an easier way to rename a variable ? */
int id = 0;
while (true)
{
try
{
string name = vs->get_name(id);
if (name == "line" || name == "point" || name == "linear")
vs->set_name(id, string("var_") + name);
id++;
} catch (const std::exception& e)
{
break;
}
}
id = 0;
while (true)
{
try
{
string name = ps->get_name(id);
if (name == "line" || name == "point" || name == "linear")
ps->set_name(id, string("var_") + name);
id++;
} catch (const std::exception& e)
{
break;
}
}
VariableTypeRemapCallback ps_var_remap_cb = [&](const SPIRType& type,
const std::string& var_name,
std::string& name_of_type) {
@ -433,8 +394,7 @@ bool slang_process(
}
}
vs_code = vs->compile(vs_attrib_remap);
vs_code = vs->compile();
ps_code = ps->compile(ps_attrib_remap);
}
else if (shader_info->type == RARCH_SHADER_GLSL)