Merge pull request #2892 from greg-lunarg/mb
[platform/upstream/glslang.git] / Test / hlsl.rw.bracket.frag
1 SamplerState       g_sSamp : register(s0);
2
3 RWTexture1D <float4> g_tTex1df4 : register(t0);
4 RWTexture1D <int4>   g_tTex1di4;
5 RWTexture1D <uint4>  g_tTex1du4;
6
7 RWTexture2D <float4> g_tTex2df4;
8 RWTexture2D <int4>   g_tTex2di4;
9 RWTexture2D <uint4>  g_tTex2du4;
10
11 RWTexture3D <float4> g_tTex3df4;
12 RWTexture3D <int4>   g_tTex3di4;
13 RWTexture3D <uint4>  g_tTex3du4;
14
15 RWTexture1DArray <float4> g_tTex1df4a;
16 RWTexture1DArray <int4>   g_tTex1di4a;
17 RWTexture1DArray <uint4>  g_tTex1du4a;
18
19 RWTexture2DArray <float4> g_tTex2df4a;
20 RWTexture2DArray <int4>   g_tTex2di4a;
21 RWTexture2DArray <uint4>  g_tTex2du4a;
22
23 struct PS_OUTPUT
24 {
25     float4 Color : SV_Target0;
26 };
27
28 uniform int   c1;
29 uniform int2  c2;
30 uniform int3  c3;
31 uniform int4  c4;
32
33 uniform int   o1;
34 uniform int2  o2;
35 uniform int3  o3;
36 uniform int4  o4;
37
38 uniform float4 uf4;
39 uniform int4   ui4;
40 uniform uint4  uu4;
41
42 int4   Fn1(in int4 x)   { return x; }
43 uint4  Fn1(in uint4 x)  { return x; }
44 float4 Fn1(in float4 x) { return x; }
45
46 void Fn2(out int4 x)   { x = int4(0); }
47 void Fn2(out uint4 x)  { x = uint4(0); }
48 void Fn2(out float4 x) { x = float4(0); }
49
50 float4 SomeValue() { return c4; }
51
52 PS_OUTPUT main()
53 {
54    PS_OUTPUT psout;
55
56    // 1D
57    g_tTex1df4[c1];
58    
59    float4 r00 = g_tTex1df4[c1];
60    int4   r01 = g_tTex1di4[c1];
61    uint4  r02 = g_tTex1du4[c1];
62
63    // 2D
64    float4 r10 = g_tTex2df4[c2];
65    int4   r11 = g_tTex2di4[c2];
66    uint4  r12 = g_tTex2du4[c2];
67    
68    // 3D
69    float4 r20 = g_tTex3df4[c3];
70    int4   r21 = g_tTex3di4[c3];
71    uint4  r22 = g_tTex3du4[c3];
72
73    float4 lf4 = uf4;
74
75    // Test as L-values
76    // 1D
77    g_tTex1df4[c1] = SomeValue(); // complex R-value
78    g_tTex1df4[c1] = lf4;
79    g_tTex1di4[c1] = int4(2,2,3,4);
80    g_tTex1du4[c1] = uint4(3,2,3,4);
81
82    // Test some operator= things, which need to do both a load and a store.
83    float4 val1 = (g_tTex1df4[c1] *= 2.0);
84    g_tTex1df4[c1] -= 3.0;
85    g_tTex1df4[c1] += 4.0;
86    
87    g_tTex1di4[c1] /= 2;
88    g_tTex1di4[c1] %= 2;
89    g_tTex1di4[c1] &= 0xffff;
90    g_tTex1di4[c1] |= 0xf0f0;
91    g_tTex1di4[c1] <<= 2;
92    g_tTex1di4[c1] >>= 2;
93
94    // 2D
95    g_tTex2df4[c2] = SomeValue(); // complex L-value
96    g_tTex2df4[c2] = lf4;
97    g_tTex2di4[c2] = int4(5,2,3,4);
98    g_tTex2du4[c2] = uint4(6,2,3,4);
99    
100    // 3D
101    g_tTex3df4[c3] = SomeValue(); // complex L-value
102    g_tTex3df4[c3] = lf4;
103    g_tTex3di4[c3] = int4(8,6,7,8);
104    g_tTex3du4[c3] = uint4(9,2,3,4);
105
106    // Test function calling
107    Fn1(g_tTex1df4[c1]);  // in
108    Fn1(g_tTex1di4[c1]);  // in
109    Fn1(g_tTex1du4[c1]);  // in
110
111    Fn2(g_tTex1df4[c1]);  // out
112    Fn2(g_tTex1di4[c1]);  // out
113    Fn2(g_tTex1du4[c1]);  // out
114
115    // Test increment operators
116    // pre-ops
117    ++g_tTex1df4[c1];
118    ++g_tTex1di4[c1];
119    ++g_tTex1du4[c1];
120
121    --g_tTex1df4[c1];
122    --g_tTex1di4[c1];
123    --g_tTex1du4[c1];
124
125    // post-ops
126    g_tTex1df4[c1]++;
127    g_tTex1du4[c1]--;
128    g_tTex1di4[c1]++;
129
130    g_tTex1df4[c1]--;
131    g_tTex1di4[c1]++;
132    g_tTex1du4[c1]--;
133
134    // read and write
135    g_tTex1df4[1] = g_tTex2df4[int2(2,3)];
136
137    psout.Color = 1.0;
138
139    return psout;
140 }