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