2019-03-14 09:29:34 +00:00
|
|
|
#pragma clang diagnostic ignored "-Wmissing-prototypes"
|
|
|
|
|
|
|
|
#include <metal_stdlib>
|
|
|
|
#include <simd/simd.h>
|
|
|
|
|
|
|
|
using namespace metal;
|
|
|
|
|
|
|
|
struct SSBO
|
|
|
|
{
|
|
|
|
float4 ssbo;
|
|
|
|
};
|
|
|
|
|
2019-03-15 10:29:17 +00:00
|
|
|
struct SSBOs
|
|
|
|
{
|
|
|
|
float4 ssbo;
|
|
|
|
};
|
|
|
|
|
2019-03-14 09:29:34 +00:00
|
|
|
struct Push
|
|
|
|
{
|
|
|
|
float4 push;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct UBO
|
|
|
|
{
|
|
|
|
float4 ubo;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct UBOs
|
|
|
|
{
|
|
|
|
float4 ubo;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct spvDescriptorSetBuffer0
|
|
|
|
{
|
2019-06-21 10:44:33 +00:00
|
|
|
texture2d<float> uTexture [[id(0)]];
|
|
|
|
sampler uTextureSmplr [[id(1)]];
|
|
|
|
array<texture2d<float>, 2> uTextures [[id(2)]];
|
|
|
|
array<sampler, 2> uTexturesSmplr [[id(4)]];
|
|
|
|
constant UBO* v_90 [[id(6)]];
|
2019-03-14 09:29:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct spvDescriptorSetBuffer1
|
|
|
|
{
|
2019-06-21 10:44:33 +00:00
|
|
|
array<texture2d<float>, 4> uTexture2 [[id(0)]];
|
|
|
|
array<sampler, 2> uSampler [[id(4)]];
|
|
|
|
device SSBO* v_60 [[id(6)]];
|
2019-10-24 11:57:05 +00:00
|
|
|
const device SSBOs* ssbos [[id(7)]][2];
|
2019-03-14 09:29:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct spvDescriptorSetBuffer2
|
|
|
|
{
|
2019-10-24 11:57:05 +00:00
|
|
|
constant UBOs* ubos [[id(0)]][4];
|
2019-03-14 09:29:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct main0_out
|
|
|
|
{
|
|
|
|
float4 FragColor [[color(0)]];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct main0_in
|
|
|
|
{
|
|
|
|
float2 vUV [[user(locn0)]];
|
|
|
|
};
|
|
|
|
|
2019-09-17 19:11:19 +00:00
|
|
|
static inline __attribute__((always_inline))
|
2022-01-18 13:34:00 +00:00
|
|
|
float4 sample_in_function2(texture2d<float> uTexture, sampler uTextureSmplr, thread float2& vUV, constant array<texture2d<float>, 4>& uTexture2, constant array<sampler, 2>& uSampler, constant array<texture2d<float>, 2>& uTextures, constant array<sampler, 2>& uTexturesSmplr, device SSBO& v_60, const device SSBOs* constant (&ssbos)[2], constant Push& registers)
|
2019-03-14 09:29:34 +00:00
|
|
|
{
|
|
|
|
float4 ret = uTexture.sample(uTextureSmplr, vUV);
|
|
|
|
ret += uTexture2[2].sample(uSampler[1], vUV);
|
|
|
|
ret += uTextures[1].sample(uTexturesSmplr[1], vUV);
|
|
|
|
ret += v_60.ssbo;
|
2019-03-15 10:29:17 +00:00
|
|
|
ret += ssbos[0]->ssbo;
|
2019-03-14 09:29:34 +00:00
|
|
|
ret += registers.push;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2019-09-17 19:11:19 +00:00
|
|
|
static inline __attribute__((always_inline))
|
2022-01-18 13:34:00 +00:00
|
|
|
float4 sample_in_function(texture2d<float> uTexture, sampler uTextureSmplr, thread float2& vUV, constant array<texture2d<float>, 4>& uTexture2, constant array<sampler, 2>& uSampler, constant array<texture2d<float>, 2>& uTextures, constant array<sampler, 2>& uTexturesSmplr, device SSBO& v_60, const device SSBOs* constant (&ssbos)[2], constant Push& registers, constant UBO& v_90, constant UBOs* constant (&ubos)[4])
|
2019-03-14 09:29:34 +00:00
|
|
|
{
|
2019-03-15 10:29:17 +00:00
|
|
|
float4 ret = sample_in_function2(uTexture, uTextureSmplr, vUV, uTexture2, uSampler, uTextures, uTexturesSmplr, v_60, ssbos, registers);
|
|
|
|
ret += v_90.ubo;
|
2019-03-14 09:29:34 +00:00
|
|
|
ret += ubos[0]->ubo;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
fragment main0_out main0(main0_in in [[stage_in]], constant spvDescriptorSetBuffer0& spvDescriptorSet0 [[buffer(0)]], constant spvDescriptorSetBuffer1& spvDescriptorSet1 [[buffer(1)]], constant spvDescriptorSetBuffer2& spvDescriptorSet2 [[buffer(2)]], constant Push& registers [[buffer(3)]])
|
|
|
|
{
|
|
|
|
main0_out out = {};
|
2019-03-15 10:29:17 +00:00
|
|
|
out.FragColor = sample_in_function(spvDescriptorSet0.uTexture, spvDescriptorSet0.uTextureSmplr, in.vUV, spvDescriptorSet1.uTexture2, spvDescriptorSet1.uSampler, spvDescriptorSet0.uTextures, spvDescriptorSet0.uTexturesSmplr, (*spvDescriptorSet1.v_60), spvDescriptorSet1.ssbos, registers, (*spvDescriptorSet0.v_90), spvDescriptorSet2.ubos);
|
|
|
|
out.FragColor += (*spvDescriptorSet0.v_90).ubo;
|
2019-03-14 09:29:34 +00:00
|
|
|
out.FragColor += (*spvDescriptorSet1.v_60).ssbo;
|
|
|
|
out.FragColor += spvDescriptorSet2.ubos[1]->ubo;
|
|
|
|
out.FragColor += registers.push;
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|