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_1 _GLF_uniform_int_values[0]
29 # #define _int_0 _GLF_uniform_int_values[1]
30 # #define _float_5_0 _GLF_uniform_float_values[0]
31 # #define _float_10_0 _GLF_uniform_float_values[1]
33 # precision highp float;
34 # precision highp int;
36 # // Contents of _GLF_uniform_float_values: [5.0, 10.0]
37 # layout(set = 0, binding = 0) uniform buf0
39 # float _GLF_uniform_float_values[2];
42 # // Contents of _GLF_uniform_int_values: [1, 0]
43 # layout(set = 0, binding = 1) uniform buf1
45 # int _GLF_uniform_int_values[2];
48 # layout(location = 0) out vec4 _GLF_color;
53 # int a = gl_FragCoord.x > _float_5_0 ? 1 : 1;
55 # int b = gl_FragCoord.x > _float_10_0 ? max(1, a) : _int_1;
60 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
64 # _GLF_color = vec4(_int_0);
67 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
70 ; Generator: Khronos Glslang Reference Front End; 10
74 %1 = OpExtInstImport "GLSL.std.450"
75 OpMemoryModel Logical GLSL450
76 OpEntryPoint Fragment %4 "main" %12 %56
77 OpExecutionMode %4 OriginUpperLeft
81 OpName %12 "gl_FragCoord"
83 OpMemberName %20 0 "_GLF_uniform_float_values"
87 OpMemberName %44 0 "_GLF_uniform_int_values"
89 OpName %56 "_GLF_color"
90 OpDecorate %12 BuiltIn FragCoord
91 OpDecorate %19 ArrayStride 16
92 OpMemberDecorate %20 0 Offset 0
94 OpDecorate %22 DescriptorSet 0
95 OpDecorate %22 Binding 0
96 OpDecorate %43 ArrayStride 16
97 OpMemberDecorate %44 0 Offset 0
99 OpDecorate %46 DescriptorSet 0
100 OpDecorate %46 Binding 1
101 OpDecorate %56 Location 0
103 %3 = OpTypeFunction %2
105 %7 = OpTypePointer Function %6
107 %10 = OpTypeVector %9 4
108 %11 = OpTypePointer Input %10
109 %12 = OpVariable %11 Input
111 %14 = OpConstant %13 0
112 %15 = OpTypePointer Input %9
113 %18 = OpConstant %13 2
114 %19 = OpTypeArray %9 %18
115 %20 = OpTypeStruct %19
116 %21 = OpTypePointer Uniform %20
117 %22 = OpVariable %21 Uniform
118 %23 = OpConstant %6 0
119 %24 = OpTypePointer Uniform %9
121 %29 = OpConstant %6 1
122 %43 = OpTypeArray %6 %18
123 %44 = OpTypeStruct %43
124 %45 = OpTypePointer Uniform %44
125 %46 = OpVariable %45 Uniform
126 %47 = OpTypePointer Uniform %6
127 %55 = OpTypePointer Output %10
128 %56 = OpVariable %55 Output
129 %4 = OpFunction %2 None %3
131 %8 = OpVariable %7 Function
132 %31 = OpVariable %7 Function
133 %37 = OpVariable %7 Function
134 %16 = OpAccessChain %15 %12 %14
136 %25 = OpAccessChain %24 %22 %23 %23
138 %28 = OpFOrdGreaterThan %27 %17 %26
139 %30 = OpSelect %6 %28 %29 %29
141 %32 = OpAccessChain %15 %12 %14
143 %34 = OpAccessChain %24 %22 %23 %29
145 %36 = OpFOrdGreaterThan %27 %33 %35
146 OpSelectionMerge %39 None
147 OpBranchConditional %36 %38 %42
150 %41 = OpExtInst %6 %1 SMax %29 %40
154 %48 = OpAccessChain %47 %46 %23 %23
162 %52 = OpIEqual %27 %51 %29
163 OpSelectionMerge %54 None
164 OpBranchConditional %52 %53 %70
166 %57 = OpAccessChain %47 %46 %23 %23
168 %59 = OpConvertSToF %9 %58
169 %60 = OpAccessChain %47 %46 %23 %29
171 %62 = OpConvertSToF %9 %61
172 %63 = OpAccessChain %47 %46 %23 %29
174 %65 = OpConvertSToF %9 %64
175 %66 = OpAccessChain %47 %46 %23 %23
177 %68 = OpConvertSToF %9 %67
178 %69 = OpCompositeConstruct %10 %59 %62 %65 %68
182 %71 = OpAccessChain %47 %46 %23 %29
184 %73 = OpConvertSToF %9 %72
185 %74 = OpCompositeConstruct %10 %73 %73 %73 %73
193 # uniforms for variant
195 # _GLF_uniform_int_values
196 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
199 # _GLF_uniform_float_values
200 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
204 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
206 PIPELINE graphics variant_pipeline
207 ATTACH variant_vertex_shader
208 ATTACH variant_fragment_shader
209 FRAMEBUFFER_SIZE 32 32
210 BIND BUFFER variant_framebuffer AS color LOCATION 0
211 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 1
212 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 0
214 CLEAR_COLOR variant_pipeline 0 0 0 255
216 CLEAR variant_pipeline
217 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 32 32
219 EXPECT variant_framebuffer IDX 0 0 SIZE 32 32 EQ_RGBA 255 0 0 255