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