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_2 _GLF_uniform_int_values[0]
29 # #define _int_0 _GLF_uniform_int_values[1]
30 # #define _int_1 _GLF_uniform_int_values[2]
31 # #define _float_1_0 _GLF_uniform_float_values[0]
32 # #define _float_0_0 _GLF_uniform_float_values[1]
33 # #define _float_2_0 _GLF_uniform_float_values[2]
35 # precision highp float;
36 # precision highp int;
38 # // Contents of _GLF_uniform_int_values: [2, 0, 1]
39 # layout(set = 0, binding = 0) uniform buf0
41 # int _GLF_uniform_int_values[3];
43 # // Contents of _GLF_uniform_float_values: [1.0, 0.0, 2.0]
44 # layout(set = 0, binding = 1) uniform buf1
46 # float _GLF_uniform_float_values[3];
48 # layout(location = 0) out vec4 _GLF_color;
52 # float arr[3] = float[3](_float_0_0, _float_1_0, _float_2_0);
58 # arr[a++] = _float_1_0;
62 # if(arr[_int_0] == _float_1_0 && arr[_int_1] == _float_1_0 && arr[_int_2] == _float_2_0)
64 # _GLF_color = vec4(arr[_int_0], _float_0_0, _float_0_0, _float_1_0);
68 # _GLF_color = vec4(_float_0_0);
71 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
74 ; Generator: Khronos Glslang Reference Front End; 10
78 %1 = OpExtInstImport "GLSL.std.450"
79 OpMemoryModel Logical GLSL450
80 OpEntryPoint Fragment %4 "main" %82
81 OpExecutionMode %4 OriginUpperLeft
86 OpMemberName %13 0 "_GLF_uniform_float_values"
90 OpMemberName %37 0 "_GLF_uniform_int_values"
92 OpName %82 "_GLF_color"
93 OpDecorate %12 ArrayStride 16
94 OpMemberDecorate %13 0 Offset 0
96 OpDecorate %15 DescriptorSet 0
97 OpDecorate %15 Binding 1
98 OpDecorate %36 ArrayStride 16
99 OpMemberDecorate %37 0 Offset 0
101 OpDecorate %39 DescriptorSet 0
102 OpDecorate %39 Binding 0
103 OpDecorate %82 Location 0
105 %3 = OpTypeFunction %2
109 %9 = OpTypeArray %6 %8
110 %10 = OpTypePointer Function %9
111 %12 = OpTypeArray %6 %8
112 %13 = OpTypeStruct %12
113 %14 = OpTypePointer Uniform %13
114 %15 = OpVariable %14 Uniform
116 %17 = OpConstant %16 0
117 %18 = OpConstant %16 1
118 %19 = OpTypePointer Uniform %6
119 %24 = OpConstant %16 2
120 %28 = OpTypePointer Function %16
121 %36 = OpTypeArray %16 %8
122 %37 = OpTypeStruct %36
123 %38 = OpTypePointer Uniform %37
124 %39 = OpVariable %38 Uniform
125 %40 = OpTypePointer Uniform %16
127 %49 = OpTypePointer Function %6
128 %80 = OpTypeVector %6 4
129 %81 = OpTypePointer Output %80
130 %82 = OpVariable %81 Output
131 %4 = OpFunction %2 None %3
133 %11 = OpVariable %10 Function
134 %29 = OpVariable %28 Function
135 %20 = OpAccessChain %19 %15 %17 %18
137 %22 = OpAccessChain %19 %15 %17 %17
139 %25 = OpAccessChain %19 %15 %17 %24
141 %27 = OpCompositeConstruct %9 %21 %23 %26
146 OpLoopMerge %32 %33 None
150 %41 = OpAccessChain %40 %39 %17 %18
152 %44 = OpSLessThanEqual %43 %35 %42
153 OpBranchConditional %44 %31 %32
156 %46 = OpIAdd %16 %45 %18
158 %47 = OpAccessChain %19 %15 %17 %17
160 %50 = OpAccessChain %49 %11 %45
166 %51 = OpAccessChain %40 %39 %17 %18
168 %53 = OpAccessChain %49 %11 %52
170 %55 = OpAccessChain %19 %15 %17 %17
172 %57 = OpFOrdEqual %43 %54 %56
173 OpSelectionMerge %59 None
174 OpBranchConditional %57 %58 %59
176 %60 = OpAccessChain %40 %39 %17 %24
178 %62 = OpAccessChain %49 %11 %61
180 %64 = OpAccessChain %19 %15 %17 %17
182 %66 = OpFOrdEqual %43 %63 %65
185 %67 = OpPhi %43 %57 %32 %66 %58
186 OpSelectionMerge %69 None
187 OpBranchConditional %67 %68 %69
189 %70 = OpAccessChain %40 %39 %17 %17
191 %72 = OpAccessChain %49 %11 %71
193 %74 = OpAccessChain %19 %15 %17 %24
195 %76 = OpFOrdEqual %43 %73 %75
198 %77 = OpPhi %43 %67 %59 %76 %68
199 OpSelectionMerge %79 None
200 OpBranchConditional %77 %78 %94
202 %83 = OpAccessChain %40 %39 %17 %18
204 %85 = OpAccessChain %49 %11 %84
206 %87 = OpAccessChain %19 %15 %17 %18
208 %89 = OpAccessChain %19 %15 %17 %18
210 %91 = OpAccessChain %19 %15 %17 %17
212 %93 = OpCompositeConstruct %80 %86 %88 %90 %92
216 %95 = OpAccessChain %19 %15 %17 %18
218 %97 = OpCompositeConstruct %80 %96 %96 %96 %96
226 # uniforms for variant
228 # _GLF_uniform_float_values
229 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
232 # _GLF_uniform_int_values
233 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
237 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
239 PIPELINE graphics variant_pipeline
240 ATTACH variant_vertex_shader
241 ATTACH variant_fragment_shader
242 FRAMEBUFFER_SIZE 256 256
243 BIND BUFFER variant_framebuffer AS color LOCATION 0
244 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 1
245 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
247 CLEAR_COLOR variant_pipeline 0 0 0 255
249 CLEAR variant_pipeline
250 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
252 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255