Fix missing dependency on sparse binds
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / data / vulkan / amber / graphicsfuzz / discard-in-loop.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 shader with a discard in a loop
21
22 # The test passes because the discard is always reached, so the background colour will remain black.
23
24 # Optimized using spirv-opt with the following arguments:
25 # '-O'
26 # spirv-opt commit hash: 6b072126595dd8c2448eb1fda616251c5e6d7079
27
28
29
30 SHADER vertex variant_vertex_shader PASSTHROUGH
31
32 # variant_fragment_shader is derived from the following GLSL:
33 # #version 310 es
34 # precision highp float;
35 #
36 # precision highp int;
37 #
38 # layout(location = 0) out vec4 _GLF_color;
39 #
40 # void main()
41 # {
42 #  for(int i = 0; i < 10; i++)
43 #   {
44 #    if(gl_FragCoord.y < 0.0)
45 #     {
46 #      if(gl_FragCoord.x < 0.0)
47 #       {
48 #        break;
49 #       }
50 #      continue;
51 #     }
52 #    discard;
53 #   }
54 #   _GLF_color = vec4(1.0, 0.0, 0.0, 1.0);
55 # }
56 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
57 ; SPIR-V
58 ; Version: 1.0
59 ; Generator: Khronos Glslang Reference Front End; 7
60 ; Bound: 64
61 ; Schema: 0
62                OpCapability Shader
63           %1 = OpExtInstImport "GLSL.std.450"
64                OpMemoryModel Logical GLSL450
65                OpEntryPoint Fragment %4 "main" %22 %45
66                OpExecutionMode %4 OriginUpperLeft
67                OpSource ESSL 310
68                OpName %4 "main"
69                OpName %22 "gl_FragCoord"
70                OpName %45 "_GLF_color"
71                OpDecorate %22 BuiltIn FragCoord
72                OpDecorate %45 Location 0
73           %2 = OpTypeVoid
74           %3 = OpTypeFunction %2
75           %6 = OpTypeInt 32 1
76           %9 = OpConstant %6 0
77          %16 = OpConstant %6 10
78          %17 = OpTypeBool
79          %19 = OpTypeFloat 32
80          %20 = OpTypeVector %19 4
81          %21 = OpTypePointer Input %20
82          %22 = OpVariable %21 Input
83          %23 = OpTypeInt 32 0
84          %24 = OpConstant %23 1
85          %25 = OpTypePointer Input %19
86          %28 = OpConstant %19 0
87          %32 = OpConstant %23 0
88          %42 = OpConstant %6 1
89          %44 = OpTypePointer Output %20
90          %45 = OpVariable %44 Output
91          %46 = OpConstant %19 1
92          %47 = OpConstantComposite %20 %46 %28 %28 %46
93          %55 = OpConstantFalse %17
94          %58 = OpConstantTrue %17
95           %4 = OpFunction %2 None %3
96           %5 = OpLabel
97                OpBranch %52
98          %52 = OpLabel
99                OpLoopMerge %51 %54 None
100                OpBranch %10
101          %10 = OpLabel
102          %61 = OpPhi %6 %9 %52 %43 %37
103          %18 = OpSLessThan %17 %61 %16
104                OpLoopMerge %12 %37 None
105                OpBranchConditional %18 %11 %12
106          %11 = OpLabel
107          %26 = OpAccessChain %25 %22 %24
108          %27 = OpLoad %19 %26
109          %29 = OpFOrdLessThan %17 %27 %28
110                OpSelectionMerge %31 None
111                OpBranchConditional %29 %30 %31
112          %30 = OpLabel
113          %33 = OpAccessChain %25 %22 %32
114          %34 = OpLoad %19 %33
115          %35 = OpFOrdLessThan %17 %34 %28
116                OpSelectionMerge %63 None
117                OpBranchConditional %35 %36 %37
118          %36 = OpLabel
119                OpBranch %12
120          %63 = OpLabel
121                OpBranch %37
122          %37 = OpLabel
123          %43 = OpIAdd %6 %61 %42
124                OpBranch %10
125          %31 = OpLabel
126          %50 = OpFunctionCall %2 %48
127                OpBranch %12
128          %12 = OpLabel
129          %62 = OpPhi %17 %55 %10 %55 %36 %58 %31
130                OpSelectionMerge %59 None
131                OpBranchConditional %62 %51 %59
132          %59 = OpLabel
133                OpStore %45 %47
134                OpBranch %51
135          %54 = OpLabel
136                OpBranch %52
137          %51 = OpLabel
138                OpReturn
139                OpFunctionEnd
140          %48 = OpFunction %2 None %3
141          %49 = OpLabel
142                OpKill
143                OpFunctionEnd
144 END
145
146
147 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
148
149 PIPELINE graphics variant_pipeline
150   ATTACH variant_vertex_shader
151   ATTACH variant_fragment_shader
152   FRAMEBUFFER_SIZE 256 256
153   BIND BUFFER variant_framebuffer AS color LOCATION 0
154 END
155 CLEAR_COLOR variant_pipeline 0 0 0 255
156
157 CLEAR variant_pipeline
158 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
159
160 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 0 0 0 255