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:
29 # #define _int_0 _GLF_uniform_int_values[0]
30 # #define _int_1 _GLF_uniform_int_values[1]
31 # #define _int_2 _GLF_uniform_int_values[2]
32 # #define _float_1_0 _GLF_uniform_float_values[0]
33 # #define _float_2_0 _GLF_uniform_float_values[1]
34 # #define _float_3_0 _GLF_uniform_float_values[2]
35 # #define _float_4_0 _GLF_uniform_float_values[3]
37 # precision highp float;
38 # precision highp int;
40 # // Contents of _GLF_uniform_float_values: [1.0, 2.0, 3.0, 4.0]
41 # layout(set = 0, binding = 0) uniform buf0
43 # float _GLF_uniform_float_values[4];
45 # // Contents of _GLF_uniform_int_values: [0, 1, 2]
46 # layout(set = 0, binding = 1) uniform buf1
48 # int _GLF_uniform_int_values[3];
50 # layout(location = 0) out vec4 _GLF_color;
54 # float arr[3] = float[3](_float_1_0, _float_2_0, _float_3_0);
56 # for (int i = 1; i < min(_int_2, 3); i++)
58 # arr[_int_2] += _float_1_0;
61 # if(arr[_int_2] == _float_4_0)
63 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
67 # _GLF_color = vec4(_int_0);
70 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
73 ; Generator: Khronos Glslang Reference Front End; 10
77 %1 = OpExtInstImport "GLSL.std.450"
78 OpMemoryModel Logical GLSL450
79 OpEntryPoint Fragment %4 "main" %70
80 OpExecutionMode %4 OriginUpperLeft
85 OpMemberName %14 0 "_GLF_uniform_float_values"
89 OpMemberName %38 0 "_GLF_uniform_int_values"
91 OpName %70 "_GLF_color"
92 OpDecorate %13 ArrayStride 16
93 OpMemberDecorate %14 0 Offset 0
95 OpDecorate %16 DescriptorSet 0
96 OpDecorate %16 Binding 0
97 OpDecorate %37 ArrayStride 16
98 OpMemberDecorate %38 0 Offset 0
100 OpDecorate %40 DescriptorSet 0
101 OpDecorate %40 Binding 1
102 OpDecorate %70 Location 0
104 %3 = OpTypeFunction %2
108 %9 = OpTypeArray %6 %8
109 %10 = OpTypePointer Function %9
110 %12 = OpConstant %7 4
111 %13 = OpTypeArray %6 %12
112 %14 = OpTypeStruct %13
113 %15 = OpTypePointer Uniform %14
114 %16 = OpVariable %15 Uniform
116 %18 = OpConstant %17 0
117 %19 = OpTypePointer Uniform %6
118 %22 = OpConstant %17 1
119 %25 = OpConstant %17 2
120 %29 = OpTypePointer Function %17
121 %37 = OpTypeArray %17 %8
122 %38 = OpTypeStruct %37
123 %39 = OpTypePointer Uniform %38
124 %40 = OpVariable %39 Uniform
125 %41 = OpTypePointer Uniform %17
126 %44 = OpConstant %17 3
128 %52 = OpTypePointer Function %6
129 %68 = OpTypeVector %6 4
130 %69 = OpTypePointer Output %68
131 %70 = OpVariable %69 Output
132 %4 = OpFunction %2 None %3
134 %11 = OpVariable %10 Function
135 %30 = OpVariable %29 Function
136 %20 = OpAccessChain %19 %16 %18 %18
138 %23 = OpAccessChain %19 %16 %18 %22
140 %26 = OpAccessChain %19 %16 %18 %25
142 %28 = OpCompositeConstruct %9 %21 %24 %27
147 OpLoopMerge %33 %34 None
151 %42 = OpAccessChain %41 %40 %18 %25
153 %45 = OpExtInst %17 %1 SMin %43 %44
154 %47 = OpSLessThan %46 %36 %45
155 OpBranchConditional %47 %32 %33
157 %48 = OpAccessChain %41 %40 %18 %25
159 %50 = OpAccessChain %19 %16 %18 %18
161 %53 = OpAccessChain %52 %11 %49
163 %55 = OpFAdd %6 %54 %51
164 %56 = OpAccessChain %52 %11 %49
169 %58 = OpIAdd %17 %57 %22
173 %59 = OpAccessChain %41 %40 %18 %25
175 %61 = OpAccessChain %52 %11 %60
177 %63 = OpAccessChain %19 %16 %18 %44
179 %65 = OpFOrdEqual %46 %62 %64
180 OpSelectionMerge %67 None
181 OpBranchConditional %65 %66 %84
183 %71 = OpAccessChain %41 %40 %18 %22
185 %73 = OpConvertSToF %6 %72
186 %74 = OpAccessChain %41 %40 %18 %18
188 %76 = OpConvertSToF %6 %75
189 %77 = OpAccessChain %41 %40 %18 %18
191 %79 = OpConvertSToF %6 %78
192 %80 = OpAccessChain %41 %40 %18 %22
194 %82 = OpConvertSToF %6 %81
195 %83 = OpCompositeConstruct %68 %73 %76 %79 %82
199 %85 = OpAccessChain %41 %40 %18 %18
201 %87 = OpConvertSToF %6 %86
202 %88 = OpCompositeConstruct %68 %87 %87 %87 %87
210 # uniforms for variant
212 # _GLF_uniform_int_values
213 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
216 # _GLF_uniform_float_values
217 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
221 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
223 PIPELINE graphics variant_pipeline
224 ATTACH variant_vertex_shader
225 ATTACH variant_fragment_shader
226 FRAMEBUFFER_SIZE 256 256
227 BIND BUFFER variant_framebuffer AS color LOCATION 0
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