summaryrefslogtreecommitdiff
path: root/tests/spec/arb_gl_spirv/execution/ubo/aoa-2.shader_test
blob: 647144275bdd60070e3f4c22ebff609b214319be (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
# UBO test using an array of arrays of ubos. UBO with two members.

[require]
SPIRV YES
GL >= 3.3
GLSL >= 4.50
GL_ARB_gl_spirv

[vertex shader passthrough]

[fragment shader spirv]
; Automatically generated from the GLSL by shader_test_spirv.py. DO NOT EDIT
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 7
; Bound: 120
; Schema: 0
               OpCapability Shader
          %1 = OpExtInstImport "GLSL.std.450"
               OpMemoryModel Logical GLSL450
               OpEntryPoint Fragment %main "main" %color
               OpExecutionMode %main OriginLowerLeft
               OpSource GLSL 450
               OpDecorate %color Location 0
               OpMemberDecorate %AOA 0 Offset 0
               OpMemberDecorate %AOA 1 Offset 16
               OpDecorate %AOA Block
               OpDecorate %arr DescriptorSet 0
               OpDecorate %arr Binding 5
       %void = OpTypeVoid
          %3 = OpTypeFunction %void
      %float = OpTypeFloat 32
    %v4float = OpTypeVector %float 4
%_ptr_Function_v4float = OpTypePointer Function %v4float
    %float_1 = OpConstant %float 1
    %float_0 = OpConstant %float 0
         %12 = OpConstantComposite %v4float %float_1 %float_0 %float_0 %float_1
%_ptr_Output_v4float = OpTypePointer Output %v4float
      %color = OpVariable %_ptr_Output_v4float Output
         %15 = OpConstantComposite %v4float %float_0 %float_1 %float_0 %float_1
    %v2float = OpTypeVector %float 2
        %AOA = OpTypeStruct %v4float %v2float
       %uint = OpTypeInt 32 0
     %uint_2 = OpConstant %uint 2
%_arr_AOA_uint_2 = OpTypeArray %AOA %uint_2
%_arr__arr_AOA_uint_2_uint_2 = OpTypeArray %_arr_AOA_uint_2 %uint_2
%_ptr_Uniform__arr__arr_AOA_uint_2_uint_2 = OpTypePointer Uniform %_arr__arr_AOA_uint_2_uint_2
        %arr = OpVariable %_ptr_Uniform__arr__arr_AOA_uint_2_uint_2 Uniform
        %int = OpTypeInt 32 1
      %int_0 = OpConstant %int 0
%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float
%float_610_072205 = OpConstant %float 610.072205
%float_24998_1719 = OpConstant %float 24998.1719
%float_8190_74414 = OpConstant %float 8190.74414
%float_26479_0312 = OpConstant %float 26479.0312
         %33 = OpConstantComposite %v4float %float_610_072205 %float_24998_1719 %float_8190_74414 %float_26479_0312
       %bool = OpTypeBool
     %v4bool = OpTypeVector %bool 4
      %int_1 = OpConstant %int 1
%_ptr_Uniform_v2float = OpTypePointer Uniform %v2float
%float_n27681_2891 = OpConstant %float -27681.2891
%float_9081_78711 = OpConstant %float 9081.78711
         %47 = OpConstantComposite %v2float %float_n27681_2891 %float_9081_78711
     %v2bool = OpTypeVector %bool 2
%float_15538_2891 = OpConstant %float 15538.2891
%float_5642_53711 = OpConstant %float 5642.53711
%float_n23131_3867 = OpConstant %float -23131.3867
%float_18541_5391 = OpConstant %float 18541.5391
         %60 = OpConstantComposite %v4float %float_15538_2891 %float_5642_53711 %float_n23131_3867 %float_18541_5391
%float_n12496_1973 = OpConstant %float -12496.1973
%float_n5854_81055 = OpConstant %float -5854.81055
         %70 = OpConstantComposite %v2float %float_n12496_1973 %float_n5854_81055
%float_n32637_8945 = OpConstant %float -32637.8945
%float_12265_4824 = OpConstant %float 12265.4824
%float_n13669_0615 = OpConstant %float -13669.0615
%float_27760_8262 = OpConstant %float 27760.8262
         %82 = OpConstantComposite %v4float %float_n32637_8945 %float_12265_4824 %float_n13669_0615 %float_27760_8262
%float_20530_7109 = OpConstant %float 20530.7109
%float_n10508_5107 = OpConstant %float -10508.5107
         %92 = OpConstantComposite %v2float %float_20530_7109 %float_n10508_5107
%float_n1013_09918 = OpConstant %float -1013.09918
%float_n23371_9824 = OpConstant %float -23371.9824
%float_n3101_10449 = OpConstant %float -3101.10449
%float_n19908_5312 = OpConstant %float -19908.5312
        %104 = OpConstantComposite %v4float %float_n1013_09918 %float_n23371_9824 %float_n3101_10449 %float_n19908_5312
%float_n29557_3516 = OpConstant %float -29557.3516
%float_30238_998 = OpConstant %float 30238.998
        %114 = OpConstantComposite %v2float %float_n29557_3516 %float_30238_998
       %main = OpFunction %void None %3
          %5 = OpLabel
 %fail_color = OpVariable %_ptr_Function_v4float Function
               OpStore %fail_color %12
               OpStore %color %15
         %27 = OpAccessChain %_ptr_Uniform_v4float %arr %int_0 %int_0 %int_0
         %28 = OpLoad %v4float %27
         %36 = OpFOrdNotEqual %v4bool %28 %33
         %37 = OpAny %bool %36
               OpSelectionMerge %39 None
               OpBranchConditional %37 %38 %39
         %38 = OpLabel
         %40 = OpLoad %v4float %fail_color
               OpStore %color %40
               OpBranch %39
         %39 = OpLabel
         %43 = OpAccessChain %_ptr_Uniform_v2float %arr %int_0 %int_0 %int_1
         %44 = OpLoad %v2float %43
         %49 = OpFOrdNotEqual %v2bool %44 %47
         %50 = OpAny %bool %49
               OpSelectionMerge %52 None
               OpBranchConditional %50 %51 %52
         %51 = OpLabel
         %53 = OpLoad %v4float %fail_color
               OpStore %color %53
               OpBranch %52
         %52 = OpLabel
         %54 = OpAccessChain %_ptr_Uniform_v4float %arr %int_0 %int_1 %int_0
         %55 = OpLoad %v4float %54
         %61 = OpFOrdNotEqual %v4bool %55 %60
         %62 = OpAny %bool %61
               OpSelectionMerge %64 None
               OpBranchConditional %62 %63 %64
         %63 = OpLabel
         %65 = OpLoad %v4float %fail_color
               OpStore %color %65
               OpBranch %64
         %64 = OpLabel
         %66 = OpAccessChain %_ptr_Uniform_v2float %arr %int_0 %int_1 %int_1
         %67 = OpLoad %v2float %66
         %71 = OpFOrdNotEqual %v2bool %67 %70
         %72 = OpAny %bool %71
               OpSelectionMerge %74 None
               OpBranchConditional %72 %73 %74
         %73 = OpLabel
         %75 = OpLoad %v4float %fail_color
               OpStore %color %75
               OpBranch %74
         %74 = OpLabel
         %76 = OpAccessChain %_ptr_Uniform_v4float %arr %int_1 %int_0 %int_0
         %77 = OpLoad %v4float %76
         %83 = OpFOrdNotEqual %v4bool %77 %82
         %84 = OpAny %bool %83
               OpSelectionMerge %86 None
               OpBranchConditional %84 %85 %86
         %85 = OpLabel
         %87 = OpLoad %v4float %fail_color
               OpStore %color %87
               OpBranch %86
         %86 = OpLabel
         %88 = OpAccessChain %_ptr_Uniform_v2float %arr %int_1 %int_0 %int_1
         %89 = OpLoad %v2float %88
         %93 = OpFOrdNotEqual %v2bool %89 %92
         %94 = OpAny %bool %93
               OpSelectionMerge %96 None
               OpBranchConditional %94 %95 %96
         %95 = OpLabel
         %97 = OpLoad %v4float %fail_color
               OpStore %color %97
               OpBranch %96
         %96 = OpLabel
         %98 = OpAccessChain %_ptr_Uniform_v4float %arr %int_1 %int_1 %int_0
         %99 = OpLoad %v4float %98
        %105 = OpFOrdNotEqual %v4bool %99 %104
        %106 = OpAny %bool %105
               OpSelectionMerge %108 None
               OpBranchConditional %106 %107 %108
        %107 = OpLabel
        %109 = OpLoad %v4float %fail_color
               OpStore %color %109
               OpBranch %108
        %108 = OpLabel
        %110 = OpAccessChain %_ptr_Uniform_v2float %arr %int_1 %int_1 %int_1
        %111 = OpLoad %v2float %110
        %115 = OpFOrdNotEqual %v2bool %111 %114
        %116 = OpAny %bool %115
               OpSelectionMerge %118 None
               OpBranchConditional %116 %117 %118
        %117 = OpLabel
        %119 = OpLoad %v4float %fail_color
               OpStore %color %119
               OpBranch %118
        %118 = OpLabel
               OpReturn
               OpFunctionEnd

[fragment shader]

#version 450

layout (location = 0) out vec4 color;
layout (binding = 5, row_major) uniform AOA
 {
    vec4 c1;
    vec2 c2;
 } arr[2][2];

void main()
{
       vec4 fail_color = vec4(1.0, 0.0, 0.0, 1.0);
       color = vec4(0.0, 1.0, 0.0, 1.0);

       if (arr[0][0].c1 != vec4(610.072190433, 24998.1713741, 8190.74402991, 26479.0313725)) {
          color = fail_color;
       }
       if (arr[0][0].c2 != vec2(-27681.288716, 9081.78673991)) {
          color = fail_color;
       }

       if (arr[0][1].c1 != vec4(15538.2894026, 5642.53723964, -23131.3873198, 18541.5383078)) {
          color = fail_color;
       }
       if (arr[0][1].c2 != vec2(-12496.1967803, -5854.8105745)) {
          color = fail_color;
       }

       if (arr[1][0].c1 != vec4(-32637.8949874, 12265.4819562, -13669.0617838, 27760.8253605)) {
          color = fail_color;
       }
       if (arr[1][0].c2 != vec2(20530.7108263, -10508.5105669)) {
          color = fail_color;
       }

       if (arr[1][1].c1 != vec4(-1013.0991989, -23371.9822385, -3101.104448, -19908.5317922)) {
          color = fail_color;
       }
       if (arr[1][1].c2 != vec2(-29557.3508507, 30238.9989166)) {
          color = fail_color;
       }
}

[test]
clear color 1.0 0.0 0.0 0.0
clear

# Note that to fill the data we use the first binding, even if each
# individual index would be associated with a different binding. We
# keep using array index for that.

block binding 5

block array index 0
block offset 0
uniform vec4 AOA.c1 610.072190433 24998.1713741 8190.74402991 26479.0313725
block offset 16
uniform vec4 AOA.c2 -27681.288716 9081.78673991

block array index 1
block offset 0
uniform vec4 AOA.c1 15538.2894026 5642.53723964 -23131.3873198 18541.5383078
block offset 16
uniform vec4 AOA.c2 -12496.1967803 -5854.8105745

block array index 2
block offset 0
uniform vec4 AOA.c1 -32637.8949874 12265.4819562 -13669.0617838 27760.8253605
block offset 16
uniform vec4 AOA.c2 20530.7108263 -10508.5105669

block array index 3
block offset 0
uniform vec4 AOA.c1 -1013.0991989 -23371.9822385 -3101.104448 -19908.5317922
block offset 16
uniform vec4 AOA.c2 -29557.3508507 30238.9989166

block binding 5
verify program_interface_query GL_UNIFORM_BLOCK AOA[0][0] GL_NUM_ACTIVE_VARIABLES 2
verify program_interface_query GL_UNIFORM_BLOCK AOA[0][0] GL_BUFFER_DATA_SIZE 32

block binding 6
verify program_interface_query GL_UNIFORM_BLOCK AOA[0][1] GL_NUM_ACTIVE_VARIABLES 2
verify program_interface_query GL_UNIFORM_BLOCK AOA[0][1] GL_BUFFER_DATA_SIZE 32

block binding 7
verify program_interface_query GL_UNIFORM_BLOCK AOA[1][0] GL_NUM_ACTIVE_VARIABLES 2
verify program_interface_query GL_UNIFORM_BLOCK AOA[1][0] GL_BUFFER_DATA_SIZE 32

block binding 8
verify program_interface_query GL_UNIFORM_BLOCK AOA[1][1] GL_NUM_ACTIVE_VARIABLES 2
verify program_interface_query GL_UNIFORM_BLOCK AOA[1][1] GL_BUFFER_DATA_SIZE 32

draw rect -1 -1 2 2
probe all rgba 0.0 1.0 0.0 1.0