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