summaryrefslogtreecommitdiff
path: root/tests/spirv/depth-texture.slang
blob: 17204249e8e62e7bc0872ed6d00f66221a24e309 (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
//TEST:SIMPLE(filecheck=SPIRV): -target spirv
//TEST:SIMPLE(filecheck=SPIRV): -target spirv -entry psMain -stage pixel

// SPIRV: OpTypeImage %{{.*}} 2D 1 0 0 1 Unknown

__generic<let sampleCount : int = 0, let format : int = 0>
typealias DepthTexture2D = _Texture<
    float,
    __Shape2D,
    0, // isArray
    0, // isMS
    sampleCount,
    0, // access
    1, // isShadow
    0, // isCombined
    format
>;

[[vk::binding(0, 0)]] DepthTexture2D depthTexture : register(t0);
[[vk::binding(1, 0)]] SamplerComparisonState comparisonSampler : register(s0);

[[shader("pixel")]]
float4 psMain(
    float4 position : SV_POSITION,
    float2 texCoord : TEXCOORD0
) : SV_TARGET {
    float comparison = depthTexture.SampleCmp(
        comparisonSampler,
        texCoord,
        0.5
    );

    if (comparison != 0.0) {
        return float4(1.0, 1.0, 1.0, 1.0);
    } else {
        return float4(0.0, 0.0, 0.0, 1.0);
    }
}