3 # Copyright 2021 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: A fragment shader that covers specific BRW 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_10 _GLF_uniform_int_values[2]
31 # #define _float_1_0 _GLF_uniform_float_values[0]
32 # #define _float_91_0 _GLF_uniform_float_values[1]
34 # precision highp float;
35 # precision highp int;
37 # // Contents of _GLF_uniform_int_values: [1, 0, 10]
38 # layout(set = 0, binding = 0) uniform buf0
40 # int _GLF_uniform_int_values[3];
43 # // Contents of _GLF_uniform_float_values: [1.0, 91.0]
44 # layout(set = 0, binding = 1) uniform buf1
46 # float _GLF_uniform_float_values[2];
49 # const int _GLF_global_loop_bound = 100;
50 # int _GLF_global_loop_count = 0;
52 # // Contents of injectionSwitch: [0.0, 1.0]
53 # layout(set = 0, binding = 2) uniform buf2
55 # vec2 injectionSwitch;
58 # layout(location = 0) out vec4 _GLF_color;
62 # float f = _float_1_0;
64 # for(int r = _int_0; r < _int_10; r ++)
66 # _GLF_global_loop_count ++;
67 # // Derivative of a uniform vector is always zero.
68 # f += dFdx(injectionSwitch).y;
71 # while(_GLF_global_loop_count < _GLF_global_loop_bound)
73 # _GLF_global_loop_count ++;
78 # if(f == _float_91_0)
80 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
84 # _GLF_color = vec4(_int_0);
87 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
90 ; Generator: Khronos Glslang Reference Front End; 10
94 %1 = OpExtInstImport "GLSL.std.450"
95 OpMemoryModel Logical GLSL450
96 OpEntryPoint Fragment %4 "main" %82
97 OpExecutionMode %4 OriginUpperLeft
100 OpName %8 "_GLF_global_loop_count"
103 OpMemberName %16 0 "_GLF_uniform_float_values"
107 OpMemberName %26 0 "_GLF_uniform_int_values"
110 OpMemberName %47 0 "injectionSwitch"
112 OpName %82 "_GLF_color"
113 OpDecorate %15 ArrayStride 16
114 OpMemberDecorate %16 0 Offset 0
116 OpDecorate %18 DescriptorSet 0
117 OpDecorate %18 Binding 1
118 OpDecorate %25 ArrayStride 16
119 OpMemberDecorate %26 0 Offset 0
121 OpDecorate %28 DescriptorSet 0
122 OpDecorate %28 Binding 0
123 OpMemberDecorate %47 0 Offset 0
125 OpDecorate %49 DescriptorSet 0
126 OpDecorate %49 Binding 2
127 OpDecorate %82 Location 0
129 %3 = OpTypeFunction %2
131 %7 = OpTypePointer Private %6
132 %8 = OpVariable %7 Private
135 %11 = OpTypePointer Function %10
137 %14 = OpConstant %13 2
138 %15 = OpTypeArray %10 %14
139 %16 = OpTypeStruct %15
140 %17 = OpTypePointer Uniform %16
141 %18 = OpVariable %17 Uniform
142 %19 = OpTypePointer Uniform %10
143 %22 = OpTypePointer Function %6
144 %24 = OpConstant %13 3
145 %25 = OpTypeArray %6 %24
146 %26 = OpTypeStruct %25
147 %27 = OpTypePointer Uniform %26
148 %28 = OpVariable %27 Uniform
149 %29 = OpConstant %6 1
150 %30 = OpTypePointer Uniform %6
151 %39 = OpConstant %6 2
153 %46 = OpTypeVector %10 2
154 %47 = OpTypeStruct %46
155 %48 = OpTypePointer Uniform %47
156 %49 = OpVariable %48 Uniform
157 %50 = OpTypePointer Uniform %46
158 %54 = OpConstant %13 1
159 %66 = OpConstant %6 100
160 %80 = OpTypeVector %10 4
161 %81 = OpTypePointer Output %80
162 %82 = OpVariable %81 Output
163 %4 = OpFunction %2 None %3
165 %12 = OpVariable %11 Function
166 %23 = OpVariable %22 Function
168 %20 = OpAccessChain %19 %18 %9 %9
171 %31 = OpAccessChain %30 %28 %9 %29
176 OpLoopMerge %35 %36 None
180 %40 = OpAccessChain %30 %28 %9 %39
182 %43 = OpSLessThan %42 %38 %41
183 OpBranchConditional %43 %34 %35
186 %45 = OpIAdd %6 %44 %29
188 %51 = OpAccessChain %50 %49 %9
191 %55 = OpCompositeExtract %10 %53 1
193 %57 = OpFAdd %10 %56 %55
198 %59 = OpIAdd %6 %58 %29
204 OpLoopMerge %62 %63 None
208 %67 = OpSLessThan %42 %65 %66
209 OpBranchConditional %67 %61 %62
212 %69 = OpIAdd %6 %68 %29
214 %70 = OpAccessChain %19 %18 %9 %9
217 %73 = OpFAdd %10 %72 %71
224 %75 = OpAccessChain %19 %18 %9 %29
226 %77 = OpFOrdEqual %42 %74 %76
227 OpSelectionMerge %79 None
228 OpBranchConditional %77 %78 %96
230 %83 = OpAccessChain %30 %28 %9 %9
232 %85 = OpConvertSToF %10 %84
233 %86 = OpAccessChain %30 %28 %9 %29
235 %88 = OpConvertSToF %10 %87
236 %89 = OpAccessChain %30 %28 %9 %29
238 %91 = OpConvertSToF %10 %90
239 %92 = OpAccessChain %30 %28 %9 %9
241 %94 = OpConvertSToF %10 %93
242 %95 = OpCompositeConstruct %80 %85 %88 %91 %94
246 %97 = OpAccessChain %30 %28 %9 %29
248 %99 = OpConvertSToF %10 %98
249 %100 = OpCompositeConstruct %80 %99 %99 %99 %99
257 # uniforms for variant
260 BUFFER variant_injectionSwitch DATA_TYPE vec2<float> STD140 DATA
263 # _GLF_uniform_float_values
264 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
267 # _GLF_uniform_int_values
268 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
272 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
274 PIPELINE graphics variant_pipeline
275 ATTACH variant_vertex_shader
276 ATTACH variant_fragment_shader
277 FRAMEBUFFER_SIZE 256 256
278 BIND BUFFER variant_framebuffer AS color LOCATION 0
279 BIND BUFFER variant_injectionSwitch AS uniform DESCRIPTOR_SET 0 BINDING 2
280 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 1
281 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
283 CLEAR_COLOR variant_pipeline 0 0 0 255
285 CLEAR variant_pipeline
286 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
288 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255