summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/shaders/Clear11.hlsl
blob: 48f5b427ec1ee6aa55ef056698321696c47d19d5 (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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
//
// Copyright (c) 2017 The ANGLE Project. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//

// Clear11.hlsl: Shaders for clearing RTVs and DSVs using draw calls and
// specifying float depth values and either float, uint or sint clear colors.
// Notes:
//  - UINT & SINT clears can only be compiled with FL10+
//  - VS_Clear_FL9 requires a VB to be bound with vertices to create
//    a primitive covering the entire surface (in clip co-ordinates)

// Constants
static const float2 g_Corners[6] =
{
    float2(-1.0f,  1.0f),
    float2( 1.0f, -1.0f),
    float2(-1.0f, -1.0f),
    float2(-1.0f,  1.0f),
    float2( 1.0f,  1.0f),
    float2( 1.0f, -1.0f),
};

// Vertex Shaders
void VS_Clear(in uint id : SV_VertexID,
              out float4 outPosition : SV_POSITION)
{
    float2 corner = g_Corners[id];
    outPosition = float4(corner.x, corner.y, 0.0f, 1.0f);
}

void VS_Multiview_Clear(in uint id : SV_VertexID,
                        in uint instanceID : SV_InstanceID,
                        out float4 outPosition : SV_POSITION,
                        out uint outLayerID : TEXCOORD0)
{
    float2 corner = g_Corners[id];
    outPosition = float4(corner.x, corner.y, 0.0f, 1.0f);
    outLayerID = instanceID;
}

void VS_Clear_FL9( in float4 inPosition : POSITION,
                   out float4 outPosition : SV_POSITION)
{
    outPosition = inPosition;
}

// Geometry shader for clearing multiview layered textures
struct GS_INPUT
{
    float4 inPosition : SV_Position;
    uint inLayerID : TEXCOORD0;
};

struct GS_OUTPUT
{
    float4 outPosition : SV_Position;
    uint outLayerID : SV_RenderTargetArrayIndex;
};

[maxvertexcount(3)]
void GS_Multiview_Clear(triangle GS_INPUT input[3], inout TriangleStream<GS_OUTPUT> outStream)
{
    GS_OUTPUT output = (GS_OUTPUT)0;
    for (int i = 0; i < 3; i++)
    {
        output.outPosition = input[i].inPosition;
        output.outLayerID = input[i].inLayerID;
        outStream.Append(output);
    }
    outStream.RestartStrip();
}

// Pixel Shader Constant Buffers
cbuffer ColorAndDepthDataFloat : register(b0)
{
    float4 color_Float   : packoffset(c0);
    float  zValueF_Float : packoffset(c1);
}

cbuffer ColorAndDepthDataSint : register(b0)
{
    int4  color_Sint   : packoffset(c0);
    float zValueF_Sint : packoffset(c1);
}

cbuffer ColorAndDepthDataUint : register(b0)
{
    uint4 color_Uint   : packoffset(c0);
    float zValueF_Uint : packoffset(c1);
}

cbuffer DepthOnlyData : register(b0)
{
    float zValue_Depth : packoffset(c1);
}

// Pixel Shader Output Structs
struct PS_OutputFloat_FL9
{
    float4 color0 : SV_TARGET0;
    float4 color1 : SV_TARGET1;
    float4 color2 : SV_TARGET2;
    float4 color3 : SV_TARGET3;
    float  depth  : SV_DEPTH;
};

struct PS_OutputFloat1
{
    float4 color0 : SV_TARGET0;
    float  depth  : SV_DEPTH;
};

struct PS_OutputFloat2
{
    float4 color0 : SV_TARGET0;
    float4 color1 : SV_TARGET1;
    float  depth  : SV_DEPTH;
};

struct PS_OutputFloat3
{
    float4 color0 : SV_TARGET0;
    float4 color1 : SV_TARGET1;
    float4 color2 : SV_TARGET2;
    float  depth  : SV_DEPTH;
};

struct PS_OutputFloat4
{
    float4 color0 : SV_TARGET0;
    float4 color1 : SV_TARGET1;
    float4 color2 : SV_TARGET2;
    float4 color3 : SV_TARGET3;
    float  depth  : SV_DEPTH;
};

struct PS_OutputFloat5
{
    float4 color0 : SV_TARGET0;
    float4 color1 : SV_TARGET1;
    float4 color2 : SV_TARGET2;
    float4 color3 : SV_TARGET3;
    float4 color4 : SV_TARGET4;
    float  depth  : SV_DEPTH;
};

struct PS_OutputFloat6
{
    float4 color0 : SV_TARGET0;
    float4 color1 : SV_TARGET1;
    float4 color2 : SV_TARGET2;
    float4 color3 : SV_TARGET3;
    float4 color4 : SV_TARGET4;
    float4 color5 : SV_TARGET5;
    float  depth  : SV_DEPTH;
};

struct PS_OutputFloat7
{
    float4 color0 : SV_TARGET0;
    float4 color1 : SV_TARGET1;
    float4 color2 : SV_TARGET2;
    float4 color3 : SV_TARGET3;
    float4 color4 : SV_TARGET4;
    float4 color5 : SV_TARGET5;
    float4 color6 : SV_TARGET6;
    float  depth  : SV_DEPTH;
};

struct PS_OutputFloat8
{
    float4 color0 : SV_TARGET0;
    float4 color1 : SV_TARGET1;
    float4 color2 : SV_TARGET2;
    float4 color3 : SV_TARGET3;
    float4 color4 : SV_TARGET4;
    float4 color5 : SV_TARGET5;
    float4 color6 : SV_TARGET6;
    float4 color7 : SV_TARGET7;
    float  depth  : SV_DEPTH;
};

struct PS_OutputUint1
{
    uint4 color0 : SV_TARGET0;
    float depth  : SV_DEPTH;
};

struct PS_OutputUint2
{
    uint4 color0 : SV_TARGET0;
    uint4 color1 : SV_TARGET1;
    float depth  : SV_DEPTH;
};

struct PS_OutputUint3
{
    uint4 color0 : SV_TARGET0;
    uint4 color1 : SV_TARGET1;
    uint4 color2 : SV_TARGET2;
    float depth  : SV_DEPTH;
};

struct PS_OutputUint4
{
    uint4 color0 : SV_TARGET0;
    uint4 color1 : SV_TARGET1;
    uint4 color2 : SV_TARGET2;
    uint4 color3 : SV_TARGET3;
    float depth  : SV_DEPTH;
};

struct PS_OutputUint5
{
    uint4 color0 : SV_TARGET0;
    uint4 color1 : SV_TARGET1;
    uint4 color2 : SV_TARGET2;
    uint4 color3 : SV_TARGET3;
    uint4 color4 : SV_TARGET4;
    float depth  : SV_DEPTH;
};

struct PS_OutputUint6
{
    uint4 color0 : SV_TARGET0;
    uint4 color1 : SV_TARGET1;
    uint4 color2 : SV_TARGET2;
    uint4 color3 : SV_TARGET3;
    uint4 color4 : SV_TARGET4;
    uint4 color5 : SV_TARGET5;
    float depth  : SV_DEPTH;
};

struct PS_OutputUint7
{
    uint4 color0 : SV_TARGET0;
    uint4 color1 : SV_TARGET1;
    uint4 color2 : SV_TARGET2;
    uint4 color3 : SV_TARGET3;
    uint4 color4 : SV_TARGET4;
    uint4 color5 : SV_TARGET5;
    uint4 color6 : SV_TARGET6;
    float depth  : SV_DEPTH;
};

struct PS_OutputUint8
{
    uint4 color0 : SV_TARGET0;
    uint4 color1 : SV_TARGET1;
    uint4 color2 : SV_TARGET2;
    uint4 color3 : SV_TARGET3;
    uint4 color4 : SV_TARGET4;
    uint4 color5 : SV_TARGET5;
    uint4 color6 : SV_TARGET6;
    uint4 color7 : SV_TARGET7;
    float depth  : SV_DEPTH;
};

struct PS_OutputSint1
{
    int4 color0 : SV_TARGET0;
    float depth : SV_DEPTH;
};

struct PS_OutputSint2
{
    int4 color0 : SV_TARGET0;
    int4 color1 : SV_TARGET1;
    float depth : SV_DEPTH;
};

struct PS_OutputSint3
{
    int4 color0 : SV_TARGET0;
    int4 color1 : SV_TARGET1;
    int4 color2 : SV_TARGET2;
    float depth : SV_DEPTH;
};

struct PS_OutputSint4
{
    int4 color0 : SV_TARGET0;
    int4 color1 : SV_TARGET1;
    int4 color2 : SV_TARGET2;
    int4 color3 : SV_TARGET3;
    float depth : SV_DEPTH;
};

struct PS_OutputSint5
{
    int4 color0 : SV_TARGET0;
    int4 color1 : SV_TARGET1;
    int4 color2 : SV_TARGET2;
    int4 color3 : SV_TARGET3;
    int4 color4 : SV_TARGET4;
    float depth : SV_DEPTH;
};

struct PS_OutputSint6
{
    int4 color0 : SV_TARGET0;
    int4 color1 : SV_TARGET1;
    int4 color2 : SV_TARGET2;
    int4 color3 : SV_TARGET3;
    int4 color4 : SV_TARGET4;
    int4 color5 : SV_TARGET5;
    float depth : SV_DEPTH;
};

struct PS_OutputSint7
{
    int4 color0 : SV_TARGET0;
    int4 color1 : SV_TARGET1;
    int4 color2 : SV_TARGET2;
    int4 color3 : SV_TARGET3;
    int4 color4 : SV_TARGET4;
    int4 color5 : SV_TARGET5;
    int4 color6 : SV_TARGET6;
    float depth : SV_DEPTH;
};

struct PS_OutputSint8
{
    int4 color0 : SV_TARGET0;
    int4 color1 : SV_TARGET1;
    int4 color2 : SV_TARGET2;
    int4 color3 : SV_TARGET3;
    int4 color4 : SV_TARGET4;
    int4 color5 : SV_TARGET5;
    int4 color6 : SV_TARGET6;
    int4 color7 : SV_TARGET7;
    float depth : SV_DEPTH;
};

struct PS_OutputDepth
{
    float depth : SV_DEPTH;
};

// Pixel Shaders
PS_OutputFloat_FL9 PS_ClearFloat_FL9(in float4 inPosition : SV_POSITION)
{
    PS_OutputFloat_FL9 outData;
    outData.color0 = color_Float;
    outData.color1 = color_Float;
    outData.color2 = color_Float;
    outData.color3 = color_Float;
    outData.depth  = zValueF_Float;
    return outData;
}

PS_OutputFloat1 PS_ClearFloat1(in float4 inPosition : SV_POSITION)
{
    PS_OutputFloat1 outData;
    outData.color0 = color_Float;
    outData.depth  = zValueF_Float;
    return outData;
}

PS_OutputFloat2 PS_ClearFloat2(in float4 inPosition : SV_POSITION)
{
    PS_OutputFloat2 outData;
    outData.color0 = color_Float;
    outData.color1 = color_Float;
    outData.depth  = zValueF_Float;
    return outData;
}

PS_OutputFloat3 PS_ClearFloat3(in float4 inPosition : SV_POSITION)
{
    PS_OutputFloat3 outData;
    outData.color0 = color_Float;
    outData.color1 = color_Float;
    outData.color2 = color_Float;
    outData.depth  = zValueF_Float;
    return outData;
}

PS_OutputFloat4 PS_ClearFloat4(in float4 inPosition : SV_POSITION)
{
    PS_OutputFloat4 outData;
    outData.color0 = color_Float;
    outData.color1 = color_Float;
    outData.color2 = color_Float;
    outData.color3 = color_Float;
    outData.depth  = zValueF_Float;
    return outData;
}

PS_OutputFloat5 PS_ClearFloat5(in float4 inPosition : SV_POSITION)
{
    PS_OutputFloat5 outData;
    outData.color0 = color_Float;
    outData.color1 = color_Float;
    outData.color2 = color_Float;
    outData.color3 = color_Float;
    outData.color4 = color_Float;
    outData.depth  = zValueF_Float;
    return outData;
}

PS_OutputFloat6 PS_ClearFloat6(in float4 inPosition : SV_POSITION)
{
    PS_OutputFloat6 outData;
    outData.color0 = color_Float;
    outData.color1 = color_Float;
    outData.color2 = color_Float;
    outData.color3 = color_Float;
    outData.color4 = color_Float;
    outData.color5 = color_Float;
    outData.depth  = zValueF_Float;
    return outData;
}

PS_OutputFloat7 PS_ClearFloat7(in float4 inPosition : SV_POSITION)
{
    PS_OutputFloat7 outData;
    outData.color0 = color_Float;
    outData.color1 = color_Float;
    outData.color2 = color_Float;
    outData.color3 = color_Float;
    outData.color4 = color_Float;
    outData.color5 = color_Float;
    outData.color6 = color_Float;
    outData.depth  = zValueF_Float;
    return outData;
}

PS_OutputFloat8 PS_ClearFloat8(in float4 inPosition : SV_POSITION)
{
    PS_OutputFloat8 outData;
    outData.color0 = color_Float;
    outData.color1 = color_Float;
    outData.color2 = color_Float;
    outData.color3 = color_Float;
    outData.color4 = color_Float;
    outData.color5 = color_Float;
    outData.color6 = color_Float;
    outData.color7 = color_Float;
    outData.depth  = zValueF_Float;
    return outData;
}

PS_OutputUint1 PS_ClearUint1(in float4 inPosition : SV_POSITION)
{
    PS_OutputUint1 outData;
    outData.color0 = color_Uint;
    outData.depth = zValueF_Uint;
    return outData;
}

PS_OutputUint2 PS_ClearUint2(in float4 inPosition : SV_POSITION)
{
    PS_OutputUint2 outData;
    outData.color0 = color_Uint;
    outData.color1 = color_Uint;
    outData.depth = zValueF_Uint;
    return outData;
}

PS_OutputUint3 PS_ClearUint3(in float4 inPosition : SV_POSITION)
{
    PS_OutputUint3 outData;
    outData.color0 = color_Uint;
    outData.color1 = color_Uint;
    outData.color2 = color_Uint;
    outData.depth = zValueF_Uint;
    return outData;
}

PS_OutputUint4 PS_ClearUint4(in float4 inPosition : SV_POSITION)
{
    PS_OutputUint4 outData;
    outData.color0 = color_Uint;
    outData.color1 = color_Uint;
    outData.color2 = color_Uint;
    outData.color3 = color_Uint;
    outData.depth = zValueF_Uint;
    return outData;
}

PS_OutputUint5 PS_ClearUint5(in float4 inPosition : SV_POSITION)
{
    PS_OutputUint5 outData;
    outData.color0 = color_Uint;
    outData.color1 = color_Uint;
    outData.color2 = color_Uint;
    outData.color3 = color_Uint;
    outData.color4 = color_Uint;
    outData.depth = zValueF_Uint;
    return outData;
}

PS_OutputUint6 PS_ClearUint6(in float4 inPosition : SV_POSITION)
{
    PS_OutputUint6 outData;
    outData.color0 = color_Uint;
    outData.color1 = color_Uint;
    outData.color2 = color_Uint;
    outData.color3 = color_Uint;
    outData.color4 = color_Uint;
    outData.color5 = color_Uint;
    outData.depth = zValueF_Uint;
    return outData;
}

PS_OutputUint7 PS_ClearUint7(in float4 inPosition : SV_POSITION)
{
    PS_OutputUint7 outData;
    outData.color0 = color_Uint;
    outData.color1 = color_Uint;
    outData.color2 = color_Uint;
    outData.color3 = color_Uint;
    outData.color4 = color_Uint;
    outData.color5 = color_Uint;
    outData.color6 = color_Uint;
    outData.depth = zValueF_Uint;
    return outData;
}

PS_OutputUint8 PS_ClearUint8(in float4 inPosition : SV_POSITION)
{
    PS_OutputUint8 outData;
    outData.color0 = color_Uint;
    outData.color1 = color_Uint;
    outData.color2 = color_Uint;
    outData.color3 = color_Uint;
    outData.color4 = color_Uint;
    outData.color5 = color_Uint;
    outData.color6 = color_Uint;
    outData.color7 = color_Uint;
    outData.depth = zValueF_Uint;
    return outData;
}

PS_OutputSint1 PS_ClearSint1(in float4 inPosition : SV_POSITION)
{
    PS_OutputSint1 outData;
    outData.color0 = color_Sint;
    outData.depth = zValueF_Sint;
    return outData;
}

PS_OutputSint2 PS_ClearSint2(in float4 inPosition : SV_POSITION)
{
    PS_OutputSint2 outData;
    outData.color0 = color_Sint;
    outData.color1 = color_Sint;
    outData.depth = zValueF_Sint;
    return outData;
}

PS_OutputSint3 PS_ClearSint3(in float4 inPosition : SV_POSITION)
{
    PS_OutputSint3 outData;
    outData.color0 = color_Sint;
    outData.color1 = color_Sint;
    outData.color2 = color_Sint;
    outData.depth = zValueF_Sint;
    return outData;
}

PS_OutputSint4 PS_ClearSint4(in float4 inPosition : SV_POSITION)
{
    PS_OutputSint4 outData;
    outData.color0 = color_Sint;
    outData.color1 = color_Sint;
    outData.color2 = color_Sint;
    outData.color3 = color_Sint;
    outData.depth = zValueF_Sint;
    return outData;
}

PS_OutputSint5 PS_ClearSint5(in float4 inPosition : SV_POSITION)
{
    PS_OutputSint5 outData;
    outData.color0 = color_Sint;
    outData.color1 = color_Sint;
    outData.color2 = color_Sint;
    outData.color3 = color_Sint;
    outData.color4 = color_Sint;
    outData.depth = zValueF_Sint;
    return outData;
}

PS_OutputSint6 PS_ClearSint6(in float4 inPosition : SV_POSITION)
{
    PS_OutputSint6 outData;
    outData.color0 = color_Sint;
    outData.color1 = color_Sint;
    outData.color2 = color_Sint;
    outData.color3 = color_Sint;
    outData.color4 = color_Sint;
    outData.color5 = color_Sint;
    outData.depth = zValueF_Sint;
    return outData;
}

PS_OutputSint7 PS_ClearSint7(in float4 inPosition : SV_POSITION)
{
    PS_OutputSint7 outData;
    outData.color0 = color_Sint;
    outData.color1 = color_Sint;
    outData.color2 = color_Sint;
    outData.color3 = color_Sint;
    outData.color4 = color_Sint;
    outData.color5 = color_Sint;
    outData.color6 = color_Sint;
    outData.depth = zValueF_Sint;
    return outData;
}

PS_OutputSint8 PS_ClearSint8(in float4 inPosition : SV_POSITION)
{
    PS_OutputSint8 outData;
    outData.color0 = color_Sint;
    outData.color1 = color_Sint;
    outData.color2 = color_Sint;
    outData.color3 = color_Sint;
    outData.color4 = color_Sint;
    outData.color5 = color_Sint;
    outData.color6 = color_Sint;
    outData.color7 = color_Sint;
    outData.depth = zValueF_Sint;
    return outData;
}

PS_OutputDepth PS_ClearDepth(in float4 inPosition : SV_POSITION)
{
    PS_OutputDepth outData;
    outData.depth = zValue_Depth;
    return outData;
}