Fix missing dependency on sparse binds
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / data / vulkan / amber / graphicsfuzz / cov-machinevaluetype-one-iter-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 GraphicsFuzz.
19
20 # Short description: A fragment shader that covers a specific machine value type code 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 # precision highp int;
30 #
31 # layout(location = 0) out vec4 _GLF_color;
32 #
33 # layout(set = 0, binding = 0) uniform buf0
34 # {
35 #     vec2 injectionSwitch;
36 # };
37 #
38 # void main()
39 # {
40 #     int a = 0;
41 #     for(int i = 0; i < int(injectionSwitch.y); i++)
42 #     {
43 #         if (a > 0)
44 #         {
45 #             break;
46 #         }
47 #         // a becomes 1.
48 #         a = ((int(injectionSwitch.y) * 2) / 2);
49 #     }
50 #
51 #     if (a == 1) // Always true.
52 #         _GLF_color = vec4(1, 0, 0, 1);
53 #     else
54 #         _GLF_color = vec4(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; 8
60 ; Bound: 56
61 ; Schema: 0
62                OpCapability Shader
63           %1 = OpExtInstImport "GLSL.std.450"
64                OpMemoryModel Logical GLSL450
65                OpEntryPoint Fragment %4 "main" %50
66                OpExecutionMode %4 OriginUpperLeft
67                OpSource ESSL 310
68                OpName %4 "main"
69                OpName %8 "a"
70                OpName %10 "i"
71                OpName %19 "buf0"
72                OpMemberName %19 0 "injectionSwitch"
73                OpName %21 ""
74                OpName %50 "_GLF_color"
75                OpMemberDecorate %19 0 Offset 0
76                OpDecorate %19 Block
77                OpDecorate %21 DescriptorSet 0
78                OpDecorate %21 Binding 0
79                OpDecorate %50 Location 0
80           %2 = OpTypeVoid
81           %3 = OpTypeFunction %2
82           %6 = OpTypeInt 32 1
83           %7 = OpTypePointer Function %6
84           %9 = OpConstant %6 0
85          %17 = OpTypeFloat 32
86          %18 = OpTypeVector %17 2
87          %19 = OpTypeStruct %18
88          %20 = OpTypePointer Uniform %19
89          %21 = OpVariable %20 Uniform
90          %22 = OpTypeInt 32 0
91          %23 = OpConstant %22 1
92          %24 = OpTypePointer Uniform %17
93          %28 = OpTypeBool
94          %38 = OpConstant %6 2
95          %42 = OpConstant %6 1
96          %48 = OpTypeVector %17 4
97          %49 = OpTypePointer Output %48
98          %50 = OpVariable %49 Output
99          %51 = OpConstant %17 1
100          %52 = OpConstant %17 0
101          %53 = OpConstantComposite %48 %51 %52 %52 %51
102          %55 = OpConstantComposite %48 %52 %52 %52 %52
103           %4 = OpFunction %2 None %3
104           %5 = OpLabel
105           %8 = OpVariable %7 Function
106          %10 = OpVariable %7 Function
107                OpStore %8 %9
108                OpStore %10 %9
109                OpBranch %11
110          %11 = OpLabel
111                OpLoopMerge %13 %14 None
112                OpBranch %15
113          %15 = OpLabel
114          %16 = OpLoad %6 %10
115          %25 = OpAccessChain %24 %21 %9 %23
116          %26 = OpLoad %17 %25
117          %27 = OpConvertFToS %6 %26
118          %29 = OpSLessThan %28 %16 %27
119                OpBranchConditional %29 %12 %13
120          %12 = OpLabel
121          %30 = OpLoad %6 %8
122          %31 = OpSGreaterThan %28 %30 %9
123                OpSelectionMerge %33 None
124                OpBranchConditional %31 %32 %33
125          %32 = OpLabel
126                OpBranch %13
127          %33 = OpLabel
128          %35 = OpAccessChain %24 %21 %9 %23
129          %36 = OpLoad %17 %35
130          %37 = OpConvertFToS %6 %36
131          %39 = OpIMul %6 %37 %38
132          %40 = OpSDiv %6 %39 %38
133                OpStore %8 %40
134                OpBranch %14
135          %14 = OpLabel
136          %41 = OpLoad %6 %10
137          %43 = OpIAdd %6 %41 %42
138                OpStore %10 %43
139                OpBranch %11
140          %13 = OpLabel
141          %44 = OpLoad %6 %8
142          %45 = OpIEqual %28 %44 %42
143                OpSelectionMerge %47 None
144                OpBranchConditional %45 %46 %54
145          %46 = OpLabel
146                OpStore %50 %53
147                OpBranch %47
148          %54 = OpLabel
149                OpStore %50 %55
150                OpBranch %47
151          %47 = OpLabel
152                OpReturn
153                OpFunctionEnd
154 END
155
156 # uniforms for variant
157
158 # injectionSwitch
159 BUFFER variant_injectionSwitch DATA_TYPE vec2<float> DATA
160  0.0 1.0
161 END
162
163 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
164
165 PIPELINE graphics variant_pipeline
166   ATTACH variant_vertex_shader
167   ATTACH variant_fragment_shader
168   FRAMEBUFFER_SIZE 256 256
169   BIND BUFFER variant_framebuffer AS color LOCATION 0
170   BIND BUFFER variant_injectionSwitch AS uniform DESCRIPTOR_SET 0 BINDING 0
171 END
172 CLEAR_COLOR variant_pipeline 0 0 0 255
173
174 CLEAR variant_pipeline
175 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
176
177 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255