File: spv.floatFetch.frag

package info (click to toggle)
glslang 16.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 51,084 kB
  • sloc: cpp: 90,714; yacc: 4,243; sh: 603; python: 305; ansic: 94; javascript: 74; makefile: 17
file content (941 lines) | stat: -rw-r--r-- 34,122 bytes parent folder | download | duplicates (6)
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
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
#version 450 core

#extension GL_ARB_sparse_texture2: enable
#extension GL_ARB_sparse_texture_clamp: enable
#extension GL_AMD_texture_gather_bias_lod: enable

layout(set = 0, binding =  0) uniform sampler1D            s1D;
layout(set = 0, binding =  1) uniform sampler2D            s2D;
layout(set = 0, binding =  2) uniform sampler3D            s3D;
layout(set = 0, binding =  3) uniform sampler2DRect        s2DRect;
layout(set = 0, binding =  4) uniform samplerCube          sCube;
layout(set = 0, binding =  5) uniform samplerBuffer        sBuffer;
layout(set = 0, binding =  6) uniform sampler2DMS          s2DMS;
layout(set = 0, binding =  7) uniform sampler1DArray       s1DArray;
layout(set = 0, binding =  8) uniform sampler2DArray       s2DArray;
layout(set = 0, binding =  9) uniform samplerCubeArray     sCubeArray;
layout(set = 0, binding = 10) uniform sampler2DMSArray     s2DMSArray;

layout(set = 0, binding = 11) uniform sampler1DShadow          s1DShadow;
layout(set = 0, binding = 12) uniform sampler2DShadow          s2DShadow;
layout(set = 0, binding = 13) uniform sampler2DRectShadow      s2DRectShadow;
layout(set = 0, binding = 14) uniform samplerCubeShadow        sCubeShadow;
layout(set = 0, binding = 15) uniform sampler1DArrayShadow     s1DArrayShadow;
layout(set = 0, binding = 16) uniform sampler2DArrayShadow     s2DArrayShadow;
layout(set = 0, binding = 17) uniform samplerCubeArrayShadow   sCubeArrayShadow;

layout(set = 1, binding =  0) layout(rgba16f) uniform image1D          i1D;
layout(set = 1, binding =  1) layout(rgba16f) uniform image2D          i2D;
layout(set = 1, binding =  2) layout(rgba16f) uniform image3D          i3D;
layout(set = 1, binding =  3) layout(rgba16f) uniform image2DRect      i2DRect;
layout(set = 1, binding =  4) layout(rgba16f) uniform imageCube        iCube;
layout(set = 1, binding =  5) layout(rgba16f) uniform image1DArray     i1DArray;
layout(set = 1, binding =  6) layout(rgba16f) uniform image2DArray     i2DArray;
layout(set = 1, binding =  7) layout(rgba16f) uniform imageCubeArray   iCubeArray;
layout(set = 1, binding =  8) layout(rgba16f) uniform imageBuffer      iBuffer;
layout(set = 1, binding =  9) layout(rgba16f) uniform image2DMS        i2DMS;
layout(set = 1, binding = 10) layout(rgba16f) uniform image2DMSArray   i2DMSArray;

layout(set = 2, binding =  0) uniform texture1D           t1D;
layout(set = 2, binding =  1) uniform texture2D           t2D;
layout(set = 2, binding =  2) uniform texture3D           t3D;
layout(set = 2, binding =  3) uniform texture2DRect       t2DRect;
layout(set = 2, binding =  4) uniform textureCube         tCube;
layout(set = 2, binding =  5) uniform texture1DArray      t1DArray;
layout(set = 2, binding =  6) uniform texture2DArray      t2DArray;
layout(set = 2, binding =  7) uniform textureCubeArray    tCubeArray;
layout(set = 2, binding =  8) uniform textureBuffer       tBuffer;
layout(set = 2, binding =  9) uniform texture2DMS         t2DMS;
layout(set = 2, binding = 10) uniform texture2DMSArray    t2DMSArray;

layout(set = 2, binding = 11) uniform sampler s;
layout(set = 2, binding = 12) uniform samplerShadow sShadow;

layout(set = 3, binding = 0, input_attachment_index = 0) uniform subpassInput   subpass;
layout(set = 3, binding = 1, input_attachment_index = 0) uniform subpassInputMS subpassMS;

layout(location =  0) in float c1;
layout(location =  1) in vec2  c2;
layout(location =  2) in vec3  c3;
layout(location =  3) in vec4  c4;

layout(location =  4) in float compare;
layout(location =  5) in float lod;
layout(location =  6) in float bias;
layout(location =  7) in float lodClamp;

layout(location =  8) in float dPdxy1;
layout(location =  9) in vec2  dPdxy2;
layout(location = 10) in vec3  dPdxy3;

const int   offset1 = 1;
const ivec2 offset2 = ivec2(1);
const ivec3 offset3 = ivec3(1);
const ivec2 offsets[4] = { offset2, offset2, offset2, offset2 };

layout(location = 0) out vec4 fragColor;

vec4 testTexture()
{
    vec4 texel = vec4(0.0);

    texel   += texture(s1D, c1);
    texel   += texture(s2D, c2);
    texel   += texture(s3D, c3);
    texel   += texture(sCube, c3);
    texel.x += texture(s1DShadow, c3);
    texel.x += texture(s2DShadow, c3);
    texel.x += texture(sCubeShadow, c4);
    texel   += texture(s1DArray, c2);
    texel   += texture(s2DArray, c3);
    texel   += texture(sCubeArray, c4);
    texel.x += texture(s1DArrayShadow, c3);
    texel.x += texture(s2DArrayShadow, c4);
    texel   += texture(s2DRect, c2);
    texel.x += texture(s2DRectShadow, c3);
    texel.x += texture(sCubeArrayShadow, c4, compare);

    return texel;
}

vec4 testTextureProj()
{
    vec4 texel = vec4(0.0);

    texel   += textureProj(s1D, c2);
    texel   += textureProj(s1D, c4);
    texel   += textureProj(s2D, c3);
    texel   += textureProj(s2D, c4);
    texel   += textureProj(s3D, c4);
    texel.x += textureProj(s1DShadow, c4);
    texel.x += textureProj(s2DShadow, c4);
    texel   += textureProj(s2DRect, c3);
    texel   += textureProj(s2DRect, c4);
    texel.x += textureProj(s2DRectShadow, c4);

    return texel;
}

vec4 testTextureLod()
{
    vec4 texel = vec4(0.0);

    texel   += textureLod(s1D, c1, lod);
    texel   += textureLod(s2D, c2, lod);
    texel   += textureLod(s3D, c3, lod);
    texel   += textureLod(sCube, c3, lod);
    texel.x += textureLod(s1DShadow, c3, lod);
    texel.x += textureLod(s2DShadow, c3, lod);
    texel   += textureLod(s1DArray, c2, lod);
    texel   += textureLod(s2DArray, c3, lod);
    texel.x += textureLod(s1DArrayShadow, c3, lod);
    texel   += textureLod(sCubeArray, c4, lod);

    return texel;
}

vec4 testTextureOffset()
{
    vec4 texel = vec4(0.0);

    texel   += textureOffset(s1D, c1, offset1);
    texel   += textureOffset(s2D, c2, offset2);
    texel   += textureOffset(s3D, c3, offset3);
    texel   += textureOffset(s2DRect, c2, offset2);
    texel.x += textureOffset(s2DRectShadow, c3, offset2);
    texel.x += textureOffset(s1DShadow, c3, offset1);
    texel.x += textureOffset(s2DShadow, c3, offset2);
    texel   += textureOffset(s1DArray, c2, offset1);
    texel   += textureOffset(s2DArray, c3, offset2);
    texel.x += textureOffset(s1DArrayShadow, c3, offset1);
    texel.x += textureOffset(s2DArrayShadow, c4, offset2);

    return texel;
}

vec4 testTextureProjOffset()
{
    vec4 texel = vec4(0.0);

    texel   += textureProjOffset(s1D, c2, offset1);
    texel   += textureProjOffset(s1D, c4, offset1);
    texel   += textureProjOffset(s2D, c3, offset2);
    texel   += textureProjOffset(s2D, c4, offset2);
    texel   += textureProjOffset(s3D, c4, offset3);
    texel   += textureProjOffset(s2DRect, c3, offset2);
    texel   += textureProjOffset(s2DRect, c4, offset2);
    texel.x += textureProjOffset(s2DRectShadow, c4, offset2);
    texel.x += textureProjOffset(s1DShadow, c4, offset1);
    texel.x += textureProjOffset(s2DShadow, c4, offset2);

    return texel;
}

vec4 testTextureLodOffset()
{
    vec4 texel = vec4(0.0);

    texel   += textureLodOffset(s1D, c1, lod, offset1);
    texel   += textureLodOffset(s2D, c2, lod, offset2);
    texel   += textureLodOffset(s3D, c3, lod, offset3);
    texel.x += textureLodOffset(s1DShadow, c3, lod, offset1);
    texel.x += textureLodOffset(s2DShadow, c3, lod, offset2);
    texel   += textureLodOffset(s1DArray, c2, lod, offset1);
    texel   += textureLodOffset(s2DArray, c3, lod, offset2);
    texel.x += textureLodOffset(s1DArrayShadow, c3, lod, offset1);

    return texel;
}

vec4 testTextureProjLodOffset()
{
    vec4 texel = vec4(0.0);

    texel   += textureProjLodOffset(s1D, c2, lod, offset1);
    texel   += textureProjLodOffset(s1D, c4, lod, offset1);
    texel   += textureProjLodOffset(s2D, c3, lod, offset2);
    texel   += textureProjLodOffset(s2D, c4, lod, offset2);
    texel   += textureProjLodOffset(s3D, c4, lod, offset3);
    texel.x += textureProjLodOffset(s1DShadow, c4, lod, offset1);
    texel.x += textureProjLodOffset(s2DShadow, c4, lod, offset2);

    return texel;
}

vec4 testTexelFetch()
{
    vec4 texel = vec4(0.0);

    texel   += texelFetch(s1D, int(c1), int(lod));
    texel   += texelFetch(s2D, ivec2(c2), int(lod));
    texel   += texelFetch(s3D, ivec3(c3), int(lod));
    texel   += texelFetch(s2DRect, ivec2(c2));
    texel   += texelFetch(s1DArray, ivec2(c2), int(lod));
    texel   += texelFetch(s2DArray, ivec3(c3), int(lod));
    texel   += texelFetch(sBuffer, int(c1));
    texel   += texelFetch(s2DMS, ivec2(c2), 1);
    texel   += texelFetch(s2DMSArray, ivec3(c3), 2);

    return texel;
}

vec4 testTexelFetchOffset()
{
    vec4 texel = vec4(0.0);

    texel   += texelFetchOffset(s1D, int(c1), int(lod), offset1);
    texel   += texelFetchOffset(s2D, ivec2(c2), int(lod), offset2);
    texel   += texelFetchOffset(s3D, ivec3(c3), int(lod), offset3);
    texel   += texelFetchOffset(s2DRect, ivec2(c2), offset2);
    texel   += texelFetchOffset(s1DArray, ivec2(c2), int(lod), offset1);
    texel   += texelFetchOffset(s2DArray, ivec3(c3), int(lod), offset2);

    return texel;
}

vec4 testTextureGrad()
{
    vec4 texel = vec4(0.0);

    texel   += textureGrad(s1D, c1, dPdxy1, dPdxy1);
    texel   += textureGrad(s2D, c2, dPdxy2, dPdxy2);
    texel   += textureGrad(s3D, c3, dPdxy3, dPdxy3);
    texel   += textureGrad(sCube, c3, dPdxy3, dPdxy3);
    texel   += textureGrad(s2DRect, c2, dPdxy2, dPdxy2);
    texel.x += textureGrad(s2DRectShadow, c3, dPdxy2, dPdxy2);
    texel.x += textureGrad(s1DShadow, c3, dPdxy1, dPdxy1);
    texel.x += textureGrad(s2DShadow, c3, dPdxy2, dPdxy2);
    texel.x += textureGrad(sCubeShadow, c4, dPdxy3, dPdxy3);
    texel   += textureGrad(s1DArray, c2, dPdxy1, dPdxy1);
    texel   += textureGrad(s2DArray, c3, dPdxy2, dPdxy2);
    texel.x += textureGrad(s1DArrayShadow, c3, dPdxy1, dPdxy1);
    texel.x += textureGrad(s2DArrayShadow, c4, dPdxy2, dPdxy2);
    texel   += textureGrad(sCubeArray, c4, dPdxy3, dPdxy3);

    return texel;
}

vec4 testTextureGradOffset()
{
    vec4 texel = vec4(0.0);

    texel   += textureGradOffset(s1D, c1, dPdxy1, dPdxy1, offset1);
    texel   += textureGradOffset(s2D, c2, dPdxy2, dPdxy2, offset2);
    texel   += textureGradOffset(s3D, c3, dPdxy3, dPdxy3, offset3);
    texel   += textureGradOffset(s2DRect, c2, dPdxy2, dPdxy2, offset2);
    texel.x += textureGradOffset(s2DRectShadow, c3, dPdxy2, dPdxy2, offset2);
    texel.x += textureGradOffset(s1DShadow, c3, dPdxy1, dPdxy1, offset1);
    texel.x += textureGradOffset(s2DShadow, c3, dPdxy2, dPdxy2, offset2);
    texel   += textureGradOffset(s1DArray, c2, dPdxy1, dPdxy1, offset1);
    texel   += textureGradOffset(s2DArray, c3, dPdxy2, dPdxy2, offset2);
    texel.x += textureGradOffset(s1DArrayShadow, c3, dPdxy1, dPdxy1, offset1);
    texel.x += textureGradOffset(s2DArrayShadow, c4, dPdxy2, dPdxy2, offset2);

    return texel;
}

vec4 testTextureProjGrad()
{
    vec4 texel = vec4(0.0);

    texel   += textureProjGrad(s1D, c2, dPdxy1, dPdxy1);
    texel   += textureProjGrad(s1D, c4, dPdxy1, dPdxy1);
    texel   += textureProjGrad(s2D, c3, dPdxy2, dPdxy2);
    texel   += textureProjGrad(s2D, c4, dPdxy2, dPdxy2);
    texel   += textureProjGrad(s3D, c4, dPdxy3, dPdxy3);
    texel   += textureProjGrad(s2DRect, c3, dPdxy2, dPdxy2);
    texel   += textureProjGrad(s2DRect, c4, dPdxy2, dPdxy2);
    texel.x += textureProjGrad(s2DRectShadow, c4, dPdxy2, dPdxy2);
    texel.x += textureProjGrad(s1DShadow, c4, dPdxy1, dPdxy1);
    texel.x += textureProjGrad(s2DShadow, c4, dPdxy2, dPdxy2);

    return texel;
}

vec4 testTextureProjGradoffset()
{
    vec4 texel = vec4(0.0);

    texel   += textureProjGradOffset(s1D, c2, dPdxy1, dPdxy1, offset1);
    texel   += textureProjGradOffset(s1D, c4, dPdxy1, dPdxy1, offset1);
    texel   += textureProjGradOffset(s2D, c3, dPdxy2, dPdxy2, offset2);
    texel   += textureProjGradOffset(s2D, c4, dPdxy2, dPdxy2, offset2);
    texel   += textureProjGradOffset(s2DRect, c3, dPdxy2, dPdxy2, offset2);
    texel   += textureProjGradOffset(s2DRect, c4, dPdxy2, dPdxy2, offset2);
    texel.x += textureProjGradOffset(s2DRectShadow, c4, dPdxy2, dPdxy2, offset2);
    texel   += textureProjGradOffset(s3D, c4, dPdxy3, dPdxy3, offset3);
    texel.x += textureProjGradOffset(s1DShadow, c4, dPdxy1, dPdxy1, offset1);
    texel.x += textureProjGradOffset(s2DShadow, c4, dPdxy2, dPdxy2, offset2);

    return texel;
}

vec4 testTextureGather()
{
    vec4 texel = vec4(0.0);

    texel   += textureGather(s2D, c2, 0);
    texel   += textureGather(s2DArray, c3, 0);
    texel   += textureGather(sCube, c3, 0);
    texel   += textureGather(sCubeArray, c4, 0);
    texel   += textureGather(s2DRect, c2, 0);
    texel   += textureGather(s2DShadow, c2, compare);
    texel   += textureGather(s2DArrayShadow, c3, compare);
    texel   += textureGather(sCubeShadow, c3, compare);
    texel   += textureGather(sCubeArrayShadow, c4, compare);
    texel   += textureGather(s2DRectShadow, c2, compare);

    return texel;
}

vec4 testTextureGatherOffset()
{
    vec4 texel = vec4(0.0);

    texel   += textureGatherOffset(s2D, c2, offset2, 0);
    texel   += textureGatherOffset(s2DArray, c3, offset2, 0);
    texel   += textureGatherOffset(s2DRect, c2, offset2, 0);
    texel   += textureGatherOffset(s2DShadow, c2, compare, offset2);
    texel   += textureGatherOffset(s2DArrayShadow, c3, compare, offset2);
    texel   += textureGatherOffset(s2DRectShadow, c2, compare, offset2);

    return texel;
}

vec4 testTextureGatherOffsets()
{
    vec4 texel = vec4(0.0);

    texel   += textureGatherOffsets(s2D, c2, offsets, 0);
    texel   += textureGatherOffsets(s2DArray, c3, offsets, 0);
    texel   += textureGatherOffsets(s2DRect, c2, offsets, 0);
    texel   += textureGatherOffsets(s2DShadow, c2, compare, offsets);
    texel   += textureGatherOffsets(s2DArrayShadow, c3, compare, offsets);
    texel   += textureGatherOffsets(s2DRectShadow, c2, compare, offsets);

    return texel;
}

vec4 testTextureGatherLod()
{
    vec4 texel = vec4(0.0);

    texel   += textureGatherLodAMD(s2D, c2, lod, 0);
    texel   += textureGatherLodAMD(s2DArray, c3, lod, 0);
    texel   += textureGatherLodAMD(sCube, c3, lod, 0);
    texel   += textureGatherLodAMD(sCubeArray, c4, lod, 0);

    return texel;
}

vec4 testTextureGatherLodOffset()
{
    vec4 texel = vec4(0.0);

    texel   += textureGatherLodOffsetAMD(s2D, c2, lod, offset2, 0);
    texel   += textureGatherLodOffsetAMD(s2DArray, c3, lod, offset2, 0);

    return texel;
}

vec4 testTextureGatherLodOffsets()
{
    vec4 texel = vec4(0.0);

    texel   += textureGatherLodOffsetsAMD(s2D, c2, lod, offsets, 0);
    texel   += textureGatherLodOffsetsAMD(s2DArray, c3, lod, offsets, 0);

    return texel;
}

ivec4 testTextureSize()
{
    ivec4 size = ivec4(0);

    size.x      += textureSize(s1D, int(lod));
    size.xy     += textureSize(s2D, int(lod));
    size.xyz    += textureSize(s3D, int(lod));
    size.xy     += textureSize(sCube, int(lod));
    size.x      += textureSize(s1DShadow, int(lod));
    size.xy     += textureSize(s2DShadow, int(lod));
    size.xy     += textureSize(sCubeShadow, int(lod));
    size.xyz    += textureSize(sCubeArray, int(lod));
    size.xyz    += textureSize(sCubeArrayShadow, int(lod));
    size.xy     += textureSize(s2DRect);
    size.xy     += textureSize(s2DRectShadow);
    size.xy     += textureSize(s1DArray, int(lod));
    size.xyz    += textureSize(s2DArray, int(lod));
    size.xy     += textureSize(s1DArrayShadow, int(lod));
    size.xyz    += textureSize(s2DArrayShadow, int(lod));
    size.x      += textureSize(sBuffer);
    size.xy     += textureSize(s2DMS);
    size.xyz    += textureSize(s2DMSArray);

    return size;
}

vec2 testTextureQueryLod()
{
    vec2 lod = vec2(0.0);

    lod  += textureQueryLod(s1D, c1);
    lod  += textureQueryLod(s2D, c2);
    lod  += textureQueryLod(s3D, c3);
    lod  += textureQueryLod(sCube, c3);
    lod  += textureQueryLod(s1DArray, c1);
    lod  += textureQueryLod(s2DArray, c2);
    lod  += textureQueryLod(sCubeArray, c3);
    lod  += textureQueryLod(s1DShadow, c1);
    lod  += textureQueryLod(s2DShadow, c2);
    lod  += textureQueryLod(sCubeArrayShadow, c3);
    lod  += textureQueryLod(s1DArrayShadow, c1);
    lod  += textureQueryLod(s2DArrayShadow, c2);
    lod  += textureQueryLod(sCubeArrayShadow, c3);

    return lod;
}

int testTextureQueryLevels()
{
    int levels = 0;

    levels  += textureQueryLevels(s1D);
    levels  += textureQueryLevels(s2D);
    levels  += textureQueryLevels(s3D);
    levels  += textureQueryLevels(sCube);
    levels  += textureQueryLevels(s1DShadow);
    levels  += textureQueryLevels(s2DShadow);
    levels  += textureQueryLevels(sCubeShadow);
    levels  += textureQueryLevels(sCubeArray);
    levels  += textureQueryLevels(sCubeArrayShadow);
    levels  += textureQueryLevels(s1DArray);
    levels  += textureQueryLevels(s2DArray);
    levels  += textureQueryLevels(s1DArrayShadow);
    levels  += textureQueryLevels(s2DArrayShadow);

    return levels;
}

int testTextureSamples()
{
    int samples = 0;

    samples += textureSamples(s2DMS);
    samples += textureSamples(s2DMSArray);

    return samples;
}

vec4 testImageLoad()
{
    vec4 texel = vec4(0.0);

    texel += imageLoad(i1D, int(c1));
    texel += imageLoad(i2D, ivec2(c2));
    texel += imageLoad(i3D, ivec3(c3));
    texel += imageLoad(i2DRect, ivec2(c2));
    texel += imageLoad(iCube, ivec3(c3));
    texel += imageLoad(iBuffer, int(c1));
    texel += imageLoad(i1DArray, ivec2(c2));
    texel += imageLoad(i2DArray, ivec3(c3));
    texel += imageLoad(iCubeArray, ivec3(c3));
    texel += imageLoad(i2DMS, ivec2(c2), 1);
    texel += imageLoad(i2DMSArray, ivec3(c3), 1);

    return texel;
}

void testImageStore(vec4 data)
{
    imageStore(i1D, int(c1), data);
    imageStore(i2D, ivec2(c2), data);
    imageStore(i3D, ivec3(c3), data);
    imageStore(i2DRect, ivec2(c2), data);
    imageStore(iCube, ivec3(c3), data);
    imageStore(iBuffer, int(c1), data);
    imageStore(i1DArray, ivec2(c2), data);
    imageStore(i2DArray, ivec3(c3), data);
    imageStore(iCubeArray, ivec3(c3), data);
    imageStore(i2DMS, ivec2(c2), 1, data);
    imageStore(i2DMSArray, ivec3(c3), 1, data);
}

vec4 testSparseTexture()
{
    vec4 texel = vec4(0.0);

    sparseTextureARB(s2D, c2, texel);
    sparseTextureARB(s3D, c3, texel);
    sparseTextureARB(sCube, c3, texel);
    sparseTextureARB(s2DShadow, c3, texel.x);
    sparseTextureARB(sCubeShadow, c4, texel.x);
    sparseTextureARB(s2DArray, c3, texel);
    sparseTextureARB(sCubeArray, c4, texel);
    sparseTextureARB(s2DArrayShadow, c4, texel.x);
    sparseTextureARB(s2DRect, c2, texel);
    sparseTextureARB(s2DRectShadow, c3, texel.x);
    sparseTextureARB(sCubeArrayShadow, c4, compare, texel.x);

    return texel;
}

vec4 testSparseTextureLod()
{
    vec4 texel = vec4(0.0);

    sparseTextureLodARB(s2D, c2, lod, texel);
    sparseTextureLodARB(s3D, c3, lod, texel);
    sparseTextureLodARB(sCube, c3, lod, texel);
    sparseTextureLodARB(s2DShadow, c3, lod, texel.x);
    sparseTextureLodARB(s2DArray, c3, lod, texel);
    sparseTextureLodARB(sCubeArray, c4, lod, texel);

    return texel;
}

vec4 testSparseTextureOffset()
{
    vec4 texel = vec4(0.0);

    sparseTextureOffsetARB(s2D, c2, offset2, texel);
    sparseTextureOffsetARB(s3D, c3, offset3, texel);
    sparseTextureOffsetARB(s2DRect, c2, offset2, texel);
    sparseTextureOffsetARB(s2DRectShadow, c3, offset2, texel.x);
    sparseTextureOffsetARB(s2DShadow, c3, offset2, texel.x);
    sparseTextureOffsetARB(s2DArray, c3, offset2, texel);
    sparseTextureOffsetARB(s2DArrayShadow, c4, offset2, texel.x);

    return texel;
}

vec4 testSparseTextureLodOffset()
{
    vec4 texel = vec4(0.0);

    sparseTextureLodOffsetARB(s2D, c2, lod, offset2, texel);
    sparseTextureLodOffsetARB(s3D, c3, lod, offset3, texel);
    sparseTextureLodOffsetARB(s2DShadow, c3, lod, offset2, texel.x);
    sparseTextureLodOffsetARB(s2DArray, c3, lod, offset2, texel);

    return texel;
}

vec4 testSparseTextureGrad()
{
    vec4 texel = vec4(0.0);

    sparseTextureGradARB(s2D, c2, dPdxy2, dPdxy2, texel);
    sparseTextureGradARB(s3D, c3, dPdxy3, dPdxy3, texel);
    sparseTextureGradARB(sCube, c3, dPdxy3, dPdxy3, texel);
    sparseTextureGradARB(s2DRect, c2, dPdxy2, dPdxy2, texel);
    sparseTextureGradARB(s2DRectShadow, c3, dPdxy2, dPdxy2, texel.x);
    sparseTextureGradARB(s2DShadow, c3, dPdxy2, dPdxy2, texel.x);
    sparseTextureGradARB(sCubeShadow, c4, dPdxy3, dPdxy3, texel.x);
    sparseTextureGradARB(s2DArray, c3, dPdxy2, dPdxy2, texel);
    sparseTextureGradARB(s2DArrayShadow, c4, dPdxy2, dPdxy2, texel.x);
    sparseTextureGradARB(sCubeArray, c4, dPdxy3, dPdxy3, texel);

    return texel;
}

vec4 testSparseTextureGradOffset()
{
    vec4 texel = vec4(0.0);

    sparseTextureGradOffsetARB(s2D, c2, dPdxy2, dPdxy2, offset2, texel);
    sparseTextureGradOffsetARB(s3D, c3, dPdxy3, dPdxy3, offset3, texel);
    sparseTextureGradOffsetARB(s2DRect, c2, dPdxy2, dPdxy2, offset2, texel);
    sparseTextureGradOffsetARB(s2DRectShadow, c3, dPdxy2, dPdxy2, offset2, texel.x);
    sparseTextureGradOffsetARB(s2DShadow, c3, dPdxy2, dPdxy2, offset2, texel.x);
    sparseTextureGradOffsetARB(s2DArray, c3, dPdxy2, dPdxy2, offset2, texel);
    sparseTextureGradOffsetARB(s2DArrayShadow, c4, dPdxy2, dPdxy2, offset2, texel.x);

    return texel;
}

vec4 testSparseTexelFetch()
{
    vec4 texel = vec4(0.0);

    sparseTexelFetchARB(s2D, ivec2(c2), int(lod), texel);
    sparseTexelFetchARB(s3D, ivec3(c3), int(lod), texel);
    sparseTexelFetchARB(s2DRect, ivec2(c2), texel);
    sparseTexelFetchARB(s2DArray, ivec3(c3), int(lod), texel);
    sparseTexelFetchARB(s2DMS, ivec2(c2), 1, texel);
    sparseTexelFetchARB(s2DMSArray, ivec3(c3), 2, texel);

    return texel;
}

vec4 testSparseTexelFetchOffset()
{
    vec4 texel = vec4(0.0);

    sparseTexelFetchOffsetARB(s2D, ivec2(c2), int(lod), offset2, texel);
    sparseTexelFetchOffsetARB(s3D, ivec3(c3), int(lod), offset3, texel);
    sparseTexelFetchOffsetARB(s2DRect, ivec2(c2), offset2, texel);
    sparseTexelFetchOffsetARB(s2DArray, ivec3(c3), int(lod), offset2, texel);

    return texel;
}

vec4 testSparseTextureGather()
{
    vec4 texel = vec4(0.0);

    sparseTextureGatherARB(s2D, c2, texel, 0);
    sparseTextureGatherARB(s2DArray, c3, texel, 0);
    sparseTextureGatherARB(sCube, c3, texel, 0);
    sparseTextureGatherARB(sCubeArray, c4, texel, 0);
    sparseTextureGatherARB(s2DRect, c2, texel, 0);
    sparseTextureGatherARB(s2DShadow, c2, compare, texel);
    sparseTextureGatherARB(s2DArrayShadow, c3, compare, texel);
    sparseTextureGatherARB(sCubeShadow, c3, compare, texel);
    sparseTextureGatherARB(sCubeArrayShadow, c4, compare, texel);
    sparseTextureGatherARB(s2DRectShadow, c2, compare, texel);

    return texel;
}

vec4 testSparseTextureGatherOffset()
{
    vec4 texel = vec4(0.0);

    sparseTextureGatherOffsetARB(s2D, c2, offset2, texel, 0);
    sparseTextureGatherOffsetARB(s2DArray, c3, offset2, texel, 0);
    sparseTextureGatherOffsetARB(s2DRect, c2, offset2, texel, 0);
    sparseTextureGatherOffsetARB(s2DShadow, c2, compare, offset2, texel);
    sparseTextureGatherOffsetARB(s2DArrayShadow, c3, compare, offset2, texel);
    sparseTextureGatherOffsetARB(s2DRectShadow, c2, compare, offset2, texel);

    return texel;
}

vec4 testSparseTextureGatherOffsets()
{
    vec4 texel = vec4(0.0);
    const ivec2 constOffsets[4] = ivec2[4](ivec2(1,2), ivec2(3,4), ivec2(15,16), ivec2(-2,0));

    sparseTextureGatherOffsetsARB(s2D, c2, constOffsets, texel, 0);
    sparseTextureGatherOffsetsARB(s2DArray, c3, constOffsets, texel, 0);
    sparseTextureGatherOffsetsARB(s2DRect, c2, constOffsets, texel, 0);
    sparseTextureGatherOffsetsARB(s2DShadow, c2, compare, constOffsets, texel);
    sparseTextureGatherOffsetsARB(s2DArrayShadow, c3, compare, constOffsets, texel);
    sparseTextureGatherOffsetsARB(s2DRectShadow, c2, compare, constOffsets, texel);

    return texel;
}

vec4 testSparseTextureGatherLod()
{
    vec4 texel = vec4(0.0);

    sparseTextureGatherLodAMD(s2D, c2, lod, texel, 0);
    sparseTextureGatherLodAMD(s2DArray, c3, lod, texel, 0);
    sparseTextureGatherLodAMD(sCube, c3, lod, texel, 0);
    sparseTextureGatherLodAMD(sCubeArray, c4, lod, texel, 0);

    return texel;
}

vec4 testSparseTextureGatherLodOffset()
{
    vec4 texel = vec4(0.0);

    sparseTextureGatherLodOffsetAMD(s2D, c2, lod, offset2, texel, 0);
    sparseTextureGatherLodOffsetAMD(s2DArray, c3, lod, offset2, texel, 0);

    return texel;
}

vec4 testSparseTextureGatherLodOffsets()
{
    vec4 texel = vec4(0.0);

    sparseTextureGatherLodOffsetsAMD(s2D, c2, lod, offsets, texel, 0);
    sparseTextureGatherLodOffsetsAMD(s2DArray, c3, lod, offsets, texel, 0);

    return texel;
}

vec4 testSparseImageLoad()
{
    vec4 texel = vec4(0.0);

    sparseImageLoadARB(i2D, ivec2(c2), texel);
    sparseImageLoadARB(i3D, ivec3(c3), texel);
    sparseImageLoadARB(i2DRect, ivec2(c2), texel);
    sparseImageLoadARB(iCube, ivec3(c3), texel);
    sparseImageLoadARB(i2DArray, ivec3(c3), texel);
    sparseImageLoadARB(iCubeArray, ivec3(c3), texel);
    sparseImageLoadARB(i2DMS, ivec2(c2), 1, texel);
    sparseImageLoadARB(i2DMSArray, ivec3(c3), 2, texel);

    return texel;
}

vec4 testSparseTextureClamp()
{
    vec4 texel = vec4(0.0);

    sparseTextureClampARB(s2D, c2, lodClamp, texel);
    sparseTextureClampARB(s3D, c3, lodClamp, texel);
    sparseTextureClampARB(sCube, c3, lodClamp, texel);
    sparseTextureClampARB(s2DShadow, c3, lodClamp, texel.x);
    sparseTextureClampARB(sCubeShadow, c4, lodClamp, texel.x);
    sparseTextureClampARB(s2DArray, c3, lodClamp, texel);
    sparseTextureClampARB(sCubeArray, c4, lodClamp, texel);
    sparseTextureClampARB(s2DArrayShadow, c4, lodClamp, texel.x);
    sparseTextureClampARB(sCubeArrayShadow, c4, compare, lodClamp, texel.x);

    return texel;
}

vec4 testTextureClamp()
{
    vec4 texel = vec4(0.0);

    texel   += textureClampARB(s1D, c1, lodClamp);
    texel   += textureClampARB(s2D, c2, lodClamp);
    texel   += textureClampARB(s3D, c3, lodClamp);
    texel   += textureClampARB(sCube, c3, lodClamp);
    texel.x += textureClampARB(s1DShadow, c3, lodClamp);
    texel.x += textureClampARB(s2DShadow, c3, lodClamp);
    texel.x += textureClampARB(sCubeShadow, c4, lodClamp);
    texel   += textureClampARB(s1DArray, c2, lodClamp);
    texel   += textureClampARB(s2DArray, c3, lodClamp);
    texel   += textureClampARB(sCubeArray, c4, lodClamp);
    texel.x += textureClampARB(s1DArrayShadow, c3, lodClamp);
    texel.x += textureClampARB(s2DArrayShadow, c4, lodClamp);
    texel.x += textureClampARB(sCubeArrayShadow, c4, compare, lodClamp);

    return texel;
}

vec4 testSparseTextureOffsetClamp()
{
    vec4 texel = vec4(0.0);

    sparseTextureOffsetClampARB(s2D, c2, offset2, lodClamp, texel);
    sparseTextureOffsetClampARB(s3D, c3, offset3, lodClamp, texel);
    sparseTextureOffsetClampARB(s2DShadow, c3, offset2, lodClamp, texel.x);
    sparseTextureOffsetClampARB(s2DArray, c3, offset2, lodClamp, texel);
    sparseTextureOffsetClampARB(s2DArrayShadow, c4, offset2, lodClamp, texel.x);

    return texel;
}

vec4 testTextureOffsetClamp()
{
    vec4 texel = vec4(0.0);

    texel   += textureOffsetClampARB(s1D, c1, offset1, lodClamp);
    texel   += textureOffsetClampARB(s2D, c2, offset2, lodClamp);
    texel   += textureOffsetClampARB(s3D, c3, offset3, lodClamp);
    texel.x += textureOffsetClampARB(s1DShadow, c3, offset1, lodClamp);
    texel.x += textureOffsetClampARB(s2DShadow, c3, offset2, lodClamp);
    texel   += textureOffsetClampARB(s1DArray, c2, offset1, lodClamp);
    texel   += textureOffsetClampARB(s2DArray, c3, offset2, lodClamp);
    texel.x += textureOffsetClampARB(s1DArrayShadow, c3, offset1, lodClamp);
    texel.x += textureOffsetClampARB(s2DArrayShadow, c4, offset2, lodClamp);
    
    return texel;
}

vec4 testSparseTextureGradClamp()
{
    vec4 texel = vec4(0.0);

    sparseTextureGradClampARB(s2D, c2, dPdxy2, dPdxy2, lodClamp, texel);
    sparseTextureGradClampARB(s3D, c3, dPdxy3, dPdxy3, lodClamp, texel);
    sparseTextureGradClampARB(sCube, c3, dPdxy3, dPdxy3, lodClamp, texel);
    sparseTextureGradClampARB(s2DShadow, c3, dPdxy2, dPdxy2, lodClamp, texel.x);
    sparseTextureGradClampARB(sCubeShadow, c4, dPdxy3, dPdxy3, lodClamp, texel.x);
    sparseTextureGradClampARB(s2DArray, c3, dPdxy2, dPdxy2, lodClamp, texel);
    sparseTextureGradClampARB(s2DArrayShadow, c4, dPdxy2, dPdxy2, lodClamp, texel.x);
    sparseTextureGradClampARB(sCubeArray, c4, dPdxy3, dPdxy3, lodClamp, texel);

    return texel;
}

vec4 testTextureGradClamp()
{
    vec4 texel = vec4(0.0);

    texel   += textureGradClampARB(s1D, c1, dPdxy1, dPdxy1, lodClamp);
    texel   += textureGradClampARB(s2D, c2, dPdxy2, dPdxy2, lodClamp);
    texel   += textureGradClampARB(s3D, c3, dPdxy3, dPdxy3, lodClamp);
    texel   += textureGradClampARB(sCube, c3, dPdxy3, dPdxy3, lodClamp);
    texel.x += textureGradClampARB(s1DShadow, c3, dPdxy1, dPdxy1, lodClamp);
    texel.x += textureGradClampARB(s2DShadow, c3, dPdxy2, dPdxy2, lodClamp);
    texel.x += textureGradClampARB(sCubeShadow, c4, dPdxy3, dPdxy3, lodClamp);
    texel   += textureGradClampARB(s1DArray, c2, dPdxy1, dPdxy1, lodClamp);
    texel   += textureGradClampARB(s2DArray, c3, dPdxy2, dPdxy2, lodClamp);
    texel.x += textureGradClampARB(s1DArrayShadow, c3, dPdxy1, dPdxy1, lodClamp);
    texel.x += textureGradClampARB(s2DArrayShadow, c4, dPdxy2, dPdxy2, lodClamp);
    texel   += textureGradClampARB(sCubeArray, c4, dPdxy3, dPdxy3, lodClamp);

    return texel;
}

vec4 testSparseTextureGradOffsetClamp()
{
    vec4 texel = vec4(0.0);

    sparseTextureGradOffsetClampARB(s2D, c2, dPdxy2, dPdxy2, offset2, lodClamp, texel);
    sparseTextureGradOffsetClampARB(s3D, c3, dPdxy3, dPdxy3, offset3, lodClamp, texel);
    sparseTextureGradOffsetClampARB(s2DShadow, c3, dPdxy2, dPdxy2, offset2, lodClamp, texel.x);
    sparseTextureGradOffsetClampARB(s2DArray, c3, dPdxy2, dPdxy2, offset2, lodClamp, texel);
    sparseTextureGradOffsetClampARB(s2DArrayShadow, c4, dPdxy2, dPdxy2, offset2, lodClamp, texel.x);

    return texel;
}

vec4 testTextureGradOffsetClamp()
{
    vec4 texel = vec4(0.0);

    texel   += textureGradOffsetClampARB(s1D, c1, dPdxy1, dPdxy1, offset1, lodClamp);
    texel   += textureGradOffsetClampARB(s2D, c2, dPdxy2, dPdxy2, offset2, lodClamp);
    texel   += textureGradOffsetClampARB(s3D, c3, dPdxy3, dPdxy3, offset3, lodClamp);
    texel.x += textureGradOffsetClampARB(s1DShadow, c3, dPdxy1, dPdxy1, offset1, lodClamp);
    texel.x += textureGradOffsetClampARB(s2DShadow, c3, dPdxy2, dPdxy2, offset2, lodClamp);
    texel   += textureGradOffsetClampARB(s1DArray, c2, dPdxy1, dPdxy1, offset1, lodClamp);
    texel   += textureGradOffsetClampARB(s2DArray, c3, dPdxy2, dPdxy2, offset2, lodClamp);
    texel.x += textureGradOffsetClampARB(s1DArrayShadow, c3, dPdxy1, dPdxy1, offset1, lodClamp);
    texel.x += textureGradOffsetClampARB(s2DArrayShadow, c4, dPdxy2, dPdxy2, offset2, lodClamp);

    return texel;
}

vec4 testCombinedTextureSampler()
{
    vec4 texel = vec4(0.0);

    texel   += texture(sampler1D(t1D, s), c1);
    texel   += texture(sampler2D(t2D, s), c2);
    texel   += texture(sampler3D(t3D, s), c3);
    texel   += texture(samplerCube(tCube, s), c3);
    texel.x += texture(sampler1DShadow(t1D, sShadow), c3);
    texel.x += texture(sampler2DShadow(t2D, sShadow), c3);
    texel.x += texture(samplerCubeShadow(tCube, sShadow), c4);
    texel   += texture(sampler1DArray(t1DArray, s), c2);
    texel   += texture(sampler2DArray(t2DArray, s), c3);
    texel   += texture(samplerCubeArray(tCubeArray, s), c4);
    texel.x += texture(sampler1DArrayShadow(t1DArray, sShadow), c3);
    texel.x += texture(sampler2DArrayShadow(t2DArray, sShadow), c4);
    texel   += texture(sampler2DRect(t2DRect, s), c2);
    texel.x += texture(sampler2DRectShadow(t2DRect, sShadow), c3);
    texel.x += texture(samplerCubeArrayShadow(tCubeArray, sShadow), c4, compare);

    return texel;
}

vec4 testSubpassLoad()
{
    return subpassLoad(subpass) + subpassLoad(subpassMS, 2);
}

void main()
{
    vec4 result = vec4(0.0);

    result  += testTexture();
    result  += testTextureProj();
    result  += testTextureLod();
    result  += testTextureOffset();
    result  += testTextureLodOffset();
    result  += testTextureProjLodOffset();
    result  += testTexelFetch();
    result  += testTexelFetchOffset();
    result  += testTextureGrad();
    result  += testTextureGradOffset();
    result  += testTextureProjGrad();
    result  += testTextureProjGradoffset();
    result  += testTextureGather();
    result  += testTextureGatherOffset();
    result  += testTextureGatherOffsets();
    result  += testTextureGatherLod();
    result  += testTextureGatherLodOffset();
    result  += testTextureGatherLodOffsets();

    result    += vec4(testTextureSize());
    result.xy += vec2(testTextureQueryLod());
    result.x  += testTextureQueryLevels();
    result.x  += testTextureSamples();

    result  += testImageLoad();
    testImageStore(result);

    result += testSparseTexture();
    result += testSparseTextureLod();
    result += testSparseTextureOffset();
    result += testSparseTextureLodOffset();
    result += testSparseTextureGrad();
    result += testSparseTextureGradOffset();
    result += testSparseTexelFetch();
    result += testSparseTexelFetchOffset();
    result += testSparseTextureGather();
    result += testSparseTextureGatherOffset();
    result += testSparseTextureGatherOffsets();
    result += testSparseTextureGatherLod();
    result += testSparseTextureGatherLodOffset();
    result += testSparseTextureGatherLodOffsets();

    result += testSparseImageLoad();

    result += testSparseTextureClamp();
    result += testTextureClamp();
    result += testSparseTextureOffsetClamp();
    result += testTextureOffsetClamp();
    result += testSparseTextureGrad();
    result += testTextureGrad();
    result += testSparseTextureGradOffsetClamp();
    result += testTextureGradOffsetClamp();

    result += testCombinedTextureSampler();
    result += testSubpassLoad();

    fragColor = result;
}