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 SHADER vertex variant_vertex_shader PASSTHROUGH
26 # variant_fragment_shader is derived from the following GLSL:
28 # #define _int_0 _GLF_uniform_int_values[0]
29 # #define _int_10 _GLF_uniform_int_values[1]
30 # #define _int_1 _GLF_uniform_int_values[2]
31 # #define _int_2 _GLF_uniform_int_values[3]
33 # precision highp float;
34 # precision highp int;
36 # // Contents of _GLF_uniform_int_values: [0, 10, 1, 2]
37 # layout(set = 0, binding = 0) uniform buf0
39 # int _GLF_uniform_int_values[4];
41 # layout(location = 0) out vec4 _GLF_color;
49 # // Loop iterates 10 times where a goes from 0 to 10
50 # // during the loop, and c goes from 1 to 2 on the
56 # // True for the first iteration.
68 # if (a == b && c == _int_2)
70 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
74 # _GLF_color = vec4(_int_0);
77 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
80 ; Generator: Khronos Glslang Reference Front End; 10
84 %1 = OpExtInstImport "GLSL.std.450"
85 OpMemoryModel Logical GLSL450
86 OpEntryPoint Fragment %4 "main" %69
87 OpExecutionMode %4 OriginUpperLeft
92 OpMemberName %12 0 "_GLF_uniform_int_values"
96 OpName %69 "_GLF_color"
97 OpDecorate %11 ArrayStride 16
98 OpMemberDecorate %12 0 Offset 0
100 OpDecorate %14 DescriptorSet 0
101 OpDecorate %14 Binding 0
102 OpDecorate %69 Location 0
104 %3 = OpTypeFunction %2
106 %7 = OpTypePointer Function %6
108 %10 = OpConstant %9 4
109 %11 = OpTypeArray %6 %10
110 %12 = OpTypeStruct %11
111 %13 = OpTypePointer Uniform %12
112 %14 = OpVariable %13 Uniform
113 %15 = OpConstant %6 0
114 %16 = OpTypePointer Uniform %6
115 %20 = OpConstant %6 1
116 %24 = OpConstant %6 2
118 %44 = OpConstant %6 3
119 %50 = OpConstantTrue %34
121 %67 = OpTypeVector %66 4
122 %68 = OpTypePointer Output %67
123 %69 = OpVariable %68 Output
124 %4 = OpFunction %2 None %3
126 %8 = OpVariable %7 Function
127 %19 = OpVariable %7 Function
128 %23 = OpVariable %7 Function
129 %17 = OpAccessChain %16 %14 %15 %15
132 %21 = OpAccessChain %16 %14 %15 %20
135 %25 = OpAccessChain %16 %14 %15 %24
140 OpLoopMerge %29 %30 None
145 %35 = OpSLessThan %34 %32 %33
146 OpBranchConditional %35 %28 %29
149 %37 = OpIAdd %6 %36 %20
152 %39 = OpAccessChain %16 %14 %15 %24
154 %41 = OpIEqual %34 %38 %40
155 OpSelectionMerge %43 None
156 OpBranchConditional %41 %42 %49
158 %45 = OpAccessChain %16 %14 %15 %44
161 %48 = OpIMul %6 %47 %46
165 OpSelectionMerge %52 None
166 OpBranchConditional %50 %51 %52
178 %56 = OpIEqual %34 %54 %55
179 OpSelectionMerge %58 None
180 OpBranchConditional %56 %57 %58
183 %60 = OpAccessChain %16 %14 %15 %44
185 %62 = OpIEqual %34 %59 %61
188 %63 = OpPhi %34 %56 %29 %62 %57
189 OpSelectionMerge %65 None
190 OpBranchConditional %63 %64 %83
192 %70 = OpAccessChain %16 %14 %15 %24
194 %72 = OpConvertSToF %66 %71
195 %73 = OpAccessChain %16 %14 %15 %15
197 %75 = OpConvertSToF %66 %74
198 %76 = OpAccessChain %16 %14 %15 %15
200 %78 = OpConvertSToF %66 %77
201 %79 = OpAccessChain %16 %14 %15 %24
203 %81 = OpConvertSToF %66 %80
204 %82 = OpCompositeConstruct %67 %72 %75 %78 %81
208 %84 = OpAccessChain %16 %14 %15 %15
210 %86 = OpConvertSToF %66 %85
211 %87 = OpCompositeConstruct %67 %86 %86 %86 %86
219 # uniforms for variant
221 # _GLF_uniform_int_values
222 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
226 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
228 PIPELINE graphics variant_pipeline
229 ATTACH variant_vertex_shader
230 ATTACH variant_fragment_shader
231 FRAMEBUFFER_SIZE 256 256
232 BIND BUFFER variant_framebuffer AS color LOCATION 0
233 BIND BUFFER variant__GLF_uniform_int_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