Fix missing dependency on sparse binds
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / data / vulkan / amber / graphicsfuzz / cov-folding-rules-merge-sub-add.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 GraphicsFuzz.
19
20 # Short description: A fragment shader that covers a specific instruction folding path.
21
22 # The test passes because 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 310 es
28 # precision highp float;
29 #
30 # layout(location = 0) out vec4 _GLF_color;
31 #
32 # void main()
33 # {
34 #     bool b = false;
35 #
36 #     // A single loop with i = 1.
37 #     for(int i = 1; i > 0; i--)
38 #     {
39 #         float a = 1.0 + float(i);
40 #
41 #         // If condition is always true.
42 #         if(2.0 - a == 0.0)
43 #             b = true;
44 #     }
45 #
46 #     // If condition is always true.
47 #     if (b)
48 #         _GLF_color = vec4(1, 0, 0, 1);
49 #     else
50 #         _GLF_color = vec4(0);
51 # }
52 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
53 ; SPIR-V
54 ; Version: 1.0
55 ; Generator: Khronos Glslang Reference Front End; 8
56 ; Bound: 48
57 ; Schema: 0
58                OpCapability Shader
59           %1 = OpExtInstImport "GLSL.std.450"
60                OpMemoryModel Logical GLSL450
61                OpEntryPoint Fragment %4 "main" %44
62                OpExecutionMode %4 OriginUpperLeft
63                OpSource ESSL 310
64                OpName %4 "main"
65                OpName %8 "b"
66                OpName %12 "i"
67                OpName %24 "a"
68                OpName %44 "_GLF_color"
69                OpDecorate %12 RelaxedPrecision
70                OpDecorate %19 RelaxedPrecision
71                OpDecorate %26 RelaxedPrecision
72                OpDecorate %37 RelaxedPrecision
73                OpDecorate %38 RelaxedPrecision
74                OpDecorate %44 Location 0
75           %2 = OpTypeVoid
76           %3 = OpTypeFunction %2
77           %6 = OpTypeBool
78           %7 = OpTypePointer Function %6
79           %9 = OpConstantFalse %6
80          %10 = OpTypeInt 32 1
81          %11 = OpTypePointer Function %10
82          %13 = OpConstant %10 1
83          %20 = OpConstant %10 0
84          %22 = OpTypeFloat 32
85          %23 = OpTypePointer Function %22
86          %25 = OpConstant %22 1
87          %29 = OpConstant %22 2
88          %32 = OpConstant %22 0
89          %36 = OpConstantTrue %6
90          %42 = OpTypeVector %22 4
91          %43 = OpTypePointer Output %42
92          %44 = OpVariable %43 Output
93          %45 = OpConstantComposite %42 %25 %32 %32 %25
94          %47 = OpConstantComposite %42 %32 %32 %32 %32
95           %4 = OpFunction %2 None %3
96           %5 = OpLabel
97           %8 = OpVariable %7 Function
98          %12 = OpVariable %11 Function
99          %24 = OpVariable %23 Function
100                OpStore %8 %9
101                OpStore %12 %13
102                OpBranch %14
103          %14 = OpLabel
104                OpLoopMerge %16 %17 None
105                OpBranch %18
106          %18 = OpLabel
107          %19 = OpLoad %10 %12
108          %21 = OpSGreaterThan %6 %19 %20
109                OpBranchConditional %21 %15 %16
110          %15 = OpLabel
111          %26 = OpLoad %10 %12
112          %27 = OpConvertSToF %22 %26
113          %28 = OpFAdd %22 %25 %27
114                OpStore %24 %28
115          %30 = OpLoad %22 %24
116          %31 = OpFSub %22 %29 %30
117          %33 = OpFOrdEqual %6 %31 %32
118                OpSelectionMerge %35 None
119                OpBranchConditional %33 %34 %35
120          %34 = OpLabel
121                OpStore %8 %36
122                OpBranch %35
123          %35 = OpLabel
124                OpBranch %17
125          %17 = OpLabel
126          %37 = OpLoad %10 %12
127          %38 = OpISub %10 %37 %13
128                OpStore %12 %38
129                OpBranch %14
130          %16 = OpLabel
131          %39 = OpLoad %6 %8
132                OpSelectionMerge %41 None
133                OpBranchConditional %39 %40 %46
134          %40 = OpLabel
135                OpStore %44 %45
136                OpBranch %41
137          %46 = OpLabel
138                OpStore %44 %47
139                OpBranch %41
140          %41 = OpLabel
141                OpReturn
142                OpFunctionEnd
143 END
144
145
146 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
147
148 PIPELINE graphics variant_pipeline
149   ATTACH variant_vertex_shader
150   ATTACH variant_fragment_shader
151   FRAMEBUFFER_SIZE 256 256
152   BIND BUFFER variant_framebuffer AS color LOCATION 0
153 END
154 CLEAR_COLOR variant_pipeline 0 0 0 255
155
156 CLEAR variant_pipeline
157 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
158
159 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255