summaryrefslogtreecommitdiffstats
path: root/tests/spirv/sv-vulkan-instance-vertex-id.slang
blob: c8654c8579e86a478c21f3b79ded62050040ce39 (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
//TEST:SIMPLE(filecheck=SPIRV): -entry main -stage vertex -target spirv -emit-spirv-directly
//TEST:SIMPLE(filecheck=GLSL): -entry main -stage vertex -target glsl
//TEST:SIMPLE(filecheck=METAL): -entry main -stage vertex -target metal
//TEST:SIMPLE(filecheck=WGSL): -entry main -stage vertex -target wgsl

struct VSInput
{
    uint vertexID : SV_VulkanVertexID;
    uint instanceID : SV_VulkanInstanceID;
};

struct VSOutput
{
    float4 position : SV_POSITION;
};

[shader("vertex")]
VSOutput main(VSInput input)
{
    VSOutput output;
    output.position = float4(input.vertexID + input.instanceID);

    // SPIRV-DAG: BuiltIn InstanceIndex
    // SPIRV-DAG: BuiltIn VertexIndex
    // SPIRV-NOT: BuiltIn BaseInstance
    // SPIRV-NOT: BuiltIn BaseVertex

    // GLSL-NOT: GL_ARB_shader_draw_parameters
    // GLSL-DAG: gl_VertexIndex
    // GLSL-NOT: gl_BaseVertex
    // GLSL-DAG: gl_InstanceIndex
    // GLSL-NOT: gl_BaseInstance

    // METAL-DAG: vertex_id
    // METAL-DAG: instance_id

    // WGSL-DAG: vertex_index
    // WGSL-DAG: instance_index

    return output;
}