Fix missing dependency on sparse binds
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / data / vulkan / amber / graphicsfuzz / cov-apfloat-unpackunorm-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 a specific floating point code path
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 310 es
28 # #define _int_1 _GLF_uniform_int_values[0]
29 # #define _int_0 _GLF_uniform_int_values[1]
30 # #define _int_5 _GLF_uniform_int_values[2]
31 #
32 # precision highp float;
33 #
34 # precision highp int;
35 #
36 # // Contents of _GLF_uniform_int_values: [1, 0]
37 # layout(set = 0, binding = 0) uniform buf0
38 # {
39 #     int _GLF_uniform_int_values[3];
40 # };
41 #
42 # layout(location = 0) out vec4 _GLF_color;
43 #
44 # void main()
45 # {
46 #     for (int i = _int_0; i < _int_5; i++)
47 #     {
48 #         vec4 v = unpackUnorm4x8(100u);
49 #
50 #         // Always false.
51 #         if (int(v.x) > i)
52 #         {
53 #             _GLF_color = vec4(_int_0);
54 #             return;
55 #         }
56 #     }
57 #     _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
58 # }
59 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
60 ; SPIR-V
61 ; Version: 1.0
62 ; Generator: Khronos Glslang Reference Front End; 8
63 ; Bound: 68
64 ; Schema: 0
65                OpCapability Shader
66           %1 = OpExtInstImport "GLSL.std.450"
67                OpMemoryModel Logical GLSL450
68                OpEntryPoint Fragment %4 "main" %47
69                OpExecutionMode %4 OriginUpperLeft
70                OpSource ESSL 310
71                OpName %4 "main"
72                OpName %8 "i"
73                OpName %12 "buf0"
74                OpMemberName %12 0 "_GLF_uniform_int_values"
75                OpName %14 ""
76                OpName %34 "v"
77                OpName %47 "_GLF_color"
78                OpDecorate %11 ArrayStride 16
79                OpMemberDecorate %12 0 Offset 0
80                OpDecorate %12 Block
81                OpDecorate %14 DescriptorSet 0
82                OpDecorate %14 Binding 0
83                OpDecorate %47 Location 0
84           %2 = OpTypeVoid
85           %3 = OpTypeFunction %2
86           %6 = OpTypeInt 32 1
87           %7 = OpTypePointer Function %6
88           %9 = OpTypeInt 32 0
89          %10 = OpConstant %9 3
90          %11 = OpTypeArray %6 %10
91          %12 = OpTypeStruct %11
92          %13 = OpTypePointer Uniform %12
93          %14 = OpVariable %13 Uniform
94          %15 = OpConstant %6 0
95          %16 = OpConstant %6 1
96          %17 = OpTypePointer Uniform %6
97          %26 = OpConstant %6 2
98          %29 = OpTypeBool
99          %31 = OpTypeFloat 32
100          %32 = OpTypeVector %31 4
101          %33 = OpTypePointer Function %32
102          %35 = OpConstant %9 100
103          %37 = OpConstant %9 0
104          %38 = OpTypePointer Function %31
105          %46 = OpTypePointer Output %32
106          %47 = OpVariable %46 Output
107           %4 = OpFunction %2 None %3
108           %5 = OpLabel
109           %8 = OpVariable %7 Function
110          %34 = OpVariable %33 Function
111          %18 = OpAccessChain %17 %14 %15 %16
112          %19 = OpLoad %6 %18
113                OpStore %8 %19
114                OpBranch %20
115          %20 = OpLabel
116                OpLoopMerge %22 %23 None
117                OpBranch %24
118          %24 = OpLabel
119          %25 = OpLoad %6 %8
120          %27 = OpAccessChain %17 %14 %15 %26
121          %28 = OpLoad %6 %27
122          %30 = OpSLessThan %29 %25 %28
123                OpBranchConditional %30 %21 %22
124          %21 = OpLabel
125          %36 = OpExtInst %32 %1 UnpackUnorm4x8 %35
126                OpStore %34 %36
127          %39 = OpAccessChain %38 %34 %37
128          %40 = OpLoad %31 %39
129          %41 = OpConvertFToS %6 %40
130          %42 = OpLoad %6 %8
131          %43 = OpSGreaterThan %29 %41 %42
132                OpSelectionMerge %45 None
133                OpBranchConditional %43 %44 %45
134          %44 = OpLabel
135          %48 = OpAccessChain %17 %14 %15 %16
136          %49 = OpLoad %6 %48
137          %50 = OpConvertSToF %31 %49
138          %51 = OpCompositeConstruct %32 %50 %50 %50 %50
139                OpStore %47 %51
140                OpReturn
141          %45 = OpLabel
142                OpBranch %23
143          %23 = OpLabel
144          %53 = OpLoad %6 %8
145          %54 = OpIAdd %6 %53 %16
146                OpStore %8 %54
147                OpBranch %20
148          %22 = OpLabel
149          %55 = OpAccessChain %17 %14 %15 %15
150          %56 = OpLoad %6 %55
151          %57 = OpConvertSToF %31 %56
152          %58 = OpAccessChain %17 %14 %15 %16
153          %59 = OpLoad %6 %58
154          %60 = OpConvertSToF %31 %59
155          %61 = OpAccessChain %17 %14 %15 %16
156          %62 = OpLoad %6 %61
157          %63 = OpConvertSToF %31 %62
158          %64 = OpAccessChain %17 %14 %15 %15
159          %65 = OpLoad %6 %64
160          %66 = OpConvertSToF %31 %65
161          %67 = OpCompositeConstruct %32 %57 %60 %63 %66
162                OpStore %47 %67
163                OpReturn
164                OpFunctionEnd
165 END
166
167 # uniforms for variant
168
169 # _GLF_uniform_int_values
170 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
171  1 0 5
172 END
173
174 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
175
176 PIPELINE graphics variant_pipeline
177   ATTACH variant_vertex_shader
178   ATTACH variant_fragment_shader
179   FRAMEBUFFER_SIZE 16 16
180   BIND BUFFER variant_framebuffer AS color LOCATION 0
181   BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
182 END
183 CLEAR_COLOR variant_pipeline 0 0 0 255
184
185 CLEAR variant_pipeline
186 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 16 16
187
188 EXPECT variant_framebuffer IDX 0 0 SIZE 16 16 EQ_RGBA 255 0 0 255