summaryrefslogtreecommitdiff
path: root/nand_opaquestip_planemask_clipmask.hlps
blob: 63a00acf26d9cb0e859aebe89c2827ccadb22fcc (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
/* Automatically generated file; do not edit */

/* nand shader for opaquestip with planemask and clipmask */

SamplerState point_sample;

Texture2D stipple : register(t0);
Texture2D clipmask : register(t1);
Texture2D<uint4> output : register(t2);

cbuffer colors :register(b0) {
    uint4 foreground;
    uint4 background;
    uint4 planemask;
}

cbuffer tile_stats :register(b1) {
    uint4 plane;
    uint2 tile_wh;
}

struct PS_INPUT {
    float2 tile_pos : TEXCOORD0;
    float2 clip_pos : TEXCOORD1;
    float2 out_pos : TEXCOORD2;
};

uint4 main(PS_INPUT input) : SV_TARGET
{
    // Test clip mask
    float4 cm = clipmask.Sample(point_sample, input.clip_pos);
    if (cm.r < 0.5) {
        discard;
        return 0;
    }

    uint4 color;

    // Load input color
    float4 pt = stipple.Sample(point_sample, input.tile_pos);
    color = foreground;
    if (pt.r < 0.5)
        color = background;

    // Load output color
    int3 pos;
    pos.xy = input.out_pos.xy;
    pos.z = 0;
    uint4 out_color = output.Load(pos);

    // rop
    color = ~color | ~out_color;

    // planemask
    color = (color & planemask) | (out_color & ~planemask);

    return color;
}