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_100 _GLF_uniform_int_values[0]
29 # #define _int_0 _GLF_uniform_int_values[1]
30 # #define _float_10_0 _GLF_uniform_float_values[0]
32 # precision highp int;
33 # precision highp float;
35 # // Contents of _GLF_uniform_float_values: 10.0
36 # layout(set = 0, binding = 0) uniform buf0
38 # float _GLF_uniform_float_values[1];
40 # // Contents of _GLF_uniform_int_values: [100, 0]
41 # layout(set = 0, binding = 1) uniform buf1
43 # int _GLF_uniform_int_values[2];
45 # // Contents of injectionSwitch: [0.0, 1.0]
46 # layout(set = 0, binding = 2) uniform buf2
48 # vec2 injectionSwitch;
50 # layout(location = 0) out vec4 _GLF_color;
54 # // To hit the coverage points this value cannot
55 # // be changed later.
56 # _GLF_color = vec4(1, 0, 0, 1);
58 # for (int i = _int_0; i < _int_100; i++)
66 # // Execution never reaches this point.
67 # if (gl_FragCoord.y < _float_10_0)
71 # _GLF_color = vec4(vec3(1.0), injectionSwitch.y);
73 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
76 ; Generator: Khronos Glslang Reference Front End; 10
80 %1 = OpExtInstImport "GLSL.std.450"
81 OpMemoryModel Logical GLSL450
82 OpEntryPoint Fragment %4 "main" %9 %47
83 OpExecutionMode %4 OriginUpperLeft
86 OpName %9 "_GLF_color"
89 OpMemberName %19 0 "_GLF_uniform_int_values"
91 OpName %47 "gl_FragCoord"
93 OpMemberName %53 0 "_GLF_uniform_float_values"
96 OpMemberName %66 0 "injectionSwitch"
98 OpDecorate %9 Location 0
99 OpDecorate %18 ArrayStride 16
100 OpMemberDecorate %19 0 Offset 0
102 OpDecorate %21 DescriptorSet 0
103 OpDecorate %21 Binding 1
104 OpDecorate %47 BuiltIn FragCoord
105 OpDecorate %52 ArrayStride 16
106 OpMemberDecorate %53 0 Offset 0
108 OpDecorate %55 DescriptorSet 0
109 OpDecorate %55 Binding 0
110 OpMemberDecorate %66 0 Offset 0
112 OpDecorate %68 DescriptorSet 0
113 OpDecorate %68 Binding 2
115 %3 = OpTypeFunction %2
117 %7 = OpTypeVector %6 4
118 %8 = OpTypePointer Output %7
119 %9 = OpVariable %8 Output
120 %10 = OpConstant %6 1
121 %11 = OpConstant %6 0
122 %12 = OpConstantComposite %7 %10 %11 %11 %10
124 %14 = OpTypePointer Function %13
126 %17 = OpConstant %16 2
127 %18 = OpTypeArray %13 %17
128 %19 = OpTypeStruct %18
129 %20 = OpTypePointer Uniform %19
130 %21 = OpVariable %20 Uniform
131 %22 = OpConstant %13 0
132 %23 = OpConstant %13 1
133 %24 = OpTypePointer Uniform %13
135 %46 = OpTypePointer Input %7
136 %47 = OpVariable %46 Input
137 %48 = OpConstant %16 1
138 %49 = OpTypePointer Input %6
139 %52 = OpTypeArray %6 %48
140 %53 = OpTypeStruct %52
141 %54 = OpTypePointer Uniform %53
142 %55 = OpVariable %54 Uniform
143 %56 = OpTypePointer Uniform %6
144 %63 = OpTypeVector %6 3
145 %64 = OpConstantComposite %63 %10 %10 %10
146 %65 = OpTypeVector %6 2
147 %66 = OpTypeStruct %65
148 %67 = OpTypePointer Uniform %66
149 %68 = OpVariable %67 Uniform
150 %4 = OpFunction %2 None %3
152 %15 = OpVariable %14 Function
154 %25 = OpAccessChain %24 %21 %22 %23
159 OpLoopMerge %29 %30 None
163 %33 = OpAccessChain %24 %21 %22 %22
165 %36 = OpSLessThan %35 %32 %34
166 OpBranchConditional %36 %28 %29
169 %38 = OpAccessChain %24 %21 %22 %23
171 %40 = OpINotEqual %35 %37 %39
172 OpSelectionMerge %42 None
173 OpBranchConditional %40 %41 %42
180 %45 = OpIAdd %13 %44 %23
184 %50 = OpAccessChain %49 %47 %48
186 %57 = OpAccessChain %56 %55 %22 %22
188 %59 = OpFOrdLessThan %35 %51 %58
189 OpSelectionMerge %61 None
190 OpBranchConditional %59 %60 %61
194 %69 = OpAccessChain %56 %68 %22 %48
196 %71 = OpCompositeExtract %6 %64 0
197 %72 = OpCompositeExtract %6 %64 1
198 %73 = OpCompositeExtract %6 %64 2
199 %74 = OpCompositeConstruct %7 %71 %72 %73 %70
205 # uniforms for variant
208 BUFFER variant_injectionSwitch DATA_TYPE vec2<float> STD140 DATA
211 # _GLF_uniform_int_values
212 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
215 # _GLF_uniform_float_values
216 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
220 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
222 PIPELINE graphics variant_pipeline
223 ATTACH variant_vertex_shader
224 ATTACH variant_fragment_shader
225 FRAMEBUFFER_SIZE 256 256
226 BIND BUFFER variant_framebuffer AS color LOCATION 0
227 BIND BUFFER variant_injectionSwitch AS uniform DESCRIPTOR_SET 0 BINDING 2
228 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 1
229 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 0
231 CLEAR_COLOR variant_pipeline 0 0 0 255
233 CLEAR variant_pipeline
234 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
236 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255