Merge vk-gl-cts/opengl-es-cts-3.2.7 into vk-gl-cts/master
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / data / vulkan / amber / graphicsfuzz / cov-double-if-true-in-loop.amber
1 #!amber
2
3 # Copyright 2020 Google LLC
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 #     http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16
17
18 # A test for a coverage-gap found by the GraphicsFuzz project.
19
20 # Short description: A fragment shader that covers specific NIR code paths
21
22 # The test passes because the shader always writes red.
23
24 SHADER vertex variant_vertex_shader PASSTHROUGH
25
26 # variant_fragment_shader is derived from the following GLSL:
27 # #version 320 es
28 # #define _int_0 _GLF_uniform_int_values[0]
29 # #define _int_10 _GLF_uniform_int_values[1]
30 # #define _int_1 _GLF_uniform_int_values[2]
31 #
32 # precision highp float;
33 # precision highp int;
34 #
35 # // Contents of _GLF_uniform_int_values: [0, 10, 1]
36 # layout(set = 0, binding = 0) uniform buf0
37 # {
38 #     int _GLF_uniform_int_values[3];
39 # };
40 #
41 # layout(location = 0) out vec4 _GLF_color;
42 #
43 # int func()
44 # {
45 #     int i = _int_0;
46 #
47 #     do
48 #     {
49 #         i++;
50 #
51 #         if (true)
52 #         {
53 #             if (true)
54 #             {
55 #                 return _int_1;
56 #             }
57 #         }
58 #     }
59 #     while (i < _int_10);
60 #
61 #     return _int_0;
62 # }
63 #
64 # void main()
65 # {
66 #     if (func() == _int_1)
67 #     {
68 #         _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
69 #     }
70 #     else
71 #     {
72 #         _GLF_color = vec4(_int_0);
73 #     }
74 # }
75 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
76 ; SPIR-V
77 ; Version: 1.0
78 ; Generator: Khronos Glslang Reference Front End; 10
79 ; Bound: 75
80 ; Schema: 0
81                OpCapability Shader
82           %1 = OpExtInstImport "GLSL.std.450"
83                OpMemoryModel Logical GLSL450
84                OpEntryPoint Fragment %4 "main" %56
85                OpExecutionMode %4 OriginUpperLeft
86                OpSource ESSL 320
87                OpName %4 "main"
88                OpName %8 "func("
89                OpName %11 "i"
90                OpName %15 "buf0"
91                OpMemberName %15 0 "_GLF_uniform_int_values"
92                OpName %17 ""
93                OpName %56 "_GLF_color"
94                OpDecorate %14 ArrayStride 16
95                OpMemberDecorate %15 0 Offset 0
96                OpDecorate %15 Block
97                OpDecorate %17 DescriptorSet 0
98                OpDecorate %17 Binding 0
99                OpDecorate %56 Location 0
100           %2 = OpTypeVoid
101           %3 = OpTypeFunction %2
102           %6 = OpTypeInt 32 1
103           %7 = OpTypeFunction %6
104          %10 = OpTypePointer Function %6
105          %12 = OpTypeInt 32 0
106          %13 = OpConstant %12 3
107          %14 = OpTypeArray %6 %13
108          %15 = OpTypeStruct %14
109          %16 = OpTypePointer Uniform %15
110          %17 = OpVariable %16 Uniform
111          %18 = OpConstant %6 0
112          %19 = OpTypePointer Uniform %6
113          %27 = OpConstant %6 1
114          %29 = OpTypeBool
115          %30 = OpConstantTrue %29
116          %35 = OpConstant %6 2
117          %53 = OpTypeFloat 32
118          %54 = OpTypeVector %53 4
119          %55 = OpTypePointer Output %54
120          %56 = OpVariable %55 Output
121           %4 = OpFunction %2 None %3
122           %5 = OpLabel
123          %47 = OpFunctionCall %6 %8
124          %48 = OpAccessChain %19 %17 %18 %35
125          %49 = OpLoad %6 %48
126          %50 = OpIEqual %29 %47 %49
127                OpSelectionMerge %52 None
128                OpBranchConditional %50 %51 %70
129          %51 = OpLabel
130          %57 = OpAccessChain %19 %17 %18 %35
131          %58 = OpLoad %6 %57
132          %59 = OpConvertSToF %53 %58
133          %60 = OpAccessChain %19 %17 %18 %18
134          %61 = OpLoad %6 %60
135          %62 = OpConvertSToF %53 %61
136          %63 = OpAccessChain %19 %17 %18 %18
137          %64 = OpLoad %6 %63
138          %65 = OpConvertSToF %53 %64
139          %66 = OpAccessChain %19 %17 %18 %35
140          %67 = OpLoad %6 %66
141          %68 = OpConvertSToF %53 %67
142          %69 = OpCompositeConstruct %54 %59 %62 %65 %68
143                OpStore %56 %69
144                OpBranch %52
145          %70 = OpLabel
146          %71 = OpAccessChain %19 %17 %18 %18
147          %72 = OpLoad %6 %71
148          %73 = OpConvertSToF %53 %72
149          %74 = OpCompositeConstruct %54 %73 %73 %73 %73
150                OpStore %56 %74
151                OpBranch %52
152          %52 = OpLabel
153                OpReturn
154                OpFunctionEnd
155           %8 = OpFunction %6 None %7
156           %9 = OpLabel
157          %11 = OpVariable %10 Function
158          %20 = OpAccessChain %19 %17 %18 %18
159          %21 = OpLoad %6 %20
160                OpStore %11 %21
161                OpBranch %22
162          %22 = OpLabel
163                OpLoopMerge %24 %25 None
164                OpBranch %23
165          %23 = OpLabel
166          %26 = OpLoad %6 %11
167          %28 = OpIAdd %6 %26 %27
168                OpStore %11 %28
169                OpSelectionMerge %32 None
170                OpBranchConditional %30 %31 %32
171          %31 = OpLabel
172                OpSelectionMerge %34 None
173                OpBranchConditional %30 %33 %34
174          %33 = OpLabel
175          %36 = OpAccessChain %19 %17 %18 %35
176          %37 = OpLoad %6 %36
177                OpReturnValue %37
178          %34 = OpLabel
179                OpBranch %32
180          %32 = OpLabel
181                OpBranch %25
182          %25 = OpLabel
183          %39 = OpLoad %6 %11
184          %40 = OpAccessChain %19 %17 %18 %27
185          %41 = OpLoad %6 %40
186          %42 = OpSLessThan %29 %39 %41
187                OpBranchConditional %42 %22 %24
188          %24 = OpLabel
189          %43 = OpAccessChain %19 %17 %18 %18
190          %44 = OpLoad %6 %43
191                OpReturnValue %44
192                OpFunctionEnd
193 END
194
195 # uniforms for variant
196
197 # _GLF_uniform_int_values
198 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
199  0 10 1
200 END
201
202 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
203
204 PIPELINE graphics variant_pipeline
205   ATTACH variant_vertex_shader
206   ATTACH variant_fragment_shader
207   FRAMEBUFFER_SIZE 256 256
208   BIND BUFFER variant_framebuffer AS color LOCATION 0
209   BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
210 END
211 CLEAR_COLOR variant_pipeline 0 0 0 255
212
213 CLEAR variant_pipeline
214 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
215
216 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255