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: A fragment shader that covers specific NIR code paths
22 # The test passes because the shader always writes red.
24 # Optimized using spirv-opt with the following arguments:
25 # '--simplify-instructions'
26 # '--reduce-load-size'
27 # '--inline-entry-points-exhaustive'
28 # '--eliminate-local-single-block'
29 # '--redundancy-elimination'
30 # '--eliminate-dead-branches'
31 # '--eliminate-dead-inserts'
32 # '--redundancy-elimination'
33 # '--eliminate-local-single-block'
34 # '--eliminate-local-multi-store'
35 # '--simplify-instructions'
36 # '--eliminate-local-multi-store'
37 # '--eliminate-dead-branches'
38 # '--eliminate-dead-branches'
40 # '--combine-access-chains'
41 # '--eliminate-local-multi-store'
42 # '--eliminate-local-single-block'
43 # '--eliminate-local-single-store'
44 # '--eliminate-dead-branches'
46 # '--eliminate-dead-branches'
48 # '--simplify-instructions'
49 # '--eliminate-dead-branches'
51 # '--eliminate-local-multi-store'
52 # '--eliminate-dead-branches'
55 # '--eliminate-local-single-store'
56 # '--redundancy-elimination'
57 # '--eliminate-local-multi-store'
58 # '--eliminate-dead-code-aggressive'
59 # spirv-opt commit hash: a0370efd589be33d5d9a85cfde2f85841b3755af
63 SHADER vertex variant_vertex_shader PASSTHROUGH
65 # variant_fragment_shader is derived from the following GLSL:
67 # #define _int_0 _GLF_uniform_int_values[0]
68 # #define _int_1 _GLF_uniform_int_values[1]
69 # #define _float_1_0 _GLF_uniform_float_values[0]
71 # precision highp int;
72 # precision highp float;
74 # // Contents of _GLF_uniform_float_values: 1.0
75 # layout(set = 0, binding = 0) uniform buf0
77 # float _GLF_uniform_float_values[1];
80 # // Contents of _GLF_uniform_int_values: [0, 1]
81 # layout(set = 0, binding = 1) uniform buf1
83 # int _GLF_uniform_int_values[2];
86 # // Contents of zero: 0
87 # layout(set = 0, binding = 2) uniform buf2
92 # layout(location = 0) out vec4 _GLF_color;
96 # vec3 v = vec3(_int_1);
97 # // Static out of bound access required to hit the coverage point.
103 # // Out of bounds access but never executed.
107 # _GLF_color = vec4(v[_int_1], _int_0, _int_0, _int_1);
109 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
112 ; Generator: Khronos Glslang Reference Front End; 10
116 %1 = OpExtInstImport "GLSL.std.450"
117 OpMemoryModel Logical GLSL450
118 OpEntryPoint Fragment %4 "main" %51
119 OpExecutionMode %4 OriginUpperLeft
124 OpMemberName %14 0 "_GLF_uniform_int_values"
127 OpMemberName %27 0 "zero"
130 OpMemberName %41 0 "_GLF_uniform_float_values"
132 OpName %51 "_GLF_color"
133 OpDecorate %13 ArrayStride 16
134 OpMemberDecorate %14 0 Offset 0
136 OpDecorate %16 DescriptorSet 0
137 OpDecorate %16 Binding 1
138 OpMemberDecorate %27 0 Offset 0
140 OpDecorate %29 DescriptorSet 0
141 OpDecorate %29 Binding 2
142 OpDecorate %40 ArrayStride 16
143 OpMemberDecorate %41 0 Offset 0
145 OpDecorate %43 DescriptorSet 0
146 OpDecorate %43 Binding 0
147 OpDecorate %51 Location 0
149 %3 = OpTypeFunction %2
151 %7 = OpTypeVector %6 3
152 %8 = OpTypePointer Function %7
155 %12 = OpConstant %11 2
156 %13 = OpTypeArray %10 %12
157 %14 = OpTypeStruct %13
158 %15 = OpTypePointer Uniform %14
159 %16 = OpVariable %15 Uniform
160 %17 = OpConstant %10 0
161 %18 = OpConstant %10 1
162 %19 = OpTypePointer Uniform %10
163 %26 = OpConstant %10 3
164 %27 = OpTypeStruct %10
165 %28 = OpTypePointer Uniform %27
166 %29 = OpVariable %28 Uniform
168 %39 = OpConstant %11 1
169 %40 = OpTypeArray %6 %39
170 %41 = OpTypeStruct %40
171 %42 = OpTypePointer Uniform %41
172 %43 = OpVariable %42 Uniform
173 %44 = OpTypePointer Uniform %6
174 %47 = OpTypePointer Function %6
175 %49 = OpTypeVector %6 4
176 %50 = OpTypePointer Output %49
177 %51 = OpVariable %50 Output
178 %4 = OpFunction %2 None %3
180 %9 = OpVariable %8 Function
181 %20 = OpAccessChain %19 %16 %17 %18
183 %22 = OpConvertSToF %6 %21
184 %23 = OpCompositeConstruct %7 %22 %22 %22
186 %30 = OpAccessChain %19 %29 %17
188 %32 = OpAccessChain %19 %16 %17 %17
190 %35 = OpSGreaterThan %34 %31 %33
191 OpSelectionMerge %37 None
192 OpBranchConditional %35 %36 %37
194 %45 = OpAccessChain %44 %43 %17 %17
196 %48 = OpAccessChain %47 %9 %26
200 %54 = OpAccessChain %47 %9 %21
202 %58 = OpConvertSToF %6 %33
203 %65 = OpCompositeConstruct %49 %55 %58 %58 %22
209 # uniforms for variant
212 BUFFER variant_zero DATA_TYPE int32[] STD140 DATA
215 # _GLF_uniform_int_values
216 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
219 # _GLF_uniform_float_values
220 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
224 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
226 PIPELINE graphics variant_pipeline
227 ATTACH variant_vertex_shader
228 ATTACH variant_fragment_shader
229 FRAMEBUFFER_SIZE 256 256
230 BIND BUFFER variant_framebuffer AS color LOCATION 0
231 BIND BUFFER variant_zero AS uniform DESCRIPTOR_SET 0 BINDING 2
232 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 1
233 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 0
235 CLEAR_COLOR variant_pipeline 0 0 0 255
237 CLEAR variant_pipeline
238 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
240 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255