summaryrefslogtreecommitdiff
path: root/contrib/SDL-3.2.8/src/render/vulkan/VULKAN_VertexShader.hlsl
blob: 373a179a2c07493bbf8e1f82b5cad455774b4324 (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
#pragma pack_matrix( row_major )

struct VertexShaderConstants
{
    matrix model;
    matrix projectionAndView;
};
[[vk::push_constant]]
ConstantBuffer<VertexShaderConstants> pushConstants;

struct VertexShaderInput
{
    float3 pos : POSITION;
    float2 tex : TEXCOORD0;
    float4 color : COLOR0;
};

struct VertexShaderOutput
{
    float4 pos : SV_POSITION;
    float2 tex : TEXCOORD0;
    float4 color : COLOR0;
    [[vk::builtin("PointSize")]] float pointSize : SV_PointSize;
};

VertexShaderOutput mainColor(VertexShaderInput input)
{
    VertexShaderOutput output;
    float4 pos = float4(input.pos, 1.0f);

    // Transform the vertex position into projected space.
    pos = mul(pos, pushConstants.model);
    pos = mul(pos, pushConstants.projectionAndView);
    output.pos = pos;

    // Pass through texture coordinates and color values without transformation
    output.tex = input.tex;
    output.color = input.color;

    // Always output pointSize so that this VS can be used with points
    output.pointSize = 1.0;

    return output;
}