dEQP-VK.graphicsfuzz.discards-in-control-flow
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / data / vulkan / amber / graphicsfuzz / discards-in-control-flow.amber
1 #!amber
2
3 # Copyright 2019 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 bug found by GraphicsFuzz.
19
20 # Short description: A fragment shader with discards in loops and conditionals
21
22 # The test passes because the fragment shader writes a red pixel, and then
23 # terminates without further output manipulation (the discards are not
24 # dynamically reachable)
25
26 SHADER vertex variant_vertex_shader PASSTHROUGH
27
28 # variant_fragment_shader is derived from the following GLSL:
29 # #version 310 es
30 #
31 # precision highp float;
32 #
33 # layout(location = 0) out vec4 _GLF_color;
34 #
35 # void main(void)
36 # {
37 #  _GLF_color = vec4(1.0, 0.0, 0.0, 1.0);
38 #  if(int(gl_FragCoord.x) < 2000) {
39 #  } else {
40 #    for(int ll = 0; ; ll++) {
41 #      if(gl_FragCoord.x < 0.0) {
42 #        discard;
43 #      }
44 #      if(ll >= 5) {
45 #        break;
46 #      }
47 #    }
48 #    if(int(gl_FragCoord.x) >= 2000) {
49 #      discard;
50 #    }
51 #  }
52 # }
53 SHADER fragment variant_fragment_shader SPIRV-ASM
54 ; SPIR-V
55 ; Version: 1.0
56 ; Generator: Khronos Glslang Reference Front End; 7
57 ; Bound: 57
58 ; Schema: 0
59                OpCapability Shader
60           %1 = OpExtInstImport "GLSL.std.450"
61                OpMemoryModel Logical GLSL450
62                OpEntryPoint Fragment %4 "main" %9 %14
63                OpExecutionMode %4 OriginUpperLeft
64                OpSource ESSL 310
65                OpName %4 "main"
66                OpName %9 "_GLF_color"
67                OpName %14 "gl_FragCoord"
68                OpName %29 "ll"
69                OpDecorate %9 Location 0
70                OpDecorate %14 BuiltIn FragCoord
71                OpDecorate %29 RelaxedPrecision
72                OpDecorate %41 RelaxedPrecision
73                OpDecorate %47 RelaxedPrecision
74                OpDecorate %49 RelaxedPrecision
75           %2 = OpTypeVoid
76           %3 = OpTypeFunction %2
77           %6 = OpTypeFloat 32
78           %7 = OpTypeVector %6 4
79           %8 = OpTypePointer Output %7
80           %9 = OpVariable %8 Output
81          %10 = OpConstant %6 1
82          %11 = OpConstant %6 0
83          %12 = OpConstantComposite %7 %10 %11 %11 %10
84          %13 = OpTypePointer Input %7
85          %14 = OpVariable %13 Input
86          %15 = OpTypeInt 32 0
87          %16 = OpConstant %15 0
88          %17 = OpTypePointer Input %6
89          %20 = OpTypeInt 32 1
90          %22 = OpConstant %20 2000
91          %23 = OpTypeBool
92          %28 = OpTypePointer Function %20
93          %30 = OpConstant %20 0
94          %42 = OpConstant %20 5
95          %48 = OpConstant %20 1
96           %4 = OpFunction %2 None %3
97           %5 = OpLabel
98          %29 = OpVariable %28 Function
99                OpStore %9 %12
100          %18 = OpAccessChain %17 %14 %16
101          %19 = OpLoad %6 %18
102          %21 = OpConvertFToS %20 %19
103          %24 = OpSLessThan %23 %21 %22
104                OpSelectionMerge %26 None
105                OpBranchConditional %24 %25 %27
106          %25 = OpLabel
107                OpBranch %26
108          %27 = OpLabel
109                OpStore %29 %30
110                OpBranch %31
111          %31 = OpLabel
112                OpLoopMerge %33 %34 None
113                OpBranch %32
114          %32 = OpLabel
115          %35 = OpAccessChain %17 %14 %16
116          %36 = OpLoad %6 %35
117          %37 = OpFOrdLessThan %23 %36 %11
118                OpSelectionMerge %39 None
119                OpBranchConditional %37 %38 %39
120          %38 = OpLabel
121                OpKill
122          %39 = OpLabel
123          %41 = OpLoad %20 %29
124          %43 = OpSGreaterThanEqual %23 %41 %42
125                OpSelectionMerge %45 None
126                OpBranchConditional %43 %44 %45
127          %44 = OpLabel
128                OpBranch %33
129          %45 = OpLabel
130                OpBranch %34
131          %34 = OpLabel
132          %47 = OpLoad %20 %29
133          %49 = OpIAdd %20 %47 %48
134                OpStore %29 %49
135                OpBranch %31
136          %33 = OpLabel
137          %50 = OpAccessChain %17 %14 %16
138          %51 = OpLoad %6 %50
139          %52 = OpConvertFToS %20 %51
140          %53 = OpSGreaterThanEqual %23 %52 %22
141                OpSelectionMerge %55 None
142                OpBranchConditional %53 %54 %55
143          %54 = OpLabel
144                OpKill
145          %55 = OpLabel
146                OpBranch %26
147          %26 = OpLabel
148                OpReturn
149                OpFunctionEnd
150 END
151
152 # uniforms for variant
153
154
155 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
156
157 PIPELINE graphics variant_pipeline
158   ATTACH variant_vertex_shader
159   ATTACH variant_fragment_shader
160   FRAMEBUFFER_SIZE 256 256
161   BIND BUFFER variant_framebuffer AS color LOCATION 0
162 END
163 CLEAR_COLOR variant_pipeline 0 0 0 255
164
165 CLEAR variant_pipeline
166 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
167
168 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255