summaryrefslogtreecommitdiffstats
path: root/tests/bugs/gh-6504-linker.slang
blob: e48c71473dd4d193214e79bffb05ddf7d7408287 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
//TEST:SIMPLE(filecheck=CHECK): -target spirv

// CHECK: OpEntryPoint

static extern const bool _AlphaTest = false;
static extern const bool _BaseColorMap = false;
static extern const bool _NormalMap = false;
static extern const bool _EmissiveMap = false;
static extern const bool _MetallicRoughnessMap = false;

interface IVertexInput
{
    float3 GetPosition();
    float3 GetNormal();
    float4 GetTangent();
    float2 GetUV();
    float4 GetBone();
}

struct StandardVertexInput : IVertexInput
{
    float3 position;
    float3 normal;
    float4 tangent;
    float2 uv;

    float3 GetPosition() {return position;}
    float3 GetNormal() {return normal;}
    float4 GetTangent() {return tangent;}
    float2 GetUV() { return uv;}
    float4 GetBone() { return float4(0,0,0,0);}
}

extern struct VertexInput : IVertexInput = StandardVertexInput;

struct PushConstant
{
    float4x4 model;
    float4x4 invTspModel;
} 

[vk_push_constant]
PushConstant pconst;

struct VertexOutput
{
    float4 position : SV_Position;
    float3 positionWS;
    float3 normalWS;
    float3 tangentWS;
    float3 bitangentWS;
    float2 uv;
}



VertexOutput SceneLitVertex(VertexInput input)
{
    VertexOutput output;
    float3 vertexPos = input.GetPosition();
    float3 normal = input.GetNormal();
    float4 tangent = input.GetTangent();

    output.positionWS = mul(pconst.model, float4(vertexPos, 1)).xyz;

    matrix<float,3,3> model33 = (float3x3)pconst.invTspModel;
    output.normalWS = mul(model33, normal).xyz;
    output.tangentWS = mul(model33, tangent.xyz);
    output.bitangentWS = tangent.w * cross(output.normalWS, output.tangentWS);
    output.uv = input.GetUV();

    float4x4 vp = {};
    output.position = mul(vp, float4(output.positionWS, 1));

    return output;
}


[shader("vertex")]
VertexOutput VertexMain(VertexInput input)
{
    return SceneLitVertex(input);
}

struct PerMaterial
{
    float4 baseColorFactor;
    float4 emissive;
    float roughness;
    float metallic;
    float alphaCutoff;

    Sampler2D baseColorTex;
    Sampler2D normalMap;
    Sampler2D metallicRoughnessMap;
    Sampler2D emissiveMap;
};

ParameterBlock<PerMaterial> perMaterial;

struct FragmentOutput
{
    float4 color : SV_Target0;
}

FragmentOutput SceneLitFragment(VertexOutput input)
{
    FragmentOutput output;
    output.color = 0;

    return output;
}

[shader("fragment")]
FragmentOutput FragmentMain(VertexOutput input)
{
    return SceneLitFragment(input);
}