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 # Optimized using spirv-opt with the following arguments:
26 # spirv-opt commit hash: a0370efd589be33d5d9a85cfde2f85841b3755af
30 SHADER vertex variant_vertex_shader PASSTHROUGH
32 # variant_fragment_shader is derived from the following GLSL:
34 # #define _int_0 _GLF_uniform_int_values[0]
35 # #define _int_1 _GLF_uniform_int_values[1]
37 # precision highp float;
38 # precision highp int;
40 # // Contents of _GLF_uniform_int_values: [0, 1]
41 # layout(set = 0, binding = 0) uniform buf0
43 # int _GLF_uniform_int_values[2];
46 # layout(location = 0) out vec4 _GLF_color;
52 # for(int i = 0; i < 1; i++)
55 # if(gl_FragCoord.y > 0.0)
69 # if(func() == _int_1)
71 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
75 # _GLF_color = vec4(_int_0);
78 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
81 ; Generator: Khronos Glslang Reference Front End; 10
85 %1 = OpExtInstImport "GLSL.std.450"
86 OpMemoryModel Logical GLSL450
87 OpEntryPoint Fragment %4 "main" %31 %61
88 OpExecutionMode %4 OriginUpperLeft
91 OpName %31 "gl_FragCoord"
93 OpMemberName %46 0 "_GLF_uniform_int_values"
95 OpName %61 "_GLF_color"
96 OpDecorate %31 BuiltIn FragCoord
97 OpDecorate %45 ArrayStride 16
98 OpMemberDecorate %46 0 Offset 0
100 OpDecorate %48 DescriptorSet 0
101 OpDecorate %48 Binding 0
102 OpDecorate %61 Location 0
104 %3 = OpTypeFunction %2
107 %16 = OpConstantTrue %15
108 %19 = OpConstant %6 0
109 %26 = OpConstant %6 1
111 %29 = OpTypeVector %28 4
112 %30 = OpTypePointer Input %29
113 %31 = OpVariable %30 Input
115 %33 = OpConstant %32 1
116 %34 = OpTypePointer Input %28
117 %37 = OpConstant %28 0
118 %44 = OpConstant %32 2
119 %45 = OpTypeArray %6 %44
120 %46 = OpTypeStruct %45
121 %47 = OpTypePointer Uniform %46
122 %48 = OpVariable %47 Uniform
123 %49 = OpTypePointer Uniform %6
124 %60 = OpTypePointer Output %29
125 %61 = OpVariable %60 Output
126 %84 = OpConstant %32 0
127 %85 = OpConstantFalse %15
129 %4 = OpFunction %2 None %3
131 OpSelectionMerge %121 None
136 %126 = OpPhi %15 %85 %97 %124 %117
137 %130 = OpPhi %6 %131 %97 %128 %117
138 OpLoopMerge %118 %117 None
141 %123 = OpPhi %6 %19 %98 %113 %111
142 %104 = OpSLessThan %15 %123 %26
143 OpLoopMerge %114 %111 None
144 OpBranchConditional %104 %105 %114
146 %106 = OpAccessChain %34 %31 %33
147 %107 = OpLoad %28 %106
148 %108 = OpFOrdGreaterThan %15 %107 %37
149 OpSelectionMerge %110 None
150 OpBranchConditional %108 %109 %110
156 %113 = OpIAdd %6 %123 %26
159 %128 = OpPhi %6 %130 %101 %26 %109
160 %124 = OpPhi %15 %126 %101 %16 %109
161 OpSelectionMerge %116 None
162 OpBranchConditional %124 %118 %116
168 OpSelectionMerge %120 None
169 OpBranchConditional %124 %121 %120
173 %55 = OpAccessChain %49 %48 %19 %26
175 %57 = OpIEqual %15 %128 %56
176 OpSelectionMerge %59 None
177 OpBranchConditional %57 %58 %75
179 %76 = OpAccessChain %49 %48 %19 %19
181 %78 = OpConvertSToF %28 %77
182 %79 = OpCompositeConstruct %29 %78 %78 %78 %78
186 %64 = OpConvertSToF %28 %56
187 %65 = OpAccessChain %49 %48 %19 %19
189 %67 = OpConvertSToF %28 %66
190 %74 = OpCompositeConstruct %29 %64 %67 %67 %64
198 # uniforms for variant
200 # _GLF_uniform_int_values
201 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
205 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
207 PIPELINE graphics variant_pipeline
208 ATTACH variant_vertex_shader
209 ATTACH variant_fragment_shader
210 FRAMEBUFFER_SIZE 32 32
211 BIND BUFFER variant_framebuffer AS color LOCATION 0
212 BIND BUFFER variant__GLF_uniform_int_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