3 # Copyright 2020 Google LLC
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
9 # http://www.apache.org/licenses/LICENSE-2.0
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.
18 # A test for a coverage-gap found by the GraphicsFuzz project.
20 # Short description: Covers specific inst combine add sub and inst combine simplify demanded code paths
22 # The test passes because the shader always writes red.
24 SHADER vertex variant_vertex_shader PASSTHROUGH
26 # variant_fragment_shader is derived from the following GLSL:
28 # #define _int_1 _GLF_uniform_int_values[0]
29 # #define _int_0 _GLF_uniform_int_values[1]
30 # #define _int_2 _GLF_uniform_int_values[2]
31 # #define _float_0_0 _GLF_uniform_float_values[0]
33 # precision highp float;
35 # precision highp int;
37 # // Contents of _GLF_uniform_float_values: 0.0
38 # layout(set = 0, binding = 0) uniform buf0
40 # float _GLF_uniform_float_values[1];
43 # // Contents of _GLF_uniform_int_values: [1, 0, 2]
44 # layout(set = 0, binding = 1) uniform buf1
46 # int _GLF_uniform_int_values[3];
49 # layout(location = 0) out vec4 _GLF_color;
55 # if (gl_FragCoord.y > _float_0_0)
61 # int i = bitCount(a);
68 # // Always returns 2.
78 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
82 # _GLF_color = vec4(_int_0);
85 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
88 ; Generator: Khronos Glslang Reference Front End; 10
92 %1 = OpExtInstImport "GLSL.std.450"
93 OpMemoryModel Logical GLSL450
94 OpEntryPoint Fragment %4 "main" %16 %68
95 OpExecutionMode %4 OriginUpperLeft
100 OpName %16 "gl_FragCoord"
102 OpMemberName %23 0 "_GLF_uniform_float_values"
106 OpMemberName %43 0 "_GLF_uniform_int_values"
109 OpName %68 "_GLF_color"
110 OpDecorate %16 BuiltIn FragCoord
111 OpDecorate %22 ArrayStride 16
112 OpMemberDecorate %23 0 Offset 0
114 OpDecorate %25 DescriptorSet 0
115 OpDecorate %25 Binding 0
116 OpDecorate %42 ArrayStride 16
117 OpMemberDecorate %43 0 Offset 0
119 OpDecorate %45 DescriptorSet 0
120 OpDecorate %45 Binding 1
121 OpDecorate %68 Location 0
123 %3 = OpTypeFunction %2
125 %7 = OpTypeFunction %6
126 %10 = OpTypePointer Function %6
127 %12 = OpConstant %6 256
129 %14 = OpTypeVector %13 4
130 %15 = OpTypePointer Input %14
131 %16 = OpVariable %15 Input
133 %18 = OpConstant %17 1
134 %19 = OpTypePointer Input %13
135 %22 = OpTypeArray %13 %18
136 %23 = OpTypeStruct %22
137 %24 = OpTypePointer Uniform %23
138 %25 = OpVariable %24 Uniform
139 %26 = OpConstant %6 0
140 %27 = OpTypePointer Uniform %13
142 %35 = OpConstant %6 1
143 %41 = OpConstant %17 3
144 %42 = OpTypeArray %6 %41
145 %43 = OpTypeStruct %42
146 %44 = OpTypePointer Uniform %43
147 %45 = OpVariable %44 Uniform
148 %46 = OpTypePointer Uniform %6
149 %61 = OpConstant %6 2
150 %67 = OpTypePointer Output %14
151 %68 = OpVariable %67 Output
152 %4 = OpFunction %2 None %3
154 %58 = OpVariable %10 Function
155 %59 = OpFunctionCall %6 %8
158 %62 = OpAccessChain %46 %45 %26 %61
160 %64 = OpIEqual %30 %60 %63
161 OpSelectionMerge %66 None
162 OpBranchConditional %64 %65 %82
164 %69 = OpAccessChain %46 %45 %26 %26
166 %71 = OpConvertSToF %13 %70
167 %72 = OpAccessChain %46 %45 %26 %35
169 %74 = OpConvertSToF %13 %73
170 %75 = OpAccessChain %46 %45 %26 %35
172 %77 = OpConvertSToF %13 %76
173 %78 = OpAccessChain %46 %45 %26 %26
175 %80 = OpConvertSToF %13 %79
176 %81 = OpCompositeConstruct %14 %71 %74 %77 %80
180 %83 = OpAccessChain %46 %45 %26 %35
182 %85 = OpConvertSToF %13 %84
183 %86 = OpCompositeConstruct %14 %85 %85 %85 %85
189 %8 = OpFunction %6 None %7
191 %11 = OpVariable %10 Function
192 %37 = OpVariable %10 Function
194 %20 = OpAccessChain %19 %16 %18
196 %28 = OpAccessChain %27 %25 %26 %26
198 %31 = OpFOrdGreaterThan %30 %21 %29
199 OpSelectionMerge %33 None
200 OpBranchConditional %31 %32 %33
203 %36 = OpIAdd %6 %34 %35
208 %39 = OpBitCount %6 %38
211 %47 = OpAccessChain %46 %45 %26 %26
213 %49 = OpSLessThan %30 %40 %48
214 OpSelectionMerge %51 None
215 OpBranchConditional %49 %50 %51
217 %52 = OpAccessChain %46 %45 %26 %26
226 # uniforms for variant
228 # _GLF_uniform_int_values
229 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
232 # _GLF_uniform_float_values
233 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
237 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
239 PIPELINE graphics variant_pipeline
240 ATTACH variant_vertex_shader
241 ATTACH variant_fragment_shader
242 FRAMEBUFFER_SIZE 256 256
243 BIND BUFFER variant_framebuffer AS color LOCATION 0
244 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 1
245 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 0
247 CLEAR_COLOR variant_pipeline 0 0 0 255
249 CLEAR variant_pipeline
250 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
252 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255