3 # Copyright 2022 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 LLVM 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_1 _GLF_uniform_int_values[1]
30 # #define _float_1_0 _GLF_uniform_float_values[0]
32 # precision highp float;
33 # precision highp int;
35 # // Contents of _GLF_uniform_float_values: 1.0
36 # layout(set = 0, binding = 0) uniform buf0
38 # float _GLF_uniform_float_values[1];
41 # // Contents of _GLF_uniform_int_values: [0, 1]
42 # layout(set = 0, binding = 1) uniform buf1
44 # int _GLF_uniform_int_values[2];
47 # layout(location = 0) out vec4 _GLF_color;
51 # float f = _float_1_0;
58 # // Multiplies a by one 120 times.
59 # for(int i = 0; i < 120; i++)
64 # // f becomes one, which is the same as the original value of f.
68 # // f = max(f, 1) = max(1, 1) = 1.
69 # f = max(f, _float_1_0);
74 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
78 # _GLF_color = vec4(_int_0);
81 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
84 ; Generator: Khronos Glslang Reference Front End; 10
88 %1 = OpExtInstImport "GLSL.std.450"
89 OpMemoryModel Logical GLSL450
90 OpEntryPoint Fragment %4 "main" %68
91 OpExecutionMode %4 OriginUpperLeft
96 OpMemberName %12 0 "_GLF_uniform_float_values"
99 OpMemberName %22 0 "_GLF_uniform_int_values"
103 OpName %68 "_GLF_color"
104 OpDecorate %11 ArrayStride 16
105 OpMemberDecorate %12 0 Offset 0
107 OpDecorate %14 DescriptorSet 0
108 OpDecorate %14 Binding 0
109 OpDecorate %21 ArrayStride 16
110 OpMemberDecorate %22 0 Offset 0
112 OpDecorate %24 DescriptorSet 0
113 OpDecorate %24 Binding 1
114 OpDecorate %68 Location 0
116 %3 = OpTypeFunction %2
118 %7 = OpTypePointer Function %6
120 %10 = OpConstant %9 1
121 %11 = OpTypeArray %6 %10
122 %12 = OpTypeStruct %11
123 %13 = OpTypePointer Uniform %12
124 %14 = OpVariable %13 Uniform
126 %16 = OpConstant %15 0
127 %17 = OpTypePointer Uniform %6
128 %20 = OpConstant %9 2
129 %21 = OpTypeArray %15 %20
130 %22 = OpTypeStruct %21
131 %23 = OpTypePointer Uniform %22
132 %24 = OpVariable %23 Uniform
133 %25 = OpConstant %15 1
134 %26 = OpTypePointer Uniform %15
136 %35 = OpTypePointer Function %15
137 %46 = OpConstant %15 120
138 %66 = OpTypeVector %6 4
139 %67 = OpTypePointer Output %66
140 %68 = OpVariable %67 Output
141 %4 = OpFunction %2 None %3
143 %8 = OpVariable %7 Function
144 %36 = OpVariable %35 Function
145 %39 = OpVariable %35 Function
146 %18 = OpAccessChain %17 %14 %16 %16
149 %27 = OpAccessChain %26 %24 %16 %25
151 %29 = OpAccessChain %26 %24 %16 %16
153 %32 = OpSGreaterThan %31 %28 %30
154 OpSelectionMerge %34 None
155 OpBranchConditional %32 %33 %34
157 %37 = OpAccessChain %26 %24 %16 %25
163 OpLoopMerge %42 %43 None
167 %47 = OpSLessThan %31 %45 %46
168 OpBranchConditional %47 %41 %42
170 %48 = OpAccessChain %26 %24 %16 %25
173 %51 = OpIMul %15 %50 %49
178 %53 = OpIAdd %15 %52 %25
183 %55 = OpConvertSToF %6 %54
188 %57 = OpAccessChain %17 %14 %16 %16
190 %59 = OpExtInst %6 %1 FMax %56 %58
193 %61 = OpAccessChain %17 %14 %16 %16
195 %63 = OpFOrdEqual %31 %60 %62
196 OpSelectionMerge %65 None
197 OpBranchConditional %63 %64 %82
199 %69 = OpAccessChain %26 %24 %16 %25
201 %71 = OpConvertSToF %6 %70
202 %72 = OpAccessChain %26 %24 %16 %16
204 %74 = OpConvertSToF %6 %73
205 %75 = OpAccessChain %26 %24 %16 %16
207 %77 = OpConvertSToF %6 %76
208 %78 = OpAccessChain %26 %24 %16 %25
210 %80 = OpConvertSToF %6 %79
211 %81 = OpCompositeConstruct %66 %71 %74 %77 %80
215 %83 = OpAccessChain %26 %24 %16 %16
217 %85 = OpConvertSToF %6 %84
218 %86 = OpCompositeConstruct %66 %85 %85 %85 %85
226 # uniforms for variant
228 # _GLF_uniform_int_values
229 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
232 # _GLF_uniform_float_values
233 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] 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 32 32
243 BIND BUFFER variant_framebuffer AS color LOCATION 0
244 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 1
245 BIND BUFFER variant__GLF_uniform_float_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 32 32
252 EXPECT variant_framebuffer IDX 0 0 SIZE 32 32 EQ_RGBA 255 0 0 255