#!amber # Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # A test for a coverage-gap found by the GraphicsFuzz project. # Short description: A fragment shader that covers specific LLVM code paths # The test passes because the shader always writes red. SHADER vertex variant_vertex_shader PASSTHROUGH # variant_fragment_shader is derived from the following GLSL: # #version 320 es # #define _int_0 _GLF_uniform_int_values[0] # #define _int_1 _GLF_uniform_int_values[1] # #define _int_2 _GLF_uniform_int_values[2] # #define _int_7 _GLF_uniform_int_values[3] # #define _int_8 _GLF_uniform_int_values[4] # # precision highp float; # precision highp int; # # // Contents of _GLF_uniform_int_values: [0, 1, 2, 7, 8] # layout(set = 0, binding = 0) uniform buf0 # { # int _GLF_uniform_int_values[5]; # }; # # const int _GLF_global_loop_bound = 10; # int _GLF_global_loop_count = 0; # # layout(location = 0) out vec4 _GLF_color; # # void main() # { # int arr0[16] = int[16](_int_0, _int_0, _int_0, _int_0, _int_0, _int_0, _int_0, _int_0, _int_0, _int_0, _int_0, _int_0, _int_0, _int_0, _int_0, _int_0); # int arr1[16] = int[16](_int_1, _int_1, _int_1, _int_1, _int_1, _int_1, _int_1, _int_1, _int_1, _int_1, _int_1, _int_1, _int_1, _int_1, _int_1, _int_1); # ivec2 v = ivec2(_int_1); # # // Iterates once. # for(int i = _int_1; i < _int_8 && _GLF_global_loop_count < _GLF_global_loop_bound; i++) # { # _GLF_global_loop_count++; # # // Iterated once. # for(int j = 1; _GLF_global_loop_count < _GLF_global_loop_bound; j++) # { # _GLF_global_loop_count++; # # do # { # _GLF_global_loop_count++; # # // Always true. # if(arr1[j + i] == _int_1) # { # v.x = _int_1; # int a = _int_1; # int b = _int_1; # # // Iterates once. # while(_GLF_global_loop_count < _GLF_global_loop_bound) # { # _GLF_global_loop_count++; # # // Iterates once. # for(int k = _int_1; k < _int_8 && _GLF_global_loop_count < _GLF_global_loop_bound; k++) # { # _GLF_global_loop_count++; # # if(b >= _int_7) # { # break; # } # b++; # # while(_GLF_global_loop_count < _GLF_global_loop_bound) # { # _GLF_global_loop_count++; # } # } # # // Always false. # if(arr0[_int_1] == _int_1) # { # a++; # } # # // Always true. # if(a == _int_1) # { # while(_GLF_global_loop_count < _GLF_global_loop_bound) # { # _GLF_global_loop_count++; # } # # arr0[a] = _int_1; # } # # if(a >= _int_7) # { # break; # } # a++; # } # # // Never iterated. # while(_GLF_global_loop_count < _GLF_global_loop_bound) # { # _GLF_global_loop_count++; # } # } # } # while(_GLF_global_loop_count < _GLF_global_loop_bound); # } # } # # arr1[v.x + v.y] = _int_2; # # // Always true. # if(arr0[_int_1] == _int_1 && arr1[_int_2] == _int_2) # { # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1); # } # else # { # _GLF_color = vec4(_int_0); # } # } SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0 ; SPIR-V ; Version: 1.0 ; Generator: Khronos Glslang Reference Front End; 10 ; Bound: 304 ; Schema: 0 OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Fragment %4 "main" %285 OpExecutionMode %4 OriginUpperLeft OpSource ESSL 320 OpName %4 "main" OpName %8 "_GLF_global_loop_count" OpName %14 "arr0" OpName %17 "buf0" OpMemberName %17 0 "_GLF_uniform_int_values" OpName %19 "" OpName %54 "arr1" OpName %91 "v" OpName %96 "i" OpName %116 "j" OpName %146 "a" OpName %149 "b" OpName %161 "k" OpName %285 "_GLF_color" OpDecorate %16 ArrayStride 16 OpMemberDecorate %17 0 Offset 0 OpDecorate %17 Block OpDecorate %19 DescriptorSet 0 OpDecorate %19 Binding 0 OpDecorate %285 Location 0 %2 = OpTypeVoid %3 = OpTypeFunction %2 %6 = OpTypeInt 32 1 %7 = OpTypePointer Private %6 %8 = OpVariable %7 Private %9 = OpConstant %6 0 %10 = OpTypeInt 32 0 %11 = OpConstant %10 16 %12 = OpTypeArray %6 %11 %13 = OpTypePointer Function %12 %15 = OpConstant %10 5 %16 = OpTypeArray %6 %15 %17 = OpTypeStruct %16 %18 = OpTypePointer Uniform %17 %19 = OpVariable %18 Uniform %20 = OpTypePointer Uniform %6 %55 = OpConstant %6 1 %89 = OpTypeVector %6 2 %90 = OpTypePointer Function %89 %95 = OpTypePointer Function %6 %105 = OpConstant %6 4 %108 = OpTypeBool %111 = OpConstant %6 10 %144 = OpConstant %10 0 %179 = OpConstant %6 3 %255 = OpConstant %10 1 %259 = OpConstant %6 2 %282 = OpTypeFloat 32 %283 = OpTypeVector %282 4 %284 = OpTypePointer Output %283 %285 = OpVariable %284 Output %4 = OpFunction %2 None %3 %5 = OpLabel %14 = OpVariable %13 Function %54 = OpVariable %13 Function %91 = OpVariable %90 Function %96 = OpVariable %95 Function %116 = OpVariable %95 Function %146 = OpVariable %95 Function %149 = OpVariable %95 Function %161 = OpVariable %95 Function OpStore %8 %9 %21 = OpAccessChain %20 %19 %9 %9 %22 = OpLoad %6 %21 %23 = OpAccessChain %20 %19 %9 %9 %24 = OpLoad %6 %23 %25 = OpAccessChain %20 %19 %9 %9 %26 = OpLoad %6 %25 %27 = OpAccessChain %20 %19 %9 %9 %28 = OpLoad %6 %27 %29 = OpAccessChain %20 %19 %9 %9 %30 = OpLoad %6 %29 %31 = OpAccessChain %20 %19 %9 %9 %32 = OpLoad %6 %31 %33 = OpAccessChain %20 %19 %9 %9 %34 = OpLoad %6 %33 %35 = OpAccessChain %20 %19 %9 %9 %36 = OpLoad %6 %35 %37 = OpAccessChain %20 %19 %9 %9 %38 = OpLoad %6 %37 %39 = OpAccessChain %20 %19 %9 %9 %40 = OpLoad %6 %39 %41 = OpAccessChain %20 %19 %9 %9 %42 = OpLoad %6 %41 %43 = OpAccessChain %20 %19 %9 %9 %44 = OpLoad %6 %43 %45 = OpAccessChain %20 %19 %9 %9 %46 = OpLoad %6 %45 %47 = OpAccessChain %20 %19 %9 %9 %48 = OpLoad %6 %47 %49 = OpAccessChain %20 %19 %9 %9 %50 = OpLoad %6 %49 %51 = OpAccessChain %20 %19 %9 %9 %52 = OpLoad %6 %51 %53 = OpCompositeConstruct %12 %22 %24 %26 %28 %30 %32 %34 %36 %38 %40 %42 %44 %46 %48 %50 %52 OpStore %14 %53 %56 = OpAccessChain %20 %19 %9 %55 %57 = OpLoad %6 %56 %58 = OpAccessChain %20 %19 %9 %55 %59 = OpLoad %6 %58 %60 = OpAccessChain %20 %19 %9 %55 %61 = OpLoad %6 %60 %62 = OpAccessChain %20 %19 %9 %55 %63 = OpLoad %6 %62 %64 = OpAccessChain %20 %19 %9 %55 %65 = OpLoad %6 %64 %66 = OpAccessChain %20 %19 %9 %55 %67 = OpLoad %6 %66 %68 = OpAccessChain %20 %19 %9 %55 %69 = OpLoad %6 %68 %70 = OpAccessChain %20 %19 %9 %55 %71 = OpLoad %6 %70 %72 = OpAccessChain %20 %19 %9 %55 %73 = OpLoad %6 %72 %74 = OpAccessChain %20 %19 %9 %55 %75 = OpLoad %6 %74 %76 = OpAccessChain %20 %19 %9 %55 %77 = OpLoad %6 %76 %78 = OpAccessChain %20 %19 %9 %55 %79 = OpLoad %6 %78 %80 = OpAccessChain %20 %19 %9 %55 %81 = OpLoad %6 %80 %82 = OpAccessChain %20 %19 %9 %55 %83 = OpLoad %6 %82 %84 = OpAccessChain %20 %19 %9 %55 %85 = OpLoad %6 %84 %86 = OpAccessChain %20 %19 %9 %55 %87 = OpLoad %6 %86 %88 = OpCompositeConstruct %12 %57 %59 %61 %63 %65 %67 %69 %71 %73 %75 %77 %79 %81 %83 %85 %87 OpStore %54 %88 %92 = OpAccessChain %20 %19 %9 %55 %93 = OpLoad %6 %92 %94 = OpCompositeConstruct %89 %93 %93 OpStore %91 %94 %97 = OpAccessChain %20 %19 %9 %55 %98 = OpLoad %6 %97 OpStore %96 %98 OpBranch %99 %99 = OpLabel OpLoopMerge %101 %102 None OpBranch %103 %103 = OpLabel %104 = OpLoad %6 %96 %106 = OpAccessChain %20 %19 %9 %105 %107 = OpLoad %6 %106 %109 = OpSLessThan %108 %104 %107 %110 = OpLoad %6 %8 %112 = OpSLessThan %108 %110 %111 %113 = OpLogicalAnd %108 %109 %112 OpBranchConditional %113 %100 %101 %100 = OpLabel %114 = OpLoad %6 %8 %115 = OpIAdd %6 %114 %55 OpStore %8 %115 OpStore %116 %55 OpBranch %117 %117 = OpLabel OpLoopMerge %119 %120 None OpBranch %121 %121 = OpLabel %122 = OpLoad %6 %8 %123 = OpSLessThan %108 %122 %111 OpBranchConditional %123 %118 %119 %118 = OpLabel %124 = OpLoad %6 %8 %125 = OpIAdd %6 %124 %55 OpStore %8 %125 OpBranch %126 %126 = OpLabel OpLoopMerge %128 %129 None OpBranch %127 %127 = OpLabel %130 = OpLoad %6 %8 %131 = OpIAdd %6 %130 %55 OpStore %8 %131 %132 = OpLoad %6 %116 %133 = OpLoad %6 %96 %134 = OpIAdd %6 %132 %133 %135 = OpAccessChain %95 %54 %134 %136 = OpLoad %6 %135 %137 = OpAccessChain %20 %19 %9 %55 %138 = OpLoad %6 %137 %139 = OpIEqual %108 %136 %138 OpSelectionMerge %141 None OpBranchConditional %139 %140 %141 %140 = OpLabel %142 = OpAccessChain %20 %19 %9 %55 %143 = OpLoad %6 %142 %145 = OpAccessChain %95 %91 %144 OpStore %145 %143 %147 = OpAccessChain %20 %19 %9 %55 %148 = OpLoad %6 %147 OpStore %146 %148 %150 = OpAccessChain %20 %19 %9 %55 %151 = OpLoad %6 %150 OpStore %149 %151 OpBranch %152 %152 = OpLabel OpLoopMerge %154 %155 None OpBranch %156 %156 = OpLabel %157 = OpLoad %6 %8 %158 = OpSLessThan %108 %157 %111 OpBranchConditional %158 %153 %154 %153 = OpLabel %159 = OpLoad %6 %8 %160 = OpIAdd %6 %159 %55 OpStore %8 %160 %162 = OpAccessChain %20 %19 %9 %55 %163 = OpLoad %6 %162 OpStore %161 %163 OpBranch %164 %164 = OpLabel OpLoopMerge %166 %167 None OpBranch %168 %168 = OpLabel %169 = OpLoad %6 %161 %170 = OpAccessChain %20 %19 %9 %105 %171 = OpLoad %6 %170 %172 = OpSLessThan %108 %169 %171 %173 = OpLoad %6 %8 %174 = OpSLessThan %108 %173 %111 %175 = OpLogicalAnd %108 %172 %174 OpBranchConditional %175 %165 %166 %165 = OpLabel %176 = OpLoad %6 %8 %177 = OpIAdd %6 %176 %55 OpStore %8 %177 %178 = OpLoad %6 %149 %180 = OpAccessChain %20 %19 %9 %179 %181 = OpLoad %6 %180 %182 = OpSGreaterThanEqual %108 %178 %181 OpSelectionMerge %184 None OpBranchConditional %182 %183 %184 %183 = OpLabel OpBranch %166 %184 = OpLabel %186 = OpLoad %6 %149 %187 = OpIAdd %6 %186 %55 OpStore %149 %187 OpBranch %188 %188 = OpLabel OpLoopMerge %190 %191 None OpBranch %192 %192 = OpLabel %193 = OpLoad %6 %8 %194 = OpSLessThan %108 %193 %111 OpBranchConditional %194 %189 %190 %189 = OpLabel %195 = OpLoad %6 %8 %196 = OpIAdd %6 %195 %55 OpStore %8 %196 OpBranch %191 %191 = OpLabel OpBranch %188 %190 = OpLabel OpBranch %167 %167 = OpLabel %197 = OpLoad %6 %161 %198 = OpIAdd %6 %197 %55 OpStore %161 %198 OpBranch %164 %166 = OpLabel %199 = OpAccessChain %20 %19 %9 %55 %200 = OpLoad %6 %199 %201 = OpAccessChain %95 %14 %200 %202 = OpLoad %6 %201 %203 = OpAccessChain %20 %19 %9 %55 %204 = OpLoad %6 %203 %205 = OpIEqual %108 %202 %204 OpSelectionMerge %207 None OpBranchConditional %205 %206 %207 %206 = OpLabel %208 = OpLoad %6 %146 %209 = OpIAdd %6 %208 %55 OpStore %146 %209 OpBranch %207 %207 = OpLabel %210 = OpLoad %6 %146 %211 = OpAccessChain %20 %19 %9 %55 %212 = OpLoad %6 %211 %213 = OpIEqual %108 %210 %212 OpSelectionMerge %215 None OpBranchConditional %213 %214 %215 %214 = OpLabel OpBranch %216 %216 = OpLabel OpLoopMerge %218 %219 None OpBranch %220 %220 = OpLabel %221 = OpLoad %6 %8 %222 = OpSLessThan %108 %221 %111 OpBranchConditional %222 %217 %218 %217 = OpLabel %223 = OpLoad %6 %8 %224 = OpIAdd %6 %223 %55 OpStore %8 %224 OpBranch %219 %219 = OpLabel OpBranch %216 %218 = OpLabel %225 = OpLoad %6 %146 %226 = OpAccessChain %20 %19 %9 %55 %227 = OpLoad %6 %226 %228 = OpAccessChain %95 %14 %225 OpStore %228 %227 OpBranch %215 %215 = OpLabel %229 = OpLoad %6 %146 %230 = OpAccessChain %20 %19 %9 %179 %231 = OpLoad %6 %230 %232 = OpSGreaterThanEqual %108 %229 %231 OpSelectionMerge %234 None OpBranchConditional %232 %233 %234 %233 = OpLabel OpBranch %154 %234 = OpLabel %236 = OpLoad %6 %146 %237 = OpIAdd %6 %236 %55 OpStore %146 %237 OpBranch %155 %155 = OpLabel OpBranch %152 %154 = OpLabel OpBranch %238 %238 = OpLabel OpLoopMerge %240 %241 None OpBranch %242 %242 = OpLabel %243 = OpLoad %6 %8 %244 = OpSLessThan %108 %243 %111 OpBranchConditional %244 %239 %240 %239 = OpLabel %245 = OpLoad %6 %8 %246 = OpIAdd %6 %245 %55 OpStore %8 %246 OpBranch %241 %241 = OpLabel OpBranch %238 %240 = OpLabel OpBranch %141 %141 = OpLabel OpBranch %129 %129 = OpLabel %247 = OpLoad %6 %8 %248 = OpSLessThan %108 %247 %111 OpBranchConditional %248 %126 %128 %128 = OpLabel OpBranch %120 %120 = OpLabel %249 = OpLoad %6 %116 %250 = OpIAdd %6 %249 %55 OpStore %116 %250 OpBranch %117 %119 = OpLabel OpBranch %102 %102 = OpLabel %251 = OpLoad %6 %96 %252 = OpIAdd %6 %251 %55 OpStore %96 %252 OpBranch %99 %101 = OpLabel %253 = OpAccessChain %95 %91 %144 %254 = OpLoad %6 %253 %256 = OpAccessChain %95 %91 %255 %257 = OpLoad %6 %256 %258 = OpIAdd %6 %254 %257 %260 = OpAccessChain %20 %19 %9 %259 %261 = OpLoad %6 %260 %262 = OpAccessChain %95 %54 %258 OpStore %262 %261 %263 = OpAccessChain %20 %19 %9 %55 %264 = OpLoad %6 %263 %265 = OpAccessChain %95 %14 %264 %266 = OpLoad %6 %265 %267 = OpAccessChain %20 %19 %9 %55 %268 = OpLoad %6 %267 %269 = OpIEqual %108 %266 %268 OpSelectionMerge %271 None OpBranchConditional %269 %270 %271 %270 = OpLabel %272 = OpAccessChain %20 %19 %9 %259 %273 = OpLoad %6 %272 %274 = OpAccessChain %95 %54 %273 %275 = OpLoad %6 %274 %276 = OpAccessChain %20 %19 %9 %259 %277 = OpLoad %6 %276 %278 = OpIEqual %108 %275 %277 OpBranch %271 %271 = OpLabel %279 = OpPhi %108 %269 %101 %278 %270 OpSelectionMerge %281 None OpBranchConditional %279 %280 %299 %280 = OpLabel %286 = OpAccessChain %20 %19 %9 %55 %287 = OpLoad %6 %286 %288 = OpConvertSToF %282 %287 %289 = OpAccessChain %20 %19 %9 %9 %290 = OpLoad %6 %289 %291 = OpConvertSToF %282 %290 %292 = OpAccessChain %20 %19 %9 %9 %293 = OpLoad %6 %292 %294 = OpConvertSToF %282 %293 %295 = OpAccessChain %20 %19 %9 %55 %296 = OpLoad %6 %295 %297 = OpConvertSToF %282 %296 %298 = OpCompositeConstruct %283 %288 %291 %294 %297 OpStore %285 %298 OpBranch %281 %299 = OpLabel %300 = OpAccessChain %20 %19 %9 %9 %301 = OpLoad %6 %300 %302 = OpConvertSToF %282 %301 %303 = OpCompositeConstruct %283 %302 %302 %302 %302 OpStore %285 %303 OpBranch %281 %281 = OpLabel OpReturn OpFunctionEnd END # uniforms for variant # _GLF_uniform_int_values BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA 0 1 2 7 8 END BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM PIPELINE graphics variant_pipeline ATTACH variant_vertex_shader ATTACH variant_fragment_shader FRAMEBUFFER_SIZE 32 32 BIND BUFFER variant_framebuffer AS color LOCATION 0 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0 END CLEAR_COLOR variant_pipeline 0 0 0 255 CLEAR variant_pipeline RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 32 32 EXPECT variant_framebuffer IDX 0 0 SIZE 32 32 EQ_RGBA 255 0 0 255